106 lines
3.1 KiB
Vue
106 lines
3.1 KiB
Vue
<template>
|
|
<set-section-card
|
|
title="绑定客户"
|
|
tone="green"
|
|
:count="customers.length"
|
|
sub="一个客户只能绑定一个套餐"
|
|
>
|
|
<template #action>
|
|
<el-button
|
|
v-if="editable"
|
|
type="primary"
|
|
size="small"
|
|
icon="Plus"
|
|
@click="dialogRef.open()"
|
|
v-hasPermi="editPerm"
|
|
>添加客户</el-button>
|
|
</template>
|
|
|
|
<el-table :data="customers" border class="customer-table" empty-text="暂未绑定客户">
|
|
<el-table-column label="客户代码" prop="customerCode" min-width="140" show-overflow-tooltip>
|
|
<template #default="{ row }">
|
|
<span class="c-code">{{ row.customerCode }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="客户名称" prop="customerName" min-width="160" show-overflow-tooltip />
|
|
<el-table-column label="优先级" width="130" align="center">
|
|
<template #default="{ row }">
|
|
<el-tag v-if="row.bindPriority === 1" size="small" type="success" effect="light">最高</el-tag>
|
|
<span v-else class="priority">{{ row.bindPriority }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
|
|
<template #default="{ row }">
|
|
<el-button link type="primary" @click="dialogRef.open(row)" v-hasPermi="editPerm">编辑</el-button>
|
|
<el-button link type="danger" @click="remove(row)" v-hasPermi="editPerm">解绑</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<set-customer-dialog
|
|
ref="dialogRef"
|
|
:price-set-id="set.priceSetId"
|
|
:default-begindate="set.effectiveDate"
|
|
:default-enddate="set.expireDate"
|
|
@success="emit('refresh')"
|
|
/>
|
|
</set-section-card>
|
|
</template>
|
|
|
|
<script setup name="SetCustomerTable">
|
|
/**
|
|
* 套餐详情 · 绑定客户表格
|
|
* 自带新增 / 编辑弹窗与解绑,数据变更后 emit('refresh') 由页面重新拉取详情。
|
|
*/
|
|
import SetSectionCard from './SetSectionCard.vue'
|
|
import SetCustomerDialog from './SetCustomerDialog.vue'
|
|
import { isChildEditable } from '../../utils/priceSet'
|
|
import { usePriceSetModule, usePriceSetPerm } from '../../composables/usePriceSetModule'
|
|
|
|
const { api } = usePriceSetModule()
|
|
const editPerm = usePriceSetPerm('edit')
|
|
|
|
const props = defineProps({
|
|
/** 套餐详情对象 */
|
|
set: {
|
|
type: Object,
|
|
required: true
|
|
}
|
|
})
|
|
|
|
const emit = defineEmits(['refresh'])
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
const dialogRef = ref()
|
|
|
|
const customers = computed(() => props.set.customers || [])
|
|
const editable = computed(() => isChildEditable(props.set.status))
|
|
|
|
function remove(row) {
|
|
proxy.$modal.confirm('确认解绑该客户?').then(() => api.delSetCustomer(row.customerPricesetId)).then(() => {
|
|
proxy.$modal.msgSuccess('已解绑')
|
|
emit('refresh')
|
|
}).catch(() => {})
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.customer-table {
|
|
border-radius: 6px;
|
|
}
|
|
.customer-table :deep(th.el-table__cell) {
|
|
background: #fafbfc;
|
|
color: #606266;
|
|
font-weight: 600;
|
|
}
|
|
.c-code {
|
|
font-family: Consolas, Monaco, monospace;
|
|
font-size: 12px;
|
|
color: #606266;
|
|
}
|
|
.priority {
|
|
color: #303133;
|
|
}
|
|
</style>
|