6 changed files with 891 additions and 0 deletions
@ -0,0 +1,75 @@ |
|||
<template> |
|||
<el-table-column :prop="prop" v-bind="$attrs"> |
|||
<template slot-scope="scope"> |
|||
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="{ 'padding-left': ((scope.row._level || 0) * 10) + 'px' }"> |
|||
<i :class="[ scope.row._expanded ? 'el-icon-caret-bottom' : 'el-icon-caret-right' ]" :style="{ 'visibility': hasChild(scope.row) ? 'visible' : 'hidden' }"></i> |
|||
{{ scope.row[prop] }} |
|||
</span> |
|||
</template> |
|||
</el-table-column> |
|||
</template> |
|||
|
|||
<script> |
|||
import isArray from 'lodash/isArray' |
|||
export default { |
|||
name: 'table-tree-column', |
|||
props: { |
|||
prop: { |
|||
type: String |
|||
}, |
|||
treeKey: { |
|||
type: String, |
|||
default: 'id' |
|||
}, |
|||
parentKey: { |
|||
type: String, |
|||
default: 'pid' |
|||
}, |
|||
childKey: { |
|||
type: String, |
|||
default: 'children' |
|||
} |
|||
}, |
|||
methods: { |
|||
hasChild (row) { |
|||
return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false |
|||
}, |
|||
// 切换处理 |
|||
toggleHandle (index, row) { |
|||
if (!this.hasChild(row)) { |
|||
return false |
|||
} |
|||
var data = this.$parent.store.states.data.slice(0) |
|||
data[index]._expanded = !data[index]._expanded |
|||
if (data[index]._expanded) { |
|||
row[this.childKey].forEach(item => { |
|||
item._level = (row._level || 0) + 1 |
|||
item._expanded = false |
|||
}) |
|||
data = data.splice(0, index + 1).concat(row[this.childKey]).concat(data) |
|||
} else { |
|||
data = this.removeChildNode(data, row[this.treeKey]) |
|||
} |
|||
this.$parent.store.commit('setData', data) |
|||
this.$nextTick(() => { |
|||
this.$parent.doLayout() |
|||
}) |
|||
}, |
|||
// 移除子节点 |
|||
removeChildNode (data, pid) { |
|||
var pids = isArray(pid) ? pid : [pid] |
|||
if (pid.length <= 0) { |
|||
return data |
|||
} |
|||
var ids = [] |
|||
for (var i = 0; i < data.length; i++) { |
|||
if (pids.indexOf(data[i][this.parentKey]) !== -1 && pids.indexOf(data[i][this.treeKey]) === -1) { |
|||
ids.push(data.splice(i, 1)[0][this.treeKey]) |
|||
i-- |
|||
} |
|||
} |
|||
return this.removeChildNode(data, ids) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,179 @@ |
|||
import Cookies from 'js-cookie' |
|||
import qs from 'qs' |
|||
export default { |
|||
data() { |
|||
/* eslint-disable */ |
|||
return { |
|||
// 设置属性
|
|||
mixinViewModuleOptions: { |
|||
createdIsNeed: true, // 此页面是否在创建时,调用查询数据列表接口?
|
|||
activatedIsNeed: false, // 此页面是否在激活(进入)时,调用查询数据列表接口?
|
|||
getDataListURL: '', // 数据列表接口,API地址
|
|||
getDataListIsPage: false, // 数据列表接口,是否需要分页?
|
|||
deleteURL: '', // 删除接口,API地址
|
|||
deleteIsBatch: false, // 删除接口,是否需要批量?
|
|||
deleteIsBatchKey: 'id', // 删除接口,批量状态下由那个key进行标记操作?比如:pid,uid...
|
|||
exportURL: '' // 导出接口,API地址
|
|||
}, |
|||
// 默认属性
|
|||
dataForm: {}, // 查询条件
|
|||
dataList: [], // 数据列表
|
|||
order: '', // 排序,asc/desc
|
|||
orderField: '', // 排序,字段
|
|||
page: 1, // 当前页码
|
|||
limit: 10, // 每页数
|
|||
total: 0, // 总条数
|
|||
dataListLoading: false, // 数据列表,loading状态
|
|||
dataListSelections: [], // 数据列表,多选项
|
|||
addOrUpdateVisible: false // 新增/更新,弹窗visible状态
|
|||
} |
|||
/* eslint-enable */ |
|||
}, |
|||
created() { |
|||
if (this.mixinViewModuleOptions.createdIsNeed) { |
|||
this.query() |
|||
} |
|||
}, |
|||
activated() { |
|||
if (this.mixinViewModuleOptions.activatedIsNeed) { |
|||
this.query() |
|||
} |
|||
}, |
|||
methods: { |
|||
// 获取数据列表
|
|||
query() { |
|||
this.dataListLoading = true |
|||
this.$http |
|||
.post(this.mixinViewModuleOptions.getDataListURL, { |
|||
order: this.order, |
|||
orderField: this.orderField, |
|||
page: this.mixinViewModuleOptions.getDataListIsPage |
|||
? this.page |
|||
: null, |
|||
limit: this.mixinViewModuleOptions.getDataListIsPage |
|||
? this.limit |
|||
: null, |
|||
...this.dataForm |
|||
}) |
|||
.then(({ data: res }) => { |
|||
this.dataListLoading = false |
|||
if (res.code !== 0) { |
|||
this.dataList = [] |
|||
this.total = 0 |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataList = this.mixinViewModuleOptions.getDataListIsPage |
|||
? res.data.list |
|||
: res.data |
|||
this.total = this.mixinViewModuleOptions.getDataListIsPage |
|||
? res.data.total |
|||
: 0 |
|||
}) |
|||
.catch(() => { |
|||
this.dataListLoading = false |
|||
}) |
|||
}, |
|||
// 多选
|
|||
dataListSelectionChangeHandle(val) { |
|||
this.dataListSelections = val |
|||
}, |
|||
// 排序
|
|||
dataListSortChangeHandle(data) { |
|||
if (!data.order || !data.prop) { |
|||
this.order = '' |
|||
this.orderField = '' |
|||
return false |
|||
} |
|||
this.order = data.order.replace(/ending$/, '') |
|||
this.orderField = data.prop.replace(/([A-Z])/g, '_$1').toLowerCase() |
|||
this.query() |
|||
}, |
|||
// 分页, 每页条数
|
|||
pageSizeChangeHandle(val) { |
|||
this.page = 1 |
|||
this.limit = val |
|||
this.query() |
|||
}, |
|||
// 分页, 当前页
|
|||
pageCurrentChangeHandle(val) { |
|||
this.page = val |
|||
this.query() |
|||
}, |
|||
getDataList: function () { |
|||
this.page = 1 |
|||
this.query() |
|||
}, |
|||
// 新增 / 修改
|
|||
addOrUpdateHandle(id) { |
|||
this.addOrUpdateVisible = true |
|||
this.$nextTick(() => { |
|||
this.$refs.addOrUpdate.dataForm.id = id |
|||
this.$refs.addOrUpdate.init() |
|||
}) |
|||
}, |
|||
// 删除
|
|||
deleteHandle(id) { |
|||
if ( |
|||
this.mixinViewModuleOptions.deleteIsBatch && |
|||
!id && |
|||
this.dataListSelections.length <= 0 |
|||
) { |
|||
return this.$message({ |
|||
message: this.$t('prompt.deleteBatch'), |
|||
type: 'warning', |
|||
duration: 500 |
|||
}) |
|||
} |
|||
this.$confirm( |
|||
this.$t('prompt.info', { handle: this.$t('delete') }), |
|||
this.$t('prompt.title'), |
|||
{ |
|||
confirmButtonText: this.$t('confirm'), |
|||
cancelButtonText: this.$t('cancel'), |
|||
type: 'warning' |
|||
} |
|||
) |
|||
.then(() => { |
|||
this.$http |
|||
.delete( |
|||
`${this.mixinViewModuleOptions.deleteURL}${ |
|||
this.mixinViewModuleOptions.deleteIsBatch ? '' : '/' + id |
|||
}`,
|
|||
this.mixinViewModuleOptions.deleteIsBatch |
|||
? { |
|||
data: id |
|||
? [id] |
|||
: this.dataListSelections.map( |
|||
(item) => |
|||
item[this.mixinViewModuleOptions.deleteIsBatchKey] |
|||
) |
|||
} |
|||
: {} |
|||
) |
|||
.then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$message({ |
|||
message: this.$t('prompt.success'), |
|||
type: 'success', |
|||
duration: 500, |
|||
onClose: () => { |
|||
this.query() |
|||
} |
|||
}) |
|||
}) |
|||
.catch(() => {}) |
|||
}) |
|||
.catch(() => {}) |
|||
}, |
|||
// 导出
|
|||
exportHandle() { |
|||
var params = qs.stringify({ |
|||
token: Cookies.get('token'), |
|||
...this.dataForm |
|||
}) |
|||
window.location.href = `${window.SITE_CONFIG['apiURL']}${this.mixinViewModuleOptions.exportURL}?${params}` |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,186 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="父级客户" prop="parentCustomerId"> |
|||
<el-select clearable v-model="dataForm.parentCustomerId" placeholder="请选择" @change="changeRootCustomer($event)"> |
|||
<el-option v-for="item in rootCustomer" :key="item.customerId" :label="item.customerName" :value="item.customerId"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="子级客户" prop="customerId"> |
|||
<el-select clearable v-model="dataForm.customerId" placeholder="请选择" @change="changeSubCustomer($event)"> |
|||
<el-option v-for="item in subCustomer" :key="item.customerId" :label="item.customerName" :value="item.customerId"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="是否启用" prop="status"> |
|||
<el-select clearable v-model="dataForm.status" placeholder="请选择"> |
|||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.name" :value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import debounce from 'lodash/debounce' |
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
areaCode: '0', |
|||
rootCustomer: [], |
|||
subCustomer: [], |
|||
statusOptions: [ |
|||
{ value: 'open', name: '启用' }, |
|||
{ value: 'closed', name: '禁用' } |
|||
], |
|||
dataForm: { |
|||
id: '', |
|||
customerId: '', |
|||
parentCustomerId: '', |
|||
pids: '0', |
|||
customerType: '', |
|||
parentCustomerType: '', |
|||
status: '', |
|||
level: '', |
|||
areaCode: '', |
|||
parentAreaCode: '' |
|||
} |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule () { |
|||
return { |
|||
customerId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
parentCustomerId: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
pids: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
status: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
level: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
areaCode: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
], |
|||
parentAreaCode: [ |
|||
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init () { |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
this.getRootCustomer() |
|||
}, |
|||
getRootCustomer () { |
|||
this.$http.get(`/gov/org/agency/areasubagency/0`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.rootCustomer = res.data |
|||
if (this.rootCustomer.length === 0) { |
|||
this.$message({ |
|||
type: 'warning', |
|||
message: '当前客户区划下没有下级客户' |
|||
}) |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
getSubCustomer () { |
|||
if (this.areaCode) { |
|||
this.$http.get(`/gov/org/agency/areasubagency/` + this.areaCode).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
res.data.forEach(element => { |
|||
if (element.customerId !== this.dataForm.parentCustomerId ){ |
|||
this.subCustomer.push(element) |
|||
} |
|||
}); |
|||
if (this.subCustomer.length === 0) { |
|||
this.$message({ |
|||
type: 'warning', |
|||
message: '该客户区划下没有下级客户' |
|||
}) |
|||
} |
|||
}).catch(() => {}) |
|||
} |
|||
}, |
|||
changeRootCustomer (e) { |
|||
this.subCustomer = [] |
|||
if (this.dataForm.parentCustomerId) { |
|||
let root = this.rootCustomer.filter(item => item.customerId === this.dataForm.parentCustomerId)[0] |
|||
if (root) { |
|||
this.dataForm.parentAreaCode = root.areaCode |
|||
|
|||
this.areaCode = root.areaCode |
|||
this.getSubCustomer() |
|||
} |
|||
} |
|||
}, |
|||
changeSubCustomer (e) { |
|||
if (this.dataForm.customerId) { |
|||
let root = this.subCustomer.filter(item => item.customerId === this.dataForm.customerId)[0] |
|||
if (root) { |
|||
this.dataForm.level = root.level |
|||
this.dataForm.areaCode = root.areaCode |
|||
} |
|||
} |
|||
}, |
|||
// 获取信息 |
|||
getInfo () { |
|||
this.$http.get(`/oper/crm/customerRelation/${this.dataForm.id}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
}).catch(() => {}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/oper/crm/customerRelation/save', this.dataForm).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$message({ |
|||
message: this.$t('prompt.success'), |
|||
type: 'success', |
|||
duration: 500, |
|||
onClose: () => { |
|||
this.visible = false |
|||
this.$emit('refreshDataList') |
|||
} |
|||
}) |
|||
}).catch(() => {}) |
|||
}) |
|||
}, 1000, { 'leading': true, 'trailing': false }) |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,139 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-__customerRelation}"> |
|||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> |
|||
<!-- <el-form-item>--> |
|||
<!-- <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>--> |
|||
<!-- </el-form-item>--> |
|||
<!-- <el-form-item>--> |
|||
<!-- <el-button @click="getDataList()">{{ $t('query') }}</el-button>--> |
|||
<!-- </el-form-item>--> |
|||
<!--<el-form-item>--> |
|||
<!--<el-button class="diy-button--add" size="small" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>--> |
|||
<!--</el-form-item>--> |
|||
<!-- <el-form-item>--> |
|||
<!-- <el-button type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>--> |
|||
<!-- </el-form-item>--> |
|||
</el-form> |
|||
<!-- <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%">--> |
|||
<!-- <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>--> |
|||
<!-- <el-table-column prop="id" label="主键" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="customerId" label="客户id" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="parentCustomerId" label="父级客户id;如果是顶级客户,此列=0" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="pids" label="当前客户的所有父级客户id,以英文冒号隔开,如果是顶级客户,此列=0" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="customerType" label="当前客户类型取值: external:外部客户,internal:内部客户" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="parentCustomerType" label="父级客户类型取值: external:外部客户,internal:内部客户;如果是顶级客户,此列=0" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="status" label="open,closed是否启用" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="level" label="当前客户级别(社区级:community,--> |
|||
<!--乡(镇、街道)级:street,--> |
|||
<!--区县级: district,--> |
|||
<!--市级: city--> |
|||
<!--省级:province)" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="areaCode" label="当前客户的地区编码,实际就是根组织的area_code" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="parentAreaCode" label="07.01:当前客户的的上级组织对应的area_code" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="delFlag" label="删除标识0未删除1已删除" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="revision" label="乐观锁" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="updatedBy" label="更新人" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column prop="updatedTime" label="更新时间" header-align="center" align="center"></el-table-column>--> |
|||
<!-- <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">--> |
|||
<!-- <template slot-scope="scope">--> |
|||
<!-- <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id, $t('update'))">{{ $t('update') }}</el-button>--> |
|||
<!-- <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>--> |
|||
<!-- </template>--> |
|||
<!-- </el-table-column>--> |
|||
<!-- </el-table>--> |
|||
<!-- <el-pagination--> |
|||
<!-- :current-page="page"--> |
|||
<!-- :page-sizes="[10, 20, 50, 100]"--> |
|||
<!-- :page-size="limit"--> |
|||
<!-- :total="total"--> |
|||
<!-- layout="total, sizes, prev, pager, next, jumper"--> |
|||
<!-- @size-change="pageSizeChangeHandle"--> |
|||
<!-- @current-change="pageCurrentChangeHandle">--> |
|||
<!-- </el-pagination>--> |
|||
<el-table |
|||
class="resi-table" |
|||
v-loading="tableLoading" |
|||
:data="tableData" |
|||
:default-expand-all="true" |
|||
row-key="areaCode" |
|||
border |
|||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
|||
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}" |
|||
:height="tableHeight"> |
|||
<el-table-column prop="areaName" label="区域名称"></el-table-column> |
|||
<el-table-column prop="customerName" label="客户名称" header-align="center" align="center"></el-table-column> |
|||
<!--<el-table-column prop="status" label="是否启用" header-align="center" align="center">--> |
|||
<!--<template slot-scope="scope">--> |
|||
<!--<el-tag v-if="scope.row.status === 'open' && scope.row.parentCustomerId !== '0'" size="small" type="success">{{ '启用' }}</el-tag>--> |
|||
<!--<el-tag v-if="scope.row.status === 'close' && scope.row.parentCustomerId !== '0'" size="small" type="danger">{{ '禁用' }}</el-tag>--> |
|||
<!--</template>--> |
|||
<!--</el-table-column>--> |
|||
<!--<el-table-column label="操作" align="center" width="300">--> |
|||
<!--<template slot-scope="scope">--> |
|||
<!--<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id, $t('update'))">{{ $t('update') }}</el-button>--> |
|||
<!--<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>--> |
|||
<!--</template>--> |
|||
<!--</el-table-column>--> |
|||
</el-table> |
|||
<!-- 弹窗, 新增 / 修改 --> |
|||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import mixinViewModule from '@/mixins/view-module' |
|||
import AddOrUpdate from './customerrelation-add-or-update' |
|||
import TableTreeColumn from '@/components/table-tree-column' |
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data () { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
createdIsNeed: false, |
|||
getDataListURL: '/gov/org/agency/customertree', |
|||
getDataListIsPage: true, |
|||
deleteURL: '/oper/crm/customerRelation', |
|||
deleteIsBatch: true |
|||
}, |
|||
tableLoading: false, |
|||
tableData: [], |
|||
dataForm: { |
|||
id: '' |
|||
} |
|||
} |
|||
}, |
|||
components: { |
|||
TableTreeColumn, |
|||
AddOrUpdate |
|||
}, |
|||
created() { |
|||
this.getTableData() |
|||
}, |
|||
methods: { |
|||
// 查询列表 |
|||
async getTableData () { |
|||
this.tableLoading = true |
|||
await this.$http.get('/gov/org/agency/customertree').then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.internalMsg ? res.internalMsg : res.msg ? res.msg : '查询失败') |
|||
} else { |
|||
this.tableData = res.data |
|||
} |
|||
}).catch(() => {}) |
|||
this.tableLoading = false |
|||
}, |
|||
addOrUpdateHandle(id, title) { |
|||
this.dialogTitle = title; |
|||
this.$nextTick(() => { |
|||
this.$refs.addOrUpdate.dataForm.id = id; |
|||
this.$refs.addOrUpdate.init(); |
|||
}); |
|||
this.addOrUpdateVisible = true; |
|||
}, |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,239 @@ |
|||
<template> |
|||
<el-dialog |
|||
:visible.sync="visible" |
|||
:title="'选择客户'" |
|||
:close-on-click-modal="false" |
|||
:close-on-press-escape="false" |
|||
width="700px" |
|||
:top="diaTop" |
|||
> |
|||
<div class="customerDiv" :style="{ height: diaHeight + 'px' }"> |
|||
<el-checkbox |
|||
:indeterminate="isIndeterminate" |
|||
v-model="checkAll" |
|||
@change="handleCheckAllChange" |
|||
>全选</el-checkbox |
|||
> |
|||
|
|||
<div |
|||
class="customerItem" |
|||
:key="item.customerId" |
|||
v-for="(item, index) in customerList" |
|||
> |
|||
<el-checkbox |
|||
:key="index" |
|||
class="customerItem" |
|||
v-model="item.selected" |
|||
:label="item.customerId" |
|||
>{{ item.customerName }}</el-checkbox |
|||
> |
|||
|
|||
<el-select |
|||
v-show="item.selected" |
|||
v-model="item.categoryKeyArr" |
|||
size="small" |
|||
multiple |
|||
collapse-tags |
|||
placeholder="请选择功能类别" |
|||
> |
|||
<el-option |
|||
v-for="item in categoryOptions" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value" |
|||
> |
|||
</el-option> |
|||
</el-select> |
|||
|
|||
<el-button |
|||
class="item-btn" |
|||
v-if="item.selected" |
|||
style="margin-left: 20px" |
|||
type="text" |
|||
size="small" |
|||
@click="copyToAll(item)" |
|||
>应用到所有客户</el-button |
|||
> |
|||
</div> |
|||
</div> |
|||
|
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="save()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import { Loading } from 'element-ui' // 引入Loading服务 |
|||
import { requestPost, requestGet } from '@/js/dai/request' |
|||
import { mapGetters } from 'vuex' |
|||
|
|||
let loading // 加载动画 |
|||
export default { |
|||
data() { |
|||
return { |
|||
visible: false, |
|||
|
|||
elseParams: {}, //选中的表单id,从父组件传过来 |
|||
|
|||
categoryOptions: [], |
|||
|
|||
customerList: [], //客户列表 |
|||
|
|||
isIndeterminate: true, |
|||
checkAll: false |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
diaWidth() { |
|||
return this.resolution === 'small' ? 60 : 50 |
|||
}, |
|||
diaHeight() { |
|||
return this.resolution === 'small' ? 350 : 600 |
|||
}, |
|||
diaTop() { |
|||
return this.resolution === 'small' ? '30px' : '100px' |
|||
}, |
|||
...mapGetters(['clientHeight', 'resolution']) |
|||
}, |
|||
|
|||
mounted() { |
|||
this.getOptions() |
|||
}, |
|||
|
|||
methods: { |
|||
handleCheckAllChange(val) { |
|||
this.customerList.forEach((item) => { |
|||
item.selected = val |
|||
}) |
|||
this.isIndeterminate = false |
|||
}, |
|||
|
|||
copyToAll(val) { |
|||
this.customerList.forEach((item) => { |
|||
item.categoryKeyArr = [...val.categoryKeyArr] |
|||
}) |
|||
}, |
|||
|
|||
async init(row) { |
|||
console.log('1111111111', row) |
|||
const { reportId, customerList } = row |
|||
this.visible = true |
|||
this.elseParams = { reportId } |
|||
this.startLoading() |
|||
|
|||
this.customerList = [] |
|||
|
|||
await this.getCustomerList() |
|||
|
|||
customerList.forEach((item) => { |
|||
let same = this.customerList.find( |
|||
(item2) => item2.customerId == item.customerId |
|||
) |
|||
if (same) { |
|||
same.selected = true |
|||
same.categoryKeyArr.push(item.categoryKey) |
|||
} |
|||
}) |
|||
|
|||
this.endLoading() |
|||
}, |
|||
|
|||
//获取所有客户列表 |
|||
async getCustomerList() { |
|||
const { data, code, msg } = await requestGet( |
|||
'/oper/crm/customer/getvalidcustomerlist', |
|||
{} |
|||
) |
|||
if (code === 0) { |
|||
this.customerList = data.map((item) => { |
|||
item.categoryKeyArr = [] |
|||
item.selected = false |
|||
return item |
|||
}) |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
//获取所有客户列表 |
|||
async getOptions() { |
|||
const { data, code, msg } = await requestPost('/sys/dict/data/dictlist', { |
|||
dictType: 'jmreport_category' |
|||
}) |
|||
if (code === 0) { |
|||
this.categoryOptions = data |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
|
|||
async save() { |
|||
this.checkCustomerList = [] |
|||
const url = '/oper/customize/icCustomerReport/edit' |
|||
const parmas = { |
|||
...this.elseParams, |
|||
type: 'add', |
|||
customerList: this.customerList |
|||
.filter((item) => item.selected) |
|||
.map((item) => ({ |
|||
customerId: item.customerId, |
|||
categoryKeys: item.categoryKeyArr |
|||
})) |
|||
} |
|||
|
|||
const { data, code, msg } = await requestPost(url, parmas) |
|||
|
|||
if (code === 0) { |
|||
this.$message.success('保存成功') |
|||
this.visible = false |
|||
this.$emit('refreshDataList') |
|||
} else { |
|||
this.$message.error(msg) |
|||
} |
|||
}, |
|||
// 开启加载动画 |
|||
startLoading() { |
|||
loading = Loading.service({ |
|||
lock: true, // 是否锁定 |
|||
text: '正在加载……', // 加载中需要显示的文字 |
|||
background: 'rgba(0,0,0,.7)' // 背景颜色 |
|||
}) |
|||
}, |
|||
// 结束加载动画 |
|||
endLoading() { |
|||
// clearTimeout(timer); |
|||
if (loading) { |
|||
loading.close() |
|||
} |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.customerDiv { |
|||
margin-left: 100px; |
|||
overflow-y: scroll; |
|||
} |
|||
.customerItem { |
|||
margin: 20px; |
|||
font-size: 15px; |
|||
display: flex; |
|||
align-items: center; |
|||
.item-btn { |
|||
visibility: hidden; |
|||
} |
|||
&:hover { |
|||
.item-btn { |
|||
visibility: visible; |
|||
} |
|||
} |
|||
} |
|||
|
|||
.item_span { |
|||
margin-left: 20px; |
|||
} |
|||
</style> |
@ -0,0 +1,73 @@ |
|||
<template> |
|||
<el-card shadow="never" class="aui-card--fill"> |
|||
<div class="mod-sys__menu"> |
|||
<el-table |
|||
v-loading="dataListLoading" |
|||
:data="dataList" |
|||
row-key="id" |
|||
border |
|||
:height="tableHeight" |
|||
style="width: 100%" |
|||
> |
|||
<el-table-column |
|||
prop="reportName" |
|||
label="模板名称" |
|||
header-align="center" |
|||
min-width="150" |
|||
></el-table-column> |
|||
<el-table-column |
|||
label="客户配置" |
|||
fixed="right" |
|||
header-align="center" |
|||
align="center" |
|||
width="150" |
|||
> |
|||
<template slot-scope="scope"> |
|||
<el-button |
|||
type="text" |
|||
size="small" |
|||
@click="showCustomerMenu(scope.row)" |
|||
>{{ '客户配置' }}</el-button |
|||
> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<!-- 客户菜单配置 --> |
|||
<customer-set ref="customerForm" @refreshDataList="getDataList" /> |
|||
</div> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import mixinViewModule from '@/mixins/view-module-post' |
|||
import { mapGetters } from 'vuex' |
|||
import CustomerSet from './customer-set' |
|||
|
|||
export default { |
|||
mixins: [mixinViewModule], |
|||
data() { |
|||
return { |
|||
mixinViewModuleOptions: { |
|||
getDataListURL: '/oper/customize/icCustomerReport/list' |
|||
}, |
|||
customerFormVisible: false, |
|||
dataForm: {} |
|||
} |
|||
}, |
|||
components: { |
|||
CustomerSet |
|||
}, |
|||
computed: { |
|||
tableHeight() { |
|||
// return this.resolution === 'small' ? this.clientHeight - 210 : this.clientHeight - 220 |
|||
return this.clientHeight - 210 |
|||
}, |
|||
...mapGetters(['clientHeight', 'resolution']) |
|||
}, |
|||
methods: { |
|||
showCustomerMenu(row) { |
|||
this.$refs['customerForm'].init(row) |
|||
} |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue