修改打单套餐功能
This commit is contained in:
-48
@@ -217,54 +217,6 @@ public class LabelPackageController extends BaseController
|
|||||||
return toAjax(payProductService.removeLabelProducts(priceSetId, productIds));
|
return toAjax(payProductService.removeLabelProducts(priceSetId, productIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:label:query')")
|
|
||||||
@GetMapping("/{priceSetId}/channels")
|
|
||||||
public AjaxResult listChannels(@PathVariable Long priceSetId)
|
|
||||||
{
|
|
||||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
|
||||||
return success(payProductService.listLabelChannels(priceSetId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
|
||||||
@Log(title = "打单套餐绑定渠道", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping("/{priceSetId}/channels")
|
|
||||||
public AjaxResult bindChannels(@PathVariable Long priceSetId, @RequestBody Map<String, Object> body)
|
|
||||||
{
|
|
||||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
|
||||||
List<String> channelIds = new ArrayList<String>();
|
|
||||||
Object rawIds = body == null ? null : body.get("channelIds");
|
|
||||||
if (rawIds instanceof List<?>)
|
|
||||||
{
|
|
||||||
for (Object item : (List<?>) rawIds)
|
|
||||||
{
|
|
||||||
if (item != null && !String.valueOf(item).trim().isEmpty())
|
|
||||||
{
|
|
||||||
channelIds.add(String.valueOf(item).trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Long productId = null;
|
|
||||||
Object rawProductId = body == null ? null : body.get("productId");
|
|
||||||
if (rawProductId instanceof Number)
|
|
||||||
{
|
|
||||||
productId = ((Number) rawProductId).longValue();
|
|
||||||
}
|
|
||||||
else if (rawProductId != null && !String.valueOf(rawProductId).trim().isEmpty()
|
|
||||||
&& !"null".equalsIgnoreCase(String.valueOf(rawProductId).trim()))
|
|
||||||
{
|
|
||||||
productId = Long.valueOf(String.valueOf(rawProductId).trim());
|
|
||||||
}
|
|
||||||
return success(payProductService.bindLabelChannels(priceSetId, channelIds, productId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
|
||||||
@Log(title = "打单套餐解绑渠道", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{priceSetId}/channels/{channelId}")
|
|
||||||
public AjaxResult unbindChannel(@PathVariable Long priceSetId, @PathVariable String channelId)
|
|
||||||
{
|
|
||||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
|
||||||
return toAjax(payProductService.unbindLabelChannel(priceSetId, channelId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:label:list')")
|
@PreAuthorize("@ss.hasPermi('price:label:list')")
|
||||||
@GetMapping("/customer/list")
|
@GetMapping("/customer/list")
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ public class ChannelProductMap
|
|||||||
|
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
/** 打单套餐 ID,对应 prc_price_set.price_set_id(应收可填) */
|
|
||||||
private Long priceSetId;
|
|
||||||
|
|
||||||
/** 渠道名称(列表回显) */
|
/** 渠道名称(列表回显) */
|
||||||
private String channelName;
|
private String channelName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,19 @@
|
|||||||
package com.bms.price.mapper;
|
package com.bms.price.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import com.bms.price.domain.ChannelProductMap;
|
import com.bms.price.domain.ChannelProductMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渠道产品关系映射
|
* Channel-product pay-type mapping.
|
||||||
*/
|
*/
|
||||||
public interface ChannelProductMapMapper
|
public interface ChannelProductMapMapper
|
||||||
{
|
{
|
||||||
ChannelProductMap selectByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
ChannelProductMap selectByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
||||||
|
|
||||||
List<ChannelProductMap> selectByPriceSetId(@Param("priceSetId") Long priceSetId);
|
|
||||||
|
|
||||||
int upsert(ChannelProductMap row);
|
int upsert(ChannelProductMap row);
|
||||||
|
|
||||||
int deleteByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
int deleteByChannelAndType(@Param("channelId") String channelId, @Param("payType") String payType);
|
||||||
|
|
||||||
int deleteByChannelTypeAndPriceSet(@Param("channelId") String channelId, @Param("payType") String payType,
|
|
||||||
@Param("priceSetId") Long priceSetId);
|
|
||||||
|
|
||||||
int deleteByProductId(@Param("productId") Long productId);
|
int deleteByProductId(@Param("productId") Long productId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ public interface PayProductTermMapper
|
|||||||
|
|
||||||
PayProductTerm selectByProductId(Long productId);
|
PayProductTerm selectByProductId(Long productId);
|
||||||
|
|
||||||
/** 打单产品所属套餐 ID */
|
|
||||||
Long selectLabelPriceSetIdByProduct(@Param("productId") Long productId);
|
|
||||||
|
|
||||||
List<PayProductTerm> selectByPriceSetId(@Param("priceSetId") Long priceSetId);
|
List<PayProductTerm> selectByPriceSetId(@Param("priceSetId") Long priceSetId);
|
||||||
|
|
||||||
|
|||||||
@@ -91,14 +91,6 @@ public interface IPayProductService
|
|||||||
/** 从打单套餐移除产品(失效/清理对应 term 明细) */
|
/** 从打单套餐移除产品(失效/清理对应 term 明细) */
|
||||||
int removeLabelProducts(Long priceSetId, Long[] productIds);
|
int removeLabelProducts(Long priceSetId, Long[] productIds);
|
||||||
|
|
||||||
/** 打单套餐已绑定渠道列表 */
|
|
||||||
java.util.List<ChannelProductMap> listLabelChannels(Long priceSetId);
|
|
||||||
|
|
||||||
/** 打单套餐批量绑定渠道(写 AR + price_set_id) */
|
|
||||||
String bindLabelChannels(Long priceSetId, java.util.List<String> channelIds, Long productId);
|
|
||||||
|
|
||||||
/** 打单套餐解绑渠道 */
|
|
||||||
int unbindLabelChannel(Long priceSetId, String channelId);
|
|
||||||
|
|
||||||
/** 取消渠道上指定收付类型的产品。payType 为空时按应付 AP */
|
/** 取消渠道上指定收付类型的产品。payType 为空时按应付 AP */
|
||||||
void unbindChannel(String channelId, String payType);
|
void unbindChannel(String channelId, String payType);
|
||||||
|
|||||||
-101
@@ -1056,103 +1056,6 @@ public class PayProductServiceImpl implements IPayProductService
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ChannelProductMap> listLabelChannels(Long priceSetId)
|
|
||||||
{
|
|
||||||
if (priceSetId == null)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<ChannelProductMap> list = channelProductMapMapper.selectByPriceSetId(priceSetId);
|
|
||||||
return list == null ? Collections.emptyList() : list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String bindLabelChannels(Long priceSetId, List<String> channelIds, Long productId)
|
|
||||||
{
|
|
||||||
if (priceSetId == null)
|
|
||||||
{
|
|
||||||
throw new ServiceException("请选择打单套餐");
|
|
||||||
}
|
|
||||||
if (channelIds == null || channelIds.isEmpty())
|
|
||||||
{
|
|
||||||
throw new ServiceException("请选择要绑定的渠道");
|
|
||||||
}
|
|
||||||
if (productId == null)
|
|
||||||
{
|
|
||||||
throw new ServiceException("请选择套餐内应收产品");
|
|
||||||
}
|
|
||||||
PrcPriceSet set = priceSetMapper.selectPrcPriceSetById(priceSetId);
|
|
||||||
if (set == null || !PrcPriceSet.CATEGORY_LABEL.equalsIgnoreCase(String.valueOf(set.getSetCategory())))
|
|
||||||
{
|
|
||||||
throw new ServiceException("打单套餐不存在");
|
|
||||||
}
|
|
||||||
Long root = resolveRoot(productId);
|
|
||||||
boolean inSet = false;
|
|
||||||
List<PayProduct> products = selectLabelProducts(priceSetId);
|
|
||||||
for (PayProduct p : products)
|
|
||||||
{
|
|
||||||
if (p != null && root.equals(p.getProductId()))
|
|
||||||
{
|
|
||||||
inSet = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!inSet)
|
|
||||||
{
|
|
||||||
throw new ServiceException("所选产品不属于本打单套餐");
|
|
||||||
}
|
|
||||||
String operator = SecurityUtils.getUsername();
|
|
||||||
int n = 0;
|
|
||||||
for (String channelId : channelIds)
|
|
||||||
{
|
|
||||||
if (isBlank(channelId))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ServiceChannel channel = serviceChannelMapper.selectServiceChannelById(channelId.trim());
|
|
||||||
if (channel == null || isBlank(channel.getChannelCode()))
|
|
||||||
{
|
|
||||||
throw new ServiceException("渠道不存在或渠道编码为空:" + channelId);
|
|
||||||
}
|
|
||||||
ChannelProductMap row = new ChannelProductMap();
|
|
||||||
row.setChannelId(channelId.trim());
|
|
||||||
row.setChannelCode(channel.getChannelCode());
|
|
||||||
row.setProductId(root);
|
|
||||||
row.setPriceSetId(priceSetId);
|
|
||||||
row.setPayType(PAY_TYPE_AR);
|
|
||||||
row.setCreateBy(operator);
|
|
||||||
row.setUpdateBy(operator);
|
|
||||||
channelProductMapMapper.upsert(row);
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
if (n <= 0)
|
|
||||||
{
|
|
||||||
throw new ServiceException("没有可绑定的渠道");
|
|
||||||
}
|
|
||||||
return "已绑定 " + n + " 个渠道";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int unbindLabelChannel(Long priceSetId, String channelId)
|
|
||||||
{
|
|
||||||
if (priceSetId == null || isBlank(channelId))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return channelProductMapMapper.deleteByChannelTypeAndPriceSet(channelId.trim(), PAY_TYPE_AR, priceSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Long resolveLabelPriceSetId(Long productId)
|
|
||||||
{
|
|
||||||
if (productId == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return payProductTermMapper.selectLabelPriceSetIdByProduct(productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PayProduct> selectLabelProducts(Long priceSetId)
|
public List<PayProduct> selectLabelProducts(Long priceSetId)
|
||||||
@@ -1756,10 +1659,6 @@ public class PayProductServiceImpl implements IPayProductService
|
|||||||
row.setChannelCode(channel.getChannelCode());
|
row.setChannelCode(channel.getChannelCode());
|
||||||
row.setProductId(storedId);
|
row.setProductId(storedId);
|
||||||
row.setPayType(type);
|
row.setPayType(type);
|
||||||
if (PAY_TYPE_AR.equals(type))
|
|
||||||
{
|
|
||||||
row.setPriceSetId(resolveLabelPriceSetId(storedId));
|
|
||||||
}
|
|
||||||
String operator = SecurityUtils.getUsername();
|
String operator = SecurityUtils.getUsername();
|
||||||
row.setCreateBy(operator);
|
row.setCreateBy(operator);
|
||||||
row.setUpdateBy(operator);
|
row.setUpdateBy(operator);
|
||||||
|
|||||||
@@ -6,37 +6,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||||
select id, channel_id as channelId, channel_code as channelCode, product_id as productId,
|
select id, channel_id as channelId, channel_code as channelCode, product_id as productId,
|
||||||
price_set_id as priceSetId, pay_type as payType, create_by as createBy, create_time as createTime,
|
pay_type as payType, create_by as createBy, create_time as createTime,
|
||||||
update_by as updateBy, update_time as updateTime
|
update_by as updateBy, update_time as updateTime
|
||||||
from srv_channel_product_map
|
from srv_channel_product_map
|
||||||
where channel_id = #{channelId} and pay_type = #{payType}
|
where channel_id = #{channelId} and pay_type = #{payType}
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.ChannelProductMap">
|
|
||||||
select m.id, m.channel_id as channelId, m.channel_code as channelCode, m.product_id as productId,
|
|
||||||
m.price_set_id as priceSetId, m.pay_type as payType,
|
|
||||||
c.channel_name as channelName, p.product_name as productName,
|
|
||||||
m.create_by as createBy, m.create_time as createTime,
|
|
||||||
m.update_by as updateBy, m.update_time as updateTime
|
|
||||||
from srv_channel_product_map m
|
|
||||||
left join srv_service_channel c on c.id = m.channel_id
|
|
||||||
left join pay_product p on p.product_id = m.product_id
|
|
||||||
where m.price_set_id = #{priceSetId}
|
|
||||||
and m.pay_type = 'AR'
|
|
||||||
order by m.update_time desc, m.id desc
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="upsert">
|
<insert id="upsert">
|
||||||
insert into srv_channel_product_map (
|
insert into srv_channel_product_map (
|
||||||
channel_id, channel_code, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
|
channel_id, channel_code, product_id, pay_type, create_by, create_time, update_by, update_time
|
||||||
) values (
|
) values (
|
||||||
#{channelId}, #{channelCode}, #{productId}, #{priceSetId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
#{channelId}, #{channelCode}, #{productId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||||
)
|
)
|
||||||
on duplicate key update
|
on duplicate key update
|
||||||
channel_code = values(channel_code),
|
channel_code = values(channel_code),
|
||||||
product_id = values(product_id),
|
product_id = values(product_id),
|
||||||
price_set_id = values(price_set_id),
|
|
||||||
update_by = values(update_by),
|
update_by = values(update_by),
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</insert>
|
</insert>
|
||||||
@@ -46,13 +32,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where channel_id = #{channelId} and pay_type = #{payType}
|
where channel_id = #{channelId} and pay_type = #{payType}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteByChannelTypeAndPriceSet">
|
|
||||||
delete from srv_channel_product_map
|
|
||||||
where channel_id = #{channelId}
|
|
||||||
and pay_type = #{payType}
|
|
||||||
and price_set_id = #{priceSetId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteByProductId">
|
<delete id="deleteByProductId">
|
||||||
delete from srv_channel_product_map where product_id = #{productId}
|
delete from srv_channel_product_map where product_id = #{productId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
@@ -41,15 +41,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectLabelPriceSetIdByProduct" resultType="long">
|
|
||||||
select price_set_id
|
|
||||||
from pay_product_term
|
|
||||||
where product_id = #{productId}
|
|
||||||
and price_set_id is not null
|
|
||||||
order by case when status = '1' then 0 when status = '0' then 1 else 2 end, version_no desc, term_id desc
|
|
||||||
limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<!-- 打单套餐产品列表:待生效+生效 -->
|
<!-- 打单套餐产品列表:待生效+生效 -->
|
||||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.PayProductTerm">
|
<select id="selectByPriceSetId" resultType="com.bms.price.domain.PayProductTerm">
|
||||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ CREATE TABLE IF NOT EXISTS `srv_channel_product_map` (
|
|||||||
`channel_id` varchar(50) NOT NULL COMMENT '渠道ID,对应 srv_service_channel.id',
|
`channel_id` varchar(50) NOT NULL COMMENT '渠道ID,对应 srv_service_channel.id',
|
||||||
`channel_code` varchar(64) DEFAULT NULL COMMENT '渠道编码,对应 srv_service_channel.channel_code',
|
`channel_code` varchar(64) DEFAULT NULL COMMENT '渠道编码,对应 srv_service_channel.channel_code',
|
||||||
`product_id` bigint(20) NOT NULL COMMENT '产品ID,应付/应收时为价卡产品编号',
|
`product_id` bigint(20) NOT NULL COMMENT '产品ID,应付/应收时为价卡产品编号',
|
||||||
`price_set_id` bigint(20) DEFAULT NULL COMMENT '应收套餐ID,对应 prc_price_set.price_set_id',
|
|
||||||
`pay_type` varchar(10) NOT NULL COMMENT '收付类型,字典 bms_pay_type:AR应收 AP应付',
|
`pay_type` varchar(10) NOT NULL COMMENT '收付类型,字典 bms_pay_type:AR应收 AP应付',
|
||||||
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
|
`create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
@@ -15,23 +14,9 @@ CREATE TABLE IF NOT EXISTS `srv_channel_product_map` (
|
|||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_channel_pay_type` (`channel_id`, `pay_type`),
|
UNIQUE KEY `uk_channel_pay_type` (`channel_id`, `pay_type`),
|
||||||
KEY `idx_channel_product_map_product` (`product_id`),
|
KEY `idx_channel_product_map_product` (`product_id`),
|
||||||
KEY `idx_channel_product_map_price_set` (`price_set_id`),
|
|
||||||
KEY `idx_channel_product_map_channel_code` (`channel_code`)
|
KEY `idx_channel_product_map_channel_code` (`channel_code`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='渠道产品关系映射';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='渠道产品关系映射';
|
||||||
|
|
||||||
SET @sql = (
|
|
||||||
SELECT IF(
|
|
||||||
COUNT(*) = 0,
|
|
||||||
'ALTER TABLE srv_channel_product_map ADD COLUMN price_set_id bigint(20) DEFAULT NULL COMMENT ''应收套餐ID,对应 prc_price_set.price_set_id'' AFTER product_id, ADD KEY idx_channel_product_map_price_set (price_set_id)',
|
|
||||||
'SELECT 1'
|
|
||||||
)
|
|
||||||
FROM information_schema.COLUMNS
|
|
||||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'srv_channel_product_map' AND COLUMN_NAME = 'price_set_id'
|
|
||||||
);
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
SET @sql_channel_code = (
|
SET @sql_channel_code = (
|
||||||
SELECT IF(
|
SELECT IF(
|
||||||
COUNT(*) = 0,
|
COUNT(*) = 0,
|
||||||
|
|||||||
@@ -162,24 +162,3 @@ export function removeLabelProducts(priceSetId, productIds) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listLabelChannels(priceSetId) {
|
|
||||||
return request({
|
|
||||||
url: '/price/label/' + priceSetId + '/channels',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function bindLabelChannels(priceSetId, data) {
|
|
||||||
return request({
|
|
||||||
url: '/price/label/' + priceSetId + '/channels',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unbindLabelChannel(priceSetId, channelId) {
|
|
||||||
return request({
|
|
||||||
url: '/price/label/' + priceSetId + '/channels/' + channelId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,182 +0,0 @@
|
|||||||
<template>
|
|
||||||
<set-section-card
|
|
||||||
:title="title"
|
|
||||||
tone="blue"
|
|
||||||
:count="rows.length"
|
|
||||||
:sub="sub"
|
|
||||||
>
|
|
||||||
<template #action>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
icon="Plus"
|
|
||||||
:disabled="!priceSetId"
|
|
||||||
@click="openBind"
|
|
||||||
v-hasPermi="['price:label:edit']"
|
|
||||||
>添加渠道</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="rows" border empty-text="暂未绑定渠道">
|
|
||||||
<el-table-column label="渠道编码" prop="channelCode" min-width="140" show-overflow-tooltip />
|
|
||||||
<el-table-column label="渠道名称" prop="channelName" min-width="180" show-overflow-tooltip />
|
|
||||||
<el-table-column label="应收产品" prop="productName" min-width="160" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="danger" @click="unbind(row)" v-hasPermi="['price:label:edit']">解绑</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<el-dialog v-model="bindOpen" title="绑定渠道" width="560px" append-to-body @closed="onClosed">
|
|
||||||
<el-form label-width="110px">
|
|
||||||
<el-form-item label="套餐产品" required>
|
|
||||||
<el-select v-model="form.productId" filterable clearable placeholder="选择本套餐内应收产品" style="width: 100%">
|
|
||||||
<el-option
|
|
||||||
v-for="item in productOptions"
|
|
||||||
:key="item.productId"
|
|
||||||
:label="item.productName"
|
|
||||||
:value="item.productId"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="渠道" required>
|
|
||||||
<el-select
|
|
||||||
v-model="form.channelIds"
|
|
||||||
multiple
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
collapse-tags
|
|
||||||
collapse-tags-tooltip
|
|
||||||
placeholder="可多选渠道"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in channelOptions"
|
|
||||||
:key="item.id"
|
|
||||||
:label="channelLabel(item)"
|
|
||||||
:value="item.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<div class="hint">绑定后会写入渠道应收产品,并关联本打单套餐。</div>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="bindOpen = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="saving" @click="submit">确定</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</set-section-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import SetSectionCard from '../../set/components/detail/SetSectionCard.vue'
|
|
||||||
import { listLabelChannels, bindLabelChannels, unbindLabelChannel, listLabelProducts } from '@/api/price/label'
|
|
||||||
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
priceSetId: { type: [Number, String], default: null }
|
|
||||||
})
|
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance()
|
|
||||||
const title = '绑定渠道'
|
|
||||||
const sub = '渠道计费时按应收产品 + 本套餐取价'
|
|
||||||
const loading = ref(false)
|
|
||||||
const rows = ref([])
|
|
||||||
const bindOpen = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const productOptions = ref([])
|
|
||||||
const channelOptions = ref([])
|
|
||||||
const form = reactive({
|
|
||||||
productId: undefined,
|
|
||||||
channelIds: []
|
|
||||||
})
|
|
||||||
|
|
||||||
function channelLabel(item) {
|
|
||||||
const code = item.channelCode || item.id || ''
|
|
||||||
const name = item.channelName || ''
|
|
||||||
return name ? (code + ' / ' + name) : String(code)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadRows() {
|
|
||||||
if (!props.priceSetId) {
|
|
||||||
rows.value = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listLabelChannels(props.priceSetId)
|
|
||||||
rows.value = res.data || []
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function openBind() {
|
|
||||||
if (!props.priceSetId) return
|
|
||||||
form.productId = undefined
|
|
||||||
form.channelIds = []
|
|
||||||
const [prodRes, chRes] = await Promise.all([
|
|
||||||
listLabelProducts(props.priceSetId),
|
|
||||||
listChannelOptions({ blOpen: '1' })
|
|
||||||
])
|
|
||||||
productOptions.value = prodRes.data || []
|
|
||||||
channelOptions.value = chRes.data || []
|
|
||||||
if (!productOptions.value.length) {
|
|
||||||
proxy.$modal.msgWarning('请先导入套餐产品价卡')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
bindOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClosed() {
|
|
||||||
form.productId = undefined
|
|
||||||
form.channelIds = []
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function submit() {
|
|
||||||
if (!form.productId) {
|
|
||||||
proxy.$modal.msgWarning('请选择套餐内应收产品')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!form.channelIds.length) {
|
|
||||||
proxy.$modal.msgWarning('请选择渠道')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
saving.value = true
|
|
||||||
bindLabelChannels(props.priceSetId, {
|
|
||||||
productId: form.productId,
|
|
||||||
channelIds: form.channelIds
|
|
||||||
}).then(res => {
|
|
||||||
proxy.$modal.msgSuccess(res.msg || res.data || '绑定成功')
|
|
||||||
bindOpen.value = false
|
|
||||||
loadRows()
|
|
||||||
}).finally(() => {
|
|
||||||
saving.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function unbind(row) {
|
|
||||||
if (!row?.channelId) return
|
|
||||||
const name = row.channelName || row.channelCode || row.channelId
|
|
||||||
proxy.$modal.confirm('确认解绑渠道「' + name + '」?').then(() => {
|
|
||||||
return unbindLabelChannel(props.priceSetId, row.channelId)
|
|
||||||
}).then(() => {
|
|
||||||
proxy.$modal.msgSuccess('已解绑')
|
|
||||||
loadRows()
|
|
||||||
}).catch(() => {})
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => props.priceSetId, () => loadRows(), { immediate: true })
|
|
||||||
|
|
||||||
defineExpose({ reload: loadRows })
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.hint {
|
|
||||||
margin: -4px 0 0 110px;
|
|
||||||
color: #909399;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
<set-customer-table :set="setInfo" @refresh="loadHeader" />
|
<set-customer-table :set="setInfo" @refresh="loadHeader" />
|
||||||
|
|
||||||
<label-channel-table ref="channelTableRef" :price-set-id="priceSetId" />
|
|
||||||
|
|
||||||
<label-version-table
|
<label-version-table
|
||||||
:versions="versions"
|
:versions="versions"
|
||||||
@edit="openEditVersion"
|
@edit="openEditVersion"
|
||||||
@@ -83,7 +81,6 @@ import SetCustomerTable from '../set/components/detail/SetCustomerTable.vue'
|
|||||||
import LabelImportDialog from './components/LabelImportDialog.vue'
|
import LabelImportDialog from './components/LabelImportDialog.vue'
|
||||||
import LabelVersionTable from './components/LabelVersionTable.vue'
|
import LabelVersionTable from './components/LabelVersionTable.vue'
|
||||||
import LabelVersionProductDrawer from './components/LabelVersionProductDrawer.vue'
|
import LabelVersionProductDrawer from './components/LabelVersionProductDrawer.vue'
|
||||||
import LabelChannelTable from './components/LabelChannelTable.vue'
|
|
||||||
|
|
||||||
const labelModuleApi = {
|
const labelModuleApi = {
|
||||||
...priceSetApi,
|
...priceSetApi,
|
||||||
@@ -133,7 +130,6 @@ const setInfo = reactive({
|
|||||||
})
|
})
|
||||||
const versions = ref([])
|
const versions = ref([])
|
||||||
const importRef = ref()
|
const importRef = ref()
|
||||||
const channelTableRef = ref()
|
|
||||||
const productDrawerVisible = ref(false)
|
const productDrawerVisible = ref(false)
|
||||||
const activeVersion = ref(null)
|
const activeVersion = ref(null)
|
||||||
|
|
||||||
@@ -183,7 +179,6 @@ async function loadVersions() {
|
|||||||
async function reloadAll() {
|
async function reloadAll() {
|
||||||
await loadHeader()
|
await loadHeader()
|
||||||
await loadVersions()
|
await loadVersions()
|
||||||
channelTableRef.value?.reload?.()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openVersionDetails(row) {
|
function openVersionDetails(row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user