This commit is contained in:
2026-04-30 09:22:53 +08:00
parent 4189ec7834
commit 5c646ff039
11 changed files with 435 additions and 58 deletions
@@ -2,6 +2,7 @@ package com.budwk.app.zhgh.staffmanage.member.controller.statistics;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.budwk.app.base.result.Result; import com.budwk.app.base.result.Result;
import com.budwk.app.zhgh.staffmanage.member.param.pageform.MemberStatisticsPageForm;
import com.budwk.app.zhgh.staffmanage.member.service.MemberStatisticsService; import com.budwk.app.zhgh.staffmanage.member.service.MemberStatisticsService;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
@@ -39,14 +40,12 @@ public class MemberAnalysisController {
@At @At
@SaCheckPermission("member.statistics.analysis") @SaCheckPermission("member.statistics.analysis")
public Result pageData(@Param(value = "queryId") String queryId, public Result pageData(@Param("..") MemberStatisticsPageForm pageForm) {
@Param(value = "queryType") String queryType,
@Param(value = "currentYear") Integer currentYear) {
List<NutMap> list = new ArrayList<>(); List<NutMap> list = new ArrayList<>();
if ("fgh".equals(queryType)) { if ("fgh".equals(pageForm.getQueryType())) {
list = memberStatisticsService.getUnionAnalysisData(queryId, currentYear); list = memberStatisticsService.getUnionAnalysisData(pageForm);
} else { } else {
list = memberStatisticsService.getUnitAnalysisData(queryId, currentYear); list = memberStatisticsService.getUnitAnalysisData(pageForm);
} }
return Result.success(list); return Result.success(list);
} }
@@ -58,10 +57,13 @@ public class MemberAnalysisController {
public void doExport(@Param("queryType") String queryType, @Param("currentYear") String currentYear, public void doExport(@Param("queryType") String queryType, @Param("currentYear") String currentYear,
@Param("queryId") String queryId, HttpServletResponse response) { @Param("queryId") String queryId, HttpServletResponse response) {
List<NutMap> list = new ArrayList<>(); List<NutMap> list = new ArrayList<>();
MemberStatisticsPageForm pageForm = new MemberStatisticsPageForm();
pageForm.setQueryId(queryId);
pageForm.setCurrentYear(Integer.valueOf(currentYear));
if ("union".equals(queryType)) { if ("union".equals(queryType)) {
list = memberStatisticsService.getUnionAnalysisData(queryId, Integer.valueOf(currentYear)); list = memberStatisticsService.getUnionAnalysisData(pageForm);
} else { } else {
list = memberStatisticsService.getUnitAnalysisData(queryId, Integer.valueOf(currentYear)); list = memberStatisticsService.getUnitAnalysisData(pageForm);
} }
NutMap sumMap = NutMap.NEW(); NutMap sumMap = NutMap.NEW();
sumMap.put("union".equals(queryType) ? "unionName" : "unitName", "合计"); sumMap.put("union".equals(queryType) ? "unionName" : "unitName", "合计");
@@ -40,7 +40,14 @@ public interface MemberStatisticsService extends BaseService<Sys_user> {
* @param currentYear 所属年度 * @param currentYear 所属年度
* @return * @return
*/ */
List<NutMap> getUnionAnalysisData(String unionId, Integer currentYear); /**
* 获取工会分析数据。
* pageForm 中除了机构和年份外,还会带上人员分类、人员属性等附加筛选条件。
*
* @param pageForm 统计查询参数
* @return 工会分析结果
*/
List<NutMap> getUnionAnalysisData(MemberStatisticsPageForm pageForm);
/** /**
@@ -49,7 +56,14 @@ public interface MemberStatisticsService extends BaseService<Sys_user> {
* @param currentYear 所属年度 * @param currentYear 所属年度
* @return * @return
*/ */
List<NutMap> getUnitAnalysisData(String unitId, Integer currentYear); /**
* 获取单位分析数据。
* pageForm 中除了机构和年份外,还会带上人员分类、人员属性等附加筛选条件。
*
* @param pageForm 统计查询参数
* @return 单位分析结果
*/
List<NutMap> getUnitAnalysisData(MemberStatisticsPageForm pageForm);
/** /**
* 导出分析数据 * 导出分析数据
@@ -29,6 +29,7 @@ import org.nutz.lang.util.NutMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @version 1.0 * @version 1.0
@@ -212,32 +213,79 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
@Override @Override
public List<NutMap> getUnionAnalysisData(String queryId, Integer currentYear) { public List<NutMap> getUnionAnalysisData(MemberStatisticsPageForm pageForm) {
String queryId = pageForm.getQueryId();
Integer currentYear = pageForm.getCurrentYear();
String lastYearPersonFilter = getAnalysisPersonFilterSql(pageForm, "his");
String currentPersonFilter = getAnalysisPersonFilterSql(pageForm, "u");
boolean useCurrentUserView = ((Integer) DateUtil.thisYear()).equals(currentYear);
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
gh.id, gh.id,
gh.unionCode, gh.unionCode,
gh.`name` as unionName, gh.`name` as unionName,
( SELECT count( 1 ) FROM member_history his LEFT JOIN vw_user u on u.id = his.userId WHERE his.`year` = @lastYear AND u.unionId = gh.id ) AS lastYearMemberNum, IFNULL(lastYear.lastYearMemberNum, 0) AS lastYearMemberNum,
( SELECT count( 1 ) FROM member_apply_record WHERE changeUnionId is not null AND unionId = gh.id AND unionId != changeUnionId AND YEAR ( applyDateTime ) = @currentYear ) AS memberUnitChangeNumIn, IFNULL(changeIn.memberUnitChangeNumIn, 0) AS memberUnitChangeNumIn,
( SELECT count( 1 ) FROM member_apply_record WHERE changeUnionId is not null AND changeUnionId = gh.id AND unionId != changeUnionId AND YEAR ( applyDateTime ) = @currentYear ) AS memberUnitChangeNumOut, IFNULL(changeOut.memberUnitChangeNumOut, 0) AS memberUnitChangeNumOut,
( SELECT count( 1 ) FROM sys_user_history his LEFT JOIN `vw_user` u ON u.loginname = his.loginname WHERE JSON_CONTAINS(his.changeTypes, '["NEW", "RESTORE"]', '$') AND u.unionId = gh.id AND YEAR ( his.changeTime ) = @currentYear ) AS newResetMemberNum, IFNULL(newReset.newResetMemberNum, 0) AS newResetMemberNum,
( SELECT count( 1 ) FROM sys_user_history his LEFT JOIN `vw_user` u ON u.loginname = his.loginname WHERE JSON_CONTAINS(his.changeTypes, '["WITHDRAWAL"]', '$') AND u.unionId = gh.id AND YEAR ( his.changeTime ) = @currentYear ) AS reduceOtherNum, IFNULL(reduceOther.reduceOtherNum, 0) AS reduceOtherNum,
( SELECT count( 1 ) FROM $table where member = 1 and unionId = gh.id) as currentYearMemberNum IFNULL(currentMember.currentYearMemberNum, 0) AS currentYearMemberNum
FROM FROM
sys_union gh sys_union gh
LEFT JOIN (
SELECT his.unionId, COUNT(1) AS lastYearMemberNum
FROM member_history his
WHERE his.`year` = @lastYear $lastYearPersonFilter
GROUP BY his.unionId
) lastYear ON lastYear.unionId = gh.id
LEFT JOIN (
SELECT unionId, COUNT(1) AS memberUnitChangeNumIn
FROM member_apply_record
WHERE changeUnionId is not null AND unionId != changeUnionId AND YEAR(applyDateTime) = @currentYear
GROUP BY unionId
) changeIn ON changeIn.unionId = gh.id
LEFT JOIN (
SELECT changeUnionId AS unionId, COUNT(1) AS memberUnitChangeNumOut
FROM member_apply_record
WHERE changeUnionId is not null AND unionId != changeUnionId AND YEAR(applyDateTime) = @currentYear
GROUP BY changeUnionId
) changeOut ON changeOut.unionId = gh.id
LEFT JOIN (
SELECT u.unionId, COUNT(1) AS newResetMemberNum
FROM sys_user_history his
JOIN vw_user u ON u.loginname = his.loginname
WHERE JSON_CONTAINS(his.changeTypes, '["NEW", "RESTORE"]', '$')
AND YEAR(his.changeTime) = @currentYear $currentPersonFilter
GROUP BY u.unionId
) newReset ON newReset.unionId = gh.id
LEFT JOIN (
SELECT u.unionId, COUNT(1) AS reduceOtherNum
FROM sys_user_history his
JOIN vw_user u ON u.loginname = his.loginname
WHERE JSON_CONTAINS(his.changeTypes, '["WITHDRAWAL"]', '$')
AND YEAR(his.changeTime) = @currentYear $currentPersonFilter
GROUP BY u.unionId
) reduceOther ON reduceOther.unionId = gh.id
LEFT JOIN (
SELECT u.unionId, COUNT(1) AS currentYearMemberNum
FROM $table u
WHERE u.member = 1 $currentPersonFilter $currentYearFilter
GROUP BY u.unionId
) currentMember ON currentMember.unionId = gh.id
$condition $condition
"""); """);
sql.setParam("lastYear", currentYear - 1); sql.setParam("lastYear", currentYear - 1);
sql.setParam("currentYear", currentYear); sql.setParam("currentYear", currentYear);
sql.setVar("table", ((Integer) DateUtil.thisYear()).equals(currentYear) ? "`vw_user`" : "member_history"); sql.setVar("table", useCurrentUserView ? "`vw_user`" : "member_history");
sql.setVar("lastYearPersonFilter", new Static(lastYearPersonFilter));
sql.setVar("currentPersonFilter", new Static(currentPersonFilter));
sql.setVar("currentYearFilter", new Static(getAnalysisYearFilterSql("u", useCurrentUserView, currentYear)));
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
cnd.and("gh.id", "=", SecurityUtil.getUnionId()); cnd.and("gh.id", "=", SecurityUtil.getUnionId());
} else { } else {
cnd.andEX("gh.id", "=", queryId); cnd.andEX("gh.id", "=", queryId);
} }
cnd.groupBy("gh.id, gh.unionCode, gh.name");
cnd.asc("gh.unionCode"); cnd.asc("gh.unionCode");
sql.setCondition(cnd); sql.setCondition(cnd);
List<NutMap> list = listMap(sql); List<NutMap> list = listMap(sql);
@@ -250,24 +298,73 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
@Override @Override
public List<NutMap> getUnitAnalysisData(String queryId, Integer currentYear) { public List<NutMap> getUnitAnalysisData(MemberStatisticsPageForm pageForm) {
String queryId = pageForm.getQueryId();
Integer currentYear = pageForm.getCurrentYear();
String lastYearPersonFilter = getAnalysisPersonFilterSql(pageForm, "his");
String currentPersonFilter = getAnalysisPersonFilterSql(pageForm, "u");
boolean useCurrentUserView = ((Integer) DateUtil.thisYear()).equals(currentYear);
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
dw.id, dw.id,
dw.unitcode as unitCode, dw.unitcode as unitCode,
dw.`name` as unitName, dw.`name` as unitName,
( SELECT count( 1 ) FROM member_history WHERE `year` = @lastYear AND unitId = dw.id ) AS lastYearMemberNum, IFNULL(lastYear.lastYearMemberNum, 0) AS lastYearMemberNum,
( SELECT count( 1 ) FROM member_apply_record WHERE changeUnitId is not null AND unitId = dw.id AND unitId != changeUnitId AND YEAR ( applyDateTime ) = @currentYear ) AS memberUnitChangeNumIn, IFNULL(changeIn.memberUnitChangeNumIn, 0) AS memberUnitChangeNumIn,
( SELECT count( 1 ) FROM member_apply_record WHERE changeUnitId is not null AND changeUnitId = dw.id AND unitId != changeUnitId AND YEAR ( applyDateTime ) = @currentYear ) AS memberUnitChangeNumOut, IFNULL(changeOut.memberUnitChangeNumOut, 0) AS memberUnitChangeNumOut,
( SELECT count( 1 ) FROM sys_user_history his LEFT JOIN vw_user u ON u.loginname = his.loginname WHERE JSON_CONTAINS(his.changeTypes, '["NEW", "RESTORE"]', '$') AND u.unitId = dw.id AND YEAR ( his.changeTime ) = @currentYear ) AS newResetMemberNum, IFNULL(newReset.newResetMemberNum, 0) AS newResetMemberNum,
( SELECT count( 1 ) FROM sys_user_history his LEFT JOIN vw_user u ON u.loginname = his.loginname WHERE JSON_CONTAINS(his.changeTypes, '["WITHDRAWAL"]', '$') AND u.unitId = dw.id AND YEAR ( his.changeTime ) = @currentYear ) AS reduceOtherNum, IFNULL(reduceOther.reduceOtherNum, 0) AS reduceOtherNum,
( SELECT count( 1 ) from vw_user where member = 1 and unitId = dw.id) as currentYearMemberNum IFNULL(currentMember.currentYearMemberNum, 0) AS currentYearMemberNum
FROM FROM
sys_unit dw sys_unit dw
LEFT JOIN (
SELECT his.unitId, COUNT(1) AS lastYearMemberNum
FROM member_history his
WHERE his.`year` = @lastYear $lastYearPersonFilter
GROUP BY his.unitId
) lastYear ON lastYear.unitId = dw.id
LEFT JOIN (
SELECT unitId, COUNT(1) AS memberUnitChangeNumIn
FROM member_apply_record
WHERE changeUnitId is not null AND unitId != changeUnitId AND YEAR(applyDateTime) = @currentYear
GROUP BY unitId
) changeIn ON changeIn.unitId = dw.id
LEFT JOIN (
SELECT changeUnitId AS unitId, COUNT(1) AS memberUnitChangeNumOut
FROM member_apply_record
WHERE changeUnitId is not null AND unitId != changeUnitId AND YEAR(applyDateTime) = @currentYear
GROUP BY changeUnitId
) changeOut ON changeOut.unitId = dw.id
LEFT JOIN (
SELECT u.unitId, COUNT(1) AS newResetMemberNum
FROM sys_user_history his
JOIN vw_user u ON u.loginname = his.loginname
WHERE JSON_CONTAINS(his.changeTypes, '["NEW", "RESTORE"]', '$')
AND YEAR(his.changeTime) = @currentYear $currentPersonFilter
GROUP BY u.unitId
) newReset ON newReset.unitId = dw.id
LEFT JOIN (
SELECT u.unitId, COUNT(1) AS reduceOtherNum
FROM sys_user_history his
JOIN vw_user u ON u.loginname = his.loginname
WHERE JSON_CONTAINS(his.changeTypes, '["WITHDRAWAL"]', '$')
AND YEAR(his.changeTime) = @currentYear $currentPersonFilter
GROUP BY u.unitId
) reduceOther ON reduceOther.unitId = dw.id
LEFT JOIN (
SELECT u.unitId, COUNT(1) AS currentYearMemberNum
FROM $table u
WHERE u.member = 1 $currentPersonFilter $currentYearFilter
GROUP BY u.unitId
) currentMember ON currentMember.unitId = dw.id
$condition $condition
"""); """);
sql.setParam("lastYear", currentYear - 1); sql.setParam("lastYear", currentYear - 1);
sql.setParam("currentYear", currentYear); sql.setParam("currentYear", currentYear);
sql.setVar("lastYearPersonFilter", new Static(lastYearPersonFilter));
sql.setVar("currentPersonFilter", new Static(currentPersonFilter));
sql.setVar("table", useCurrentUserView ? "`vw_user`" : "member_history");
sql.setVar("currentYearFilter", new Static(getAnalysisYearFilterSql("u", useCurrentUserView, currentYear)));
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and("dw.unitLevel", "=", 3); cnd.and("dw.unitLevel", "=", 3);
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) { if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
@@ -275,7 +372,6 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
} else { } else {
cnd.andEX("dw.id", "=", queryId); cnd.andEX("dw.id", "=", queryId);
} }
cnd.groupBy("dw.id", "dw.unitcode", "dw.name");
cnd.asc("dw.unitcode"); cnd.asc("dw.unitcode");
sql.setCondition(cnd); sql.setCondition(cnd);
List<NutMap> list = listMap(sql); List<NutMap> list = listMap(sql);
@@ -286,6 +382,61 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
return list; return list;
} }
/**
* 分析统计的 SQL 由多个子查询组成,外层机构条件不会自动作用到人员子查询。
* 这里统一拼出人员分类、人员属性的过滤片段,分别注入到各个统计子查询里,
* 保证 analysis 页面和前端标签筛选口径一致。
*
* @param pageForm 查询参数
* @param alias 子查询里的人员表别名
* @return 可直接拼接到子查询 WHERE 末尾的 SQL 片段
*/
private String getAnalysisPersonFilterSql(MemberStatisticsPageForm pageForm, String alias) {
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append(getAnalysisInSql(alias, "aidFundMemberUserType", pageForm.getAidFundMemberUserTypes()));
sqlBuilder.append(getAnalysisInSql(alias, "userAttribute", pageForm.getUserAttributes()));
return sqlBuilder.toString();
}
/**
* analysis 的当前数量在查历史年度时会切到 member_history
* 这里统一补年度条件,避免历史年度把整张历史表都统计进去。
*
* @param alias 子查询别名
* @param useCurrentUserView 是否使用当前人员视图
* @param currentYear 查询年度
* @return 年度过滤 SQL 片段
*/
private String getAnalysisYearFilterSql(String alias, boolean useCurrentUserView, Integer currentYear) {
if (useCurrentUserView) {
return "";
}
return " AND " + alias + ".`year` = " + currentYear;
}
/**
* 这里仅用于拼接 analysis 模块固定字段的 IN 条件,
* 会过滤空值并转义单引号,避免直接把前端原始值拼回 SQL。
*
* @param alias 子查询别名
* @param columnName 字段名
* @param values 筛选值列表
* @return IN 条件 SQL 片段
*/
private String getAnalysisInSql(String alias, String columnName, List<String> values) {
if (Lang.isEmpty(values)) {
return "";
}
List<String> validValues = values.stream().filter(Strings::isNotBlank).collect(Collectors.toList());
if (Lang.isEmpty(validValues)) {
return "";
}
String inValueSql = validValues.stream()
.map(value -> "'" + value.replace("'", "''") + "'")
.collect(Collectors.joining(", "));
return " AND " + alias + "." + columnName + " IN (" + inValueSql + ")";
}
@Override @Override
public Workbook exportAnalysisExcel(List<NutMap> list, String queryType) { public Workbook exportAnalysisExcel(List<NutMap> list, String queryType) {
@@ -348,6 +499,7 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
// sql.setVar("abbr", new Static("his")); // sql.setVar("abbr", new Static("his"));
} }
cnd.andEX("u.userAttribute", "in", pageForm.getUserAttributes()); cnd.andEX("u.userAttribute", "in", pageForm.getUserAttributes());
cnd.andEX("u.aidFundMemberUserType", "in", pageForm.getAidFundMemberUserTypes());
cnd.groupBy("un.id", "un.unionCode", "un.name"); cnd.groupBy("un.id", "un.unionCode", "un.name");
cnd.asc("un.unionCode"); cnd.asc("un.unionCode");
sql.setCondition(cnd); sql.setCondition(cnd);
@@ -388,6 +540,7 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
sql.setVar("yearCnd", new Static(" AND u.`year` = %d".formatted(currentYear))); sql.setVar("yearCnd", new Static(" AND u.`year` = %d".formatted(currentYear)));
} }
cnd.andEX("u.userAttribute", "in", pageForm.getUserAttributes()); cnd.andEX("u.userAttribute", "in", pageForm.getUserAttributes());
cnd.andEX("u.aidFundMemberUserType", "in", pageForm.getAidFundMemberUserTypes());
cnd.and("un.unitLevel", "=", 2); cnd.and("un.unitLevel", "=", 2);
cnd.groupBy("un.id", "un.unitcode", "un.name"); cnd.groupBy("un.id", "un.unitcode", "un.name");
cnd.asc("un.unitcode"); cnd.asc("un.unitcode");
@@ -55,4 +55,10 @@ public class WelfareListPageForm extends PageForm {
@ApiModelProperty("在职状态") @ApiModelProperty("在职状态")
private String[] userStates; private String[] userStates;
@ApiModelProperty("人员分类")
private String aidFundMemberUserType;
@ApiModelProperty("人员属性")
private String userAttribute;
} }
@@ -31,4 +31,10 @@ public class WelfareSelectionSituationPageForm extends PageForm {
@ApiModelProperty("是否已选择") @ApiModelProperty("是否已选择")
private Boolean isSelect; private Boolean isSelect;
@ApiModelProperty("人员分类")
private String aidFundMemberUserType;
@ApiModelProperty("人员属性")
private String userAttribute;
} }
@@ -417,6 +417,8 @@ public class WelfareListServiceImpl extends BaseServiceImpl<WelfareList> impleme
cnd.andEX("t1.personType", "in", pageForm.getPersonTypes()); cnd.andEX("t1.personType", "in", pageForm.getPersonTypes());
cnd.andEX("t1.preparedBy", "in", pageForm.getPreparedBys()); cnd.andEX("t1.preparedBy", "in", pageForm.getPreparedBys());
cnd.andEX("t1.userState", "in", pageForm.getUserStates()); cnd.andEX("t1.userState", "in", pageForm.getUserStates());
cnd.andEX("t2.aidFundMemberUserType", "=", pageForm.getAidFundMemberUserType());
cnd.andEX("t2.userAttribute", "=", pageForm.getUserAttribute());
if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) { if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
cnd.asc("t1.welfareUnionName"); cnd.asc("t1.welfareUnionName");
cnd.asc("t1.welfareUnitName"); cnd.asc("t1.welfareUnitName");
@@ -83,6 +83,8 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
cnd.and("t1.projectId", "=", pageForm.getProjectId()); cnd.and("t1.projectId", "=", pageForm.getProjectId());
cnd.andEX("t2.selectOptionId", "=", pageForm.getWelfareOptionId()); cnd.andEX("t2.selectOptionId", "=", pageForm.getWelfareOptionId());
cnd.andEX("t4.aidFundMemberUserType", "=", pageForm.getAidFundMemberUserType());
cnd.andEX("t4.userAttribute", "=", pageForm.getUserAttribute());
if (StrUtil.isNotBlank(pageForm.getUserName())) { if (StrUtil.isNotBlank(pageForm.getUserName())) {
cnd.where().andLike("t4.username", pageForm.getUserName()); cnd.where().andLike("t4.username", pageForm.getUserName());
@@ -1,6 +1,45 @@
<!--# <!--#
layout("/layouts/platform.html"){ layout("/layouts/platform.html"){
#--> #-->
<style>
.query-row {
display: flex;
align-items: flex-start;
margin-bottom: 12px;
}
.query-row-title {
width: 120px;
min-width: 120px;
line-height: 32px;
}
.query-row-content {
flex: 1;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
}
.query-row-content-tag {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
gap: 8px;
}
.query-tag-item {
margin-right: 0;
cursor: pointer;
}
.query-tag-actions {
display: inline-flex;
align-items: center;
gap: 10px;
line-height: 32px;
}
</style>
<div id="app" v-cloak> <div id="app" v-cloak>
<guava ref="guava"> <guava ref="guava">
<template> <template>
@@ -40,6 +79,56 @@ layout("/layouts/platform.html"){
</search-item> </search-item>
</search> </search>
</el-card> </el-card>
<el-card shadow="never">
<el-row type="flex" align="middle" class="query-row query-row-tag">
<el-col class="query-row-title">人员分类:</el-col>
<el-col class="query-row-content query-row-content-tag">
<el-tag
class="query-tag-item"
v-for="item in aidFundMemberUserTypeOptions"
:key="item.code"
:effect="pageForm.aidFundMemberUserTypes.includes(item.code)?'dark':'plain'"
@click="tagClick('aidFundMemberUserTypes',item.code)">
{{ item.name }}
</el-tag>
<span class="query-tag-actions">
<el-link type="danger"
v-if="aidFundMemberUserTypeOptions.length&&pageForm.aidFundMemberUserTypes.length"
:underline="false"
@click="pageForm.aidFundMemberUserTypes=[];doSearch()">清空
</el-link>
<el-link :underline="false"
@click="pageForm.aidFundMemberUserTypes=aidFundMemberUserTypeOptions.map(p=>p.code);doSearch()"
type="success">全部
</el-link>
</span>
</el-col>
</el-row>
<el-row type="flex" align="middle" class="query-row query-row-tag">
<el-col class="query-row-title">人员属性:</el-col>
<el-col class="query-row-content query-row-content-tag">
<el-tag class="query-tag-item"
v-for="item in userAttributeOptions"
:key="item.code"
:effect="pageForm.userAttributes.includes(item.code)?'dark':'plain'"
@click="tagClick('userAttributes',item.code)">
{{ item.name }}
</el-tag>
<span class="query-tag-actions">
<el-link type="danger"
v-if="userAttributeOptions.length&&pageForm.userAttributes.length"
:underline="false"
@click="pageForm.userAttributes=[];doSearch()">清空
</el-link>
<el-link :underline="false"
@click="pageForm.userAttributes=userAttributeOptions.map(p=>p.code);doSearch()"
type="success">全部
</el-link>
</span>
</el-col>
</el-row>
</el-card>
<el-card shadow="never" class="mt10"> <el-card shadow="never" class="mt10">
<table-tool label="会员分析"></table-tool> <table-tool label="会员分析"></table-tool>
@@ -122,9 +211,13 @@ layout("/layouts/platform.html"){
}, },
unions: [], unions: [],
units: [], units: [],
aidFundMemberUserTypeOptions: [],
userAttributeOptions: [],
pageForm: { pageForm: {
currentYear: moment().format("YYYY"), currentYear: moment().format("YYYY"),
queryType: "fgh" queryType: "fgh",
userAttributes: [],
aidFundMemberUserTypes: []
}, },
fullTableData: [] fullTableData: []
}, },
@@ -146,15 +239,42 @@ layout("/layouts/platform.html"){
this.units = data this.units = data
}) })
} }
this.$businessTool.getDictOptions("AIDFUND_MEMBER_USER_TYPE").then((data) => {
this.aidFundMemberUserTypeOptions = data
})
this.$businessTool.getDictOptions("USER_ATTRIBUTE").then((data) => {
this.userAttributeOptions = data
})
}, },
pageData() { pageData() {
this.$axios.post(loc() + "/pageData", this.pageForm).then((res) => { // 统计接口按 JSON 字符串接收多选条件,这里统一在提交前做转换,保证人员分类和人员属性都能正确过滤。
const pageForm = clone(this.pageForm)
pageForm.aidFundMemberUserTypes = JSON.stringify(this.pageForm.aidFundMemberUserTypes)
pageForm.userAttributes = JSON.stringify(this.pageForm.userAttributes)
this.$axios.post(loc() + "/pageData", pageForm).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.tableData = res.data this.tableData = res.data
this.pageForm.totalCount = res.data.totalCount this.pageForm.totalCount = res.data.totalCount
} }
}) })
} },
tagClick(key,code) {
if (key === "userAttributes") {
if (this.pageForm.userAttributes.includes(code)) {
this.pageForm.userAttributes.splice(this.pageForm.userAttributes.indexOf(code), 1)
} else {
this.pageForm.userAttributes.push(code)
}
}
if (key === "aidFundMemberUserTypes") {
if (this.pageForm.aidFundMemberUserTypes.includes(code)) {
this.pageForm.aidFundMemberUserTypes.splice(this.pageForm.aidFundMemberUserTypes.indexOf(code), 1)
} else {
this.pageForm.aidFundMemberUserTypes.push(code)
}
}
this.doSearch()
},
}, },
created() { created() {
this.initData() this.initData()
@@ -3,24 +3,40 @@ layout("/layouts/platform.html"){
#--> #-->
<style> .query-row { <style> .query-row {
display: flex; display: flex;
align-items: center; align-items: flex-start;
margin-bottom: 10px; margin-bottom: 12px;
} }
.query-row-title { .query-row-title {
width: 120px; width: 120px;
min-width: 120px; min-width: 120px;
line-height: 32px;
} }
.query-row-content { .query-row-content {
flex: 1; flex: 1;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: flex-start;
} }
.query-row-content-tag { .query-row-content-tag {
flex: 1; display: flex;
flex-wrap: wrap;
align-items: flex-start;
gap: 8px;
}
.query-tag-item {
margin-right: 0;
cursor: pointer;
}
.query-tag-actions {
display: inline-flex;
align-items: center;
gap: 10px;
line-height: 32px;
} }
</style> </style>
<div id="app" v-cloak> <div id="app" v-cloak>
@@ -65,27 +81,51 @@ layout("/layouts/platform.html"){
</el-card> </el-card>
<el-card shadow="never" class="mt10"> <el-card shadow="never" class="mt10">
<el-row type="flex" align="middle" class="query-row query-row-tag">
<el-col class="query-row-title">人员分类:</el-col>
<el-col class="query-row-content query-row-content-tag">
<el-tag
class="query-tag-item"
v-for="item in aidFundMemberUserTypeOptions"
:key="item.code"
:effect="pageForm.aidFundMemberUserTypes.includes(item.code)?'dark':'plain'"
@click="tagClick('aidFundMemberUserTypes',item.code)">
{{ item.name }}
</el-tag>
<span class="query-tag-actions">
<el-link type="danger"
v-if="aidFundMemberUserTypeOptions.length&&pageForm.aidFundMemberUserTypes.length"
:underline="false"
@click="pageForm.aidFundMemberUserTypes=[];doSearch()">清空
</el-link>
<el-link :underline="false"
@click="pageForm.aidFundMemberUserTypes=aidFundMemberUserTypeOptions.map(p=>p.code);doSearch()"
type="success">全部
</el-link>
</span>
</el-col>
</el-row>
<el-row type="flex" align="middle" class="query-row query-row-tag"> <el-row type="flex" align="middle" class="query-row query-row-tag">
<el-col class="query-row-title">人员属性:</el-col> <el-col class="query-row-title">人员属性:</el-col>
<el-col class="query-row-content query-row-content-tag"> <el-col class="query-row-content query-row-content-tag">
<el-tag style="margin-right: 10px;cursor: pointer" <el-tag class="query-tag-item"
v-for="item in userAttributeOptions" v-for="item in userAttributeOptions"
:key="item.code" :key="item.code"
:type="item.name"
:effect="pageForm.userAttributes.includes(item.code)?'dark':'plain'" :effect="pageForm.userAttributes.includes(item.code)?'dark':'plain'"
@click="tagClick(item.code)"> @click="tagClick('userAttributes',item.code)">
{{ item.name }} {{ item.name }}
</el-tag> </el-tag>
<span class="query-tag-actions">
<el-link type="danger" <el-link type="danger"
v-if="userAttributeOptions.length&&pageForm.userAttributes.length" v-if="userAttributeOptions.length&&pageForm.userAttributes.length"
:underline="false" :underline="false"
@click="pageForm.userAttributes=[];doSearch()">清空 @click="pageForm.userAttributes=[];doSearch()">清空
</el-link> </el-link>
<el-link :underline="false" <el-link :underline="false"
@click="pageForm.userAttributes=userAttributeOptions.map(p=>p.code);doSearch()" @click="pageForm.userAttributes=userAttributeOptions.map(p=>p.code);doSearch()"
type="success">全部 type="success">全部
</el-link> </el-link>
</span>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
@@ -137,8 +177,10 @@ layout("/layouts/platform.html"){
pageForm: { pageForm: {
currentYear: moment().format("YYYY"), currentYear: moment().format("YYYY"),
queryType: "fgh", queryType: "fgh",
userAttributes: [] userAttributes: [],
} aidFundMemberUserTypes: []
},
aidFundMemberUserTypeOptions: [],
}, },
methods: { methods: {
doExport() {}, doExport() {},
@@ -158,20 +200,34 @@ layout("/layouts/platform.html"){
this.units = data this.units = data
}) })
} }
this.$businessTool.getDictOptions("USER_ATTRIBUTE").then((data) => { this.$businessTool.getDictOptions("AIDFUND_MEMBER_USER_TYPE").then((data) => {
this.userAttributeOptions = data this.aidFundMemberUserTypeOptions = data
}) })
this.$businessTool.getDictOptions("USER_ATTRIBUTE").then((data) => {
this.userAttributeOptions = data
})
}, },
tagClick(code) { tagClick(key,code) {
if (this.pageForm.userAttributes.includes(code)) { if (key === "userAttributes") {
this.pageForm.userAttributes.splice(this.pageForm.userAttributes.indexOf(code), 1) if (this.pageForm.userAttributes.includes(code)) {
} else { this.pageForm.userAttributes.splice(this.pageForm.userAttributes.indexOf(code), 1)
this.pageForm.userAttributes.push(code) } else {
} this.pageForm.userAttributes.push(code)
}
}
if (key === "aidFundMemberUserTypes") {
if (this.pageForm.aidFundMemberUserTypes.includes(code)) {
this.pageForm.aidFundMemberUserTypes.splice(this.pageForm.aidFundMemberUserTypes.indexOf(code), 1)
} else {
this.pageForm.aidFundMemberUserTypes.push(code)
}
}
this.doSearch() this.doSearch()
}, },
pageData() { pageData() {
const pageForm = clone(this.pageForm) const pageForm = clone(this.pageForm)
// 统计接口按 JSON 字符串接收多选条件,这里把人员分类和人员属性统一成同一提交口径。
pageForm.aidFundMemberUserTypes = JSON.stringify(this.pageForm.aidFundMemberUserTypes)
pageForm.userAttributes = JSON.stringify(this.pageForm.userAttributes) pageForm.userAttributes = JSON.stringify(this.pageForm.userAttributes)
this.$axios.post(loc() + "/pageData", pageForm).then((res) => { this.$axios.post(loc() + "/pageData", pageForm).then((res) => {
if (res.code === 0) { if (res.code === 0) {
@@ -61,6 +61,14 @@ 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="人员分类">
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select v-model="pageForm.userAttribute" placeholder="请选择人员属性" @change="doSearch"
code="USER_ATTRIBUTE"></dict-select>
</search-item>
</search> </search>
</el-card> </el-card>
@@ -109,6 +109,14 @@ layout("/layouts/platform.html"){
v-model="pageForm.userStates" v-model="pageForm.userStates"
></dict-select> ></dict-select>
</search-item> </search-item>
<search-item label="人员分类">
<dict-select v-model="pageForm.aidFundMemberUserType" placeholder="请选择人员分类" @change="doSearch"
code="AIDFUND_MEMBER_USER_TYPE"></dict-select>
</search-item>
<search-item label="人员属性">
<dict-select v-model="pageForm.userAttribute" placeholder="请选择人员属性" @change="doSearch"
code="USER_ATTRIBUTE"></dict-select>
</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">-->