commit
This commit is contained in:
@@ -1,22 +1,17 @@
|
||||
package com.budwk.app.client.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.client.auth.service.ClientAuthService;
|
||||
import com.budwk.app.client.auth.vo.ClientLoginBody;
|
||||
import com.budwk.app.sys.models.Client_user;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import com.budwk.app.web.commons.auth.service.ValidateService;
|
||||
import com.budwk.app.web.commons.slog.SLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.budwk.app.sys.models;
|
||||
package com.budwk.app.client.auth.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
@@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.budwk.app.client.auth.service;
|
||||
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.client.auth.vo.ClientLoginBody;
|
||||
import com.budwk.app.sys.models.Client_user;
|
||||
import com.budwk.app.client.auth.models.Client_user;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import com.budwk.app.web.commons.auth.service.ValidateService;
|
||||
import org.nutz.dao.Cnd;
|
||||
|
||||
+2
@@ -1,12 +1,14 @@
|
||||
package com.budwk.app.client.module.activity.vo;
|
||||
|
||||
import com.budwk.app.module.activity.models.ActUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报名
|
||||
*/
|
||||
@Data
|
||||
public class ClientActivitySignVO {
|
||||
|
||||
private String activityId;
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.module.activity.service.ActUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:ActGroupController
|
||||
* @Date 2025/4/25 16:03
|
||||
* @注释 活动签到人员分组
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/activity/group")
|
||||
public class ActGroupController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private ActUserService actUserService;
|
||||
|
||||
@At("")
|
||||
@SaCheckPermission("activity.group")
|
||||
@Ok("beetl:/platform/activity/group/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.group")
|
||||
public Result pageData(PageForm pageForm, String activityId){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+135
-8
@@ -1,23 +1,43 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.client.auth.models.Client_user;
|
||||
import com.budwk.app.client.module.activity.vo.ClientActivitySignVO;
|
||||
import com.budwk.app.module.activity.models.ActUser;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.service.ActUserService;
|
||||
import com.budwk.app.module.activity.vo.page.ActUserPageForm;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:ActUserController
|
||||
* @Date 2025/4/24 18:31
|
||||
* @注释
|
||||
* @注释 活动报名人员
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@@ -39,28 +59,135 @@ public class ActUserController {
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result pageData(){
|
||||
return null;
|
||||
public Result pageData(ActUserPageForm pageForm){
|
||||
Sql sql = actUserService.getSignUpSql(pageForm);
|
||||
Pagination pagination = actUserService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock(true);
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result signUpActivity(){
|
||||
@SLog(tag = "报名人员管理", msg = "电脑端替他人报名")
|
||||
public Result doAddActUser(ClientActivitySignVO vo){
|
||||
try {
|
||||
lock.lock();
|
||||
// new Act
|
||||
// 报名时间
|
||||
LocalDateTime localDateTime = DateUtil.date().toLocalDateTime();
|
||||
// 活动id
|
||||
Long activityId = Long.parseLong(vo.getActivityId());
|
||||
|
||||
List<ActUser> userList = vo.getUserList();
|
||||
|
||||
// 在系统的人,要区分是否已经报了名,报名了的就修改记录,没报名的添加记录
|
||||
List<ActUser> doSignUserList = userList.stream().filter(user -> user.getUserId() != null).toList();
|
||||
Set<Long> userIdSet = doSignUserList.stream().map(ActUser::getUserId).collect(Collectors.toSet());
|
||||
List<ActUser> signUpUser = dao.query(ActUser.class, Cnd.where("userId", "in", userIdSet).and(ActUser::getActivityId, "=", activityId));
|
||||
|
||||
if (Lang.isNotEmpty(signUpUser)) {
|
||||
Map<Long, ActUser> map = signUpUser.stream().collect(Collectors.toMap(ActUser::getUserId, user -> user));
|
||||
for (ActUser user : doSignUserList) {
|
||||
ActUser actUser = map.get(user.getUserId());
|
||||
if (actUser != null) {
|
||||
user.setId(actUser.getId());
|
||||
}
|
||||
user.setUserId(user.getUserId());
|
||||
user.setSignUpTime(localDateTime);
|
||||
user.setSignUpContacts(vo.getContactName());
|
||||
user.setSignUpMobile(vo.getContactPhone());
|
||||
user.setActivityId(activityId);
|
||||
user.setUnitName(vo.getUnitName());
|
||||
}
|
||||
dao.insertOrUpdate(doSignUserList);
|
||||
} else {
|
||||
for (ActUser user : doSignUserList) {
|
||||
user.setUserId(user.getUserId());
|
||||
user.setSignUpTime(localDateTime);
|
||||
user.setSignUpContacts(vo.getContactName());
|
||||
user.setSignUpMobile(vo.getContactPhone());
|
||||
user.setActivityId(activityId);
|
||||
user.setUnitName(vo.getUnitName());
|
||||
}
|
||||
dao.insertOrUpdate(doSignUserList);
|
||||
}
|
||||
|
||||
// 找出不在系统的人,添加到client_user表中,再添加报名记录
|
||||
List<ActUser> needInitClientUserList = userList.stream().filter(user -> user.getUserId() == null).toList();
|
||||
for (ActUser user : needInitClientUserList) {
|
||||
Client_user clientUser = new Client_user();
|
||||
clientUser.setUserName(user.getUserName());
|
||||
clientUser.setSex(user.getSex());
|
||||
clientUser.setPhone(user.getPhone());
|
||||
dao.insert(clientUser);
|
||||
|
||||
user.setUserId(clientUser.getId());
|
||||
user.setSignUpTime(localDateTime);
|
||||
user.setSignUpContacts(vo.getContactName());
|
||||
user.setSignUpMobile(vo.getContactPhone());
|
||||
user.setActivityId(activityId);
|
||||
user.setUnitName(vo.getUnitName());
|
||||
}
|
||||
dao.insert(needInitClientUserList);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
lock.unlock();
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
@SLog(tag = "报名人员管理", msg = "删除报名人员")
|
||||
public Result doDeleteActUser(String id){
|
||||
dao.delete(ActUser.class, id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
@SLog(tag = "报名人员管理", msg = "修改报名人员信息")
|
||||
public Result doModifyActUser(ActUser actUser){
|
||||
dao.updateIgnoreNull(actUser);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result findSignUserInfo(String userId){
|
||||
return Result.success(dao.fetch(ActUser.class, Cnd.where(ActUser::getUserId, "=", userId)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前年度的所有活动信息
|
||||
*/
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result getActivityList(String year){
|
||||
List<Activity> activityList = dao.query(Activity.class, Cnd.where("YEAR(startTime)", "=", year).and(Activity::getDelFlag, "=", false));
|
||||
return Result.success(activityList);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission("activity.user")
|
||||
public Result queryUser(String query, String activityId){
|
||||
Sql sql = Sqls.create("SELECT id,username,phone FROM client_user $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("username", query);
|
||||
seg.orLike("phone", query);
|
||||
cnd.and(seg);
|
||||
// cnd.and(new Static(" id not in (select userId from act_user where activityId = '%s' AND userId IS NOT NULL)".formatted(activityId)));
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = actUserService.listPageMap(1, 10, sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-2
@@ -1,12 +1,15 @@
|
||||
package com.budwk.app.module.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.module.activity.models.ActUser;
|
||||
import com.budwk.app.module.activity.service.ActUserService;
|
||||
import com.budwk.app.module.activity.vo.page.ActUserPageForm;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
@@ -32,8 +35,27 @@ public class ActUserServiceImpl extends BaseServiceImpl<ActUser> implements ActU
|
||||
@Override
|
||||
public Sql getSignUpSql(ActUserPageForm pageForm) {
|
||||
Sql sql = Sqls.create("""
|
||||
|
||||
SELECT
|
||||
u.*,
|
||||
act.`title` AS activityName
|
||||
FROM
|
||||
act_user u
|
||||
LEFT JOIN activity act ON act.id = u.activityId
|
||||
$condition
|
||||
""");
|
||||
return null;
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("u.activityId", "=", pageForm.getActivityId());
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.orLike("u.userName", pageForm.getSearchKeyword());
|
||||
seg.orLike("u.phone", pageForm.getSearchKeyword());
|
||||
cnd.and(seg);
|
||||
}
|
||||
// cnd.andEX("u.phone", "like", "%" + pageForm.getPhone() + "%");
|
||||
if (StrUtil.isNotBlank(pageForm.getUnitName())) {
|
||||
cnd.and("u.unitName", "like", "%" + pageForm.getUnitName() + "%");
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,4 +227,4 @@ public class SLogService implements Runnable {
|
||||
sysLog.setLoginname(SecurityUtil.getUserLoginname());
|
||||
return sysLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,399 @@
|
||||
<!--#
|
||||
layout("/layouts/platform_1.html"){
|
||||
#-->
|
||||
<div id="app">
|
||||
<el-card shadow="never">
|
||||
<div class="search">
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">年度</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
:clearable="false"
|
||||
placeholder="选择年"
|
||||
style="width: 100%"
|
||||
type="year"
|
||||
@change="getActivityList"
|
||||
v-model="pageForm.year"
|
||||
value-format="yyyy"
|
||||
></el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">所属活动</div>
|
||||
<div class="search-item-option">
|
||||
<el-select @change="doSearch"
|
||||
placeholder="请选择活动查询"
|
||||
style="width: 100%;"
|
||||
v-model="pageForm.activityId">
|
||||
<el-option :label="item.title" :value="item.id"
|
||||
v-for="item in activityList"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-item">
|
||||
<div class="search-item-label">姓名/电话</div>
|
||||
<div class="search-item-option">
|
||||
<el-input v-model="pageForm.searchKeyword" placeholder="请输入姓名"
|
||||
clearable @keyup.enter.native="doSearch"></el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-query">
|
||||
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt-3">
|
||||
<el-row type="flex" class="mb-3">
|
||||
<el-button icon="el-icon-plus" type="primary" size="small" @click="openAddUser">添加报名人员</el-button>
|
||||
</el-row>
|
||||
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData">
|
||||
<el-table-column label="序号" type="index" header-align="center" align="center"
|
||||
width="50"></el-table-column>
|
||||
<el-table-column label="姓名" prop="userName"></el-table-column>
|
||||
<el-table-column label="性别" prop="sex"></el-table-column>
|
||||
<el-table-column label="联系方式" prop="phone"></el-table-column>
|
||||
<el-table-column label="身份证件号" prop="idCard"></el-table-column>
|
||||
<el-table-column label="职务" prop="position"></el-table-column>
|
||||
<el-table-column label="所属单位" prop="unitName"></el-table-column>
|
||||
<el-table-column label="报名时间" prop="signUpTime"></el-table-column>
|
||||
<el-table-column label="操作" fixed="right" width="250">
|
||||
<template #default="scope">
|
||||
<el-button type="text" @click="openModify">修改</el-button>
|
||||
<el-button type="text" class="text-danger" @click="onTableRowDelete(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
|
||||
<el-dialog title="添加报名人员" :visible.sync="addDialog" width="60%">
|
||||
<el-form :model="formData" :rules="formRules" ref="formRef" label-width="100px">
|
||||
<el-form-item label="活动名称" prop="activityName">
|
||||
<el-input v-model="formData.activityName" readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="参加单位" prop="unitName">
|
||||
<el-input v-model="formData.unitName" placeholder="请输入参加单位"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人" prop="contactName">
|
||||
<el-input v-model="formData.contactName" placeholder="请输入联系人"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式" prop="contactPhone">
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入联系方式" maxlength="11" type="text" show-word-limit></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="报名人员" prop="userList">
|
||||
<el-table :data="formData.userList" border size="small" width="100%">
|
||||
<el-table-column label="姓名" prop="userName" fixed width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-autocomplete style="width: 100%"
|
||||
v-model="row.userName"
|
||||
:fetch-suggestions="queryUserAsync"
|
||||
placeholder="请输入内容"
|
||||
@select="handleSelect($event, row)"
|
||||
></el-autocomplete>
|
||||
<!-- <el-input v-model="row.userName" maxlength="50"-->
|
||||
<!-- placeholder="请输入姓名"></el-input>-->
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="性别" prop="name" width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-radio-group v-model="row.sex">
|
||||
<el-radio label="男"></el-radio>
|
||||
<el-radio label="女"></el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系方式" prop="phone" width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-input v-model="row.phone" maxlength="11" type="text"
|
||||
show-word-limit placeholder="请输入联系方式"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="身份证件号" prop="idCard" width="250">
|
||||
<template slot-scope="{row}">
|
||||
<el-input v-model="row.idCard" maxlength="18" type="text"
|
||||
show-word-limit placeholder="请输入身份证件号"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="职务" prop="position" width="200">
|
||||
<template slot-scope="{row}">
|
||||
<el-input v-model="row.position" maxlength="100"
|
||||
placeholder="请输入职务"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!--<el-table-column label="所属单位" prop="unitName" width="250">
|
||||
<template slot-scope="{row}">
|
||||
<el-input v-model="row.unitName" maxlength="100" placeholder="请输所属单位"></el-input>
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column width="100px" fixed="right">
|
||||
<template slot="header" slot-scope="scope">
|
||||
<el-button type="primary" size="mini"
|
||||
@click="formData.userList.push({})">添加
|
||||
</el-button>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="formData.userList.length===0"
|
||||
@click="formData.userList.splice(scope.$index,1)"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="addDialog = false">取 消</el-button>
|
||||
<el-button type="primary" @click="onAddUserSubmit">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="修改报名信息" :visible.sync="modifyDialog" width="40%">
|
||||
<el-form :model="modifyForm" :rules="modifyRules" ref="modifyFormRef" label-width="100px">
|
||||
<el-form-item label="姓名" prop="userName">
|
||||
<el-input v-model="modifyForm.userName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="性别" prop="sex">
|
||||
<el-radio-group v-model="modifyForm.sex">
|
||||
<el-radio label="男"></el-radio>
|
||||
<el-radio label="女"></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式" prop="phone">
|
||||
<el-input v-model="modifyForm.phone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="身份证件号" prop="idCard">
|
||||
<el-input v-model="modifyForm.idCard"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="职务" prop="position">
|
||||
<el-input v-model="modifyForm.position"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属单位" prop="unitName">
|
||||
<el-input v-model="modifyForm.unitName"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="modifyDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="onModifySubmit">提交</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vue = new Vue({
|
||||
el: "#app",
|
||||
mixins: [initTableMixins],
|
||||
data() {
|
||||
return {
|
||||
pageForm: {
|
||||
year: new Date().getFullYear() + '',
|
||||
},
|
||||
activityList: [],
|
||||
// 修改表单
|
||||
modifyDialog: false,
|
||||
modifyForm: {},
|
||||
modifyRules: {
|
||||
userName: [{required: true, message: '请输入姓名', trigger: ['blur', 'change']}],
|
||||
sex: [{required: true, message: '请选择性别', trigger: ['blur', 'change']}],
|
||||
phone: [{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (!value) {
|
||||
// 如果值为空,直接通过校验
|
||||
callback();
|
||||
} else if (/^[1][345789][0-9]{9}$/.test(value)) {
|
||||
// 手机号格式正确
|
||||
callback();
|
||||
} else if (/^\d+-\d+$/.test(value) && value.length <= 16) {
|
||||
// 座机号格式正确
|
||||
callback();
|
||||
} else {
|
||||
// 格式错误,返回错误信息
|
||||
callback(new Error(value.includes('-') ? '座机号码格式错误' : '手机号码格式错误'));
|
||||
}
|
||||
},
|
||||
trigger: ["change", "blur"]
|
||||
}],
|
||||
idCard: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (!value) {
|
||||
// 如果值为空,直接通过校验
|
||||
callback();
|
||||
} else if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}(\d|[Xx])$/.test(value)) {
|
||||
// 18位身份证号码格式正确
|
||||
callback();
|
||||
} else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) {
|
||||
// 15位身份证号码格式正确
|
||||
callback();
|
||||
} else if (/^[1-9]\d{5}(18|19|20)?\d{2}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) {
|
||||
// 外国人身份证号码格式正确(18位)
|
||||
callback();
|
||||
} else if (/^[1-9]\d{7}((0[1-9])|(10|11|12))(([0|1|2][0-9])|10|20|30|31)\d{3}$/.test(value)) {
|
||||
// 外国人身份证号码格式正确(15位)
|
||||
callback();
|
||||
} else {
|
||||
// 格式错误,返回错误信息
|
||||
callback(new Error("身份证号码格式错误"));
|
||||
}
|
||||
},
|
||||
trigger: ["change", "blur"]
|
||||
}
|
||||
],
|
||||
position: [{required: true, message: '请输入职务', trigger: ['blur', 'change']}],
|
||||
unitName: [{required: true, message: '请输入所属单位', trigger: ['blur', 'change']}],
|
||||
},
|
||||
|
||||
// 添加报名人员相关
|
||||
addDialog: false,
|
||||
formData: {
|
||||
activityId: '',
|
||||
userList: []
|
||||
},
|
||||
formRules: {
|
||||
activityId: [{required: true, message: '请选择活动', trigger: ['blur', 'change']}],
|
||||
unitName: [{required: true, message: '请填写参加单位', trigger: ['blur', 'change']}],
|
||||
contactName: [{required: true, message: '请填写联系人', trigger: ['blur', 'change']}],
|
||||
contactPhone: [{required: true, message: '请填写联系电话', trigger: ['blur', 'change']}],
|
||||
userList: [{required: true, message: '请添加报名人员', trigger: ['blur', 'change']}]
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openAddUser(){
|
||||
if (!this.pageForm.activityId) {
|
||||
this.$message.warning('请先选择活动')
|
||||
return
|
||||
}
|
||||
this.formData.userList = []
|
||||
this.addDialog = true
|
||||
this.formData.activityId = this.pageForm.activityId
|
||||
this.formData.activityName = this.activityList.find(item => item.id === this.formData.activityId).title
|
||||
},
|
||||
async queryUserAsync(query, cb){
|
||||
const resp = await $.post('/platform/activity/user/queryUser', {
|
||||
query,
|
||||
activityId: this.formData.activityId
|
||||
})
|
||||
if (resp.code === 0) {
|
||||
if (resp.data.list && resp.data.list.length > 0) {
|
||||
cb(resp.data.list.map(v => {
|
||||
return {value: v.username + '(' + (v.phone ? v.phone : '未填写联系方式') + ')', ...v}
|
||||
}))
|
||||
} else {
|
||||
cb([])
|
||||
}
|
||||
} else {
|
||||
cb([])
|
||||
}
|
||||
},
|
||||
handleSelect(item, row){
|
||||
this.$set(row, 'userId', item.id)
|
||||
this.$set(row, 'userName', item.username)
|
||||
this.$set(row, 'sex', item.sex)
|
||||
this.$set(row, 'phone', item.phone ? item.phone : '')
|
||||
},
|
||||
async onAddUserSubmit(){
|
||||
const userList = this.formData.userList;
|
||||
if (!userList || userList === []) {
|
||||
this.$message.warning("请添加报名人员")
|
||||
return
|
||||
}
|
||||
|
||||
let errorMessages = [];
|
||||
const requiredFields = [
|
||||
{ key: 'userName', message: '姓名不能为空' },
|
||||
{ key: 'sex', message: '性别不能为空' },
|
||||
{ key: 'phone', message: '联系方式不能为空' },
|
||||
{ key: 'idCard', message: '身份证件号不能为空' },
|
||||
{ key: 'position', message: '职务不能为空' }
|
||||
];
|
||||
|
||||
userList.forEach((user, index) => {
|
||||
requiredFields.forEach(field => {
|
||||
if (user[field.key] == null || user[field.key] === "") {
|
||||
errorMessages.push('第' + (index + 1) + '行:' + field.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (errorMessages.length > 0) {
|
||||
// 将错误信息转换为 HTML 格式,使用 <br> 实现换行
|
||||
const errorSummary = errorMessages.join("<br>");
|
||||
this.$message.warning({
|
||||
message: errorSummary,
|
||||
dangerouslyUseHTMLString: true
|
||||
});
|
||||
return
|
||||
}
|
||||
const formData = JSON.parse(JSON.stringify(this.formData));
|
||||
formData.userList = JSON.stringify(this.formData.userList)
|
||||
const resp = await $.post('/platform/activity/user/doAddActUser', formData)
|
||||
if (resp.code === 0) {
|
||||
this.$message.success(resp.msg)
|
||||
this.addDialog = false
|
||||
this.formData = {
|
||||
activityId: '',
|
||||
userList: []
|
||||
}
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.warning('操作失败')
|
||||
console.log(resp.msg)
|
||||
}
|
||||
},
|
||||
async openModify(row) {
|
||||
const resp = await $.post('/platform/activity/user/findSignUserInfo', {id: row.id})
|
||||
if (resp.code === 0) {
|
||||
this.modifyForm = resp.data
|
||||
this.modifyDialog = true
|
||||
} else {
|
||||
this.$message.warning('查询异常')
|
||||
console.log(resp.msg)
|
||||
}
|
||||
},
|
||||
onModifySubmit() {
|
||||
this.$refs.modifyFormRef.validate(async valid => {
|
||||
if (valid) {
|
||||
const resp = await $.post('/platform/activity/user/doModifyActUser', this.modifyForm)
|
||||
if (resp.code === 0) {
|
||||
this.$message.success(resp.msg)
|
||||
this.modifyDialog = false
|
||||
this.$refs.modifyFormRef.resetFields()
|
||||
this.doSearch()
|
||||
} else {
|
||||
this.$message.warning('操作失败')
|
||||
console.log(resp.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async getActivityList(){
|
||||
const resp = await $.post('/platform/activity/user/getActivityList', {
|
||||
year: this.pageForm.year
|
||||
})
|
||||
if (resp.code === 0 && resp.data && resp.data.length > 0) {
|
||||
this.activityList = resp.data
|
||||
this.$set(this.pageForm, 'activityId', this.activityList[0].id)
|
||||
} else {
|
||||
this.$set(this.pageForm, 'activityId', '')
|
||||
console.log(resp.msg)
|
||||
}
|
||||
this.pageData()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getActivityList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
Reference in New Issue
Block a user