<template>
|
<div style="margin-right: 30px">
|
<!-- 操作按钮区域 -->
|
<div class="table-operator">
|
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
|
<a-divider type="vertical" />
|
<a-button @click="loadData()" type="primary" icon="search">刷新</a-button>
|
<!--<a-button type="primary" icon="download" @click="handleExportXls('Activity')">导出</a-button>-->
|
</div>
|
|
<!-- table区域-begin -->
|
<div>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
class="infoTable"
|
:scroll="{ x: true }"
|
:columns="defaultColumns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
@change="handleTableChange"
|
>
|
<span slot="action" slot-scope="text, record">
|
<a @click="handleEdit(record)">编辑</a>
|
<a-divider v-if="record.id != 1 && record.id != 2" type="vertical" />
|
<a-popconfirm
|
v-if="record.id != 1 && record.id != 2"
|
title="确定删除吗?"
|
@confirm="() => handleDelete(record.id)"
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
</div>
|
<!-- table区域-end -->
|
|
<!-- 表单区域 -->
|
<CustTypeModal ref="modalForm" @ok="modalFormOk"></CustTypeModal>
|
</div>
|
</template>
|
|
<script>
|
import CustTypeModal from './CustTypeModal'
|
import { JeecgListMixin } from '@tievd/cube-block/lib/mixins/JeecgListMixin'
|
import { UI_CACHE_DB_DICT_DATA } from '@tievd/cube-block/lib/store/mutation-types'
|
import { deleteAction } from '@tievd/cube-block/lib/api/manage'
|
import Vue from 'vue'
|
|
export default {
|
name: 'ActivityList',
|
|
mixins: [JeecgListMixin],
|
|
components: {
|
CustTypeModal,
|
},
|
|
data() {
|
return {
|
description: 'Activity列表',
|
// 表头
|
columns: [],
|
// 列定义
|
defaultColumns: [
|
{
|
title: '序号',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
},
|
{
|
title: '客户类型',
|
align: 'center',
|
dataIndex: 'clientName',
|
},
|
{
|
title: '规则配置',
|
align: 'center',
|
dataIndex: 'endTime',
|
customRender: (t, r) => {
|
if (r.clientConfigs.length > 1) {
|
let x = r.clientConfigs.map((el, index) => {
|
return (
|
<div>
|
条件{index + 1}: {this.transformConfigText(el)}
|
</div>
|
)
|
})
|
return {
|
children: x,
|
}
|
} else {
|
let x = r.clientConfigs.map((el, index) => {
|
return <div>{this.transformConfigText(el)}</div>
|
})
|
return {
|
children: x,
|
}
|
}
|
},
|
},
|
|
{
|
title: '操作',
|
dataIndex: 'action',
|
width: 150,
|
align: 'center',
|
scopedSlots: { customRender: 'action' },
|
},
|
],
|
url: {
|
list: '/jyz/clientConfig/list',
|
delete: '/jyz/clientConfig/delete',
|
deleteBatch: '/jyz/activity/deleteBatch',
|
exportXlsUrl: '/jyz/activity/exportXls',
|
},
|
}
|
},
|
|
methods: {
|
modalFormOk() {
|
// 添加/编辑成功后刷新页面以更新字典缓存
|
window.location.reload()
|
},
|
handleDelete(id) {
|
// 删除前清除前端字典缓存
|
// 删除后刷新页面以更新字典缓存
|
deleteAction(this.url.delete, { id: id })
|
.then((res) => {
|
if (res.success) {
|
this.$message.success(res.message)
|
window.location.reload()
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
this.loading = false
|
})
|
},
|
transformConfigText(obj) {
|
var text = ''
|
if (obj.timeStr == '1,YEARS') {
|
text += '近1年'
|
}
|
if (obj.timeStr == '3,MONTHS') {
|
text += '近3月'
|
}
|
if (obj.timeStr == '6,MONTHS') {
|
text += '近6月'
|
}
|
if (obj.timeStr == '7,DAYS') {
|
text += '近7天'
|
}
|
if (obj.timeStr == '30,DAYS') {
|
text += '近30天'
|
}
|
if (obj.countType == 1) {
|
text += '累计加油'
|
}
|
if (obj.countType == 2) {
|
text += '每月加油'
|
}
|
if (obj.countRef == -1) {
|
text += `小于${obj.countNum}次`
|
}
|
if (obj.countRef == 0) {
|
text += `等于${obj.countNum}次`
|
}
|
if (obj.countRef == 1) {
|
text += `大于${obj.countNum}次`
|
}
|
return text
|
},
|
},
|
|
created() {},
|
}
|
</script>
|
<style scoped lang="less">
|
@import '~@assets/less/common.less';
|
/deep/ .ant-table-body {
|
height: 500px;
|
}
|
</style>
|