<template>
|
<div>
|
<el-card style="margin: 10px;" class="affix-container">
|
<div>
|
<div style="display: flex;justify-content: space-between">
|
<div>
|
<b style="margin-right: 20px">{{ $t('menu.VIPCouponHistory') }}</b>
|
</div>
|
<div>
|
<el-input :placeholder="$t('message.PleaseInputKeyWords')" maxlength="64"
|
:prefix-icon="icon.Search"
|
clearable
|
size="default"
|
@clear="SearchData"
|
style="width: 200px;margin-right: 10px" v-model="searchValue.filter"
|
@keydown.enter.native="SearchData" :disabled="showAdvanceSearchView"></el-input>
|
<el-button type="primary" size="default" :icon="icon.Search" @click="SearchData"
|
:disabled="showAdvanceSearchView">
|
{{ $t('button.Search') }}
|
</el-button>
|
<el-button type="warning" size="default"
|
:icon="showAdvanceSearchView?icon.CaretTop:icon.CaretBottom"
|
@click="showAdvanceSearchView = !showAdvanceSearchView">
|
{{ $t('button.AdvancedSearch') }}
|
</el-button>
|
</div>
|
</div>
|
<transition name="slide-fade">
|
<div v-show="showAdvanceSearchView" class="advanced-search-box">
|
<el-form size="default" label-width="120px">
|
<el-row :style="{margin: '10px 0px 0px 0px'}">
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Code')" :style="{marginBottom: '0px'}">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.code"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :style="{margin: '10px 0px 0px 0px'}">
|
<el-col :span="7">
|
<el-form-item :label="$t('label.ActivityName')" :style="{marginBottom: '0px'}">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.activityname"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :style="{margin: '10px 0px 0px 0px'}">
|
<el-col :span="7">
|
<el-form-item :label="$t('label.VIPName')" :style="{marginBottom: '0px'}">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.mastername"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :style="{margin: '10px 0px 0px 0px'}">
|
<el-col :span="21" :style="{ textAlign: 'right'}" :offset="0">
|
<el-button size="default" :icon="icon.Search" type="primary"
|
@click="SearchData">
|
{{ $t('button.Search') }}
|
</el-button>
|
<el-button size="default" :icon="icon.Delete" type="info" plain
|
@click="ClearSearchData">
|
{{ $t('button.Clear') }}
|
</el-button>
|
<el-button size="default" :icon="icon.CircleClose" type="danger" plain
|
@click="showAdvanceSearchView = !showAdvanceSearchView">
|
{{ $t('button.Close') }}
|
</el-button>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
</transition>
|
</div>
|
<el-divider :style="{'margin':'10px 0px'}"></el-divider>
|
<div>
|
<el-table
|
:data="entityList" stripe border
|
v-loading="loading"
|
element-loading-text="Loading..."
|
element-loading-spinner="el-icon-loading"
|
element-loading-background="rgba(0, 0, 0, 0.8)"
|
size="default"
|
:header-row-style="{height: '40px',color: 'var(--el-color-primary)',background: '#f5f4f4', }"
|
:header-cell-style="{height: '40px', margin: '0px', padding: '0px', background: 'transparent'}"
|
:row-style="{height: '30px', margin: '0px', padding: '0px',}"
|
:cell-style="{height: '30px',margin: '0px', padding: '0px',}"
|
@row-dblclick="showEditView">
|
<el-table-column type="index" fixed :label="$t('label.Index')" width="65"/>
|
<el-table-column prop="code" sortable align="left" :label="$t('label.Code')" width="200"/>
|
<el-table-column prop="activityname" sortable align="left" :label="$t('label.ActivityName')"
|
width="200"/>
|
<el-table-column prop="status" sortable :label="$t('label.Status')" align="left" width="100">
|
<template #default="scope">
|
<el-tag v-if="scope.row.status===0" type="success">{{ $t('label.VALID') }}</el-tag>
|
<el-tag v-else-if="scope.row.status===1" type="info">{{ $t('label.LOCKED') }}</el-tag>
|
<el-tag v-else-if="scope.row.status===2" type="danger">{{ $t('label.EXPIRED') }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="type" sortable align="left" :label="$t('label.Type')" width="150">
|
<template #default="scope">
|
<el-tag v-if="scope.row.type === 0" type="success">
|
{{ $t('label.ByDiscountRate') }}
|
</el-tag>
|
<el-tag v-else-if="scope.row.type === 1" type="warning">
|
{{ $t('label.ByFullDiscount') }}
|
</el-tag>
|
<el-tag v-else type="danger">
|
{{ $t('label.ByVoucher') }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="amount" sortable align="left" :label="$t('label.Amount')" width="150"/>
|
<el-table-column prop="discount" sortable align="right" :label="$t('label.Discount')" width="150"/>
|
<el-table-column prop="discountrate" sortable align="right" :label="$t('label.DiscountRate')"
|
width="170"/>
|
<el-table-column prop="validdatefrom" width="150" align="left" :label="$t('label.ValidDateFrom')"
|
:formatter="formatterDatetime"/>
|
<el-table-column prop="validdateto" width="150" align="left" :label="$t('label.ValidDateTo')"
|
:formatter="formatterDatetime"/>
|
<el-table-column prop="issuingtime" width="150" align="left" :label="$t('label.IssuingTime')"
|
:formatter="formatterDatetime"/>
|
<el-table-column prop="usagetime" width="150" align="left" :label="$t('label.UsageTime')"
|
:formatter="formatterDatetime"/>
|
<el-table-column prop="mastername" align="left" :label="$t('label.VIPName')" width="200"/>
|
<el-table-column prop="createtime" width="150" align="left" :label="$t('label.CreateTime')"
|
:formatter="formatterDatetime"/>
|
<el-table-column prop="remark" min-width="500" width="*" align="left"
|
:label="$t('label.Remark')"/>
|
<el-table-column fixed="right" width="130" :label="$t('label.Operation')">
|
<template #default="scope">
|
<el-button @click="showEditView(scope.row)" :icon="icon.Edit"
|
size="small"
|
type="primary" circle>
|
</el-button>
|
<el-button @click="deleteItem(scope.row)" :icon="icon.Delete"
|
size="small"
|
type="danger" circle>
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-affix position="bottom" :offset="10" target=".affix-container">
|
<div style="background: white;padding-bottom:10px;">
|
<el-divider :style="{'margin':'10px 0px'}"></el-divider>
|
<div style="margin-top:10px; display: flex;justify-content: flex-end">
|
<el-pagination
|
:currentPage="pageIndex"
|
:page-size="pageSize"
|
background
|
@current-change="currentChange"
|
@size-change="sizeChange"
|
:page-sizes="[10, 20, 50, 100, 200]"
|
layout="sizes, prev, pager, next, jumper, ->, total, slot"
|
:total="total">
|
</el-pagination>
|
</div>
|
</div>
|
</el-affix>
|
</div>
|
</el-card>
|
<div v-dialogdrag>
|
<el-dialog :title="title"
|
id="detailDialog"
|
v-model="dialogVisible"
|
:close-on-click-modal="false"
|
class="el-dialog-customer"
|
width="1000px">
|
<template #header>
|
<el-row>
|
<el-col :span="12">
|
<el-icon style="font:normal bold 20px arial,sans-serif;vertical-align: -10%"
|
v-if="dialogMode==='new'">
|
<plus/>
|
</el-icon>
|
<el-icon v-else style="font:normal bold 20px arial,serif;vertical-align: -10%">
|
<edit/>
|
</el-icon>
|
<span style="margin-left: 10px; font:normal bold 20px arial,serif;">{{ title }}</span>
|
</el-col>
|
</el-row>
|
</template>
|
<el-card style="margin-top: 0px;">
|
<el-form :model="entity" size="default" :rules="rules" ref="dialogForm" label-width="120px">
|
<el-tabs>
|
<el-tab-pane :label="$t('label.BasicInformation')">
|
<el-row>
|
<el-col :span="14">
|
<el-form-item :label="$t('label.ActivityName')" prop="activityname">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="entity.activityname" disabled="disabled"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Code')" prop="code">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="entity.code" disabled="disabled"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.VIPName')" prop="mastername">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="entity.mastername" disabled="disabled"
|
placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Amount')" prop="amount">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
maxlength="64" disabled="disabled"
|
:precision="0" :step="10"
|
v-model="entity.amount"/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Discount')" prop="discount">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
maxlength="64" disabled="disabled"
|
:precision="2" :step="0.1"
|
v-model="entity.discount"/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.DiscountRate')" prop="discountrate">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
maxlength="64" disabled="disabled"
|
:min="0.1" :max="1"
|
:precision="2" :step="0.05"
|
v-model="entity.discountrate"/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="21">
|
<el-form-item :label="$t('label.ValidDate')" prop="validdatefrom">
|
<el-date-picker disabled="disabled"
|
size="default"
|
v-model="validtimeduration"
|
type="daterange"
|
range-separator="-"
|
:start-placeholder="$t('label.ValidDateFrom')"
|
:end-placeholder="$t('label.ValidDateTo')"
|
format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.IssuingTime')" prop="issuingtime">
|
<el-date-picker
|
v-model="entity.issuingtime"
|
disabled="disabled"
|
size="default"
|
type="date"
|
placeholder="">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.UsageTime')" prop="usagetime">
|
<el-date-picker
|
v-model="entity.createtime"
|
disabled="disabled"
|
size="default"
|
type="date"
|
placeholder="">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.CreateTime')" prop="createtime">
|
<el-date-picker
|
v-model="entity.createtime"
|
disabled="disabled"
|
size="default"
|
type="date"
|
placeholder="">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="14">
|
<el-form-item :label="$t('label.Remark')" prop="remark">
|
<el-input type="textarea" :rows="3" maxlength="500" placeholder=""
|
disabled="disabled"
|
v-model="entity.remark"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
</el-tabs>
|
</el-form>
|
</el-card>
|
<template #footer>
|
<el-button type="danger" @click="dialogVisible = false" :icon="icon.CircleClose" size="default"
|
plain>
|
{{ $t('button.Close') }}
|
</el-button>
|
</template>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import * as icon from '@element-plus/icons-vue'
|
import {onMounted, onBeforeUnmount, getCurrentInstance, reactive, toRefs} from "vue";
|
import {formatDate, GetDateStr} from '../../../utils/common'
|
import {
|
GetVIPCouponHistories,
|
DeleteVIPCouponHistory
|
} from "../../../api/admin/vip"
|
import {useBasicInfoStore} from "../../../store/basicInfo";
|
import * as elementplus from "element-plus";
|
|
export default {
|
name: "VIPCouponHistory",
|
components: {},
|
setup() {
|
let {proxy} = getCurrentInstance();
|
const store = useBasicInfoStore();
|
const state = reactive({
|
//common properties
|
title: '',
|
total: 0,
|
pageIndex: 1,
|
pageSize: store.config.ListSize,
|
loading: false,
|
windowWidth: document.documentElement.clientWidth,
|
windowHeight: document.documentElement.clientHeight,
|
dialogVisible: false,
|
dialogMode: 'new',
|
shoppingCartTitle: '',
|
shoppingCartDialogVisible: false,
|
showAdvanceSearchView: false,
|
searchValue: {
|
filter: "",
|
activityname: "",
|
code: "",
|
mastername: "",
|
},
|
entityList: [],
|
entity: {
|
id: "",
|
type: "",
|
activityname: "",
|
code: "",
|
distributioncondition: "",
|
amount: null,
|
discount: null,
|
discountrate: null,
|
validdatefrom: null,
|
validdateto: null,
|
issuingtime: null,
|
usagetime: null,
|
orderno: null,
|
masterid: null,
|
mastercode: null,
|
mastername: null,
|
status: 0,
|
createtime: "",
|
updatetime: "",
|
isdeleted: null,
|
remark: "",
|
},
|
validtimeduration: [],
|
rules: {
|
name: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Name')})}`,
|
}],
|
}
|
});
|
|
onMounted(() => {
|
Init();
|
LoadData();
|
});
|
onBeforeUnmount(() => {
|
|
});
|
|
const Init = () => {
|
let nowfrom = new Date();
|
let validdatefrom = GetDateStr(nowfrom, 0, 0, 0);
|
|
let nowto = new Date();
|
let validdateto = GetDateStr(nowto, 1, 0, 0);
|
|
state.validtimeduration = [validdatefrom, validdateto];
|
};
|
const sizeChange = (currentSize) => {
|
state.pageSize = currentSize;
|
store.config.ListSize = state.pageSize;
|
LoadData();
|
};
|
const currentChange = (currentPage) => {
|
state.pageIndex = currentPage;
|
LoadData();
|
};
|
const clearAddOrEditModel = () => {
|
state.entity = {
|
id: "",
|
type: "",
|
activityname: "",
|
code: "",
|
distributioncondition: "",
|
amount: null,
|
discount: null,
|
discountrate: null,
|
validdatefrom: null,
|
validdateto: null,
|
issuingtime: null,
|
usagetime: null,
|
orderno: null,
|
masterid: null,
|
mastercode: null,
|
mastername: null,
|
status: 0,
|
createtime: "",
|
updatetime: "",
|
isdeleted: null,
|
remark: "",
|
}
|
};
|
const getSearchCondition = () => {
|
let condition;
|
if (!state.showAdvanceSearchView) {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
filter: state.searchValue.filter,
|
permissionLevel: store.config.permissionLevel,
|
}
|
} else {
|
condition = {
|
pageIndex: state.pageIndex,
|
pageSize: state.pageSize,
|
activityname: state.searchValue.activityname,
|
code: state.searchValue.code,
|
mastername: state.searchValue.mastername,
|
}
|
}
|
|
return condition;
|
};
|
const LoadData = () => {
|
state.loading = true;
|
let condition = getSearchCondition();
|
|
GetVIPCouponHistories(condition).then(resp => {
|
state.loading = false;
|
if (resp.data) {
|
state.entityList = resp.data.data;
|
state.total = resp.data.total;
|
}
|
}).catch(err => {
|
console.error(err);
|
});
|
};
|
|
const SearchData = () => {
|
state.pageIndex = 1;
|
LoadData();
|
};
|
const ClearSearchData = () => {
|
state.searchValue = {
|
filter: "",
|
activityname: "",
|
code: "",
|
mastername: "",
|
};
|
};
|
const showAddView = () => {
|
clearAddOrEditModel();
|
|
state.entity.validdatefrom = state.validtimeduration[0];
|
state.entity.validdateto = state.validtimeduration[1];
|
|
state.title = proxy.$t('button.New');
|
state.dialogMode = 'new';
|
state.dialogVisible = true;
|
};
|
const showEditView = (data) => {
|
state.title = `${proxy.$t('button.Edit')} [${data.name}]`;
|
state.validtimeduration = [data.validdatefrom, data.validdateto];
|
state.dialogMode = 'edit';
|
state.entity = data;
|
|
state.dialogVisible = true;
|
};
|
|
const onSubmit = () => {
|
state.entity.validdatefrom = state.validtimeduration[0];
|
state.entity.validdateto = state.validtimeduration[1];
|
|
if (state.entity.id) {
|
proxy.$refs['dialogForm'].validate(valid => {
|
if (valid) {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToSubmit')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
type: 'warning',
|
center: true
|
}).then(() => {
|
const rLoading = proxy.openLoading("#detailDialog");
|
|
UpdateVIPCouponHistory(state.entity)
|
.then(resp => {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
state.dialogVisible = false;
|
LoadData();
|
}
|
rLoading.close();
|
})
|
.catch(error => {
|
console.error(error);
|
proxy.$message.error({message: error});
|
});
|
}).catch((error) => {
|
console.error(error)
|
});
|
}
|
});
|
} else {
|
proxy.$refs['dialogForm'].validate(valid => {
|
if (valid) {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToSubmit')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
type: 'warning',
|
center: true
|
}).then(() => {
|
const rLoading = proxy.openLoading("#detailDialog");
|
CreateVIPCouponHistory(state.entity)
|
.then(resp => {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
state.dialogVisible = false;
|
LoadData();
|
}
|
rLoading.close();
|
})
|
.catch(error => {
|
console.error(error);
|
proxy.$message.error({message: error});
|
});
|
}).catch((error) => {
|
console.error(error)
|
});
|
}
|
});
|
}
|
};
|
const deleteItem = (data) => {
|
proxy.$confirm(`${proxy.$t('message.AreYouSureToRemove')}`, `${proxy.$t('label.SystemConfirm')}`, {
|
confirmButtonText: `${proxy.$t('button.Yes')}`,
|
cancelButtonText: `${proxy.$t('button.No')}`,
|
confirmButtonClass: 'confirmButtonClass',
|
cancelButtonClass: 'cancelButtonClass',
|
type: 'warning',
|
center: true
|
}).then(() => {
|
state.loading = true;
|
DeleteVIPCouponHistory(data.id)
|
.then(resp => {
|
if (resp) {
|
if (resp.data && resp.data.code !== 200) {
|
elementplus.ElMessageBox.alert(
|
`${proxy.$t('message.' + resp.data.message)}`,
|
'',
|
{
|
confirmButtonText: 'OK',
|
type: 'error',
|
}
|
);
|
} else {
|
LoadData();
|
}
|
}
|
state.loading = false;
|
})
|
.catch(error => {
|
console.error(error);
|
state.loading = false;
|
proxy.$message.error({message: error});
|
});
|
}).catch((error) => {
|
console.error(error)
|
});
|
};
|
|
//formatter
|
const formatterDatetime = (row, column) => {
|
let date = null;
|
switch (column.property) {
|
case "createtime":
|
if (!row.createtime)
|
return null;
|
date = new Date(row.createtime);
|
break;
|
case "birthday":
|
if (!row.birthday)
|
return null;
|
date = new Date(row.birthday);
|
break;
|
case "actiontime":
|
if (!row.actiontime)
|
return null;
|
date = new Date(row.actiontime);
|
break;
|
case "validdateto":
|
if (!row.validdateto)
|
return null;
|
date = new Date(row.validdateto);
|
break;
|
case "validdatefrom":
|
if (!row.validdatefrom)
|
return null;
|
date = new Date(row.validdatefrom);
|
break;
|
case "issuingtime":
|
if (!row.issuingtime)
|
return null;
|
date = new Date(row.issuingtime);
|
break;
|
case "usagetime":
|
if (!row.usagetime)
|
return null;
|
date = new Date(row.usagetime);
|
break;
|
}
|
|
return formatDate(date, 'yyyy-MM-dd hh:mm');
|
};
|
const formatterStatusBoolean = (row, column) => {
|
var ret = ''
|
if (row.status) {
|
ret = "Valid";
|
} else {
|
ret = "Invalid";
|
}
|
return ret;
|
};
|
const capitalize = (value) => {
|
if (!value) return ''
|
value = value.toString()
|
return value.charAt(0).toUpperCase() + value.slice(1)
|
};
|
|
return {
|
...toRefs(state),
|
LoadData,
|
sizeChange,
|
currentChange,
|
clearAddOrEditModel,
|
SearchData,
|
showAddView,
|
onSubmit,
|
showEditView,
|
deleteItem,
|
ClearSearchData,
|
formatterDatetime,
|
formatterStatusBoolean,
|
capitalize,
|
icon
|
}
|
},
|
}
|
</script>
|
|
<style>
|
|
</style>
|