爱心帮扶系统-疗休养管理-活动报名:新增面向对象字段(人员选择器);如果选择了人员范围,报名时仅范围内人员可以报名;

This commit is contained in:
dd3s_206
2026-06-17 11:33:20 +08:00
parent 3f1a9d9b4c
commit f0c0027f0c
11 changed files with 240 additions and 23 deletions
@@ -9,6 +9,7 @@ import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
@@ -76,8 +77,15 @@ public class LxyCommon {
@At
@ViReturn
public Object getHdList() {
return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` ORDER BY hdcjsj desc "));
public Object getHdList(Integer year) {
Sql sql = Sqls.create("SELECT id,`name` FROM `lxy_hd` $condition");
Cnd cnd = Cnd.NEW();
if (year != null) {
cnd.and(new org.nutz.dao.util.cri.Static("YEAR(hdcjsj) = " + year));
}
cnd.desc("hdcjsj");
sql.setCondition(cnd);
return lxyHdService.list(sql);
}
@At
@@ -88,8 +96,16 @@ public class LxyCommon {
@At
@ViReturn
public Object getNowHdList() {
return lxyHdService.list(Sqls.create("SELECT id,`name` FROM `lxy_hd` WHERE now() < bmjzsj ORDER BY hdcjsj desc "));
public Object getNowHdList(Integer year) {
Sql sql = Sqls.create("SELECT id,`name` FROM `lxy_hd` $condition");
Cnd cnd = Cnd.NEW();
cnd.and(new org.nutz.dao.util.cri.Static("now() < bmjzsj"));
if (year != null) {
cnd.and(new org.nutz.dao.util.cri.Static("YEAR(hdcjsj) = " + year));
}
cnd.desc("hdcjsj");
sql.setCondition(cnd);
return lxyHdService.list(sql);
}
}
@@ -101,6 +101,7 @@ public class LxyFghShController {
cnd.and(new Static("bm.bmzt = 1 "));
cnd.and(new Static("bm.bmlx = 2 "));
cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))"));
if (Strings.isNotBlank(hdid)) {
cnd.and("bm.hdid", "=", hdid);
@@ -16,6 +16,7 @@ import io.v.nutz.sys.services.SysUserService;
import io.v.nutz.web.commons.utils.ShiroUtil;
import io.v.nutz.zhgh.lxy.model.Lxy_bm;
import io.v.nutz.zhgh.lxy.model.Lxy_grxx;
import io.v.nutz.zhgh.lxy.model.Lxy_hd;
import io.v.nutz.zhgh.lxy.model.Lxy_mefp;
import io.v.nutz.zhgh.lxy.service.LxyBmService;
import io.v.nutz.zhgh.lxy.service.LxyGrxxService;
@@ -182,6 +183,7 @@ public class LxyGhbmController {
Cnd cnd = Cnd.NEW();
cnd.and("member", "=", 1);
cnd.and("unit.unionid", "=", unionid);
addActivityScopeCnd(cnd, "u", hdid);
cnd.and(new Static("u.id NOT IN ( SELECT bm.userid FROM lxy_bm bm WHERE bm.hdid = '" + hdid + "' OR hdid = '1' ) "));
if (checks != null && checks.length > 0) {
for (String check : checks) {
@@ -241,6 +243,9 @@ public class LxyGhbmController {
return Result.error("未获取到报名数据,请选择人员报名");
}
if (!checkActivityUserScope(bmList.get(0).getHdid(), bmList.stream().map(Lxy_bm::getUserid).collect(Collectors.toList()))) {
return Result.error("存在不在活动人员范围内的人员,请重新选择");
}
String unionId = Vi.getUnionId();
Lxy_mefp meNum = dao.fetch(Lxy_mefp.class, Cnd.where("hdid", "=", bmList.get(0).getHdid()).and("ghid", "=", unionId));
@@ -416,6 +421,7 @@ public class LxyGhbmController {
List<String> sourUserIdList = sourceList.stream().map(Lxy_bm::getUserid).collect(Collectors.toList());
String today = cn.hutool.core.date.DateUtil.today();
Integer activityGroupId = getActivityGroupId(projectId);
// 要插入的数据
List<Lxy_bm> bmList = new ArrayList<>();
@@ -440,6 +446,12 @@ public class LxyGhbmController {
continue;
}
if (activityGroupId != null && dao.count("activity_user_scope", Cnd.where("groupId", "=", activityGroupId).and("userId", "=", user.getId())) == 0) {
temp.setRemark("此人员不在活动人员范围内");
errorInfos.add(temp);
continue;
}
if (lastJoinUserIds.contains(user.getId())) {
temp.setRemark("此教师参加过以往疗休养,请更换人员上报");
errorInfos.add(temp);
@@ -506,4 +518,28 @@ public class LxyGhbmController {
}
}
private void addActivityScopeCnd(Cnd cnd, String userAlias, String hdid) {
Integer activityGroupId = getActivityGroupId(hdid);
if (activityGroupId != null) {
cnd.and(new Static(userAlias + ".id IN (SELECT userId FROM activity_user_scope WHERE groupId = " + activityGroupId + ")"));
}
}
private boolean checkActivityUserScope(String hdid, List<String> userIds) {
Integer activityGroupId = getActivityGroupId(hdid);
if (activityGroupId == null) {
return true;
}
List<String> ids = userIds.stream().filter(Strings::isNotBlank).distinct().collect(Collectors.toList());
if (ids.size() != userIds.size()) {
return false;
}
return dao.count("activity_user_scope", Cnd.where("groupId", "=", activityGroupId).and("userId", "in", ids)) == ids.size();
}
private Integer getActivityGroupId(String hdid) {
Lxy_hd hd = lxyHdService.fetch(hdid);
return hd == null ? null : hd.getActivityGroupId();
}
}
@@ -107,6 +107,7 @@ public class LxyGrBmController {
cnd.and(new Static("now() < hd.bmjzsj"));
cnd.and(new Static("bm.bmlx = 2 "));
cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))"));
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin"})) {
cnd.and("u.id", "=", ShiroUtil.getPrincipalProperty("id"));
@@ -74,8 +74,12 @@ public class LxyHdCon {
CndPlus cnd = CndPlus.create();
cnd.andEx("YEAR(hdcjsj)", "=", year);
cnd.andEx("id", "=", hdcd);
cnd.andEx("id", "=", pastQuota);
if (Strings.isNotBlank(hdcd)) {
cnd.and("id", "=", hdcd);
}
if (Strings.isNotBlank(pastQuota)) {
cnd.and("id", "=", pastQuota);
}
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
cnd.where().andLike(searchName, searchKeyword);
}
@@ -94,9 +98,13 @@ public class LxyHdCon {
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object doAdd(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, Lxy_mefp[] mefp) throws IOException {
public Object doAdd(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, Lxy_mefp[] mefp,
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
@Param(value = "activityGroupName", required = false) String activityGroupName) throws IOException {
hd.setHdcjsj(new Date());
hd.setActivityGroupId(activityGroupId);
hd.setActivityGroupName(Strings.isBlank(activityGroupName) ? "全部教职工" : activityGroupName);
hd = lxyHdService.insert(hd);
for (Lxy_mefp lxyMefp : mefp) {
@@ -136,8 +144,16 @@ public class LxyHdCon {
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
@ViReturn
@RequiresPermissions("zgfw.lxy.hdmange")
public Object doEdit(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, String[] delFiles) throws IOException {
public Object doEdit(Lxy_hd hd, @Param(value = "files",required = false) TempFile[] files, String[] delFiles,
@Param(value = "activityGroupId", required = false) Integer activityGroupId,
@Param(value = "activityGroupName", required = false) String activityGroupName) throws IOException {
hd.setActivityGroupId(activityGroupId);
hd.setActivityGroupName(Strings.isBlank(activityGroupName) ? "全部教职工" : activityGroupName);
lxyHdService.updateIgnoreNull(hd);
baseService.dao().update(Lxy_hd.class,
Chain.make("activityGroupId", activityGroupId)
.add("activityGroupName", hd.getActivityGroupName()),
Cnd.where("id", "=", hd.getId()));
for (TempFile file : files) {
String rid = R.UU32();
@@ -80,6 +80,7 @@ public class LxyMetjController {
if (!ShiroUtil.hasAnyRoles(new String[]{"sysadmin", "SchoolUnionAdmin"})) {
cnd.and(new Static("mefp.ghid in " + vi.getMangeUnionStr()));
cnd.and(new Static("(hd.activityGroupId IS NULL OR EXISTS (SELECT 1 FROM activity_user_scope aus LEFT JOIN sys_user u ON u.id = aus.userId WHERE aus.groupId = hd.activityGroupId AND u.unionid = mefp.ghid))"));
}
if (year != null) {
@@ -141,6 +142,7 @@ public class LxyMetjController {
"FROM\n" +
"\tsys_user u\n" +
"\tLEFT JOIN lxy_bm bm ON bm.userid = u.id AND bm.hdid = '" + hdid + "'\n" +
"\tLEFT JOIN lxy_hd hd ON hd.id = '" + hdid + "'\n" +
"\tLEFT JOIN sys_unit unit ON u.unitid = unit.id\n" +
"\tLEFT JOIN ry_rygl_gr ry ON ry.userid = u.id\n" +
"\tLEFT JOIN sys_union un ON unit.unionid = un.id $condition");
@@ -148,6 +150,7 @@ public class LxyMetjController {
Cnd cnd = Cnd.NEW();
cnd.and("unit.unionid", "=", unionid);
cnd.and(new Static("(hd.activityGroupId IS NULL OR u.id IN (SELECT userId FROM activity_user_scope WHERE groupId = hd.activityGroupId))"));
if (sign == 0) {
cnd.and(new Static("u.id not in (SELECT bm.userid from lxy_bm bm WHERE bm.bmlx=2 AND bm.hdid = '" + hdid + "')"));
@@ -54,6 +54,16 @@ public class Lxy_hd {
@ColDefine(type = ColType.VARCHAR, width = 30)
private String hdcd;
@Column
@Comment("面向对象")
@ColDefine(type = ColType.INT)
private Integer activityGroupId;
@Column
@Comment("面向对象名称")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String activityGroupName;
@Column
@Comment("活动注意事项")
@ColDefine(type = ColType.TEXT)
@@ -305,8 +305,8 @@ const getGzzllx = async () => {
* 获取疗休养活动
* @returns {Promise<*>}
*/
const getLxyHd = async () => {
const { data } = await $.get("/platform/zgfw/lxy/common/getHdList")
const getLxyHd = async (year) => {
const { data } = await $.get("/platform/zgfw/lxy/common/getHdList", { year })
return data
}
const getlxyHdCd = async () => {
@@ -314,8 +314,8 @@ const getlxyHdCd = async () => {
return data
}
const getNowLxyHd = async () => {
const { data } = await $.get("/platform/zgfw/lxy/common/getNowHdList")
const getNowLxyHd = async (year) => {
const { data } = await $.get("/platform/zgfw/lxy/common/getNowHdList", { year })
return data
}
@@ -48,7 +48,13 @@ layout("/layouts/platform.html"){
<guava ref="guava">
<el-card shadow="never">
<div class="btn-group tool-button mt5">
<el-date-picker placeholder="选择年度" type="year" v-model="pageForm.year" value-format="yyyy"></el-date-picker>
<el-date-picker
@change="hdSearch"
placeholder="选择年度"
type="year"
v-model="pageForm.year"
value-format="yyyy"
></el-date-picker>
</div>
<div class="btn-group tool-button mt5">
<el-select @change="doSearch" clearable filterable placeholder="请选择活动" v-model="pageForm.hdid">
@@ -750,6 +756,11 @@ display: -webkit-box;
const { data } = await $.get(base + "/platform/zgfw/lxy/fghsh/getBmInfo", { id })
return data
},
async hdSearch() {
this.lxyHd = await getNowLxyHd(this.pageForm.year)
this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : ""
this.doSearch()
},
async openViewXx(row) {
this.viewData = await this.getLxyBmInfo(row.id)
this.pageForm.hdid = row.hdid
@@ -831,8 +842,8 @@ display: -webkit-box;
},
async created() {
this.unions = await getUnions()
this.lxyHd = await getNowLxyHd()
this.pageForm.hdid = this.lxyHd[0].id
this.lxyHd = await getNowLxyHd(this.pageForm.year)
this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : ""
this.pageData()
this.unionList = await getUnions()
this.nationList = nation
@@ -43,12 +43,26 @@ layout("/layouts/platform.html"){
<div class="transition-item" v-show="v=='index'">
<el-card shadow="never">
<div class="btn-group tool-button mt5">
<el-date-picker placeholder="选择年度" type="year" v-model="pageForm.year" value-format="yyyy"></el-date-picker>
<el-date-picker
@change="hdSearch"
placeholder="选择年度"
type="year"
v-model="pageForm.year"
value-format="yyyy"
></el-date-picker>
</div>
<div class="btn-group tool-button mt5">
<!--<div class="btn-group tool-button mt5">
<el-select class="d-select" clearable filterable placeholder="请选择活动" v-model="pageForm.pastQuota" width="300px">
<el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in lxyHd"></el-option>
</el-select>
</div>-->
<div class="btn-group tool-button mt5">
<el-input
clearable
placeholder="请输入活动名称"
v-model="pageForm.searchKeyword"
@keyup.enter.native="doSearch"
></el-input>
</div>
<!--<div class="btn-group tool-button mt5">
<el-select class="d-select" clearable filterable placeholder="请选择场地"
@@ -182,6 +196,31 @@ layout("/layouts/platform.html"){
<el-input maxlength="100" placeholder="请填写活动场地" type="text" v-model="formData.hdcd"></el-input>
</el-form-item>
<el-form-item label="面向对象" prop="activityGroupId">
<div style="display: flex; justify-content: space-between">
<div style="width: 99%">
<el-select
@change="changeActivity"
clearable
filterable
placeholder="请选择可报名人员范围"
style="width: 99%"
v-model="formData.activityGroupId"
>
<el-option
:key="item.groupId"
:label="item.groupName"
:value="item.groupId"
v-for="item in activityGroupList"
></el-option>
</el-select>
</div>
<div>
<el-button @click="$refs.drawerUserScope.userScopeDialog = true" type="primary">设置</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="报名条件" prop="hdzysx">
<el-input
maxlength="500"
@@ -316,6 +355,31 @@ layout("/layouts/platform.html"){
<el-input maxlength="100" placeholder="请填写活动场地" type="text" v-model="formData.hdcd"></el-input>
</el-form-item>
<el-form-item label="面向对象" prop="activityGroupId">
<div style="display: flex; justify-content: space-between">
<div style="width: 99%">
<el-select
@change="changeActivity"
clearable
filterable
placeholder="请选择可报名人员范围"
style="width: 99%"
v-model="formData.activityGroupId"
>
<el-option
:key="item.groupId"
:label="item.groupName"
:value="item.groupId"
v-for="item in activityGroupList"
></el-option>
</el-select>
</div>
<div>
<el-button @click="$refs.drawerUserScope.userScopeDialog = true" type="primary">设置</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="报名条件" prop="hdzysx">
<el-input
maxlength="500"
@@ -400,6 +464,12 @@ layout("/layouts/platform.html"){
</transition>
</el-row>
</guava>
<drawer-user-scope
@group_change="getActivityGroup"
ref="drawerUserScope"
:group_id.sync="formData.activityGroupId"
></drawer-user-scope>
</div>
<script>
let E = window.wangEditor
@@ -408,6 +478,9 @@ layout("/layouts/platform.html"){
const vue = new Vue({
el: "#app",
components: {
"drawer-user-scope": httpVueLoader("/components/plugins/DrawerUserScope.vue")
},
data() {
let validHdnr = (rule, value, callback) => {
if (!this.formData.hdnr || !dd3s.html2txt(this.formData.hdnr)) {
@@ -432,16 +505,18 @@ layout("/layouts/platform.html"){
tabLoading: false,
userLoading: false,
formData: {},
activityGroupList: [],
tableData: [],
pageForm: {
year: new Date().getFullYear() + "",
searchName: "id",
searchName: "name",
searchKeyword: "",
pageNumber: 1,
pageSize: 10,
totalCount: 0,
pageOrderName: "",
pageOrderBy: ""
pageOrderBy: "",
pastQuota: ""
},
formRules: {
name: [{ required: true, message: "请填写活动名称", trigger: ["blur", "change"] }],
@@ -456,7 +531,26 @@ layout("/layouts/platform.html"){
delFiles: []
}
},
watch: {
"formData.activityGroupId"(val) {
this.changeActivity(val)
}
},
methods: {
changeActivity(val) {
if (val) {
const group = this.activityGroupList.find((v) => v.groupId === val)
this.$set(this.formData, "activityGroupName", group ? group.groupName : "")
} else {
this.$set(this.formData, "activityGroupName", "全部教职工")
}
},
async getActivityGroup() {
this.activityGroupList = await getActivityGroup()
if (this.formData.activityGroupId) {
this.changeActivity(this.formData.activityGroupId)
}
},
mefpChange() {
if (this.pastQuota === "") {
this.unions_ = this.unions.map((v) => {
@@ -564,6 +658,9 @@ layout("/layouts/platform.html"){
doEdit() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (!this.formData.activityGroupId) {
this.formData.activityGroupName = "全部教职工"
}
this.formData.bmkssj = this.formData.bmsj[0]
this.formData.bmjzsj = this.formData.bmsj[1]
@@ -646,6 +743,12 @@ layout("/layouts/platform.html"){
if (data.code == 0) {
data.data.hdsj = [data.data.hdkssj, data.data.hdjssj]
data.data.bmsj = [data.data.bmkssj, data.data.bmjzsj]
const activityGroupId =
data.data.activityGroupId === undefined ? data.data.activitygroupid : data.data.activityGroupId
if (activityGroupId !== undefined && activityGroupId !== null && activityGroupId !== "") {
data.data.activityGroupId = Number(activityGroupId)
}
data.data.activityGroupName = data.data.activityGroupName || data.data.activitygroupname || "全部教职工"
data.data.mefp.map((m) => {
const union = this.unions.find((un) => un.id === m.ghid)
m.membercount = union.membercount
@@ -718,6 +821,9 @@ layout("/layouts/platform.html"){
doAdd() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (!this.formData.activityGroupId) {
this.formData.activityGroupName = "全部教职工"
}
this.formData.bmkssj = this.formData.bmsj[0]
this.formData.bmjzsj = this.formData.bmsj[1]
@@ -813,6 +919,11 @@ layout("/layouts/platform.html"){
this.pageForm.pageNumber = 1
this.pageData()
},
async hdSearch() {
this.pageForm.pastQuota = ""
this.lxyHd = await getLxyHd(this.pageForm.year)
this.doSearch()
},
pageOrder(column) {
//按字段排序
this.pageForm.pageOrderName = column.prop
@@ -856,7 +967,8 @@ layout("/layouts/platform.html"){
async created() {
const unions_resp = await $.get(loc() + "/getUnions")
this.unions = unions_resp.data
this.lxyHd = await getLxyHd()
await this.getActivityGroup()
this.lxyHd = await getLxyHd(this.pageForm.year)
this.lxyHdCd = await getlxyHdCd()
this.pageData()
}
@@ -10,7 +10,13 @@ layout("/layouts/platform.html"){
<guava ref="guava">
<el-card shadow="never">
<div class="btn-group tool-button mt5">
<el-date-picker placeholder="选择年度" type="year" v-model="pageForm.year" value-format="yyyy"></el-date-picker>
<el-date-picker
@change="hdSearch"
placeholder="选择年度"
type="year"
v-model="pageForm.year"
value-format="yyyy"
></el-date-picker>
</div>
<div class="btn-group tool-button mt5">
<el-select @change="pageData" clearable filterable placeholder="请选择活动" v-model="pageForm.hdid">
@@ -547,6 +553,11 @@ layout("/layouts/platform.html"){
this.pageForm.pageNumber = 1
this.pageData()
},
async hdSearch() {
this.lxyHd = await getLxyHd(this.pageForm.year)
this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : ""
this.doSearch()
},
doSearchGh() {
this.tabKey = new Date().getTime()
this.pageForm.pageNumber = 1
@@ -593,8 +604,8 @@ layout("/layouts/platform.html"){
},
async created() {
this.unions = await getUnions()
this.lxyHd = await getLxyHd()
this.pageForm.hdid = this.lxyHd[0].id
this.lxyHd = await getLxyHd(this.pageForm.year)
this.pageForm.hdid = this.lxyHd.length > 0 ? this.lxyHd[0].id : ""
this.pageData()
}
})