职工福利:福利统计和选择情况新增‘管理员代选择’按钮;(查询和导出已同步);

This commit is contained in:
dd3s_206
2026-06-03 18:24:43 +08:00
parent 13b8af999a
commit 4cb9e46fc5
11 changed files with 390 additions and 29 deletions
@@ -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")
@@ -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
@@ -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)
@@ -32,4 +32,7 @@ public class WelfareSelectionSituationPageForm extends PageForm {
@ApiModelProperty("是否已选择")
private Boolean isSelect;
@ApiModelProperty("是否管理员代选")
private Boolean isSelectByAdmin;
}
@@ -16,7 +16,7 @@ public interface WelfareStatisticsService extends BaseService<WelfareProject> {
* @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<WelfareProject> {
* @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<WelfareProject> {
* @param unionId
* @param response
*/
void exportSelectedUnionUser(String projectId, String unionId, HttpServletResponse response);
void exportSelectedUnionUser(String projectId, String unionId, Boolean isSelectByAdmin, HttpServletResponse response);
/**
* Pagination
@@ -37,6 +37,15 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
super(dao);
}
private void appendSelectByAdminCnd(Cnd cnd, Boolean isSelectByAdmin) {
if (Boolean.TRUE.equals(isSelectByAdmin)) {
cnd.and("t2.isSelectByAdmin", "=", true);
} else if (Boolean.FALSE.equals(isSelectByAdmin)) {
cnd.and("t2.id", "IS NOT", null);
cnd.and(Cnd.exps("t2.isSelectByAdmin", "=", false).or("t2.isSelectByAdmin", "is", null));
}
}
@Override
public Pagination pageData(WelfareSelectionSituationPageForm pageForm) {
Sql sql = Sqls.create("""
@@ -50,6 +59,10 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
GROUP_CONCAT(DISTINCT t3.optionName) AS selectedOptions,
GROUP_CONCAT(DISTINCT t2.mobile) AS mobile,
GROUP_CONCAT(DISTINCT t2.receiveAddress) AS receiveAddress,
CASE
WHEN MAX(t2.isSelectByAdmin) = 1 THEN '是'
ELSE '否'
END AS selectByAdminName,
t4.username AS userName,
t4.loginname AS loginName,
t4.sex,
@@ -79,6 +92,7 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
}
cnd.andEX("t1.welfareUnitId", "in", pageForm.getUnitIds());
cnd.andEX("t1.welfareUnionId", "=", pageForm.getUnionId());
appendSelectByAdminCnd(cnd, pageForm.getIsSelectByAdmin());
if (pageForm.getIsSelect() != null) {
if (pageForm.getIsSelect()) {
@@ -110,6 +124,10 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
GROUP_CONCAT(DISTINCT t3.optionName) AS selectedOptions,
GROUP_CONCAT(DISTINCT t2.mobile) AS mobile,
GROUP_CONCAT(DISTINCT t2.receiveAddress) AS receiveAddress,
CASE
WHEN MAX(t2.isSelectByAdmin) = 1 THEN '是'
ELSE '否'
END AS selectByAdminName,
t4.username AS userName,
t4.loginname AS loginName,
t4.sex,
@@ -138,6 +156,7 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
}
cnd.andEX("t1.welfareUnitId", "in", pageForm.getUnitIds());
cnd.andEX("t1.welfareUnionId", "=", pageForm.getUnionId());
appendSelectByAdminCnd(cnd, pageForm.getIsSelectByAdmin());
if (pageForm.getIsSelect() != null) {
if (pageForm.getIsSelect()) {
@@ -170,6 +189,7 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
entities.add(new ExcelExportEntity("所属单位", "welfareUnitName", 20));
entities.add(new ExcelExportEntity("所属工会", "welfareUnionName", 20));
entities.add(new ExcelExportEntity("所选福利", "selectedOptions", 20));
entities.add(new ExcelExportEntity("是否管理员代选", "selectByAdminName", 20));
entities.add(new ExcelExportEntity("福利号码", "welfareMobile", 20));
entities.add(new ExcelExportEntity("联系电话", "mobile", 20));
@@ -407,6 +407,7 @@ public class WelfareSingleServiceImpl extends BaseServiceImpl implements Welfare
selection.setReceiveAddress(null);
selection.setSubjectId(v.getString("subjectId"));
selection.setSelectNum(v.getInt("selectNum"));
selection.setIsSelectByAdmin(true);
return selection;
}).collect(Collectors.toList());
dao().insert(userSelections);
@@ -41,8 +41,25 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
super(dao);
}
private void appendSelectByAdminCnd(Cnd cnd, String field, Boolean isSelectByAdmin) {
if (Boolean.TRUE.equals(isSelectByAdmin)) {
cnd.and(field, "=", true);
} else if (Boolean.FALSE.equals(isSelectByAdmin)) {
cnd.and(Cnd.exps(field, "=", false).or(field, "is", null));
}
}
private String buildSelectByAdminJoinCnd(String field, Boolean isSelectByAdmin) {
if (Boolean.TRUE.equals(isSelectByAdmin)) {
return " AND " + field + " = 1";
} else if (Boolean.FALSE.equals(isSelectByAdmin)) {
return " AND (" + field + " = 0 OR " + field + " IS NULL)";
}
return "";
}
@Override
public NutMap pageData(String projectId, String unionId) {
public NutMap pageData(String projectId, String unionId, Boolean isSelectByAdmin) {
// 分工会数据
List<Sys_union> unions = dao().query(Sys_union.class, Cnd.NEW().andEX(Sys_union::getId, "=", unionId).asc(Sys_union::getUnionCode));
List<NutMap> mapUnions = BeanUtil.copyToList(unions, NutMap.class);
@@ -71,8 +88,10 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
`welfare_list` t1
LEFT JOIN welfare_project_user_selection t2 ON t2.selectUserId = t1.userId
AND t2.welfareId = t1.projectId
$selectByAdminJoinCnd
$condition
""");
sql.setVar("selectByAdminJoinCnd", buildSelectByAdminJoinCnd("t2.isSelectByAdmin", isSelectByAdmin));
Cnd cnd = Cnd.NEW();
cnd.and("t1.projectId", "=", projectId);
cnd.andEX("t1.welfareUnionId", "=", unionId);
@@ -92,6 +111,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
""");
Cnd cnd2 = Cnd.NEW();
cnd2.and("t1.welfareId", "=", projectId);
appendSelectByAdminCnd(cnd2, "t1.isSelectByAdmin", isSelectByAdmin);
sql2.setCondition(cnd2);
List<NutMap> userSelections = listMap(sql2);
@@ -119,7 +139,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
}
@Override
public Pagination selectedUnionUserPageData(PageForm pageForm, String projectId, String unionId) {
public Pagination selectedUnionUserPageData(PageForm pageForm, String projectId, String unionId, Boolean isSelectByAdmin) {
Sql sql = Sqls.create("""
SELECT
u.loginname AS loginName,
@@ -132,6 +152,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
u.postDoctoralJoinDate,
DATE_FORMAT(u.birthday, '%Y-%m-%d') AS birthday,
wpus.mobile,
CASE WHEN MAX(wpus.isSelectByAdmin) = 1 THEN '管理员代选' ELSE '个人选择' END AS selectByAdminName,
GROUP_CONCAT(DISTINCT wpso.optionName, '', wpus.selectNum, '份)') selectOptionName
FROM
welfare_project_user_selection wpus
@@ -143,6 +164,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
Cnd cnd = Cnd.NEW();
cnd.and("wl.welfareUnionId", "=", unionId);
cnd.and("wpus.welfareId", "=", projectId);
appendSelectByAdminCnd(cnd, "wpus.isSelectByAdmin", isSelectByAdmin);
cnd.groupBy("u.loginname");
cnd.desc("wl.welfareUnionName").desc("wl.welfareUnitName").desc("wpus.selectOptionId");
@@ -150,6 +172,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
SqlExpressionGroup seg = new SqlExpressionGroup();
seg.orLike("u.loginname", pageForm.getSearchKeyword());
seg.orLike("u.username", pageForm.getSearchKeyword());
cnd.and(seg);
}
sql.setCondition(cnd);
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
@@ -157,7 +180,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
}
@Override
public void exportSelectedUnionUser(String projectId, String unionId, HttpServletResponse response) {
public void exportSelectedUnionUser(String projectId, String unionId, Boolean isSelectByAdmin, HttpServletResponse response) {
Sql sql = Sqls.create("""
SELECT
u.loginname AS loginName,
@@ -170,6 +193,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
u.postDoctoralJoinDate,
DATE_FORMAT(u.birthday, '%Y-%m-%d') AS birthday,
wpus.mobile,
CASE WHEN MAX(wpus.isSelectByAdmin) = 1 THEN '管理员代选' ELSE '个人选择' END AS selectByAdminName,
GROUP_CONCAT(DISTINCT wpso.optionName, '', wpus.selectNum, '份)') selectOptionName
FROM
welfare_project_user_selection wpus
@@ -182,6 +206,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
Cnd cnd = Cnd.NEW();
cnd.and("wl.welfareUnionId", "=", unionId);
cnd.and("wpus.welfareId", "=", projectId);
appendSelectByAdminCnd(cnd, "wpus.isSelectByAdmin", isSelectByAdmin);
cnd.groupBy("u.loginname");
cnd.desc("wl.welfareUnionName").desc("wl.welfareUnitName").desc("wpus.selectOptionId");
sql.setCondition(cnd);
@@ -208,6 +233,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
entities.add(new ExcelExportEntity("单位", "welfareUnitName", 20));
entities.add(new ExcelExportEntity("工会", "welfareUnionName", 20));
entities.add(new ExcelExportEntity("手机号", "mobile", 20));
entities.add(new ExcelExportEntity("选择方式", "selectByAdminName", 20));
entities.add(new ExcelExportEntity("所选福利", "selectOptionName", 20));
// 设置导出参数
@@ -361,6 +387,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
exportEntities.add(new ExcelExportEntity("电话号码", "mobile", 20));
exportEntities.add(new ExcelExportEntity("所在分工会", "welfareUnionName", 20));
exportEntities.add(new ExcelExportEntity("所在单位", "welfareUnitName", 20));
exportEntities.add(new ExcelExportEntity("选择方式", "selectByAdminName", 20));
exportEntities.add(new ExcelExportEntity("所在福利", "optionName", 50));
Sql sql = Sqls.create("""
@@ -372,6 +399,7 @@ public class WelfareStatisticsServiceImpl extends BaseServiceImpl<WelfareProject
wpus.mobile,
wpus.selectOptionId,
wpso.optionName,
CASE WHEN MAX(wpus.isSelectByAdmin) = 1 THEN '管理员代选' ELSE '个人选择' END AS selectByAdminName,
GROUP_CONCAT(DISTINCT wpso.optionName, '', wpus.selectNum, '份)') selectOptionName
FROM
welfare_project_user_selection wpus
@@ -61,6 +61,13 @@ layout("/layouts/platform.html"){
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unitOptions"></el-option>
</el-select>
</search-item>
<search-item label="管理员代选">
<el-select clearable placeholder="请选择是否管理员代选" style="width: 100%" v-model="pageForm.isSelectByAdmin">
<el-option :value="true" label="是"></el-option>
<el-option :value="false" label="否"></el-option>
</el-select>
</search-item>
</search>
</el-card>
@@ -75,6 +82,16 @@ layout("/layouts/platform.html"){
<el-button type="primary" size="small" icon="el-icon-download" style="margin-left: 10px" @click="exportXlsx">
导出选择情况表
</el-button>
<el-button
type="primary"
size="small"
icon="el-icon-edit"
style="margin-left: 10px"
@click="selectOptionByAdmin"
v-if="$auth.hasRoleOr(['SYSADMIN','SCHOOL_UNION_ADMIN','SCHOOL_UNION_WELFARE_ADMIN'])"
>
管理员代选择
</el-button>
</table-tool>
<el-table
@@ -114,6 +131,34 @@ layout("/layouts/platform.html"){
<el-dialog title="代选" :visible.sync="optionSelectVisible" width="60%">
<option-select ref="optionSelectRef" @refresh="optionSelectVisible=false;doSearch();"></option-select>
</el-dialog>
<el-dialog :visible.sync="selectByAdminDialogVisible" title="管理员统一选择福利" width="35%">
<el-form label-position="right" label-width="120px">
<el-form-item label="福利选项">
<el-row :gutter="10" :key="item.id" style="margin: 10px" v-for="(item, oidx) in welfareAdminOptions">
<el-col :span="6">
<el-tag style="height:40px;line-height:40px;width: 100%;">
<span style="display: flex; justify-content: center;">{{item.optionName}}</span>
</el-tag>
</el-col>
<el-col :span="18">
<el-input-number
:max="optionMax(item)"
:min="0"
@change="numChange($event, oidx)"
style="width: 50%"
v-model="item.selectNum"
></el-input-number>
</el-col>
</el-row>
</el-form-item>
</el-form>
<el-alert class="text-primary mb10">给没有选择的福利人员统一代选择</el-alert>
<el-row justify="end" type="flex">
<el-button @click="selectByAdminDialogVisible=false">取消</el-button>
<el-button :loading="doSelectByAdminLoading" @click="doSelectByAdmin" type="primary">提交</el-button>
</el-row>
</el-dialog>
</guava>
</div>
@@ -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(() => {
@@ -28,6 +28,12 @@ layout("/layouts/platform.html"){
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in unionOptions"></el-option>
</el-select>
</search-item>
<search-item label="选择方式">
<el-select clearable placeholder="选择方式" style="width: 100%" v-model="pageForm.isSelectByAdmin">
<el-option :value="true" label="管理员代选"></el-option>
<el-option :value="false" label="个人选择"></el-option>
</el-select>
</search-item>
</search>
</el-card>
@@ -38,6 +44,9 @@ layout("/layouts/platform.html"){
<el-button :disabled="!pageForm.projectId" @click="exportSummary" icon="el-icon-printer" size="small" type="primary">
导出汇总表
</el-button>
<el-button :disabled="!pageForm.projectId" @click="selectOptionByAdmin" icon="el-icon-edit" size="small" type="primary">
管理员代选择
</el-button>
</template>
</table-tool>
<el-table
@@ -76,6 +85,34 @@ layout("/layouts/platform.html"){
</template>
</guava>
<el-dialog :visible.sync="selectByAdminDialogVisible" title="管理员统一选择福利" width="35%">
<el-form label-position="right" label-width="120px">
<el-form-item label="福利选项">
<el-row :gutter="10" :key="item.id" style="margin: 10px" v-for="(item, oidx) in welfareOptions">
<el-col :span="6">
<el-tag style="height:40px;line-height:40px;width: 100%;">
<span style="display: flex; justify-content: center;">{{item.optionName}}</span>
</el-tag>
</el-col>
<el-col :span="18">
<el-input-number
:max="optionMax(item)"
:min="0"
@change="numChange($event, oidx)"
style="width: 50%"
v-model="item.selectNum"
></el-input-number>
</el-col>
</el-row>
</el-form-item>
</el-form>
<el-alert class="text-primary mb10">给没有选择的福利人员统一代选择</el-alert>
<el-row justify="end" type="flex">
<el-button @click="selectByAdminDialogVisible=false">取消</el-button>
<el-button :loading="doSelectByAdminLoading" @click="doSelectByAdmin" type="primary">提交</el-button>
</el-row>
</el-dialog>
<selected-user ref="selectedUserRef"></selected-user>
<unselected-user ref="unSelectedUserRef"></unselected-user>
</div>
@@ -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 (
@@ -3,6 +3,17 @@ const selectedUser = {
<el-dialog :title="unionName+'已选择用户'" :visible.sync="visible" width="70%">
<div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
<div>
<el-select
v-model="pageForm.isSelectByAdmin"
placeholder="选择方式"
style="width: 140px;"
size="small"
clearable
@change="doSearch"
>
<el-option :value="true" label="管理员代选"></el-option>
<el-option :value="false" label="个人选择"></el-option>
</el-select>
<el-input
v-model="pageForm.searchKeyword"
placeholder="请输入姓名或工号"
@@ -55,6 +66,7 @@ const selectedUser = {
{ prop: "postDoctoralJoinDate", label: "进站时间", sortable: true },
{ label: "单位", prop: "welfareUnitName" },
{ label: "手机号", prop: "mobile" },
{ label: "选择方式", prop: "selectByAdminName" },
{ label: "所选福利", prop: "selectOptionName" }
]
}
@@ -65,16 +77,20 @@ const selectedUser = {
this.projectId = projectId
this.unionId = id
this.unionName = name
this.searchKeyword = ""
this.pageForm.searchKeyword = ""
this.$set(this.pageForm, "isSelectByAdmin", null)
this.pageData()
},
pageData() {
const pageForm = Object.assign({}, this.pageForm)
if (pageForm.isSelectByAdmin === "" || pageForm.isSelectByAdmin === null || pageForm.isSelectByAdmin === undefined) {
delete pageForm.isSelectByAdmin
}
this.$axios
.post("/platform/welfare/statistics/selectedUnionUserPageData", {
...this.pageForm,
...pageForm,
projectId: this.projectId,
unionId: this.unionId,
keyword: this.searchKeyword
unionId: this.unionId
})
.then((res) => {
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)
}
}
}