客户批量绑定价格套餐
This commit is contained in:
+14
@@ -15,6 +15,7 @@ import com.bms.common.core.controller.BaseController;
|
|||||||
import com.bms.common.core.domain.AjaxResult;
|
import com.bms.common.core.domain.AjaxResult;
|
||||||
import com.bms.common.enums.BusinessType;
|
import com.bms.common.enums.BusinessType;
|
||||||
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||||
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSetBatch;
|
||||||
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
||||||
import com.bms.customer.customerinfo.service.IBmsCustomerPriceSetService;
|
import com.bms.customer.customerinfo.service.IBmsCustomerPriceSetService;
|
||||||
|
|
||||||
@@ -65,6 +66,19 @@ public class BmsCustomerPriceSetController extends BaseController
|
|||||||
return toAjax(customerPriceSetService.saveBind(bind));
|
return toAjax(customerPriceSetService.saveBind(bind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量绑定套餐(客户管理列表勾选多个客户;一个客户仅一个套餐,已绑定可选择覆盖或跳过)
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('customersupplier:customerinfo:edit')")
|
||||||
|
@Log(title = "客户套餐批量绑定", businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("/bind/batch")
|
||||||
|
public AjaxResult batchBind(@RequestBody BmsCustomerPriceSetBatch req)
|
||||||
|
{
|
||||||
|
req.setCreateBy(getUsername());
|
||||||
|
req.setUpdateBy(getUsername());
|
||||||
|
return success(customerPriceSetService.batchBind(req));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解绑客户套餐
|
* 解绑客户套餐
|
||||||
*/
|
*/
|
||||||
|
|||||||
+7
@@ -116,6 +116,13 @@ public class BmsCustomer extends BaseEntity
|
|||||||
@Excel(name = "绑定产品代码")
|
@Excel(name = "绑定产品代码")
|
||||||
private String productCodes;
|
private String productCodes;
|
||||||
|
|
||||||
|
/** 已绑定价格套餐ID(join prc_customer_price_set,一个客户至多一个套餐;非表字段,仅展示) */
|
||||||
|
private Long priceSetId;
|
||||||
|
|
||||||
|
/** 已绑定价格套餐名称(join prc_price_set;非表字段,仅展示) */
|
||||||
|
@Excel(name = "绑定套餐")
|
||||||
|
private String priceSetName;
|
||||||
|
|
||||||
/** 附件列表(子表 ctr_customer_attachment) */
|
/** 附件列表(子表 ctr_customer_attachment) */
|
||||||
private List<BmsCustomerAttachment> attachmentList;
|
private List<BmsCustomerAttachment> attachmentList;
|
||||||
|
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package com.bms.customer.customerinfo.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.bms.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户套餐批量绑定入参(客户管理列表-批量绑定套餐)
|
||||||
|
*
|
||||||
|
* @author bms
|
||||||
|
* @date 2026-10-10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class BmsCustomerPriceSetBatch extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 待绑定客户ID集合 */
|
||||||
|
private List<Long> customerIds;
|
||||||
|
|
||||||
|
/** 价格套餐ID */
|
||||||
|
private Long priceSetId;
|
||||||
|
|
||||||
|
/** 绑定优先级,数字越小越优先 */
|
||||||
|
private Integer bindPriority;
|
||||||
|
|
||||||
|
/** 绑定生效日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date prBegindate;
|
||||||
|
|
||||||
|
/** 绑定失效日期(空=长期) */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date prEnddate;
|
||||||
|
|
||||||
|
/** 绑定备注 */
|
||||||
|
private String priceSetNote;
|
||||||
|
|
||||||
|
/** 已绑定套餐的客户是否覆盖更换(false=跳过,true=更换为本次套餐) */
|
||||||
|
private Boolean overwriteExisting;
|
||||||
|
}
|
||||||
+7
@@ -2,6 +2,7 @@ package com.bms.customer.customerinfo.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||||
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSetBatch;
|
||||||
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +24,12 @@ public interface IBmsCustomerPriceSetService
|
|||||||
*/
|
*/
|
||||||
public int saveBind(BmsCustomerPriceSet bind);
|
public int saveBind(BmsCustomerPriceSet bind);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量绑定套餐:未绑定的客户新增;已绑定客户按 overwriteExisting 决定更换或跳过。
|
||||||
|
* 返回执行结果摘要文案。
|
||||||
|
*/
|
||||||
|
public String batchBind(BmsCustomerPriceSetBatch req);
|
||||||
|
|
||||||
/** 按绑定主键解绑 */
|
/** 按绑定主键解绑 */
|
||||||
public int deleteBindByIds(Long[] customerPricesetIds);
|
public int deleteBindByIds(Long[] customerPricesetIds);
|
||||||
}
|
}
|
||||||
|
|||||||
+94
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import com.bms.common.exception.ServiceException;
|
import com.bms.common.exception.ServiceException;
|
||||||
import com.bms.customer.customerinfo.domain.BmsCustomer;
|
import com.bms.customer.customerinfo.domain.BmsCustomer;
|
||||||
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||||
|
import com.bms.customer.customerinfo.domain.BmsCustomerPriceSetBatch;
|
||||||
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
import com.bms.customer.customerinfo.domain.BmsPriceSetOption;
|
||||||
import com.bms.customer.customerinfo.mapper.BmsCustomerPriceSetMapper;
|
import com.bms.customer.customerinfo.mapper.BmsCustomerPriceSetMapper;
|
||||||
import com.bms.customer.customerinfo.service.IBmsCustomerLogService;
|
import com.bms.customer.customerinfo.service.IBmsCustomerLogService;
|
||||||
@@ -122,6 +123,99 @@ public class BmsCustomerPriceSetServiceImpl implements IBmsCustomerPriceSetServi
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
|
||||||
|
public String batchBind(BmsCustomerPriceSetBatch req)
|
||||||
|
{
|
||||||
|
if (req == null || req.getCustomerIds() == null || req.getCustomerIds().isEmpty())
|
||||||
|
{
|
||||||
|
throw new ServiceException("请先勾选要绑定套餐的客户");
|
||||||
|
}
|
||||||
|
if (req.getPriceSetId() == null)
|
||||||
|
{
|
||||||
|
throw new ServiceException("请选择要绑定的套餐");
|
||||||
|
}
|
||||||
|
BmsPriceSetOption set = bindMapper.selectPriceSetOptionById(req.getPriceSetId());
|
||||||
|
if (set == null)
|
||||||
|
{
|
||||||
|
throw new ServiceException("所选套餐不存在");
|
||||||
|
}
|
||||||
|
if (!"E".equals(set.getStatus()))
|
||||||
|
{
|
||||||
|
throw new ServiceException("仅生效中的套餐允许绑定,当前套餐状态不可用");
|
||||||
|
}
|
||||||
|
if (req.getPrBegindate() == null)
|
||||||
|
{
|
||||||
|
throw new ServiceException("绑定生效日期不能为空");
|
||||||
|
}
|
||||||
|
if (req.getPrEnddate() != null && req.getPrBegindate().after(req.getPrEnddate()))
|
||||||
|
{
|
||||||
|
throw new ServiceException("失效日期不能早于生效日期");
|
||||||
|
}
|
||||||
|
Integer priority = (req.getBindPriority() == null || req.getBindPriority() < 1) ? 1 : req.getBindPriority();
|
||||||
|
boolean overwrite = Boolean.TRUE.equals(req.getOverwriteExisting());
|
||||||
|
|
||||||
|
// 去重,保持勾选顺序
|
||||||
|
List<Long> customerIds = req.getCustomerIds().stream().distinct().collect(java.util.stream.Collectors.toList());
|
||||||
|
int inserted = 0, replaced = 0, skipped = 0;
|
||||||
|
List<String> skippedNames = new java.util.ArrayList<>();
|
||||||
|
for (Long customerId : customerIds)
|
||||||
|
{
|
||||||
|
BmsCustomer customer = customerService.selectBmsCustomerByCustomerId(customerId);
|
||||||
|
if (customer == null)
|
||||||
|
{
|
||||||
|
skipped++;
|
||||||
|
skippedNames.add("ID:" + customerId + "(不存在)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BmsCustomerPriceSet existing = bindMapper.selectBindByCustomerId(customerId);
|
||||||
|
if (existing != null && !overwrite)
|
||||||
|
{
|
||||||
|
skipped++;
|
||||||
|
skippedNames.add(customer.getCustomerName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BmsCustomerPriceSet bind = new BmsCustomerPriceSet();
|
||||||
|
bind.setCustomerId(customerId);
|
||||||
|
bind.setPriceSetId(req.getPriceSetId());
|
||||||
|
bind.setBindPriority(priority);
|
||||||
|
bind.setPrBegindate(req.getPrBegindate());
|
||||||
|
bind.setPrEnddate(req.getPrEnddate());
|
||||||
|
bind.setPriceSetNote(req.getPriceSetNote());
|
||||||
|
bind.setCreateBy(req.getCreateBy());
|
||||||
|
bind.setUpdateBy(req.getUpdateBy());
|
||||||
|
// saveBind 内部完成客户/套餐校验、新增或更新、业务操作日志记录
|
||||||
|
saveBind(bind);
|
||||||
|
if (existing != null)
|
||||||
|
{
|
||||||
|
replaced++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inserted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
msg.append("批量绑定完成:共 ").append(customerIds.size()).append(" 个客户,新绑定 ")
|
||||||
|
.append(inserted).append(" 个");
|
||||||
|
if (overwrite)
|
||||||
|
{
|
||||||
|
msg.append(",更换 ").append(replaced).append(" 个");
|
||||||
|
}
|
||||||
|
msg.append(",跳过 ").append(skipped).append(" 个");
|
||||||
|
if (skipped > 0 && !overwrite)
|
||||||
|
{
|
||||||
|
String names = skippedNames.stream().limit(10).collect(java.util.stream.Collectors.joining("、"));
|
||||||
|
msg.append("(已绑定套餐:").append(names);
|
||||||
|
if (skippedNames.size() > 10)
|
||||||
|
{
|
||||||
|
msg.append(" 等");
|
||||||
|
}
|
||||||
|
msg.append(",如需更换请勾选覆盖选项)");
|
||||||
|
}
|
||||||
|
return msg.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteBindByIds(Long[] customerPricesetIds)
|
public int deleteBindByIds(Long[] customerPricesetIds)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="throwRatio" column="throw_ratio" />
|
<result property="throwRatio" column="throw_ratio" />
|
||||||
<result property="creditEd" column="credit_ed" />
|
<result property="creditEd" column="credit_ed" />
|
||||||
<result property="productCodes" column="product_codes" />
|
<result property="productCodes" column="product_codes" />
|
||||||
|
<result property="priceSetId" column="price_set_id" />
|
||||||
|
<result property="priceSetName" column="price_set_name" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
@@ -54,7 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
c.product_codes, c.remark,
|
c.product_codes, c.remark,
|
||||||
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag,
|
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag,
|
||||||
su.nick_name as sales_user_nick_name
|
su.nick_name as sales_user_nick_name,
|
||||||
|
cps.price_set_id, ps.price_set_name
|
||||||
from ctr_customer c
|
from ctr_customer c
|
||||||
<!-- 老系统同步数据 sales_user_id 存员工工号(=sys_user.user_name);
|
<!-- 老系统同步数据 sales_user_id 存员工工号(=sys_user.user_name);
|
||||||
BMS 手工新建数据可能存数字 user_id,两种都要能关联上。
|
BMS 手工新建数据可能存数字 user_id,两种都要能关联上。
|
||||||
@@ -62,6 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
left join sys_user su
|
left join sys_user su
|
||||||
on su.del_flag = '0'
|
on su.del_flag = '0'
|
||||||
and (su.user_name = c.sales_user_id or su.user_id = c.sales_user_id + 0)
|
and (su.user_name = c.sales_user_id or su.user_id = c.sales_user_id + 0)
|
||||||
|
<!-- 客户套餐绑定:uk_customer_one_set 保证一客户至多一条,不会放大行数 -->
|
||||||
|
left join prc_customer_price_set cps on cps.customer_id = c.customer_id
|
||||||
|
left join prc_price_set ps on ps.price_set_id = cps.price_set_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectBmsCustomerList" parameterType="BmsCustomer" resultMap="BmsCustomerResult">
|
<select id="selectBmsCustomerList" parameterType="BmsCustomer" resultMap="BmsCustomerResult">
|
||||||
|
|||||||
@@ -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) {
|
export function delCustomerPriceSet(customerPricesetIds) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -85,6 +85,16 @@
|
|||||||
|
|
||||||
>客户余额</el-button>
|
>客户余额</el-button>
|
||||||
</el-col>
|
</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-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="info"
|
type="info"
|
||||||
@@ -176,6 +186,14 @@
|
|||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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 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">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="290" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@@ -196,6 +214,72 @@
|
|||||||
@pagination="getList"
|
@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
|
<customer-log-dialog
|
||||||
v-model="logOpen"
|
v-model="logOpen"
|
||||||
@@ -208,6 +292,7 @@
|
|||||||
|
|
||||||
<script setup name="Customer">
|
<script setup name="Customer">
|
||||||
import { listCustomer, delCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
|
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 { useProducts, parseProductCodes } from '@/components/ProductSelect/useProducts'
|
||||||
import CustomerLogDialog from './components/CustomerLogDialog.vue'
|
import CustomerLogDialog from './components/CustomerLogDialog.vue'
|
||||||
import { useColumnSettings } from '@/utils/columnSettings'
|
import { useColumnSettings } from '@/utils/columnSettings'
|
||||||
@@ -234,6 +319,7 @@ const columnDefs = [
|
|||||||
{ key: 'throwRatio', label: '抛比' },
|
{ key: 'throwRatio', label: '抛比' },
|
||||||
{ key: 'creditEd', label: '信用额度' },
|
{ key: 'creditEd', label: '信用额度' },
|
||||||
{ key: 'productCodes', label: '绑定产品' },
|
{ key: 'productCodes', label: '绑定产品' },
|
||||||
|
{ key: 'priceSetName', label: '绑定套餐' },
|
||||||
{ key: 'remark', label: '备注说明' }
|
{ key: 'remark', label: '备注说明' }
|
||||||
]
|
]
|
||||||
const { colVisible, isColVisible, toggleColumn, resetColumns } = useColumnSettings('customer-info-list', columnDefs)
|
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() {
|
function handleExport() {
|
||||||
proxy.download('/customersupplier/customerinfo/export', {
|
proxy.download('/customersupplier/customerinfo/export', {
|
||||||
@@ -396,3 +553,22 @@ function handleViewLog(row) {
|
|||||||
|
|
||||||
getList()
|
getList()
|
||||||
</script>
|
</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