Merge branch 'master' into feat_本工会单独业务
This commit is contained in:
+2
-1
@@ -90,7 +90,8 @@ public class WelfareSelectionSituationController {
|
|||||||
return Result.error("此用户没有选择的权限");
|
return Result.error("此用户没有选择的权限");
|
||||||
}
|
}
|
||||||
|
|
||||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
// 人工修改选择与批量代选按项目串行,保留本接口原有的修改语义。
|
||||||
|
WelfareProject project = welfareProjectService.lockProjectForSelection(projectId);
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return Result.error("福利项目不存在");
|
return Result.error("福利项目不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-3
@@ -22,6 +22,7 @@ import org.nutz.ioc.aop.Aop;
|
|||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
|
import org.nutz.lang.Strings;
|
||||||
import org.nutz.mvc.annotation.At;
|
import org.nutz.mvc.annotation.At;
|
||||||
import org.nutz.mvc.annotation.Ok;
|
import org.nutz.mvc.annotation.Ok;
|
||||||
import org.nutz.mvc.annotation.Param;
|
import org.nutz.mvc.annotation.Param;
|
||||||
@@ -205,14 +206,42 @@ public class WelfareStatisticsController {
|
|||||||
welfareStatisticsService.exportSummary(projectId,response);
|
welfareStatisticsService.exportSummary(projectId,response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param projectId 福利项目 ID
|
||||||
|
* @param unionId 页面工会筛选 ID,空值表示账号权限内的工会
|
||||||
|
* @return JSON Result,data.project 包含项目规则和套餐,data.unSelectedCount 为未选人数
|
||||||
|
*/
|
||||||
|
@At
|
||||||
|
@SaCheckPermission("welfare.statistics")
|
||||||
|
@ApiOperation("获取批量代选配置")
|
||||||
|
public Result batchSelectInfo(String projectId, String unionId) {
|
||||||
|
if (Strings.isBlank(projectId) || projectId.length() > 32
|
||||||
|
|| (unionId != null && unionId.length() > 32)) {
|
||||||
|
return Result.error("请选择有效的福利项目和工会");
|
||||||
|
}
|
||||||
|
return welfareStatisticsService.batchSelectInfo(projectId, unionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param projectId 福利项目 ID
|
||||||
|
* @param unionId 页面工会筛选 ID,实际操作范围由 service 按登录账号限制
|
||||||
|
* @param welfareOptions JSON 数组,每项包含 id(套餐 ID)、selectNum(每人正整数份数)
|
||||||
|
* @return JSON Result,data.assignedCount 为实际分配人数,data.skippedCount 为范围内已选人数
|
||||||
|
*/
|
||||||
@At
|
@At
|
||||||
@SaCheckPermission("welfare.statistics")
|
@SaCheckPermission("welfare.statistics")
|
||||||
@Aop(TransAop.READ_COMMITTED)
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
@SLog(tag = "福利统计", msg = "管理员代选福利")
|
@SLog(tag = "福利统计", msg = "管理员代选福利")
|
||||||
@ApiOperation("管理员代选福利")
|
@ApiOperation("管理员代选福利")
|
||||||
public Result doSelectByAdmin(@Valid String projectId, @Param("welfareOptions") @Valid String welfareOptions) {
|
public Result doSelectByAdmin(String projectId, String unionId, @Param("welfareOptions") String welfareOptions) {
|
||||||
welfareSingleService.doSelectByAdmin(projectId, welfareOptions);
|
if (Strings.isBlank(projectId) || projectId.length() > 32
|
||||||
return Result.success();
|
|| (unionId != null && unionId.length() > 32)) {
|
||||||
|
return Result.error("请选择有效的福利项目和工会");
|
||||||
|
}
|
||||||
|
if (Strings.isBlank(welfareOptions) || welfareOptions.length() > 65536) {
|
||||||
|
return Result.error("请选择有效的福利套餐");
|
||||||
|
}
|
||||||
|
return welfareStatisticsService.batchSelect(projectId, unionId, welfareOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -10,6 +10,7 @@ import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
|||||||
import com.budwk.app.zhgh.welfare.model.WelfareList;
|
import com.budwk.app.zhgh.welfare.model.WelfareList;
|
||||||
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
||||||
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
|
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
|
||||||
|
import com.budwk.app.zhgh.welfare.service.WelfareProjectService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||||
import org.nutz.dao.Chain;
|
import org.nutz.dao.Chain;
|
||||||
@@ -42,6 +43,8 @@ public class WelfareUserChooseController {
|
|||||||
private Dao dao;
|
private Dao dao;
|
||||||
@Inject
|
@Inject
|
||||||
private BaseService baseService;
|
private BaseService baseService;
|
||||||
|
@Inject
|
||||||
|
private WelfareProjectService welfareProjectService;
|
||||||
|
|
||||||
@At("")
|
@At("")
|
||||||
@Ok("beetl:/platform/zhgh/welfare/userChoose/index.html")
|
@Ok("beetl:/platform/zhgh/welfare/userChoose/index.html")
|
||||||
@@ -89,7 +92,8 @@ public class WelfareUserChooseController {
|
|||||||
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
|
@SLog(type = "welfare", tag = "选择福利", msg = "福利")
|
||||||
@SaCheckPermission("welfare.user.choose")
|
@SaCheckPermission("welfare.user.choose")
|
||||||
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections, String projectId) {
|
public Result confirmSelect(@Param("welfareUserSelections") WelfareUserSelection[] welfareUserSelections, String projectId) {
|
||||||
WelfareProject project = baseService.dao().fetch(WelfareProject.class, projectId);
|
// 兼容旧选择入口,与新的批量代选入口共用项目事务锁。
|
||||||
|
WelfareProject project = welfareProjectService.lockProjectForSelection(projectId);
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return Result.error("福利项目不存在");
|
return Result.error("福利项目不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -92,7 +92,8 @@ public class WelfareUserSelectController {
|
|||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return Result.error("您没有选择的权限");
|
return Result.error("您没有选择的权限");
|
||||||
}
|
}
|
||||||
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
|
// 与统计页批量代选共用项目锁,避免检查未选状态后发生交叉写入。
|
||||||
|
WelfareProject project = welfareProjectService.lockProjectForSelection(projectId);
|
||||||
|
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return Result.error("福利项目不存在");
|
return Result.error("福利项目不存在");
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class WelfareUserSelection extends BaseModel implements Serializable {
|
|||||||
|
|
||||||
@Column
|
@Column
|
||||||
@Comment("选择用户")
|
@Comment("选择用户")
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ public interface WelfareProjectService extends BaseService<WelfareProject> {
|
|||||||
*/
|
*/
|
||||||
WelfareProject projectInfo(String projectId);
|
WelfareProject projectInfo(String projectId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在调用方的 READ_COMMITTED 事务中锁定项目,使批量代选和个人提交按顺序执行。
|
||||||
|
*
|
||||||
|
* @param projectId 福利项目 ID,不接收用户 ID 或套餐 ID
|
||||||
|
* @return 锁定后的项目实体;项目不存在或 ID 为空时返回 null,锁随调用方事务结束释放
|
||||||
|
*/
|
||||||
|
WelfareProject lockProjectForSelection(String projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询可用于沿用配置的历史福利项目。
|
* 查询可用于沿用配置的历史福利项目。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.budwk.app.zhgh.welfare.service;
|
|||||||
|
|
||||||
import com.budwk.app.base.page.Pagination;
|
import com.budwk.app.base.page.Pagination;
|
||||||
import com.budwk.app.base.param.PageForm;
|
import com.budwk.app.base.param.PageForm;
|
||||||
|
import com.budwk.app.base.result.Result;
|
||||||
import com.budwk.app.base.service.BaseService;
|
import com.budwk.app.base.service.BaseService;
|
||||||
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
@@ -10,6 +11,25 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
public interface WelfareStatisticsService extends BaseService<WelfareProject> {
|
public interface WelfareStatisticsService extends BaseService<WelfareProject> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取批量代选弹框的项目规则、套餐及实时未选人数。
|
||||||
|
*
|
||||||
|
* @param projectId 当前福利项目 ID
|
||||||
|
* @param unionId 页面筛选的工会 ID;为空表示当前账号权限内的工会
|
||||||
|
* @return Result,data.project 为项目及 options,data.unSelectedCount 为去重后的未选人数
|
||||||
|
*/
|
||||||
|
Result batchSelectInfo(String projectId, String unionId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按当前项目规则向权限范围内的未选人员分配同一套餐组合。
|
||||||
|
*
|
||||||
|
* @param projectId 当前福利项目 ID
|
||||||
|
* @param unionId 页面筛选的工会 ID;分工会角色始终限制在本工会
|
||||||
|
* @param welfareOptions JSON 数组,每项仅使用 id(套餐 ID)和 selectNum(正整数份数)
|
||||||
|
* @return Result,data.assignedCount 为本次分配人数,data.skippedCount 为范围内已选人数
|
||||||
|
*/
|
||||||
|
Result batchSelect(String projectId, String unionId, String welfareOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
* @param projectId
|
* @param projectId
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.budwk.app.zhgh.welfare.service.impl;
|
package com.budwk.app.zhgh.welfare.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||||
import com.budwk.app.sys.models.Sys_home_activity;
|
import com.budwk.app.sys.models.Sys_home_activity;
|
||||||
import com.budwk.app.sys.models.Sys_user;
|
import com.budwk.app.sys.models.Sys_user;
|
||||||
@@ -49,6 +50,24 @@ public class WelfareProjectServiceImpl extends BaseServiceImpl<WelfareProject> i
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WelfareProject lockProjectForSelection(String projectId) {
|
||||||
|
if (StrUtil.isBlank(projectId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 所有选择入口先锁同一项目,再读写选择记录;锁必须覆盖完整的外层提交事务。
|
||||||
|
Sql sql = Sqls.create(
|
||||||
|
"SELECT id FROM welfare_project "
|
||||||
|
+ "WHERE id = @projectId FOR UPDATE"
|
||||||
|
);
|
||||||
|
sql.setParam("projectId", projectId);
|
||||||
|
if (listMap(sql).isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return fetch(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WelfareProject> listHistoryProject() {
|
public List<WelfareProject> listHistoryProject() {
|
||||||
return dao().query(WelfareProject.class, Cnd.NEW().desc(WelfareProject::getYear).desc(WelfareProject::getChoiceTimeStart));
|
return dao().query(WelfareProject.class, Cnd.NEW().desc(WelfareProject::getYear).desc(WelfareProject::getChoiceTimeStart));
|
||||||
|
|||||||
+228
@@ -10,6 +10,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.budwk.app.base.constant.RoleConstant;
|
import com.budwk.app.base.constant.RoleConstant;
|
||||||
import com.budwk.app.base.page.Pagination;
|
import com.budwk.app.base.page.Pagination;
|
||||||
import com.budwk.app.base.param.PageForm;
|
import com.budwk.app.base.param.PageForm;
|
||||||
|
import com.budwk.app.base.result.Result;
|
||||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||||
import com.budwk.app.base.utils.CommonDownloadUtil;
|
import com.budwk.app.base.utils.CommonDownloadUtil;
|
||||||
import com.budwk.app.sys.models.Sys_union;
|
import com.budwk.app.sys.models.Sys_union;
|
||||||
@@ -17,10 +18,13 @@ import com.budwk.app.web.commons.auth.utils.AuthUtil;
|
|||||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||||
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
import com.budwk.app.zhgh.welfare.model.WelfareProject;
|
||||||
import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption;
|
import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption;
|
||||||
|
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
|
||||||
|
import com.budwk.app.zhgh.welfare.service.WelfareProjectService;
|
||||||
import com.budwk.app.zhgh.welfare.service.WelfareStatisticsService;
|
import com.budwk.app.zhgh.welfare.service.WelfareStatisticsService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Dao;
|
import org.nutz.dao.Dao;
|
||||||
import org.nutz.dao.FieldFilter;
|
import org.nutz.dao.FieldFilter;
|
||||||
@@ -29,21 +33,245 @@ import org.nutz.dao.sql.Sql;
|
|||||||
import org.nutz.dao.util.Daos;
|
import org.nutz.dao.util.Daos;
|
||||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||||
import org.nutz.ioc.loader.annotation.IocBean;
|
import org.nutz.ioc.loader.annotation.IocBean;
|
||||||
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
|
import org.nutz.ioc.aop.Aop;
|
||||||
|
import org.nutz.json.Json;
|
||||||
import org.nutz.lang.util.NutMap;
|
import org.nutz.lang.util.NutMap;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@IocBean(args = {"refer:dao"})
|
@IocBean(args = {"refer:dao"})
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject> implements WelfareStatisticsService {
|
public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject> implements WelfareStatisticsService {
|
||||||
|
@Inject
|
||||||
|
private WelfareProjectService welfareProjectService;
|
||||||
|
|
||||||
public WelfareStatisticsServiceImpl(Dao dao) {
|
public WelfareStatisticsServiceImpl(Dao dao) {
|
||||||
super(dao);
|
super(dao);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result batchSelectInfo(String projectId, String unionId) {
|
||||||
|
String scopeError = validateBatchScope(unionId);
|
||||||
|
if (scopeError != null) {
|
||||||
|
return Result.error(scopeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
WelfareProject project = welfareProjectService.projectInfo(projectId);
|
||||||
|
String projectError = validateBatchProject(project);
|
||||||
|
if (projectError != null) {
|
||||||
|
return Result.error(projectError);
|
||||||
|
}
|
||||||
|
long unSelectedCount = batchSelectionUsers(projectId, unionId).stream()
|
||||||
|
.filter(user -> user.getInt("hasSelected") == 0)
|
||||||
|
.count();
|
||||||
|
return Result.success(NutMap.NEW()
|
||||||
|
.addv("project", project)
|
||||||
|
.addv("unSelectedCount", unSelectedCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
|
public Result batchSelect(String projectId, String unionId, String welfareOptions) {
|
||||||
|
String scopeError = validateBatchScope(unionId);
|
||||||
|
if (scopeError != null) {
|
||||||
|
return Result.error(scopeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先锁项目再读取最新规则和人员状态,重复批量请求会依次执行并跳过已选人员。
|
||||||
|
WelfareProject project = welfareProjectService.lockProjectForSelection(projectId);
|
||||||
|
if (project != null) {
|
||||||
|
dao().fetchLinks(project, "options", Cnd.NEW().asc("optionSort"));
|
||||||
|
}
|
||||||
|
String projectError = validateBatchProject(project);
|
||||||
|
if (projectError != null) {
|
||||||
|
return Result.error(projectError);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NutMap> requestedOptions;
|
||||||
|
try {
|
||||||
|
requestedOptions = Json.fromJsonAsList(NutMap.class, welfareOptions);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return Result.error("套餐参数格式不正确,请重新打开弹框选择");
|
||||||
|
}
|
||||||
|
String selectionError = validateBatchOptions(project, requestedOptions);
|
||||||
|
if (selectionError != null) {
|
||||||
|
return Result.error(selectionError);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NutMap> users = batchSelectionUsers(projectId, unionId);
|
||||||
|
Map<String, WelfareProjectSubjectOption> optionsById = project.getOptions().stream()
|
||||||
|
.collect(Collectors.toMap(WelfareProjectSubjectOption::getId, option -> option));
|
||||||
|
Date selectTime = new Date();
|
||||||
|
List<WelfareUserSelection> pending = new ArrayList<>();
|
||||||
|
int assignedCount = 0;
|
||||||
|
int skippedCount = 0;
|
||||||
|
for (NutMap user : users) {
|
||||||
|
if (user.getInt("hasSelected") != 0) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NutMap requested : requestedOptions) {
|
||||||
|
WelfareProjectSubjectOption option = optionsById.get(requested.getString("id"));
|
||||||
|
WelfareUserSelection selection = new WelfareUserSelection();
|
||||||
|
selection.setWelfareId(projectId);
|
||||||
|
selection.setSubjectId(option.getSubjectId());
|
||||||
|
selection.setSelectOptionId(option.getId());
|
||||||
|
selection.setSelectUserId(user.getString("userId"));
|
||||||
|
selection.setUserName(user.getString("userName"));
|
||||||
|
selection.setSelectNum(requested.getInt("selectNum"));
|
||||||
|
selection.setSelectTime(selectTime);
|
||||||
|
// 批量操作仅代选套餐,不代填个人收货地址,也不修改名单或选择记录的签收状态。
|
||||||
|
pending.add(selection);
|
||||||
|
if (pending.size() >= 500) {
|
||||||
|
dao().insert(pending);
|
||||||
|
pending.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assignedCount++;
|
||||||
|
}
|
||||||
|
if (!pending.isEmpty()) {
|
||||||
|
dao().insert(pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分批写入仍属于同一事务;写入异常向上抛出,使所有批次一起回滚。
|
||||||
|
String message = assignedCount == 0 ? "没有需要分配的未选人员,已选记录保持不变"
|
||||||
|
: "已为" + assignedCount + "位未选人员分配套餐,已选记录保持不变";
|
||||||
|
return Result.success(message, NutMap.NEW()
|
||||||
|
.addv("assignedCount", assignedCount)
|
||||||
|
.addv("skippedCount", skippedCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查项目是否具备可执行的选择规则,异常配置不使用前端默认值掩盖。
|
||||||
|
*/
|
||||||
|
private String validateBatchProject(WelfareProject project) {
|
||||||
|
if (project == null) {
|
||||||
|
return "福利项目不存在";
|
||||||
|
}
|
||||||
|
if (Boolean.TRUE.equals(project.getIsDisabled())) {
|
||||||
|
return "福利项目已禁用,不能分配套餐";
|
||||||
|
}
|
||||||
|
if (!"radio".equals(project.getIsCheckBox()) && !"checkBox".equals(project.getIsCheckBox())) {
|
||||||
|
return "福利项目未配置有效的选择模式";
|
||||||
|
}
|
||||||
|
if ("checkBox".equals(project.getIsCheckBox())
|
||||||
|
&& (project.getMultiSelectNum() == null || project.getMultiSelectNum() < 1)) {
|
||||||
|
return "福利项目未配置有效的可选份数";
|
||||||
|
}
|
||||||
|
if (project.getOptions() == null || project.getOptions().isEmpty()) {
|
||||||
|
return "福利项目尚未配置套餐";
|
||||||
|
}
|
||||||
|
long defaultCount = project.getOptions().stream()
|
||||||
|
.filter(option -> Boolean.TRUE.equals(option.getIsSystemDefault()))
|
||||||
|
.count();
|
||||||
|
if (defaultCount > 1) {
|
||||||
|
return "福利项目配置了多个系统默认套餐,请先检查项目配置";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后端独立校验套餐归属、正整数份数、单多选及必选项;不信任前端传入的题目或人员字段。
|
||||||
|
*/
|
||||||
|
private String validateBatchOptions(WelfareProject project, List<NutMap> requestedOptions) {
|
||||||
|
if (requestedOptions == null || requestedOptions.isEmpty()) {
|
||||||
|
return "请至少选择一份福利套餐";
|
||||||
|
}
|
||||||
|
boolean single = "radio".equals(project.getIsCheckBox());
|
||||||
|
int limit = single ? 1 : project.getMultiSelectNum();
|
||||||
|
Set<String> optionIds = project.getOptions().stream()
|
||||||
|
.map(WelfareProjectSubjectOption::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<String> selectedIds = new HashSet<>();
|
||||||
|
long total = 0;
|
||||||
|
for (NutMap option : requestedOptions) {
|
||||||
|
if (option == null || !optionIds.contains(option.getString("id"))) {
|
||||||
|
return "所选套餐不属于当前福利项目,请重新打开弹框选择";
|
||||||
|
}
|
||||||
|
if (!selectedIds.add(option.getString("id"))) {
|
||||||
|
return "同一套餐不能重复提交,请通过份数设置数量";
|
||||||
|
}
|
||||||
|
Object value = option.get("selectNum");
|
||||||
|
if (!(value instanceof Number) || !value.toString().matches("[1-9][0-9]*")) {
|
||||||
|
return "套餐份数必须为正整数";
|
||||||
|
}
|
||||||
|
long quantity;
|
||||||
|
try {
|
||||||
|
quantity = Long.parseLong(value.toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return "套餐份数超出允许范围";
|
||||||
|
}
|
||||||
|
if ((single || !Boolean.TRUE.equals(project.getSingleOptionSupportMultipleSelection()))
|
||||||
|
&& quantity > 1) {
|
||||||
|
return "当前福利项目每个套餐最多选择1份";
|
||||||
|
}
|
||||||
|
if (quantity > limit || total > limit - quantity) {
|
||||||
|
return "每人选择的套餐总份数不能超过" + limit + "份";
|
||||||
|
}
|
||||||
|
total += quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (WelfareProjectSubjectOption option : project.getOptions()) {
|
||||||
|
if (Boolean.TRUE.equals(option.getIsSystemDefault()) && !selectedIds.contains(option.getId())) {
|
||||||
|
return "系统默认福利“" + option.getOptionName() + "”不可取消";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 与统计列表保持相同的分工会角色口径,缺失工会信息时拒绝扩大到全校。
|
||||||
|
*/
|
||||||
|
private boolean isBatchBranchRole() {
|
||||||
|
return AuthUtil.hasRole(RoleConstant.BRANCH_UNION_CHAIRMAN.name())
|
||||||
|
|| AuthUtil.hasRole(RoleConstant.BRANCH_UNION_ADMIN.name())
|
||||||
|
|| AuthUtil.hasRole(RoleConstant.BRANCH_UNION_WENTI_SPORTS.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String validateBatchScope(String unionId) {
|
||||||
|
if (isBatchBranchRole()) {
|
||||||
|
String currentUnionId = SecurityUtil.getUnionId();
|
||||||
|
if (StrUtil.isBlank(currentUnionId)) {
|
||||||
|
return "当前账号未关联工会,不能批量分配套餐";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(unionId) && !currentUnionId.equals(unionId)) {
|
||||||
|
return "只能为本工会人员分配套餐";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从项目福利名单按人员去重;任一非空套餐记录即视为已选,不补齐或覆盖其原有组合。
|
||||||
|
*/
|
||||||
|
private List<NutMap> batchSelectionUsers(String projectId, String unionId) {
|
||||||
|
Sql sql = Sqls.create(
|
||||||
|
"SELECT DISTINCT wl.userId, u.username AS userName, "
|
||||||
|
+ "EXISTS (SELECT 1 FROM welfare_project_user_selection selection "
|
||||||
|
+ "WHERE selection.welfareId = wl.projectId "
|
||||||
|
+ "AND selection.selectUserId = wl.userId "
|
||||||
|
+ "AND selection.selectOptionId IS NOT NULL) AS hasSelected "
|
||||||
|
+ "FROM welfare_list wl "
|
||||||
|
+ "INNER JOIN sys_user u ON u.id = wl.userId "
|
||||||
|
+ "$condition ORDER BY wl.userId"
|
||||||
|
);
|
||||||
|
Cnd condition = Cnd.where("wl.projectId", "=", projectId);
|
||||||
|
String effectiveUnionId = isBatchBranchRole() ? SecurityUtil.getUnionId() : unionId;
|
||||||
|
condition.andEX("wl.welfareUnionId", "=", effectiveUnionId);
|
||||||
|
sql.setCondition(condition);
|
||||||
|
return listMap(sql);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NutMap pageData(String projectId, String unionId) {
|
public NutMap pageData(String projectId, String unionId) {
|
||||||
// 分工会数据
|
// 分工会数据
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const filterUser = {
|
|||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
|
||||||
|
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
|
||||||
<search-item label="三级单位">
|
<search-item label="三级单位">
|
||||||
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
|
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
|
||||||
v-model="pageForm.threeUnitId">
|
v-model="pageForm.threeUnitId">
|
||||||
@@ -85,6 +86,7 @@ const filterUser = {
|
|||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<search-item label="人员类型:">
|
<search-item label="人员类型:">
|
||||||
<dict-select clearable code="USER_PERSON_TYPE"
|
<dict-select clearable code="USER_PERSON_TYPE"
|
||||||
@@ -94,6 +96,7 @@ const filterUser = {
|
|||||||
v-model="pageForm.personTypes"></dict-select>
|
v-model="pageForm.personTypes"></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
|
||||||
|
<!-- 福利模块暂不提供人员属性筛选,保留控件代码便于恢复。
|
||||||
<search-item label="人员属性:">
|
<search-item label="人员属性:">
|
||||||
<dict-select clearable code="USER_ATTRIBUTE"
|
<dict-select clearable code="USER_ATTRIBUTE"
|
||||||
multiple
|
multiple
|
||||||
@@ -101,6 +104,7 @@ const filterUser = {
|
|||||||
placeholder="请选择人员属性"
|
placeholder="请选择人员属性"
|
||||||
v-model="pageForm.userAttributes"></dict-select>
|
v-model="pageForm.userAttributes"></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<search-item label="在职状态:">
|
<search-item label="在职状态:">
|
||||||
<dict-select clearable code="USER_STATE"
|
<dict-select clearable code="USER_STATE"
|
||||||
|
|||||||
@@ -61,14 +61,24 @@ layout("/layouts/platform.html"){
|
|||||||
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unitOptions"></el-option>
|
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unitOptions"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
<!-- 福利模块暂不提供人员分类、人员属性筛选,保留控件代码便于恢复。
|
||||||
<search-item label="人员分类">
|
<search-item label="人员分类">
|
||||||
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
|
<dict-select
|
||||||
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
|
v-model="pageForm.aidFundMemberUserType"
|
||||||
|
placeholder="请选择人员分类"
|
||||||
|
@change="doSearch"
|
||||||
|
code="AIDFUND_MEMBER_USER_TYPE"
|
||||||
|
></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
<search-item label="人员属性">
|
<search-item label="人员属性">
|
||||||
<dict-select v-model="pageForm.userAttribute" placeholder="请选择人员属性" @change="doSearch"
|
<dict-select
|
||||||
code="USER_ATTRIBUTE"></dict-select>
|
v-model="pageForm.userAttribute"
|
||||||
|
placeholder="请选择人员属性"
|
||||||
|
@change="doSearch"
|
||||||
|
code="USER_ATTRIBUTE"
|
||||||
|
></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<el-button @click="resetSearch">重置</el-button>
|
<el-button @click="resetSearch">重置</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,505 @@
|
|||||||
|
const batchSelectDialog = {
|
||||||
|
template: /*language=HTML*/ `
|
||||||
|
<div>
|
||||||
|
<el-dialog
|
||||||
|
class="welfare-batch-dialog"
|
||||||
|
title="一键分配套餐"
|
||||||
|
width="820px"
|
||||||
|
top="6vh"
|
||||||
|
:visible="visible"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="!formLoading"
|
||||||
|
:show-close="!formLoading"
|
||||||
|
:before-close="onClose">
|
||||||
|
<div v-loading="tableLoading">
|
||||||
|
<p class="welfare-batch-subtitle">为尚未选择福利的人员统一分配套餐</p>
|
||||||
|
<el-alert
|
||||||
|
title="仅分配给未选择人员,已选择人员不受影响"
|
||||||
|
type="info"
|
||||||
|
show-icon
|
||||||
|
:closable="false">
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<el-alert
|
||||||
|
v-if="loadError"
|
||||||
|
class="welfare-batch-error"
|
||||||
|
:title="loadError"
|
||||||
|
type="error"
|
||||||
|
show-icon
|
||||||
|
:closable="false">
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<template v-if="project.id">
|
||||||
|
<div class="welfare-batch-overview">
|
||||||
|
<div class="welfare-batch-project">
|
||||||
|
<span>福利项目</span>
|
||||||
|
<strong>{{ project.name }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="welfare-batch-people">
|
||||||
|
<span>待分配人数</span>
|
||||||
|
<strong>{{ unSelectedCount }} 人</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="welfare-batch-rules">
|
||||||
|
<strong>项目选择规则</strong>
|
||||||
|
<div>{{ ruleText }}</div>
|
||||||
|
<div v-if="systemDefaultOption" class="welfare-batch-muted">
|
||||||
|
系统默认套餐自动选中,不可取消,份数计入可选上限。
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="welfare-batch-heading">
|
||||||
|
<strong>选择福利套餐</strong>
|
||||||
|
<span>每人已选 <b>{{ selectedCount }}</b> / {{ selectionLimit }} 份</span>
|
||||||
|
</div>
|
||||||
|
<div class="welfare-batch-options">
|
||||||
|
<div
|
||||||
|
v-for="option in options"
|
||||||
|
:key="option.id"
|
||||||
|
class="welfare-batch-option"
|
||||||
|
:class="{ 'is-selected': option.selectNum > 0 }">
|
||||||
|
<el-radio
|
||||||
|
v-if="isSingle"
|
||||||
|
:value="selectedRadioId"
|
||||||
|
:label="option.id"
|
||||||
|
:disabled="formLoading || !!systemDefaultOption"
|
||||||
|
@change="selectSingle(option)">
|
||||||
|
<span class="welfare-batch-radio-label">选择{{ option.optionName }}</span>
|
||||||
|
</el-radio>
|
||||||
|
<el-image
|
||||||
|
class="welfare-batch-image"
|
||||||
|
:src="imageUrl(option.imgUrl)"
|
||||||
|
fit="contain">
|
||||||
|
<div slot="error" class="welfare-batch-image-empty">
|
||||||
|
<i class="el-icon-picture-outline"></i>
|
||||||
|
</div>
|
||||||
|
</el-image>
|
||||||
|
<div class="welfare-batch-option-content">
|
||||||
|
<div class="welfare-batch-option-title">
|
||||||
|
<strong>{{ option.optionName }}</strong>
|
||||||
|
<el-tag v-if="option.isSystemDefault" size="mini">系统默认</el-tag>
|
||||||
|
</div>
|
||||||
|
<div v-if="option.simpleDesc || option.supplier" class="welfare-batch-muted">
|
||||||
|
{{ option.simpleDesc || option.supplier }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span v-if="isSingle && option.selectNum > 0" class="welfare-batch-selected">已选择</span>
|
||||||
|
<el-input-number
|
||||||
|
v-if="!isSingle"
|
||||||
|
size="small"
|
||||||
|
:value="option.selectNum"
|
||||||
|
:min="option.isSystemDefault ? 1 : 0"
|
||||||
|
:max="optionMax(option)"
|
||||||
|
:precision="0"
|
||||||
|
:step="1"
|
||||||
|
:step-strictly="true"
|
||||||
|
:disabled="formLoading"
|
||||||
|
@change="changeQuantity(option, $event)">
|
||||||
|
</el-input-number>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p v-if="selectedCount >= selectionLimit" class="welfare-batch-muted welfare-batch-limit">
|
||||||
|
已达项目可选上限,可调整选择后重新分配。
|
||||||
|
</p>
|
||||||
|
<p v-if="unSelectedCount === 0" class="welfare-batch-muted welfare-batch-limit">
|
||||||
|
当前没有需要分配的未选人员。
|
||||||
|
</p>
|
||||||
|
<div class="welfare-batch-summary">
|
||||||
|
<strong>
|
||||||
|
每位未选人员将获得:
|
||||||
|
<span>{{ selectionSummary || '请先选择福利套餐' }}</span>
|
||||||
|
</strong>
|
||||||
|
<div class="welfare-batch-muted">
|
||||||
|
共 {{ unSelectedCount }} 人,每人 {{ selectedCount }} 份;提交时重新核验,已选择人员自动跳过。
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template slot="footer">
|
||||||
|
<el-button :disabled="formLoading" @click="onClose()">取消</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:loading="formLoading"
|
||||||
|
:disabled="!canSubmit"
|
||||||
|
@click="submit">
|
||||||
|
确认分配({{ unSelectedCount }}人)
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
tableLoading: false,
|
||||||
|
formLoading: false,
|
||||||
|
projectId: "",
|
||||||
|
unionId: "",
|
||||||
|
project: {},
|
||||||
|
options: [],
|
||||||
|
unSelectedCount: 0,
|
||||||
|
loadError: "",
|
||||||
|
requestVersion: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isSingle() {
|
||||||
|
return this.project.isCheckBox === "radio"
|
||||||
|
},
|
||||||
|
selectionLimit() {
|
||||||
|
return this.isSingle ? 1 : Number(this.project.multiSelectNum || 0)
|
||||||
|
},
|
||||||
|
systemDefaultOption() {
|
||||||
|
return this.options.find((option) => option.isSystemDefault)
|
||||||
|
},
|
||||||
|
selectedRadioId() {
|
||||||
|
const selected = this.options.find((option) => option.selectNum > 0)
|
||||||
|
return selected ? selected.id : ""
|
||||||
|
},
|
||||||
|
selectedCount() {
|
||||||
|
return this.options.reduce((total, option) => total + option.selectNum, 0)
|
||||||
|
},
|
||||||
|
ruleText() {
|
||||||
|
if (this.isSingle) {
|
||||||
|
return "单选 · 每人选择 1 份"
|
||||||
|
}
|
||||||
|
const multipleRule = this.project.singleOptionSupportMultipleSelection
|
||||||
|
? "同一套餐可选多份" : "同一套餐最多 1 份"
|
||||||
|
return "多选 · 每人最多 " + this.selectionLimit + " 份 · " + multipleRule
|
||||||
|
},
|
||||||
|
selectionSummary() {
|
||||||
|
return this.options
|
||||||
|
.filter((option) => option.selectNum > 0)
|
||||||
|
.map((option) => option.optionName + " × " + option.selectNum + " 份")
|
||||||
|
.join(" + ")
|
||||||
|
},
|
||||||
|
canSubmit() {
|
||||||
|
return !!this.project.id && !this.loadError && !this.tableLoading && !this.formLoading
|
||||||
|
&& this.unSelectedCount > 0 && this.selectedCount > 0
|
||||||
|
&& this.selectedCount <= this.selectionLimit
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* projectId 为当前福利项目 ID,unionId 为页面工会筛选。
|
||||||
|
* 初始化接口返回 data.project(项目规则及 options)和 data.unSelectedCount(未选人数)。
|
||||||
|
* 每次打开重新加载;请求版本号防止关闭后迟到的响应覆盖下一次弹框。
|
||||||
|
*/
|
||||||
|
onOpen(projectId, unionId) {
|
||||||
|
this.projectId = projectId
|
||||||
|
this.unionId = unionId || ""
|
||||||
|
this.project = {}
|
||||||
|
this.options = []
|
||||||
|
this.unSelectedCount = 0
|
||||||
|
this.loadError = ""
|
||||||
|
this.visible = true
|
||||||
|
this.tableLoading = true
|
||||||
|
this.requestVersion += 1
|
||||||
|
const version = this.requestVersion
|
||||||
|
return this.$axios.post("/platform/welfare/statistics/batchSelectInfo", {
|
||||||
|
projectId: this.projectId,
|
||||||
|
unionId: this.unionId
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (version !== this.requestVersion || !this.visible) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.project = res.data.project
|
||||||
|
this.unSelectedCount = Number(res.data.unSelectedCount)
|
||||||
|
this.options = this.project.options.map((option) => ({
|
||||||
|
...option,
|
||||||
|
selectNum: option.isSystemDefault ? 1 : 0
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (version === this.requestVersion) {
|
||||||
|
this.loadError = error.msg || error.message || "加载失败,请关闭后重试"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (version === this.requestVersion) {
|
||||||
|
this.tableLoading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 提交期间不允许关闭,避免请求仍在执行时再次打开并重复提交。
|
||||||
|
onClose(done) {
|
||||||
|
if (this.formLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.requestVersion += 1
|
||||||
|
this.visible = false
|
||||||
|
this.tableLoading = false
|
||||||
|
if (typeof done === "function") {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
imageUrl(value) {
|
||||||
|
return commonUtil.getFileUrl(value)
|
||||||
|
},
|
||||||
|
// 单选项目按 1 份计数,系统默认套餐存在时不能切换到其他套餐。
|
||||||
|
selectSingle(option) {
|
||||||
|
if (this.formLoading || this.systemDefaultOption) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.options.forEach((item) => {
|
||||||
|
this.$set(item, "selectNum", item.id === option.id ? 1 : 0)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 每项上限取项目剩余份数与单项上限的较小值,默认套餐保留至少 1 份。
|
||||||
|
optionMax(option) {
|
||||||
|
const perOptionLimit = this.project.singleOptionSupportMultipleSelection ? this.selectionLimit : 1
|
||||||
|
const remaining = this.selectionLimit - this.selectedCount + option.selectNum
|
||||||
|
return Math.max(option.isSystemDefault ? 1 : 0, Math.min(perOptionLimit, remaining))
|
||||||
|
},
|
||||||
|
changeQuantity(option, value) {
|
||||||
|
if (this.formLoading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const minimum = option.isSystemDefault ? 1 : 0
|
||||||
|
const quantity = Number(value)
|
||||||
|
if (!Number.isInteger(quantity)) {
|
||||||
|
this.$set(option, "selectNum", minimum)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$set(option, "selectNum", Math.max(minimum, Math.min(this.optionMax(option), quantity)))
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 只提交套餐 ID 和每人份数;人员、题目归属及有效规则由后端重新核验。
|
||||||
|
* 返回 Result.data.assignedCount 为实际分配人数,skippedCount 为范围内已选人数。
|
||||||
|
*/
|
||||||
|
submit() {
|
||||||
|
if (!this.canSubmit) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const selectedOptions = this.options
|
||||||
|
.filter((option) => option.selectNum > 0)
|
||||||
|
.map((option) => ({
|
||||||
|
id: option.id,
|
||||||
|
selectNum: option.selectNum
|
||||||
|
}))
|
||||||
|
this.formLoading = true
|
||||||
|
return this.$axios.post("/platform/welfare/statistics/doSelectByAdmin", {
|
||||||
|
projectId: this.projectId,
|
||||||
|
unionId: this.unionId,
|
||||||
|
welfareOptions: JSON.stringify(selectedOptions)
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
this.visible = false
|
||||||
|
this.$emit("success")
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// 全局拦截器已显示接口错误,保留当前选择供用户检查或重试。
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.formLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: /*language=CSS*/ `
|
||||||
|
/deep/ .welfare-batch-dialog .el-dialog {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-width: calc(100vw - 40px);
|
||||||
|
max-height: 88vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-dialog .el-dialog__header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-dialog .el-dialog__title {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-dialog .el-dialog__body {
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0 24px 12px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-subtitle {
|
||||||
|
margin: 0 0 20px;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-dialog .el-alert--info {
|
||||||
|
background-color: #ecf5ff;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-error {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-overview {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 24px;
|
||||||
|
margin: 22px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-project {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
gap: 16px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-project > span {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-project strong {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-people {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-people strong {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-rules {
|
||||||
|
padding: 14px 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
line-height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-heading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin: 20px 0 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-heading > strong {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-heading b {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-options {
|
||||||
|
max-height: 340px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border: 1px solid #dcdfe6;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option + .welfare-batch-option {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option.is-selected {
|
||||||
|
border-color: #409eff;
|
||||||
|
background: #ecf5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option .el-radio {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option .el-radio__label {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-radio-label {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
clip-path: inset(50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-image {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-image-empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
background: #f5f7fa;
|
||||||
|
color: #c0c4cc;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
line-height: 24px;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option-title {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-option .el-input-number {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 130px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-selected {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-muted {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-limit {
|
||||||
|
margin: 10px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-summary {
|
||||||
|
margin-top: 18px;
|
||||||
|
padding-top: 14px;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
line-height: 26px;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-summary strong span {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .welfare-batch-dialog .el-dialog__footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 14px 24px 20px;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
@@ -45,6 +45,14 @@ layout("/layouts/platform.html"){
|
|||||||
导出汇总表
|
导出汇总表
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
<el-button
|
||||||
|
:disabled="!pageForm.projectId"
|
||||||
|
@click="openBatchSelect"
|
||||||
|
icon="el-icon-present"
|
||||||
|
size="small"
|
||||||
|
type="primary">
|
||||||
|
一键分配套餐
|
||||||
|
</el-button>
|
||||||
</table-tool>
|
</table-tool>
|
||||||
<el-table
|
<el-table
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
@@ -84,18 +92,21 @@ layout("/layouts/platform.html"){
|
|||||||
|
|
||||||
<selected-user ref="selectedUserRef"></selected-user>
|
<selected-user ref="selectedUserRef"></selected-user>
|
||||||
<unselected-user ref="unSelectedUserRef"></unselected-user>
|
<unselected-user ref="unSelectedUserRef"></unselected-user>
|
||||||
|
<batch-select-dialog ref="batchSelectRef" @success="doSearch"></batch-select-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script nonce="${cspNonce!}">
|
<script nonce="${cspNonce!}">
|
||||||
<!--#include('selectedUser.js'){}#-->
|
<!--#include('selectedUser.js'){}#-->
|
||||||
<!--#include('unSelectedUser.js'){}#-->
|
<!--#include('unSelectedUser.js'){}#-->
|
||||||
|
<!--#include('batchSelectDialog.js'){}#-->
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
mixins: [initTableMixins],
|
mixins: [initTableMixins],
|
||||||
components: {
|
components: {
|
||||||
"selected-user": selectedUser,
|
"selected-user": selectedUser,
|
||||||
"unselected-user": unSelectedUser
|
"unselected-user": unSelectedUser,
|
||||||
|
"batch-select-dialog": batchSelectDialog
|
||||||
},
|
},
|
||||||
store,
|
store,
|
||||||
data() {
|
data() {
|
||||||
@@ -113,6 +124,14 @@ layout("/layouts/platform.html"){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 仅传递当前项目与页面工会筛选,弹框重新读取真实项目规则和未选人数。
|
||||||
|
openBatchSelect() {
|
||||||
|
if (!this.pageForm.projectId) {
|
||||||
|
this.$message.warning("请先选择福利项目")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$refs.batchSelectRef.onOpen(this.pageForm.projectId, this.pageForm.unionId)
|
||||||
|
},
|
||||||
resetSearch() {
|
resetSearch() {
|
||||||
this.pageForm.year = new Date().getFullYear().toString()
|
this.pageForm.year = new Date().getFullYear().toString()
|
||||||
const isBranchChairman = !this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_ADMIN", "SCHOOL_UNION_WELFARE_ADMIN"]) &&
|
const isBranchChairman = !this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_ADMIN", "SCHOOL_UNION_WELFARE_ADMIN"]) &&
|
||||||
@@ -147,14 +166,19 @@ layout("/layouts/platform.html"){
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async pageData() {
|
pageData() {
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
const resp = await this.$axios.post("/platform/welfare/statistics/pageData", this.pageForm)
|
// 批量分配成功后复用原统计接口,动态套餐列和人数一起刷新。
|
||||||
|
return this.$axios.post("/platform/welfare/statistics/pageData", this.pageForm)
|
||||||
|
.then((resp) => {
|
||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
this.tableColumns = resp.data.tableColumn
|
this.tableColumns = resp.data.tableColumn
|
||||||
this.tableData = resp.data.tableList
|
this.tableData = resp.data.tableList
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
this.tableLoading = false
|
this.tableLoading = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async getWelfareProjectList() {
|
async getWelfareProjectList() {
|
||||||
const res = await this.$axios.post("/platform/welfare/project/mange/getWelfareList", { year: this.pageForm.year })
|
const res = await this.$axios.post("/platform/welfare/project/mange/getWelfareList", { year: this.pageForm.year })
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ const addUser = {
|
|||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
|
||||||
|
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
|
||||||
<search-item label="三级单位">
|
<search-item label="三级单位">
|
||||||
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
|
<el-select clearable filterable placeholder="请先选择所属单位" style="width: 100%"
|
||||||
v-model="pageForm.threeUnitId">
|
v-model="pageForm.threeUnitId">
|
||||||
@@ -87,6 +88,7 @@ const addUser = {
|
|||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<search-item label="人员类型:">
|
<search-item label="人员类型:">
|
||||||
<dict-select clearable code="USER_PERSON_TYPE"
|
<dict-select clearable code="USER_PERSON_TYPE"
|
||||||
@@ -96,6 +98,7 @@ const addUser = {
|
|||||||
v-model="pageForm.personTypes"></dict-select>
|
v-model="pageForm.personTypes"></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
|
||||||
|
<!-- 福利模块暂不提供人员属性筛选,保留控件代码便于恢复。
|
||||||
<search-item label="人员属性:">
|
<search-item label="人员属性:">
|
||||||
<dict-select clearable code="USER_ATTRIBUTE"
|
<dict-select clearable code="USER_ATTRIBUTE"
|
||||||
multiple
|
multiple
|
||||||
@@ -103,6 +106,7 @@ const addUser = {
|
|||||||
placeholder="请选择人员属性"
|
placeholder="请选择人员属性"
|
||||||
v-model="pageForm.userAttributes"></dict-select>
|
v-model="pageForm.userAttributes"></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<search-item label="在职状态:">
|
<search-item label="在职状态:">
|
||||||
<dict-select clearable code="USER_STATE"
|
<dict-select clearable code="USER_STATE"
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ layout("/layouts/platform.html"){
|
|||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
|
||||||
|
<!-- 福利模块暂不提供三级单位筛选,保留控件代码便于恢复。
|
||||||
<search-item label="三级单位">
|
<search-item label="三级单位">
|
||||||
<el-select
|
<el-select
|
||||||
clearable
|
clearable
|
||||||
@@ -101,6 +102,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in threeUnitOptions"></el-option>
|
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in threeUnitOptions"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<search-item label="人员类型:">
|
<search-item label="人员类型:">
|
||||||
<dict-select
|
<dict-select
|
||||||
@@ -124,14 +126,27 @@ layout("/layouts/platform.html"){
|
|||||||
v-model="pageForm.userStates"
|
v-model="pageForm.userStates"
|
||||||
></dict-select>
|
></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
<!-- 福利模块暂不提供人员分类、人员属性筛选,保留控件代码便于恢复。
|
||||||
<search-item label="人员分类">
|
<search-item label="人员分类">
|
||||||
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
|
<dict-select
|
||||||
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
|
v-model="pageForm.aidFundMemberUserType"
|
||||||
|
placeholder="请选择人员分类"
|
||||||
|
@change="doSearch"
|
||||||
|
code="AIDFUND_MEMBER_USER_TYPE"
|
||||||
|
></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
<search-item label="人员属性">
|
<search-item label="人员属性">
|
||||||
<dict-select v-model="pageForm.userAttributes" placeholder="请选择人员属性" @change="doSearch"
|
<dict-select
|
||||||
code="USER_ATTRIBUTE" clearable multiple collapse-tags></dict-select>
|
v-model="pageForm.userAttributes"
|
||||||
|
placeholder="请选择人员属性"
|
||||||
|
@change="doSearch"
|
||||||
|
code="USER_ATTRIBUTE"
|
||||||
|
clearable
|
||||||
|
multiple
|
||||||
|
collapse-tags
|
||||||
|
></dict-select>
|
||||||
</search-item>
|
</search-item>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- <search-item label="所选福利:">-->
|
<!-- <search-item label="所选福利:">-->
|
||||||
<!-- <el-select clearable placeholder="请选择所选福利" style="width: 100%" v-model="pageForm.optionId">-->
|
<!-- <el-select clearable placeholder="请选择所选福利" style="width: 100%" v-model="pageForm.optionId">-->
|
||||||
|
|||||||
@@ -2005,10 +2005,13 @@ layout("/layouts/platform_h5.html"){
|
|||||||
this.selectRadioOption(option.id)
|
this.selectRadioOption(option.id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (option.isSystemDefault) return
|
// 切换单选项时,旧步进器归零也会触发 change;仅允许当前选中项主动归零时取消选择。
|
||||||
|
if (option.isSystemDefault || this.selectedRadioId !== option.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.selectedRadioId = ""
|
this.selectedRadioId = ""
|
||||||
this.projectInfo.options.forEach((item) => {
|
this.projectInfo.options.forEach((item) => {
|
||||||
item.selectNum = 0
|
this.$set(item, "selectNum", 0)
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user