diff --git a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java index 7d0768c..3477c72 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareSelectionSituationController.java @@ -15,6 +15,7 @@ import com.budwk.app.zhgh.welfare.model.WelfareUserSelection; import com.budwk.app.zhgh.welfare.param.WelfareSelectionSituationPageForm; import com.budwk.app.zhgh.welfare.service.WelfareListService; import com.budwk.app.zhgh.welfare.service.WelfareSelectionSituationService; +import com.budwk.app.zhgh.welfare.service.WelfareSingleService; import com.budwk.app.zhgh.welfare.service.WelfareStatisticsService; import com.jogamp.common.util.SecurityUtil; import io.swagger.annotations.Api; @@ -49,6 +50,8 @@ public class WelfareSelectionSituationController { private WelfareStatisticsService welfareStatisticsService; @Inject private WelfareSelectionSituationService situationService; + @Inject + private WelfareSingleService welfareSingleService; @At("") @Ok("beetl:/platform/zhgh/welfare/selectionSituation/index.html") @@ -107,11 +110,22 @@ public class WelfareSelectionSituationController { welfareUserSelection.setWelfareId(projectId); welfareUserSelection.setSelectUserId(userId); welfareUserSelection.setSelectTime(new Date()); + welfareUserSelection.setIsSelectByAdmin(true); } dao.insert(selections); return Result.success("选择成功"); } + @At + @SaCheckPermission("welfare.selection.situation") + @Aop(TransAop.READ_COMMITTED) + @SLog(tag = "选择情况", msg = "管理员代选福利") + @ApiOperation("管理员代选福利") + public Result doSelectByAdmin(@Valid String projectId, @Param("welfareOptions") @Valid String welfareOptions) { + welfareSingleService.doSelectByAdmin(projectId, welfareOptions); + return Result.success(); + } + @At @SaCheckPermission("welfare.selection.situation") diff --git a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareStatisticsController.java b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareStatisticsController.java index 29a3641..b0c9b7a 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareStatisticsController.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/controller/WelfareStatisticsController.java @@ -71,8 +71,8 @@ public class WelfareStatisticsController { @At @SaCheckPermission("welfare.statistics") - public Result pageData(String projectId, String unionId) { - NutMap data = welfareStatisticsService.pageData(projectId, unionId); + public Result pageData(String projectId, String unionId, Boolean isSelectByAdmin) { + NutMap data = welfareStatisticsService.pageData(projectId, unionId, isSelectByAdmin); return Result.success(data); } @@ -80,8 +80,8 @@ public class WelfareStatisticsController { @At @SaCheckPermission("welfare.statistics") @ApiOperation("查询某分工会已选择人员") - public Result selectedUnionUserPageData(@Valid PageForm pageForm, String projectId, String unionId) { - Pagination pagination = welfareStatisticsService.selectedUnionUserPageData(pageForm, projectId, unionId); + public Result selectedUnionUserPageData(@Valid PageForm pageForm, String projectId, String unionId, Boolean isSelectByAdmin) { + Pagination pagination = welfareStatisticsService.selectedUnionUserPageData(pageForm, projectId, unionId, isSelectByAdmin); return Result.success(pagination); } @@ -89,8 +89,8 @@ public class WelfareStatisticsController { @Ok("void") @SaCheckPermission("welfare.statistics") @ApiOperation("导出某分工会已选择人员") - public void exportSelectedUnionUser(String projectId, String unionId, HttpServletResponse response) { - welfareStatisticsService.exportSelectedUnionUser(projectId, unionId, response); + public void exportSelectedUnionUser(String projectId, String unionId, Boolean isSelectByAdmin, HttpServletResponse response) { + welfareStatisticsService.exportSelectedUnionUser(projectId, unionId, isSelectByAdmin, response); } @At diff --git a/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java b/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java index e258a36..76c260a 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/model/WelfareUserSelection.java @@ -80,6 +80,12 @@ public class WelfareUserSelection extends BaseModel implements Serializable { @ColDefine(type = ColType.INT) private Integer selectNum; + @Column + @Comment("是否管理员代选") + @ColDefine(type = ColType.BOOLEAN) + @Default("0") + private Boolean isSelectByAdmin; + @Column @Comment("手机号") @ColDefine(type = ColType.VARCHAR, width = 20) diff --git a/src/main/java/com/budwk/app/zhgh/welfare/param/WelfareSelectionSituationPageForm.java b/src/main/java/com/budwk/app/zhgh/welfare/param/WelfareSelectionSituationPageForm.java index a35a793..8631812 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/param/WelfareSelectionSituationPageForm.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/param/WelfareSelectionSituationPageForm.java @@ -32,4 +32,7 @@ public class WelfareSelectionSituationPageForm extends PageForm { @ApiModelProperty("是否已选择") private Boolean isSelect; + + @ApiModelProperty("是否管理员代选") + private Boolean isSelectByAdmin; } diff --git a/src/main/java/com/budwk/app/zhgh/welfare/service/WelfareStatisticsService.java b/src/main/java/com/budwk/app/zhgh/welfare/service/WelfareStatisticsService.java index 1217d76..809cf58 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/service/WelfareStatisticsService.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/service/WelfareStatisticsService.java @@ -16,7 +16,7 @@ public interface WelfareStatisticsService extends BaseService { * @param unionId * @return */ - NutMap pageData(String projectId, String unionId); + NutMap pageData(String projectId, String unionId, Boolean isSelectByAdmin); /** * 查询某分工会已选择人员 @@ -24,7 +24,7 @@ public interface WelfareStatisticsService extends BaseService { * @param projectId * @param unionId */ - Pagination selectedUnionUserPageData(PageForm pageForm, String projectId, String unionId); + Pagination selectedUnionUserPageData(PageForm pageForm, String projectId, String unionId, Boolean isSelectByAdmin); /** * 导出某分工会已选择人员 @@ -32,7 +32,7 @@ public interface WelfareStatisticsService extends BaseService { * @param unionId * @param response */ - void exportSelectedUnionUser(String projectId, String unionId, HttpServletResponse response); + void exportSelectedUnionUser(String projectId, String unionId, Boolean isSelectByAdmin, HttpServletResponse response); /** * Pagination diff --git a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java index cd0e69f..4e0b89d 100644 --- a/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/welfare/service/impl/WelfareSelectionSituationServiceImpl.java @@ -37,6 +37,15 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl unions = dao().query(Sys_union.class, Cnd.NEW().andEX(Sys_union::getId, "=", unionId).asc(Sys_union::getUnionCode)); List mapUnions = BeanUtil.copyToList(unions, NutMap.class); @@ -71,8 +88,10 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl userSelections = listMap(sql2); @@ -119,7 +139,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl + + + + + + + @@ -75,6 +82,16 @@ layout("/layouts/platform.html"){ 导出选择情况表 + + 管理员代选择 + + + + + + + + + {{item.optionName}} + + + + + + + + + 给没有选择的福利人员统一代选择 + + 取消 + 提交 + + @@ -144,20 +189,30 @@ layout("/layouts/platform.html"){ { prop: "welfareUnionName", label: "所属工会", sortable: true }, { prop: "welfareUnitName", label: "所属单位", sortable: true }, { prop: "selectedOptions", label: "所选福利", sortable: true }, + { prop: "selectByAdminName", label: "是否管理员代选", sortable: true }, { prop: "welfareMobile", label: "福利号码", sortable: true } ], - optionSelectVisible: false + optionSelectVisible: false, + selectByAdminDialogVisible: false, + doSelectByAdminLoading: false, + welfareAdminOptions: [] } }, computed: { + currentProject() { + if (this.pageForm.projectId) { + return this.projectOptions.find((item) => item.id === this.pageForm.projectId) || {} + } + return {} + }, welfareOptions() { if (this.pageForm.projectId) { - return this.projectOptions.find((item) => item.id === this.pageForm.projectId).options + return this.currentProject.options || [] } return [] }, provideMode() { - return this.projectOptions.find((item) => item.id === this.pageForm.projectId).provideMode + return this.currentProject.provideMode } }, methods: { @@ -177,8 +232,12 @@ layout("/layouts/platform.html"){ // 获取数据 pageData() { this.tableLoading = true + const pageForm = Object.assign({}, this.pageForm) + if (pageForm.isSelectByAdmin === "" || pageForm.isSelectByAdmin === null || pageForm.isSelectByAdmin === undefined) { + delete pageForm.isSelectByAdmin + } this.$axios - .post("/platform/welfare/selection/situation/pageData", { pageForm: JSON.stringify(this.pageForm) }) + .post("/platform/welfare/selection/situation/pageData", { pageForm: JSON.stringify(pageForm) }) .then((res) => { if (res.code === 0) { this.tableData = res.data.list @@ -192,10 +251,95 @@ layout("/layouts/platform.html"){ // 导出选择情况表 exportXlsx() { - this.$downLoad("/platform/welfare/selection/situation/exportXlsx", { pageForm: JSON.stringify(this.pageForm) }) + const pageForm = Object.assign({}, this.pageForm) + if (pageForm.isSelectByAdmin === "" || pageForm.isSelectByAdmin === null || pageForm.isSelectByAdmin === undefined) { + delete pageForm.isSelectByAdmin + } + this.$downLoad("/platform/welfare/selection/situation/exportXlsx", { pageForm: JSON.stringify(pageForm) }) }, - // 管理员待选 + optionMax(option) { + if (option.maxNum !== undefined && option.maxNum !== null) { + return option.maxNum + } + if (this.currentProject.isCheckBox === "checkBox" && this.currentProject.singleOptionSupportMultipleSelection) { + return this.currentProject.multiSelectNum || 99 + } + return 1 + }, + + numChange(value, optionIndex) { + const currentValue = Number(value) || 0 + this.$set(this.welfareAdminOptions[optionIndex], "selectNum", currentValue) + if (this.currentProject.isCheckBox !== "checkBox") { + this.welfareAdminOptions.forEach((option, index) => { + this.$set(option, "selectNum", index === optionIndex && currentValue > 0 ? 1 : 0) + }) + return + } + + if (!this.currentProject.singleOptionSupportMultipleSelection && currentValue > 1) { + this.$set(this.welfareAdminOptions[optionIndex], "selectNum", 1) + this.$message.warning("此套餐最多只能选择1份") + return + } + + const sum = this.welfareAdminOptions.reduce((total, option) => total + (option.selectNum || 0), 0) + const maxSelectNum = this.currentProject.isCheckBox === "checkBox" ? (this.currentProject.multiSelectNum || 1) : 1 + if (sum > maxSelectNum) { + this.$set(this.welfareAdminOptions[optionIndex], "selectNum", Math.max(0, currentValue - (sum - maxSelectNum))) + this.$message.warning("此次福利最多只能选择" + maxSelectNum + "份") + } + }, + + selectOptionByAdmin() { + if (!this.pageForm.projectId) { + this.$message.warning("请先选择福利项目") + return + } + this.welfareAdminOptions = this.welfareOptions.map((item) => Object.assign({}, item, { selectNum: 0 })) + this.selectByAdminDialogVisible = true + }, + + doSelectByAdmin() { + const sum = this.welfareAdminOptions.reduce((total, option) => total + (option.selectNum || 0), 0) + if (sum === 0) { + this.$message.warning("请选择福利") + return + } + + this.$confirm("请确定是否给未选择的教职工一键选择当前福利?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(async () => { + this.doSelectByAdminLoading = true + try { + const welfareOptions = this.welfareAdminOptions.map((w) => { + return { + id: w.id, + subjectId: w.subjectId, + selectNum: w.selectNum + } + }) + const resp = await this.$axios.post("/platform/welfare/selection/situation/doSelectByAdmin", { + welfareOptions: JSON.stringify(welfareOptions), + projectId: this.pageForm.projectId + }) + if (resp.code === 0) { + this.pageData() + this.selectByAdminDialogVisible = false + this.$message.success(resp.msg || "操作成功") + } else { + this.$message.warning(resp.msg || "操作失败") + } + } finally { + this.doSelectByAdminLoading = false + } + }).catch(() => {}) + }, + + // 管理员代选 proxySelect(row) { this.optionSelectVisible = true this.$nextTick(() => { diff --git a/src/main/resources/views/platform/zhgh/welfare/statistics/index.html b/src/main/resources/views/platform/zhgh/welfare/statistics/index.html index 7457569..ce28fb5 100644 --- a/src/main/resources/views/platform/zhgh/welfare/statistics/index.html +++ b/src/main/resources/views/platform/zhgh/welfare/statistics/index.html @@ -28,6 +28,12 @@ layout("/layouts/platform.html"){ + + + + + + @@ -38,6 +44,9 @@ layout("/layouts/platform.html"){ 导出汇总表 + + 管理员代选择 + + + + + + + + {{item.optionName}} + + + + + + + + + 给没有选择的福利人员统一代选择 + + 取消 + 提交 + + + @@ -102,7 +139,9 @@ layout("/layouts/platform.html"){ welfareOptions: [], projectInfo: {}, clearable: false, - tableColumns: [] + tableColumns: [], + selectByAdminDialogVisible: false, + doSelectByAdminLoading: false } }, methods: { @@ -130,9 +169,95 @@ layout("/layouts/platform.html"){ }) }, + optionMax(option) { + if (option.maxNum !== undefined && option.maxNum !== null) { + return option.maxNum + } + if (this.projectInfo.isCheckBox === "checkBox" && this.projectInfo.singleOptionSupportMultipleSelection) { + return this.projectInfo.multiSelectNum || 99 + } + return 1 + }, + + numChange(value, optionIndex) { + const currentValue = Number(value) || 0 + this.$set(this.welfareOptions[optionIndex], "selectNum", currentValue) + if (this.projectInfo.isCheckBox !== "checkBox") { + this.welfareOptions.forEach((option, index) => { + this.$set(option, "selectNum", index === optionIndex && currentValue > 0 ? 1 : 0) + }) + return + } + + if (!this.projectInfo.singleOptionSupportMultipleSelection && currentValue > 1) { + this.$set(this.welfareOptions[optionIndex], "selectNum", 1) + this.$message.warning("此套餐最多只能选择1份") + return + } + + const sum = this.welfareOptions.reduce((total, option) => total + (option.selectNum || 0), 0) + const maxSelectNum = this.projectInfo.isCheckBox === "checkBox" ? (this.projectInfo.multiSelectNum || 1) : 1 + if (sum > maxSelectNum) { + this.$set(this.welfareOptions[optionIndex], "selectNum", Math.max(0, currentValue - (sum - maxSelectNum))) + this.$message.warning("此次福利最多只能选择" + maxSelectNum + "份") + } + }, + + selectOptionByAdmin() { + if (!this.pageForm.projectId) { + this.$message.warning("请先选择福利项目") + return + } + this.getWelfareOptions() + this.selectByAdminDialogVisible = true + }, + + doSelectByAdmin() { + const selectNums = this.welfareOptions.map((v) => v.selectNum || 0) + const sum = selectNums.reduce((total, current) => total + current, 0) + if (sum === 0) { + this.$message.warning("请选择福利") + return + } + + this.$confirm("请确定是否给未选择的教职工一键选择当前福利?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(async () => { + this.doSelectByAdminLoading = true + try { + const welfareOptions = this.welfareOptions.map((w) => { + return { + id: w.id, + subjectId: w.subjectId, + selectNum: w.selectNum + } + }) + const resp = await this.$axios.post("/platform/welfare/statistics/doSelectByAdmin", { + welfareOptions: JSON.stringify(welfareOptions), + projectId: this.pageForm.projectId + }) + if (resp.code === 0) { + this.pageData() + this.selectByAdminDialogVisible = false + this.$message.success(resp.msg || "操作成功") + } else { + this.$message.warning(resp.msg || "操作失败") + } + } finally { + this.doSelectByAdminLoading = false + } + }).catch(() => {}) + }, + async pageData() { this.tableLoading = true - const resp = await this.$axios.post("/platform/welfare/statistics/pageData", this.pageForm) + const pageForm = Object.assign({}, this.pageForm) + if (pageForm.isSelectByAdmin === "" || pageForm.isSelectByAdmin === null || pageForm.isSelectByAdmin === undefined) { + delete pageForm.isSelectByAdmin + } + const resp = await this.$axios.post("/platform/welfare/statistics/pageData", pageForm) if (resp.code === 0) { this.tableColumns = resp.data.tableColumn this.tableData = resp.data.tableList @@ -151,8 +276,8 @@ layout("/layouts/platform.html"){ }, getWelfareOptions() { const data = this.welfareProjectList.find((p) => p.id === this.pageForm.projectId) - this.projectInfo = data - this.welfareOptions = data.options + this.projectInfo = data || {} + this.welfareOptions = data && data.options ? data.options.map((item) => Object.assign({}, item, { selectNum: 0 })) : [] }, async init() { if ( diff --git a/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js b/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js index 0798e09..306ad71 100644 --- a/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js +++ b/src/main/resources/views/platform/zhgh/welfare/statistics/selectedUser.js @@ -3,6 +3,17 @@ const selectedUser = {
+ + + + { if (res.code === 0) { @@ -84,14 +100,18 @@ const selectedUser = { }) }, handleSearch() { - this.pageForm.pageNum = 1 + this.pageForm.pageNumber = 1 this.pageData() }, handleExport() { - this.$downLoad("/platform/welfare/statistics/exportSelectedUnionUser", { + const params = { projectId: this.projectId, unionId: this.unionId - }) + } + if (this.pageForm.isSelectByAdmin !== null && this.pageForm.isSelectByAdmin !== undefined && this.pageForm.isSelectByAdmin !== "") { + params.isSelectByAdmin = this.pageForm.isSelectByAdmin + } + this.$downLoad("/platform/welfare/statistics/exportSelectedUnionUser", params) } } }