去掉套餐用户绑定功能逻辑
This commit is contained in:
@@ -27,7 +27,6 @@ import com.bms.common.enums.BusinessType;
|
|||||||
import com.bms.common.utils.MessageUtils;
|
import com.bms.common.utils.MessageUtils;
|
||||||
import com.bms.common.utils.StringUtils;
|
import com.bms.common.utils.StringUtils;
|
||||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||||
import com.bms.price.domain.PrcPriceSetUser;
|
|
||||||
import com.bms.price.domain.PrcPriceExcelFile;
|
import com.bms.price.domain.PrcPriceExcelFile;
|
||||||
import com.bms.price.domain.PrcPriceSet;
|
import com.bms.price.domain.PrcPriceSet;
|
||||||
import com.bms.price.domain.PrcPriceSetDetail;
|
import com.bms.price.domain.PrcPriceSetDetail;
|
||||||
@@ -388,29 +387,4 @@ public class PriceSetController extends BaseController
|
|||||||
return toAjax(priceSetService.deleteCustomerByIds(customerPricesetIds));
|
return toAjax(priceSetService.deleteCustomerByIds(customerPricesetIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:set:list')")
|
|
||||||
@GetMapping("/viewer/list")
|
|
||||||
public TableDataInfo viewerList(PrcPriceSetUser query)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<PrcPriceSetUser> list = priceSetService.selectViewerList(query);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:set:edit')")
|
|
||||||
@Log(title = "Package viewer bind", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping("/viewer")
|
|
||||||
public AjaxResult addViewer(@RequestBody PrcPriceSetUser row)
|
|
||||||
{
|
|
||||||
row.setCreateBy(getUsername());
|
|
||||||
return toAjax(priceSetService.insertViewer(row));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('price:set:edit')")
|
|
||||||
@Log(title = "Package viewer bind", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/viewer/{psuIds}")
|
|
||||||
public AjaxResult removeViewer(@PathVariable Long[] psuIds)
|
|
||||||
{
|
|
||||||
return toAjax(priceSetService.deleteViewerByIds(psuIds));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ public class PrcPriceSet extends BaseEntity
|
|||||||
private List<PrcPriceSetDetail> details;
|
private List<PrcPriceSetDetail> details;
|
||||||
private List<PrcPriceSetVersion> versions;
|
private List<PrcPriceSetVersion> versions;
|
||||||
private List<PrcCustomerPriceSet> customers;
|
private List<PrcCustomerPriceSet> customers;
|
||||||
/** viewers explicitly bound to this package */
|
|
||||||
private List<PrcPriceSetUser> viewers;
|
|
||||||
/** async save task id (not persisted) */
|
/** async save task id (not persisted) */
|
||||||
private String saveTaskId;
|
private String saveTaskId;
|
||||||
/** Y: ignored on save; library pull only via /detail/pullFromLibrary */
|
/** Y: ignored on save; library pull only via /detail/pullFromLibrary */
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.bms.price.domain;
|
|
||||||
|
|
||||||
import com.bms.common.core.domain.BaseEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/** 套餐可查看人绑定:prc_price_set_user */
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class PrcPriceSetUser extends BaseEntity
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private Long psuId;
|
|
||||||
private Long priceSetId;
|
|
||||||
private Long userId;
|
|
||||||
/** login account */
|
|
||||||
private String userName;
|
|
||||||
/** display only, not a table column */
|
|
||||||
private String nickName;
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.bms.price.mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import com.bms.price.domain.PrcPriceSetUser;
|
|
||||||
|
|
||||||
public interface PrcPriceSetUserMapper
|
|
||||||
{
|
|
||||||
PrcPriceSetUser selectPrcPriceSetUserById(Long psuId);
|
|
||||||
|
|
||||||
List<PrcPriceSetUser> selectPrcPriceSetUserList(PrcPriceSetUser query);
|
|
||||||
|
|
||||||
int insertPrcPriceSetUser(PrcPriceSetUser row);
|
|
||||||
|
|
||||||
int deletePrcPriceSetUserByIds(Long[] psuIds);
|
|
||||||
|
|
||||||
int deleteByPriceSetId(Long priceSetId);
|
|
||||||
|
|
||||||
int countBySetAndUser(@Param("priceSetId") Long priceSetId, @Param("userId") Long userId);
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import com.bms.price.domain.PrcPriceSet;
|
|||||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||||
import com.bms.price.domain.PrcPriceSetDetail;
|
import com.bms.price.domain.PrcPriceSetDetail;
|
||||||
import com.bms.price.domain.PrcPriceSetSaveTask;
|
import com.bms.price.domain.PrcPriceSetSaveTask;
|
||||||
import com.bms.price.domain.PrcPriceSetUser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 价格套餐 服务层
|
* 价格套餐 服务层
|
||||||
@@ -92,12 +91,6 @@ public interface IPrcPriceSetService
|
|||||||
|
|
||||||
public int deleteCustomerByIds(Long[] customerPricesetIds);
|
public int deleteCustomerByIds(Long[] customerPricesetIds);
|
||||||
|
|
||||||
public List<PrcPriceSetUser> selectViewerList(PrcPriceSetUser query);
|
|
||||||
|
|
||||||
public int insertViewer(PrcPriceSetUser row);
|
|
||||||
|
|
||||||
public int deleteViewerByIds(Long[] psuIds);
|
|
||||||
|
|
||||||
/** chain expire_time = next version effective_time, then refresh 0/3/1/2 */
|
/** chain expire_time = next version effective_time, then refresh 0/3/1/2 */
|
||||||
public int refreshAllVersionStatus();
|
public int refreshAllVersionStatus();
|
||||||
|
|
||||||
|
|||||||
+2
-62
@@ -30,7 +30,6 @@ import com.bms.price.domain.BmsProductCountry;
|
|||||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||||
import com.bms.price.domain.PrcPriceExcelFile;
|
import com.bms.price.domain.PrcPriceExcelFile;
|
||||||
import com.bms.price.domain.PrcPriceSet;
|
import com.bms.price.domain.PrcPriceSet;
|
||||||
import com.bms.price.domain.PrcPriceSetUser;
|
|
||||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||||
import com.bms.price.domain.PrcPriceSetDetail;
|
import com.bms.price.domain.PrcPriceSetDetail;
|
||||||
import com.bms.price.domain.PrcPriceSetProduct;
|
import com.bms.price.domain.PrcPriceSetProduct;
|
||||||
@@ -44,12 +43,9 @@ import com.bms.price.mapper.PrcCustomerPriceSetMapper;
|
|||||||
import com.bms.price.mapper.PrcPriceSetDetailMapper;
|
import com.bms.price.mapper.PrcPriceSetDetailMapper;
|
||||||
import com.bms.price.mapper.PrcPriceSetMapper;
|
import com.bms.price.mapper.PrcPriceSetMapper;
|
||||||
import com.bms.price.mapper.PrcPriceSetProductMapper;
|
import com.bms.price.mapper.PrcPriceSetProductMapper;
|
||||||
import com.bms.price.mapper.PrcPriceSetUserMapper;
|
|
||||||
import com.bms.price.mapper.PrcPriceSetVersionMapper;
|
import com.bms.price.mapper.PrcPriceSetVersionMapper;
|
||||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||||
import com.bms.common.core.domain.entity.SysUser;
|
|
||||||
import com.bms.system.mapper.SysUserMapper;
|
|
||||||
import com.bms.price.service.IBmsProductService;
|
import com.bms.price.service.IBmsProductService;
|
||||||
import com.bms.price.search.IBillSearchStore;
|
import com.bms.price.search.IBillSearchStore;
|
||||||
import com.bms.price.search.PriceChangeEsLog;
|
import com.bms.price.search.PriceChangeEsLog;
|
||||||
@@ -105,12 +101,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PrcCustomerPriceSetMapper customerMapper;
|
private PrcCustomerPriceSetMapper customerMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PrcPriceSetUserMapper priceSetUserMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserMapper sysUserMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BmsProductCountryMapper productCountryMapper;
|
private BmsProductCountryMapper productCountryMapper;
|
||||||
|
|
||||||
@@ -149,18 +139,14 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Price-set list data scope: bound customer's sales user (same as customer list),
|
* Price-set list data scope: bound customer's sales user (same as customer list)
|
||||||
* package creator, or explicit viewer bind. Super admin skips filter in DataScopeAspect.
|
* or package creator. Super admin skips filter in DataScopeAspect.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "su", userField = "user_id",
|
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "su", userField = "user_id",
|
||||||
permission = "price:set:list")
|
permission = "price:set:list")
|
||||||
public List<PrcPriceSet> selectPrcPriceSetList(PrcPriceSet set)
|
public List<PrcPriceSet> selectPrcPriceSetList(PrcPriceSet set)
|
||||||
{
|
{
|
||||||
if (set != null)
|
|
||||||
{
|
|
||||||
set.getParams().put("viewerUserId", SecurityUtils.getUserId());
|
|
||||||
}
|
|
||||||
List<PrcPriceSet> list = setMapper.selectPrcPriceSetList(set);
|
List<PrcPriceSet> list = setMapper.selectPrcPriceSetList(set);
|
||||||
for (PrcPriceSet item : list)
|
for (PrcPriceSet item : list)
|
||||||
{
|
{
|
||||||
@@ -2468,49 +2454,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
|||||||
return customerMapper.deletePrcCustomerPriceSetByIds(customerPricesetIds);
|
return customerMapper.deletePrcCustomerPriceSetByIds(customerPricesetIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<PrcPriceSetUser> selectViewerList(PrcPriceSetUser query)
|
|
||||||
{
|
|
||||||
return priceSetUserMapper.selectPrcPriceSetUserList(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public int insertViewer(PrcPriceSetUser row)
|
|
||||||
{
|
|
||||||
if (row == null || row.getPriceSetId() == null || row.getUserId() == null)
|
|
||||||
{
|
|
||||||
throw new ServiceException("price set user bind requires priceSetId and userId");
|
|
||||||
}
|
|
||||||
requireSet(row.getPriceSetId());
|
|
||||||
if (priceSetUserMapper.countBySetAndUser(row.getPriceSetId(), row.getUserId()) > 0)
|
|
||||||
{
|
|
||||||
throw new ServiceException("user already bound to this price set");
|
|
||||||
}
|
|
||||||
SysUser user = sysUserMapper.selectUserById(row.getUserId());
|
|
||||||
if (user == null)
|
|
||||||
{
|
|
||||||
throw new ServiceException("user not found");
|
|
||||||
}
|
|
||||||
row.setUserName(user.getUserName());
|
|
||||||
if (StringUtils.isEmpty(row.getCreateBy()))
|
|
||||||
{
|
|
||||||
row.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
}
|
|
||||||
return priceSetUserMapper.insertPrcPriceSetUser(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public int deleteViewerByIds(Long[] psuIds)
|
|
||||||
{
|
|
||||||
if (psuIds == null || psuIds.length == 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return priceSetUserMapper.deletePrcPriceSetUserByIds(psuIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void replaceChildren(PrcPriceSet set)
|
private void replaceChildren(PrcPriceSet set)
|
||||||
{
|
{
|
||||||
saveOrUpdateVersion(set);
|
saveOrUpdateVersion(set);
|
||||||
@@ -3277,9 +3220,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
|||||||
PrcCustomerPriceSet cquery = new PrcCustomerPriceSet();
|
PrcCustomerPriceSet cquery = new PrcCustomerPriceSet();
|
||||||
cquery.setPriceSetId(priceSetId);
|
cquery.setPriceSetId(priceSetId);
|
||||||
set.setCustomers(customerMapper.selectPrcCustomerPriceSetList(cquery));
|
set.setCustomers(customerMapper.selectPrcCustomerPriceSetList(cquery));
|
||||||
PrcPriceSetUser uquery = new PrcPriceSetUser();
|
|
||||||
uquery.setPriceSetId(priceSetId);
|
|
||||||
set.setViewers(priceSetUserMapper.selectPrcPriceSetUserList(uquery));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillVersionChildren(PrcPriceSetVersion version)
|
private void fillVersionChildren(PrcPriceSetVersion version)
|
||||||
|
|||||||
@@ -105,14 +105,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
AND su.user_name = s.created_by COLLATE utf8mb4_general_ci
|
AND su.user_name = s.created_by COLLATE utf8mb4_general_ci
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
)
|
)
|
||||||
<if test="params.viewerUserId != null">
|
|
||||||
OR EXISTS (
|
|
||||||
SELECT 1
|
|
||||||
FROM prc_price_set_user psu
|
|
||||||
WHERE psu.price_set_id = s.price_set_id
|
|
||||||
AND psu.user_id = #{params.viewerUserId}
|
|
||||||
)
|
|
||||||
</if>
|
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.bms.price.mapper.PrcPriceSetUserMapper">
|
|
||||||
|
|
||||||
<resultMap type="PrcPriceSetUser" id="PrcPriceSetUserResult">
|
|
||||||
<id property="psuId" column="psu_id" />
|
|
||||||
<result property="priceSetId" column="price_set_id" />
|
|
||||||
<result property="userId" column="user_id" />
|
|
||||||
<result property="userName" column="user_name" />
|
|
||||||
<result property="nickName" column="nick_name" />
|
|
||||||
<result property="createBy" column="created_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectVo">
|
|
||||||
select psu.psu_id, psu.price_set_id, psu.user_id, psu.user_name,
|
|
||||||
u.nick_name, psu.created_by, psu.create_time
|
|
||||||
from prc_price_set_user psu
|
|
||||||
left join sys_user u on u.user_id = psu.user_id
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectPrcPriceSetUserById" parameterType="Long" resultMap="PrcPriceSetUserResult">
|
|
||||||
<include refid="selectVo"/>
|
|
||||||
where psu.psu_id = #{psuId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPrcPriceSetUserList" parameterType="PrcPriceSetUser" resultMap="PrcPriceSetUserResult">
|
|
||||||
<include refid="selectVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="priceSetId != null">AND psu.price_set_id = #{priceSetId}</if>
|
|
||||||
<if test="userId != null">AND psu.user_id = #{userId}</if>
|
|
||||||
<if test="userName != null and userName != ''">AND psu.user_name = #{userName}</if>
|
|
||||||
</where>
|
|
||||||
order by psu.psu_id asc
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="countBySetAndUser" resultType="int">
|
|
||||||
select count(1) from prc_price_set_user
|
|
||||||
where price_set_id = #{priceSetId} and user_id = #{userId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertPrcPriceSetUser" parameterType="PrcPriceSetUser" useGeneratedKeys="true" keyProperty="psuId">
|
|
||||||
insert into prc_price_set_user (price_set_id, user_id, user_name, created_by, create_time)
|
|
||||||
values (#{priceSetId}, #{userId}, #{userName}, #{createBy}, sysdate())
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<delete id="deletePrcPriceSetUserByIds" parameterType="Long">
|
|
||||||
delete from prc_price_set_user where psu_id in
|
|
||||||
<foreach collection="array" item="id" open="(" separator="," close=")">#{id}</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteByPriceSetId" parameterType="Long">
|
|
||||||
delete from prc_price_set_user where price_set_id = #{priceSetId}
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
||||||
@@ -806,23 +806,6 @@ CREATE TABLE `prc_customer_price_set` (
|
|||||||
CONSTRAINT `fk_customer_price_set` FOREIGN KEY (`price_set_id`) REFERENCES `prc_price_set` (`price_set_id`)
|
CONSTRAINT `fk_customer_price_set` FOREIGN KEY (`price_set_id`) REFERENCES `prc_price_set` (`price_set_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户套餐表-客户某时间段内使用的套餐';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户套餐表-客户某时间段内使用的套餐';
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 表结构:`prc_price_set_user`
|
|
||||||
-- ----------------------------
|
|
||||||
CREATE TABLE `prc_price_set_user` (
|
|
||||||
`psu_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
||||||
`price_set_id` bigint(20) NOT NULL COMMENT '价格套餐id',
|
|
||||||
`user_id` bigint(20) NOT NULL COMMENT '用户id',
|
|
||||||
`user_name` varchar(64) NOT NULL DEFAULT '' COMMENT '登录账号',
|
|
||||||
`created_by` varchar(64) DEFAULT '' COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
|
||||||
PRIMARY KEY (`psu_id`),
|
|
||||||
UNIQUE KEY `uk_psu_set_user` (`price_set_id`,`user_id`),
|
|
||||||
KEY `idx_psu_user` (`user_id`),
|
|
||||||
KEY `idx_psu_set` (`price_set_id`),
|
|
||||||
CONSTRAINT `fk_psu_set` FOREIGN KEY (`price_set_id`) REFERENCES `prc_price_set` (`price_set_id`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='套餐可见用户绑定';
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 表结构:`prc_income_bill`
|
-- 表结构:`prc_income_bill`
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
@@ -1,16 +1,4 @@
|
|||||||
-- Price set viewer bind
|
-- Drop package viewer bind table (feature removed)
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS prc_price_set_user (
|
DROP TABLE IF EXISTS prc_price_set_user;
|
||||||
psu_id bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
||||||
price_set_id bigint(20) NOT NULL COMMENT '价格套餐id',
|
|
||||||
user_id bigint(20) NOT NULL COMMENT '用户id',
|
|
||||||
user_name varchar(64) NOT NULL DEFAULT '' COMMENT '登录账号',
|
|
||||||
created_by varchar(64) DEFAULT '' COMMENT '创建人',
|
|
||||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
|
||||||
PRIMARY KEY (psu_id),
|
|
||||||
UNIQUE KEY uk_psu_set_user (price_set_id, user_id),
|
|
||||||
KEY idx_psu_user (user_id),
|
|
||||||
KEY idx_psu_set (price_set_id),
|
|
||||||
CONSTRAINT fk_psu_set FOREIGN KEY (price_set_id) REFERENCES prc_price_set (price_set_id) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='套餐可见用户绑定';
|
|
||||||
|
|||||||
@@ -412,26 +412,3 @@ export function delSetCustomer(ids) {
|
|||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listSetViewer(query) {
|
|
||||||
return request({
|
|
||||||
url: '/price/set/viewer/list',
|
|
||||||
method: 'get',
|
|
||||||
params: query
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addSetViewer(data) {
|
|
||||||
return request({
|
|
||||||
url: '/price/set/viewer',
|
|
||||||
method: 'post',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function delSetViewer(ids) {
|
|
||||||
return request({
|
|
||||||
url: '/price/set/viewer/' + ids,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,174 +0,0 @@
|
|||||||
<template>
|
|
||||||
<set-section-card
|
|
||||||
title="绑定用户"
|
|
||||||
tone="orange"
|
|
||||||
:count="viewers.length"
|
|
||||||
sub="指定用户可查看本套餐(不受销售数据权限限制)"
|
|
||||||
>
|
|
||||||
<template #action>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="Plus"
|
|
||||||
size="small"
|
|
||||||
v-hasPermi="['price:set:edit']"
|
|
||||||
@click="openBind"
|
|
||||||
>绑定用户</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-table :data="viewers" border class="user-table" empty-text="暂未绑定用户">
|
|
||||||
<el-table-column label="账号" prop="userName" min-width="140" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span class="u-code">{{ row.userName }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="姓名" prop="nickName" min-width="140" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ row.nickName || '-' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="danger"
|
|
||||||
v-hasPermi="['price:set:edit']"
|
|
||||||
@click="onUnbind(row)"
|
|
||||||
>解绑</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<el-dialog
|
|
||||||
v-model="bindVisible"
|
|
||||||
title="绑定用户"
|
|
||||||
width="480px"
|
|
||||||
append-to-body
|
|
||||||
@closed="onClosed"
|
|
||||||
>
|
|
||||||
<el-form label-width="80px">
|
|
||||||
<el-form-item label="用户" required>
|
|
||||||
<el-select
|
|
||||||
v-model="selectedUserIds"
|
|
||||||
multiple
|
|
||||||
filterable
|
|
||||||
collapse-tags
|
|
||||||
collapse-tags-tooltip
|
|
||||||
placeholder="请选择用户"
|
|
||||||
style="width: 100%"
|
|
||||||
:loading="userLoading"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="u in userOptions"
|
|
||||||
:key="u.userId"
|
|
||||||
:label="formatUser(u)"
|
|
||||||
:value="u.userId"
|
|
||||||
:disabled="u.status === '1' || boundUserIdSet.has(String(u.userId))"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="bindVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="submitting" @click="submitBind">确定</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</set-section-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup name="SetUserTable">
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import SetSectionCard from './SetSectionCard.vue'
|
|
||||||
import { useUsers } from '@/components/UserSelect/useUsers'
|
|
||||||
import { addSetViewer, delSetViewer } from '@/api/price/set'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
set: { type: Object, required: true }
|
|
||||||
})
|
|
||||||
const emit = defineEmits(['changed'])
|
|
||||||
|
|
||||||
const { userList, ensureUsers } = useUsers()
|
|
||||||
const viewers = computed(() => props.set.viewers || [])
|
|
||||||
const boundUserIdSet = computed(() => new Set(viewers.value.map(v => String(v.userId))))
|
|
||||||
|
|
||||||
const bindVisible = ref(false)
|
|
||||||
const selectedUserIds = ref([])
|
|
||||||
const userLoading = ref(false)
|
|
||||||
const submitting = ref(false)
|
|
||||||
const userOptions = computed(() => userList.value || [])
|
|
||||||
|
|
||||||
function formatUser(u) {
|
|
||||||
const name = u.nickName || u.userName || ''
|
|
||||||
return u.userName ? (name + ' (' + u.userName + ')') : name
|
|
||||||
}
|
|
||||||
|
|
||||||
function openBind() {
|
|
||||||
selectedUserIds.value = []
|
|
||||||
bindVisible.value = true
|
|
||||||
userLoading.value = true
|
|
||||||
ensureUsers().finally(() => { userLoading.value = false })
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClosed() {
|
|
||||||
selectedUserIds.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitBind() {
|
|
||||||
const ids = (selectedUserIds.value || []).filter(id => !boundUserIdSet.value.has(String(id)))
|
|
||||||
if (!ids.length) {
|
|
||||||
ElMessage.warning('请选择要绑定的用户')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!props.set.priceSetId) {
|
|
||||||
ElMessage.warning('套餐不存在')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
submitting.value = true
|
|
||||||
let ok = 0
|
|
||||||
let fail = 0
|
|
||||||
try {
|
|
||||||
for (const userId of ids) {
|
|
||||||
try {
|
|
||||||
await addSetViewer({ priceSetId: props.set.priceSetId, userId })
|
|
||||||
ok++
|
|
||||||
} catch (e) {
|
|
||||||
fail++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ok) ElMessage.success('绑定成功 ' + ok + (fail ? (',失败 ' + fail) : ''))
|
|
||||||
else ElMessage.error('绑定失败')
|
|
||||||
bindVisible.value = false
|
|
||||||
emit('changed')
|
|
||||||
} finally {
|
|
||||||
submitting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUnbind(row) {
|
|
||||||
if (!row || !row.psuId) return
|
|
||||||
ElMessageBox.confirm(
|
|
||||||
'确认解绑用户 ' + (row.nickName || row.userName || '') + ' ?',
|
|
||||||
'解绑确认',
|
|
||||||
{ type: 'warning' }
|
|
||||||
).then(() => delSetViewer(row.psuId)).then(() => {
|
|
||||||
ElMessage.success('已解绑')
|
|
||||||
emit('changed')
|
|
||||||
}).catch(() => {})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.user-table {
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
.user-table :deep(th.el-table__cell) {
|
|
||||||
background: #fafbfc;
|
|
||||||
color: #606266;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.u-code {
|
|
||||||
font-family: Consolas, Monaco, monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
<set-customer-table :set="set" />
|
<set-customer-table :set="set" />
|
||||||
|
|
||||||
<set-user-table :set="set" @changed="load" />
|
|
||||||
|
|
||||||
<set-version-table
|
<set-version-table
|
||||||
v-model="currentPsvId"
|
v-model="currentPsvId"
|
||||||
:versions="set.versions || []"
|
:versions="set.versions || []"
|
||||||
@@ -80,7 +78,6 @@
|
|||||||
import SetDetailHeader from './components/detail/SetDetailHeader.vue'
|
import SetDetailHeader from './components/detail/SetDetailHeader.vue'
|
||||||
import SetBasicInfoCard from './components/detail/SetBasicInfoCard.vue'
|
import SetBasicInfoCard from './components/detail/SetBasicInfoCard.vue'
|
||||||
import SetCustomerTable from './components/detail/SetCustomerTable.vue'
|
import SetCustomerTable from './components/detail/SetCustomerTable.vue'
|
||||||
import SetUserTable from './components/detail/SetUserTable.vue'
|
|
||||||
import SetVersionTable from './components/detail/SetVersionTable.vue'
|
import SetVersionTable from './components/detail/SetVersionTable.vue'
|
||||||
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
|
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
|
||||||
import SetVersionExcelFileDrawer from './components/detail/SetVersionExcelFileDrawer.vue'
|
import SetVersionExcelFileDrawer from './components/detail/SetVersionExcelFileDrawer.vue'
|
||||||
|
|||||||
Reference in New Issue
Block a user