<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.VIPDepositActivity') }}</b>
|
<el-button link type="primary" size="default" :icon="icon.CirclePlus" @click="showAddView">
|
{{ $t('button.New') }}
|
</el-button>
|
</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.Name')" :style="{ marginBottom: '0px' }">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="searchValue.name" placeholder=""></el-input>
|
</el-form-item>
|
</el-col>
|
<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="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="120"/>
|
<el-table-column prop="name" sortable align="left" :label="$t('label.Name')" width="150"/>
|
<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="description" :label="$t('label.Description')"
|
width="300"/>
|
<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="present" sortable align="right" :label="$t('label.Present')" width="150"/>
|
<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 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.Name')" prop="name">
|
<el-input size="default" :prefix-icon="icon.Edit" maxlength="64"
|
v-model="entity.name"
|
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.Amount')" prop="amount">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
maxlength="64"
|
: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"
|
: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"
|
:min="0.1" :max="1"
|
:precision="2" :step="0.05"
|
v-model="entity.discountrate"/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="7">
|
<el-form-item :label="$t('label.Present')" prop="present">
|
<el-input-number size="default" :prefix-icon="icon.Edit"
|
maxlength="64"
|
:precision="2" :step="0.1"
|
v-model="entity.present"/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="14">
|
<el-form-item :label="$t('label.Status')" prop="status">
|
<el-radio-group v-model="entity.status">
|
<el-radio :label="0">{{ $t('label.Enabled') }}</el-radio>
|
<el-radio :label="1">{{ $t('label.Disabled') }}</el-radio>
|
</el-radio-group>
|
</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=""
|
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="primary" @click="onSubmit" :icon="icon.CircleCheck" size="default">
|
{{ $t('button.Submit') }}
|
</el-button>
|
<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} from '../../../utils/common'
|
import {
|
GetVIPDepositActivities,
|
UpdateVIPDepositActivity,
|
CreateVIPDepositActivity,
|
DeleteVIPDepositActivity
|
} from "../../../api/admin/vip"
|
import {useBasicInfoStore} from "../../../store/basicInfo";
|
import * as elementplus from "element-plus";
|
|
export default {
|
name: "VIPDepositActivity",
|
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',
|
showAdvanceSearchView: false,
|
searchValue: {
|
filter: "",
|
name: "",
|
code: "",
|
description: "",
|
status: null,
|
},
|
entityList: [],
|
entity: {
|
id: "",
|
name: "",
|
code: "",
|
description: "",
|
amount: 0,
|
discount: 0,
|
discountrate: 0,
|
present: 0,
|
status: 0,
|
createtime: "",
|
updatetime: "",
|
isdeleted: null,
|
remark: "",
|
},
|
rules: {
|
name: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Name')})}`,
|
}],
|
amount: [{
|
required: true,
|
message: `${proxy.$t('message.IsRequired', {name: proxy.$t('label.Amount')})}`,
|
}],
|
}
|
});
|
|
onMounted(() => {
|
Init();
|
LoadData();
|
});
|
onBeforeUnmount(() => {
|
|
});
|
|
const Init = () => {
|
|
};
|
const sizeChange = (currentSize) => {
|
state.pageSize = currentSize;
|
store.config.ListSize = state.pageSize;
|
LoadData();
|
};
|
const currentChange = (currentPage) => {
|
state.pageIndex = currentPage;
|
LoadData();
|
};
|
const clearAddOrEditModel = () => {
|
state.entity = {
|
id: "",
|
name: "",
|
code: "",
|
description: "",
|
amount: 0,
|
discount: 0,
|
discountrate: 0,
|
present: 0,
|
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,
|
name: state.searchValue.name,
|
code: state.searchValue.code,
|
status: state.searchValue.status,
|
}
|
}
|
|
return condition;
|
};
|
const LoadData = () => {
|
state.loading = true;
|
let condition = getSearchCondition();
|
|
GetVIPDepositActivities(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: "",
|
name: "",
|
diamondtype: "",
|
nickname: "",
|
city: "",
|
province: "",
|
country: "",
|
idcard: "",
|
};
|
};
|
|
const showAddView = () => {
|
clearAddOrEditModel();
|
state.title = proxy.$t('button.New');
|
state.dialogMode = 'new';
|
state.dialogVisible = true;
|
};
|
const showEditView = (data) => {
|
state.title = `${proxy.$t('button.Edit')} [${data.name}]`;
|
state.dialogMode = 'edit';
|
state.entity = data;
|
|
state.dialogVisible = true;
|
};
|
|
const onSubmit = () => {
|
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");
|
UpdateVIPDepositActivity(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");
|
CreateVIPDepositActivity(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;
|
DeleteVIPDepositActivity(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;
|
}
|
|
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>
|
.el-transfer-panel {
|
height: 350px;
|
width: 300px;
|
}
|
|
.el-transfer-panel__body {
|
height: 350px;
|
width: 300px;
|
}
|
|
.el-transfer-panel__list {
|
height: 350px;
|
width: 300px;
|
}
|
|
.el-transfer-panel__list.is-filterable {
|
height: 250px;
|
width: 300px;
|
}
|
</style>
|