客户批量绑定价格套餐
This commit is contained in:
@@ -27,6 +27,15 @@ export function saveCustomerPriceSet(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 批量绑定客户套餐(customerIds + priceSetId;overwriteExisting 控制已绑定客户是否覆盖)
|
||||
export function batchBindCustomerPriceSet(data) {
|
||||
return request({
|
||||
url: '/customersupplier/customerinfo/priceset/bind/batch',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 解绑客户套餐
|
||||
export function delCustomerPriceSet(customerPricesetIds) {
|
||||
return request({
|
||||
|
||||
@@ -85,6 +85,16 @@
|
||||
|
||||
>客户余额</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Box"
|
||||
:disabled="multiple"
|
||||
@click="handleBatchBindPriceSet"
|
||||
v-hasPermi="['customersupplier:customerinfo:edit']"
|
||||
>批量绑定套餐</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
@@ -176,6 +186,14 @@
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColVisible('priceSetName')" label="绑定套餐" align="center" prop="priceSetName" min-width="160">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.priceSetName" type="primary" size="small" :title="scope.row.priceSetName">
|
||||
{{ scope.row.priceSetName }}
|
||||
</el-tag>
|
||||
<span v-else style="color: #909399;">未绑定</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColVisible('remark')" label="备注说明" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="290" fixed="right">
|
||||
<template #default="scope">
|
||||
@@ -196,6 +214,72 @@
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 批量绑定套餐弹窗 -->
|
||||
<el-dialog title="批量绑定套餐" v-model="batchDialog.visible" width="600px" append-to-body>
|
||||
<el-alert type="info" :closable="false" show-icon style="margin-bottom: 14px;">
|
||||
<template #title>
|
||||
已选 {{ selectedRows.length }} 个客户,其中
|
||||
<b :style="{ color: boundCount ? '#e6a23c' : '' }">{{ boundCount }}</b>
|
||||
个已绑定套餐;一个客户只能绑定一个套餐。
|
||||
</template>
|
||||
</el-alert>
|
||||
<div class="batch-customers">
|
||||
<el-tag
|
||||
v-for="c in selectedRows"
|
||||
:key="c.customerId"
|
||||
:type="c.priceSetId ? 'warning' : 'info'"
|
||||
size="small"
|
||||
class="batch-customer-tag"
|
||||
:title="c.priceSetName ? ('已绑定:' + c.priceSetName) : ''"
|
||||
>
|
||||
{{ c.customerName }}<span v-if="c.priceSetName">({{ c.priceSetName }})</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-form ref="batchFormRef" :model="batchForm" :rules="batchRules" label-width="92px" style="margin-top: 14px;">
|
||||
<el-form-item label="价格套餐" prop="priceSetId">
|
||||
<el-select v-model="batchForm.priceSetId" filterable placeholder="请选择生效中的套餐" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="opt in priceSetOptions"
|
||||
:key="opt.priceSetId"
|
||||
:label="((opt.priceSetCode || '') + ' ' + opt.priceSetName).trim()"
|
||||
:value="opt.priceSetId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="生效日期" prop="prBegindate">
|
||||
<el-date-picker v-model="batchForm.prBegindate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期" style="width: 100%;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="失效日期" prop="prEnddate">
|
||||
<el-date-picker v-model="batchForm.prEnddate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="长期有效" style="width: 100%;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="优先级">
|
||||
<el-input-number v-model="batchForm.bindPriority" :min="1" controls-position="right" style="width: 100%;" />
|
||||
<div class="batch-tip">数字越小优先级越高,1 为最高</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="batchForm.priceSetNote" type="textarea" :rows="2" maxlength="100"
|
||||
show-word-limit placeholder="绑定备注(选填)" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="boundCount > 0">
|
||||
<el-checkbox v-model="batchForm.overwriteExisting">
|
||||
覆盖已绑定套餐的客户(不勾选则跳过这 {{ boundCount }} 个客户)
|
||||
</el-checkbox>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" :loading="batchDialog.loading" @click="submitBatchBind">确 定</el-button>
|
||||
<el-button @click="batchDialog.visible = false">取 消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 客户业务操作日志弹窗 -->
|
||||
<customer-log-dialog
|
||||
v-model="logOpen"
|
||||
@@ -208,6 +292,7 @@
|
||||
|
||||
<script setup name="Customer">
|
||||
import { listCustomer, delCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
|
||||
import { listPriceSetOption, batchBindCustomerPriceSet } from "@/api/customersuppliermanagement/customerinfo/customerPriceSet.js"
|
||||
import { useProducts, parseProductCodes } from '@/components/ProductSelect/useProducts'
|
||||
import CustomerLogDialog from './components/CustomerLogDialog.vue'
|
||||
import { useColumnSettings } from '@/utils/columnSettings'
|
||||
@@ -234,6 +319,7 @@ const columnDefs = [
|
||||
{ key: 'throwRatio', label: '抛比' },
|
||||
{ key: 'creditEd', label: '信用额度' },
|
||||
{ key: 'productCodes', label: '绑定产品' },
|
||||
{ key: 'priceSetName', label: '绑定套餐' },
|
||||
{ key: 'remark', label: '备注说明' }
|
||||
]
|
||||
const { colVisible, isColVisible, toggleColumn, resetColumns } = useColumnSettings('customer-info-list', columnDefs)
|
||||
@@ -372,6 +458,77 @@ function handleCustomerMoney(row) {
|
||||
}
|
||||
|
||||
|
||||
/** ========== 批量绑定套餐 ========== */
|
||||
const batchDialog = reactive({ visible: false, loading: false })
|
||||
const batchFormRef = ref(null)
|
||||
const priceSetOptions = ref([])
|
||||
const batchForm = ref({})
|
||||
const batchRules = {
|
||||
priceSetId: [{ required: true, message: '请选择价格套餐', trigger: 'change' }],
|
||||
prBegindate: [{ required: true, message: '绑定生效日期不能为空', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 勾选客户中已绑定套餐的数量 */
|
||||
const boundCount = computed(() => selectedRows.value.filter(r => r.priceSetId).length)
|
||||
|
||||
/** 打开批量绑定弹窗 */
|
||||
function handleBatchBindPriceSet() {
|
||||
if (!selectedRows.value.length) {
|
||||
proxy.$modal.msgWarning('请先勾选要绑定套餐的客户')
|
||||
return
|
||||
}
|
||||
batchForm.value = {
|
||||
priceSetId: null,
|
||||
bindPriority: 1,
|
||||
prBegindate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
|
||||
prEnddate: null,
|
||||
priceSetNote: null,
|
||||
overwriteExisting: false
|
||||
}
|
||||
batchDialog.visible = true
|
||||
// 生效套餐选项只拉一次
|
||||
if (!priceSetOptions.value.length) {
|
||||
listPriceSetOption().then(res => { priceSetOptions.value = res.data || [] })
|
||||
}
|
||||
nextTick(() => batchFormRef.value && batchFormRef.value.clearValidate())
|
||||
}
|
||||
|
||||
/** 提交批量绑定 */
|
||||
function submitBatchBind() {
|
||||
batchFormRef.value.validate(valid => {
|
||||
if (!valid) return
|
||||
if (batchForm.value.prEnddate && batchForm.value.prBegindate > batchForm.value.prEnddate) {
|
||||
proxy.$modal.msgWarning('失效日期不能早于生效日期')
|
||||
return
|
||||
}
|
||||
const total = selectedRows.value.length
|
||||
const bound = boundCount.value
|
||||
const setName = (priceSetOptions.value.find(o => o.priceSetId === batchForm.value.priceSetId) || {}).priceSetName || ''
|
||||
let confirmMsg = `确认将选中的 ${total} 个客户批量绑定套餐「${setName}」?`
|
||||
if (bound > 0 && !batchForm.value.overwriteExisting) {
|
||||
confirmMsg += `\n其中 ${bound} 个客户已绑定套餐,将自动跳过。`
|
||||
} else if (bound > 0) {
|
||||
confirmMsg += `\n其中 ${bound} 个客户已绑定套餐,将被更换为该套餐(原套餐失效)。`
|
||||
}
|
||||
proxy.$modal.confirm(confirmMsg).then(() => {
|
||||
batchDialog.loading = true
|
||||
return batchBindCustomerPriceSet({
|
||||
customerIds: selectedRows.value.map(r => r.customerId),
|
||||
priceSetId: batchForm.value.priceSetId,
|
||||
bindPriority: batchForm.value.bindPriority,
|
||||
prBegindate: batchForm.value.prBegindate,
|
||||
prEnddate: batchForm.value.prEnddate,
|
||||
priceSetNote: batchForm.value.priceSetNote,
|
||||
overwriteExisting: batchForm.value.overwriteExisting
|
||||
})
|
||||
}).then(res => {
|
||||
proxy.$modal.msgSuccess(res.msg || '批量绑定成功')
|
||||
batchDialog.visible = false
|
||||
getList()
|
||||
}).catch(() => {}).finally(() => { batchDialog.loading = false })
|
||||
})
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('/customersupplier/customerinfo/export', {
|
||||
@@ -396,3 +553,22 @@ function handleViewLog(row) {
|
||||
|
||||
getList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.batch-customers {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
padding: 8px 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
.batch-customer-tag {
|
||||
margin: 2px 4px 2px 0;
|
||||
}
|
||||
.batch-tip {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user