fix: 优化活动人数限制
This commit is contained in:
+64
-8
@@ -86,6 +86,7 @@ public class TrainSignUpApplyController {
|
||||
@Param(value = "id") String id,
|
||||
@Param(value = "dataType") String dataType) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("isDisabled", "=", false);
|
||||
cnd.andEX("id", "=", id);
|
||||
cnd.andEX("`year`", "=", year);
|
||||
//查询报名中
|
||||
@@ -150,6 +151,7 @@ public class TrainSignUpApplyController {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("type.id", "=", courseTypeId);
|
||||
cnd.and("tsuc.activityId", "=", activityId);
|
||||
cnd.and(new Static("tsuc.activityId in (select id from train_sign_up_activity where isDisabled = 0)"));
|
||||
|
||||
if (Lang.isNotEmpty(assortTypes)) {
|
||||
cnd.and("tsuc.assort", "in", assortTypes);
|
||||
@@ -174,6 +176,7 @@ public class TrainSignUpApplyController {
|
||||
List<TrainSignUpActivityCourse> courseTimes = dao.query(TrainSignUpActivityCourse.class, Cnd.where("courseId", "=", c.getString("id")).asc("courseDate"));
|
||||
c.put("courseTimes", courseTimes);
|
||||
|
||||
c.put("quotaScope", "活动");
|
||||
c.put("hasRegisterNum", statisticsService.queryCourseCount(c.getString("id"), c.getString("courseType")));
|
||||
c.put("hasWaitingNum", statisticsService.queryCourseWaitCount(c.getString("id"), c.getString("courseType")));
|
||||
//当前用户是否报过
|
||||
@@ -184,7 +187,10 @@ public class TrainSignUpApplyController {
|
||||
if (Lang.isNotEmpty(unionLimit)) {
|
||||
NutMap nutMap = unionLimit.stream().filter(o -> o.getString("id").equals(SecurityUtil.getUnionId())).findFirst().orElse(null);
|
||||
if (nutMap != null) {
|
||||
c.put("quotaScope", "本工会");
|
||||
c.put("coursePeopleNumber", nutMap.getInt("limitCount"));
|
||||
c.put("hasRegisterNum", statisticsService.queryCourseCount(c.getString("id"), c.getString("courseType"), SecurityUtil.getUnionId()));
|
||||
c.put("courseReservedNumber", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +231,11 @@ public class TrainSignUpApplyController {
|
||||
|
||||
currentFamilyNumber = currentFamilyNumber != null ? currentFamilyNumber : 0;
|
||||
TrainSignUpCourse course = dao.fetch(TrainSignUpCourse.class, courseId);
|
||||
if (course == null) return Result.error("子活动不存在");
|
||||
TrainSignUpActivity activity = dao.fetch(TrainSignUpActivity.class, course.getActivityId());
|
||||
if (activity == null || activity.isDisabled()) {
|
||||
return Result.error("活动已关闭或不存在,无法报名");
|
||||
}
|
||||
|
||||
//判断时间
|
||||
if (DateUtil.compare(new Date(), activity.getActivitySignUpStartTime(), "yyyy-MM-dd HH:mm:ss") < 0) {
|
||||
@@ -282,6 +292,23 @@ public class TrainSignUpApplyController {
|
||||
@ApiOperation("查询子活动时间段")
|
||||
@SaCheckPermission(value = {"trainSignUp.apply", "h5.trainSignUp.apply"}, mode = SaMode.OR)
|
||||
public Result getCourseTimeSelectList(String courseId) {
|
||||
TrainSignUpCourse course = dao.fetch(TrainSignUpCourse.class, courseId);
|
||||
if (course == null) return Result.error("子活动不存在");
|
||||
int normalRemaining = Integer.MAX_VALUE;
|
||||
if (course.getCoursePeopleNumber() > 0) {
|
||||
normalRemaining = Math.max(0, course.getCoursePeopleNumber() - course.getCourseReservedNumber()
|
||||
- statisticsService.queryCourseCount(courseId, course.getCourseType()));
|
||||
}
|
||||
if (Lang.isNotEmpty(course.getUnionLimit())) {
|
||||
String unionId = SecurityUtil.getUnionId();
|
||||
NutMap union = course.getUnionLimit().stream().filter(v -> v.getString("id").equals(unionId)).findFirst().orElse(null);
|
||||
int unionRemaining = union == null || StrUtil.isBlank(unionId) ? 0 : Math.max(0, union.getInt("limitCount")
|
||||
- statisticsService.queryCourseCount(courseId, course.getCourseType(), unionId));
|
||||
normalRemaining = Math.min(normalRemaining, unionRemaining);
|
||||
}
|
||||
final int availableNormal = normalRemaining;
|
||||
boolean signFull = trainSignUpActivityService.isSignFull(course, 0)
|
||||
|| trainSignUpActivityService.isSignFullByUnionId(course, 0);
|
||||
// 查课程的时间段
|
||||
List<TrainSignUpActivityCourse> courseList = dao.query(TrainSignUpActivityCourse.class, Cnd.where("courseId", "=", courseId).asc("courseStartTime"));
|
||||
|
||||
@@ -299,14 +326,20 @@ public class TrainSignUpApplyController {
|
||||
String id = v.getId();
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
List<TrainSignUpUserCourse> trainSignUpUserCourses = collectMap.get(id);
|
||||
int remainingNum = v.getCourseLimitNum() != null ? v.getCourseLimitNum() : 0;
|
||||
if (Lang.isNotEmpty(trainSignUpUserCourses)) {
|
||||
remainingNum = v.getCourseLimitNum() - trainSignUpUserCourses.size();
|
||||
}
|
||||
int timeRemaining = Math.max(0, (v.getCourseLimitNum() == null ? 0 : v.getCourseLimitNum())
|
||||
- (trainSignUpUserCourses == null ? 0 : trainSignUpUserCourses.size()));
|
||||
int remainingNum = Math.min(timeRemaining, availableNormal);
|
||||
boolean expired = v.getCourseEndTime() == null || !v.getCourseEndTime().after(new Date());
|
||||
boolean disabled = expired || signFull || timeRemaining == 0;
|
||||
nutMap.put("remainingNum", remainingNum);
|
||||
nutMap.put("text", DateUtil.format(v.getCourseStartTime(), "MM月dd日 HH:mm") + "至" + DateUtil.format(v.getCourseEndTime(), "HH:mm") + "段(剩" + remainingNum + ")");
|
||||
nutMap.put("limitNum", v.getCourseLimitNum() == null ? 0 : v.getCourseLimitNum());
|
||||
String timeText = DateUtil.format(v.getCourseStartTime(), "MM月dd日 HH:mm") + " - " + DateUtil.format(v.getCourseEndTime(), "HH:mm");
|
||||
nutMap.put("timeText", timeText);
|
||||
nutMap.put("text", timeText + " (余" + remainingNum + ")");
|
||||
nutMap.put("expired", expired);
|
||||
nutMap.put("endTime", v.getCourseEndTime() == null ? 0 : v.getCourseEndTime().getTime());
|
||||
nutMap.put("value", id);
|
||||
nutMap.put("disabled", remainingNum == 0);
|
||||
nutMap.put("disabled", disabled);
|
||||
return nutMap;
|
||||
}).toList();
|
||||
return Result.success(list);
|
||||
@@ -319,15 +352,27 @@ public class TrainSignUpApplyController {
|
||||
try {
|
||||
lock.lock();
|
||||
|
||||
if (StrUtil.isBlank(activityCourseId) || StrUtil.isBlank(courseId)) {
|
||||
return Result.error("请选择报名时间段");
|
||||
}
|
||||
TrainSignUpActivityCourse course = dao.fetch(TrainSignUpActivityCourse.class, activityCourseId);
|
||||
if (course == null || !courseId.equals(course.getCourseId())) {
|
||||
return Result.error("报名时间段无效,请重新选择");
|
||||
}
|
||||
if (course.getCourseEndTime() == null || !course.getCourseEndTime().after(new Date())) {
|
||||
return Result.error("该时间段已结束,无法报名,请重新选择");
|
||||
}
|
||||
List<TrainSignUpUser> userList = dao.query(TrainSignUpUser.class, Cnd.where("courseId", "=", courseId).and("state", "=", 1));
|
||||
List<String> isList = userList.stream().map(TrainSignUpUser::getUserId).toList();
|
||||
|
||||
// 该时间段下已报名的人数
|
||||
int count = dao.count(TrainSignUpUserCourse.class, Cnd.where("activityCourseId", "=", activityCourseId)
|
||||
int count = isList.isEmpty() ? 0 : dao.count(TrainSignUpUserCourse.class, Cnd.where("activityCourseId", "=", activityCourseId)
|
||||
.and("courseId", "=", courseId).and("userId", "in", isList));
|
||||
// 获取该时间段下的活动课程限制报名人数
|
||||
TrainSignUpActivityCourse course = dao.fetch(TrainSignUpActivityCourse.class, activityCourseId);
|
||||
Integer courseLimitNum = course.getCourseLimitNum();
|
||||
if (courseLimitNum == null || courseLimitNum < 1) {
|
||||
return Result.error("该时间段名额设置无效,暂不能报名");
|
||||
}
|
||||
// 报名加上自己,如果大于了限制人数,那就无法报名
|
||||
if (count + 1 > courseLimitNum) {
|
||||
return Result.error("该时间段名额已报满,请选择其他时段报名");
|
||||
@@ -356,6 +401,11 @@ public class TrainSignUpApplyController {
|
||||
//判断人数
|
||||
int number = 0;
|
||||
TrainSignUpCourse course = trainSignUpActivityService.dao().fetch(TrainSignUpCourse.class, trainSignUpUser.getCourseId());
|
||||
if (course == null) return Result.error("子活动不存在");
|
||||
TrainSignUpActivity activity = dao.fetch(TrainSignUpActivity.class, course.getActivityId());
|
||||
if (activity == null || activity.isDisabled()) {
|
||||
return Result.error("活动已关闭或不存在,无法报名");
|
||||
}
|
||||
TrainSignUpType type = trainSignUpActivityService.dao().fetch(TrainSignUpType.class, course.getCourseType());
|
||||
if (type != null) {
|
||||
if (type.getIsBringFamily() && type.getIsAddFamily()) {
|
||||
@@ -372,6 +422,12 @@ public class TrainSignUpApplyController {
|
||||
if (signFullByUnionId) {
|
||||
return Result.error("该活动您所在的分工会名额不足");
|
||||
}
|
||||
if (Boolean.TRUE.equals(course.getCourseIsLimitApply())) {
|
||||
Result timeResult = validateSourceSignUp(trainSignUpUser.getActivityCourseId(), course.getId());
|
||||
if (!timeResult.isSuccess()) {
|
||||
return timeResult;
|
||||
}
|
||||
}
|
||||
trainSignUpActivityService.doSignUp(trainSignUpUser);
|
||||
return Result.success("报名成功");
|
||||
} catch (Exception e) {
|
||||
|
||||
+20
@@ -154,6 +154,26 @@ public class TrainSignUpManageController {
|
||||
@SaCheckPermission("trainSignUp.manage")
|
||||
@SLog(tag = "品牌活动-活动管理", msg = "新增/修改活动")
|
||||
public Result doHandle(TrainSignUpActivity activity) {
|
||||
if (activity.getCourseList() != null) {
|
||||
for (int i = 0; i < activity.getCourseList().size(); i++) {
|
||||
TrainSignUpCourse course = activity.getCourseList().get(i);
|
||||
int peopleNumber = course.getCoursePeopleNumber();
|
||||
if (peopleNumber <= 0) continue;
|
||||
if (Boolean.TRUE.equals(course.getCourseIsLimitApply()) && course.getCourseTimeList() != null) {
|
||||
long timeTotal = course.getCourseTimeList().stream()
|
||||
.mapToLong(v -> v.getCourseLimitNum() == null ? 0 : v.getCourseLimitNum()).sum();
|
||||
if (timeTotal > peopleNumber) {
|
||||
return Result.error("第" + (i + 1) + "行各时间段限制人数合计为" + timeTotal + "人,不能超过子活动人数" + peopleNumber + "人");
|
||||
}
|
||||
}
|
||||
if (course.getUnionLimit() != null) {
|
||||
long unionTotal = course.getUnionLimit().stream().mapToLong(v -> v.getInt("limitCount", 0)).sum();
|
||||
if (unionTotal > peopleNumber) {
|
||||
return Result.error("第" + (i + 1) + "行分工会限制总人数为" + unionTotal + "人,不能超过子活动人数" + peopleNumber + "人");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(activity.getId())) {
|
||||
trainSignUpActivityManageService.add(activity, null);
|
||||
} else {
|
||||
|
||||
@@ -382,10 +382,8 @@ module.exports = {
|
||||
|
||||
handleRemove(file, fileList) {
|
||||
if (this.upload_result_category === "interval") {
|
||||
if (this.upload_result_type === "id") {
|
||||
}
|
||||
if (this.upload_result_type === "url") {
|
||||
}
|
||||
this.$emit("update:value", fileList.map((e) => e.response.data).join(","))
|
||||
return
|
||||
}
|
||||
|
||||
if (this.upload_result_category === "array") {
|
||||
|
||||
@@ -46,9 +46,11 @@ const applyForm = {
|
||||
:rules="{ required: true, message: '请选择报名时段', trigger: 'blur'}">
|
||||
<el-select style="width: 100%" v-model="formData.activityCourseId" placeholder="请选择报名时段">
|
||||
<el-option v-for="item in courseTimeSelectList"
|
||||
:label="item.text.substring(0, 12)"
|
||||
:label="item.text" :disabled="item.disabled"
|
||||
:value="item.value"
|
||||
:key="item.value"></el-option>
|
||||
:key="item.value">
|
||||
<span>{{item.timeText}} (<span style="color: #c33714">余{{item.remainingNum}}</span>)</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -123,12 +125,13 @@ const applyForm = {
|
||||
async getCourseTimeSelectList(o) {
|
||||
const resp = await $.post('/platform/trainSignUp/apply/getCourseTimeSelectList',{ courseId: o.id })
|
||||
if (resp.code === 0) {
|
||||
this.courseTimeSelectList = resp.data
|
||||
this.courseTimeSelectList = resp.data.filter(item => !item.expired && item.endTime > Date.now())
|
||||
} else {
|
||||
this.$message.warning('获取时段信息失败,请联系管理员')
|
||||
}
|
||||
},
|
||||
async onOpen(row, course) {
|
||||
this.$set(this.formData, "activityCourseId", undefined)
|
||||
this.initData(row, course)
|
||||
if (row.courseIsLimitApply) {
|
||||
await this.getCourseTimeSelectList(row)
|
||||
@@ -192,8 +195,8 @@ const applyForm = {
|
||||
initData(row, course) {
|
||||
this.$set(this.formData, 'username', this.$store.state.user.username)
|
||||
this.$set(this.formData, 'loginname', this.$store.state.user.loginname)
|
||||
this.$set(this.formData, 'unionName', this.$store.state.user.union.name)
|
||||
this.$set(this.formData, 'unitName', this.$store.state.user.unit.name)
|
||||
this.$set(this.formData, 'unionName', this.$store.state.user.union?.name || "")
|
||||
this.$set(this.formData, 'unitName', this.$store.state.user.unit?.name || "")
|
||||
this.$set(this.formData, 'sex', this.$store.state.user.sex)
|
||||
this.$set(this.formData, 'activityId', row.activityId)
|
||||
this.$set(this.formData, 'courseId', row.id)
|
||||
|
||||
@@ -187,6 +187,17 @@ const courseList = {
|
||||
this.queryCourseAssort()
|
||||
},
|
||||
onSign(row) {
|
||||
const user = this.$store.state.user
|
||||
const missingFields = []
|
||||
if (!user?.unit?.name) missingFields.push("所属单位")
|
||||
if (!user?.union?.name) missingFields.push("所属工会")
|
||||
if (missingFields.length > 0) {
|
||||
this.$alert("您的" + missingFields.join("、") + "信息缺失,暂无法报名,请联系管理员完善人员信息", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
const course = this.courseTypeList.find((v) => v.id === row.courseType)
|
||||
this.$axios.post("/platform/trainSignUp/apply/validateSignUp", {courseId: row.id})
|
||||
.then((res) => {
|
||||
@@ -260,17 +271,19 @@ const courseList = {
|
||||
})
|
||||
},
|
||||
calcSignUpCount(o) {
|
||||
if(!o.coursePeopleNumber) {
|
||||
return "名额数不限制"
|
||||
const scope = o.quotaScope || "活动"
|
||||
if(!Number(o.coursePeopleNumber) && scope !== "本工会") {
|
||||
return "已报名" + (Number(o.hasRegisterNum) || 0) + "人"
|
||||
}
|
||||
let lave = o.coursePeopleNumber - (o.hasRegisterNum + o.courseReservedNumber)
|
||||
const remaining = Math.max(0, o.coursePeopleNumber - (o.hasRegisterNum + o.courseReservedNumber))
|
||||
if(o.courseIsLimitApply) {
|
||||
return "<span style='color: red'>余" + remaining + "</span>/" + o.coursePeopleNumber + "人"
|
||||
}
|
||||
let text = "<span style='color: red'>余" + remaining + "</span>/" + o.coursePeopleNumber + "人"
|
||||
if(o.reserveMode === 2) {
|
||||
let lave2 = o.waitingNum - o.hasWaitingNum
|
||||
return "<span style='color: red'>余" + lave +"</span>/" + o.coursePeopleNumber + "人"
|
||||
+ ",<span style='color: red'>候补余" + lave2 + "</span>/" + o.waitingNum + "人"
|
||||
} else {
|
||||
return "<span style='color: red'>余" + lave +"</span>/" + o.coursePeopleNumber + "人"
|
||||
text += ",活动候补余" + Math.max(0, o.waitingNum - o.hasWaitingNum) + "/" + o.waitingNum + "人"
|
||||
}
|
||||
return text
|
||||
},
|
||||
async pageData() {
|
||||
const pageForm = clone({...this.pageForm})
|
||||
|
||||
@@ -106,6 +106,7 @@ layout("/layouts/platform.html"){
|
||||
<!--#include('../manage/info.js'){}#-->
|
||||
new Vue({
|
||||
el: "#app",
|
||||
store,
|
||||
mixins: [initTableMixins],
|
||||
components: {
|
||||
"course-list": courseList,
|
||||
|
||||
@@ -567,6 +567,24 @@ const basicForm = {
|
||||
})
|
||||
},
|
||||
async doHandle(type) {
|
||||
const limitInvalid = this.formData.courseList.some((course, index) => {
|
||||
if (!(course.coursePeopleNumber > 0)) return false
|
||||
const rowLabel = "第" + (index + 1) + "行"
|
||||
if (course.courseIsLimitApply) {
|
||||
const timeTotal = (course.courseTimeList || []).reduce((sum, item) => sum + (Number(item.courseLimitNum) || 0), 0)
|
||||
if (timeTotal > course.coursePeopleNumber) {
|
||||
this.$message.warning(rowLabel + "各时间段限制人数合计为" + timeTotal + "人,不能超过子活动人数" + course.coursePeopleNumber + "人")
|
||||
return true
|
||||
}
|
||||
}
|
||||
const unionTotal = (course.unionLimit || []).reduce((sum, item) => sum + (Number(item.limitCount) || 0), 0)
|
||||
if (unionTotal > course.coursePeopleNumber) {
|
||||
this.$message.warning(rowLabel + "分工会限制总人数为" + unionTotal + "人,不能超过子活动人数" + course.coursePeopleNumber + "人")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
if (limitInvalid) return
|
||||
const cloneData = clone(this.formData)
|
||||
cloneData.activitySignUpStartTime = cloneData.activitySignTime !== undefined ? cloneData.activitySignTime[0] : null
|
||||
cloneData.activitySignUpEndTime = cloneData.activitySignTime !== undefined ? cloneData.activitySignTime[1] : null
|
||||
|
||||
@@ -179,7 +179,15 @@ const courseTime = {
|
||||
},
|
||||
//设置课程时间确定
|
||||
doConfirmSetUpCourse() {
|
||||
const courseTableData = this.formData.courseList[this.courseIndex].courseTimeList
|
||||
const course = this.formData.courseList[this.courseIndex]
|
||||
const courseTableData = course.courseTimeList
|
||||
if (course.coursePeopleNumber > 0 && course.courseIsLimitApply) {
|
||||
const total = courseTableData.reduce((sum, item) => sum + (Number(item.courseLimitNum) || 0), 0)
|
||||
if (total > course.coursePeopleNumber) {
|
||||
this.$message.warning("各时间段限制人数合计为" + total + "人,不能超过子活动人数" + course.coursePeopleNumber + "人")
|
||||
return
|
||||
}
|
||||
}
|
||||
if (courseTableData.length === 0) {
|
||||
this.$message.warning("请填写时间!")
|
||||
return
|
||||
|
||||
@@ -134,7 +134,7 @@ const unionForm = {
|
||||
this.summaryCount = array.reduce((prev, curr) => {
|
||||
const value = Number(curr.limitCount)
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr.limitCount
|
||||
return prev + value
|
||||
} else {
|
||||
return prev
|
||||
}
|
||||
@@ -160,7 +160,7 @@ const unionForm = {
|
||||
this.summaryCount = this.formData.courseList[this.unionLimitIndex].unionLimit.reduce((prev, curr) => {
|
||||
const value = Number(curr.limitCount)
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr.limitCount
|
||||
return prev + value
|
||||
} else {
|
||||
return prev
|
||||
}
|
||||
@@ -184,6 +184,12 @@ const unionForm = {
|
||||
})
|
||||
},
|
||||
doConfirmSetUpUnionLimit() {
|
||||
const course = this.formData.courseList[this.unionLimitIndex]
|
||||
this.calSummaryCount()
|
||||
if (course.coursePeopleNumber > 0 && this.summaryCount > course.coursePeopleNumber) {
|
||||
this.$message.warning("分工会限制总人数为" + this.summaryCount + "人,不能超过子活动人数" + course.coursePeopleNumber + "人")
|
||||
return
|
||||
}
|
||||
this.setUpUnionLimitDialog = false
|
||||
},
|
||||
//应用比例设置
|
||||
|
||||
@@ -6,9 +6,10 @@ const times = {
|
||||
<van-action-sheet v-model="visible" title="时间段" cancel-text="取消">
|
||||
<div id="mapContainer" v-if="row?.isMobileSign === true && row?.signType === 3"
|
||||
style="width: 100%; height: 250px"></div>
|
||||
<button v-for="(item,index) in row?.courseTimes" type="button" class="van-action-sheet__item">
|
||||
<button v-for="(item,index) in row?.courseTimes" type="button" class="van-action-sheet__item" style="position: relative">
|
||||
<span v-if="$moment(item.courseEndTime).isSameOrBefore($moment())" style="position: absolute; top: 8px; right: 12px; width: 44px; height: 44px; box-sizing: border-box; border: 3px double #969799; border-radius: 50%; color: #969799; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; transform: rotate(-15deg); pointer-events: none">已结束</span>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center">
|
||||
<div>
|
||||
<div style="text-align: left">
|
||||
<div class="van-action-sheet__name">
|
||||
<label>{{ weekdayCNMap[$moment(item.courseDate).day()] }}</label>
|
||||
<label>{{ $moment(item.courseDate).format('YYYY-MM-DD') }}</label>
|
||||
@@ -18,6 +19,9 @@ const times = {
|
||||
$moment(item.courseEndTime).format('MM-DD HH:mm')}}
|
||||
</div>
|
||||
</div>
|
||||
<span v-if="row.courseIsLimitApply && timeQuotas[item.activityCourseId || item.id]" style="color: #000; white-space: nowrap; margin-left: auto; margin-right: 12px; align-self: center">
|
||||
<span style="color: #c33714">余{{timeQuotas[item.activityCourseId || item.id].remainingNum}}</span>/{{timeQuotas[item.activityCourseId || item.id].limitNum}}人
|
||||
</span>
|
||||
<div v-if="row.isSign === true && row.isMobileSign === true" class="sign_button">
|
||||
<van-button
|
||||
v-if="item.isAttend !== true
|
||||
@@ -49,6 +53,7 @@ const times = {
|
||||
return {
|
||||
visible: false,
|
||||
row: null,
|
||||
timeQuotas: {},
|
||||
weekdayCNMap: {0: '周日', 1: '周一', 2: '周二', 3: '周三', 4: '周四', 5: '周五', 6: '周六'},
|
||||
|
||||
selectCourseTime: {},
|
||||
@@ -66,7 +71,11 @@ const times = {
|
||||
onSignClose() {
|
||||
this.$refs.scanCodeRef.closeScan()
|
||||
},
|
||||
onOpen(row) {
|
||||
onOpen(row, timeQuotas = []) {
|
||||
this.timeQuotas = timeQuotas.reduce((result, item) => {
|
||||
result[item.value] = item
|
||||
return result
|
||||
}, {})
|
||||
this.row = row
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
|
||||
@@ -32,7 +32,11 @@ const applyForm = {
|
||||
:columns="courseTimeSelectList"
|
||||
@confirm="onCourseConfirm"
|
||||
@cancel="showCoursePicker=false"
|
||||
></van-picker>
|
||||
>
|
||||
<template #option="item">
|
||||
<span>{{item.timeText}} (<span style="color: #c33714">余{{item.remainingNum}}</span>)</span>
|
||||
</template>
|
||||
</van-picker>
|
||||
</van-popup>
|
||||
</template>
|
||||
<train-dynamic-form v-model="dynamicColumnsData" ref="dynamicForm"></train-dynamic-form>
|
||||
@@ -62,6 +66,8 @@ const applyForm = {
|
||||
methods: {
|
||||
async onOpen(row, courseType) {
|
||||
this.row = row
|
||||
this.$set(this.formData, "activityCourseId", undefined)
|
||||
this.$set(this.formData, "courseTimeName", "")
|
||||
this.init(row, courseType)
|
||||
if(row.courseIsLimitApply) {
|
||||
await this.getCourseTimeSelectList(row)
|
||||
@@ -71,8 +77,8 @@ const applyForm = {
|
||||
init(row, courseType) {
|
||||
this.$set(this.formData, 'username', this.$store.state.user.username)
|
||||
this.$set(this.formData, 'loginname', this.$store.state.user.loginname)
|
||||
this.$set(this.formData, 'unionName', this.$store.state.user.union.name)
|
||||
this.$set(this.formData, 'unitName', this.$store.state.user.unit.name)
|
||||
this.$set(this.formData, 'unionName', this.$store.state.user.union?.name || "")
|
||||
this.$set(this.formData, 'unitName', this.$store.state.user.unit?.name || "")
|
||||
this.$set(this.formData, 'sex', this.$store.state.user.sex)
|
||||
this.$set(this.formData, 'activityId', row.activityId)
|
||||
this.$set(this.formData, 'courseId', row.id)
|
||||
@@ -83,15 +89,19 @@ const applyForm = {
|
||||
})
|
||||
},
|
||||
onCourseConfirm(val){
|
||||
if (!val || val.disabled || val.endTime <= Date.now()) {
|
||||
this.$toast("该时段不可报名,请选择其他时段")
|
||||
return
|
||||
}
|
||||
this.formData.activityCourseId = val.value
|
||||
this.$set(this.formData, "activityCourseId", val.value)
|
||||
this.$set(this.formData, "courseTimeName", val.text.substring(0, 12))
|
||||
this.$set(this.formData, "courseTimeName", val.text)
|
||||
this.showCoursePicker = false
|
||||
},
|
||||
async getCourseTimeSelectList(o) {
|
||||
const resp = await this.$axios.post('/platform/trainSignUp/apply/getCourseTimeSelectList',{courseId: o.id})
|
||||
if (resp.code === 0) {
|
||||
this.courseTimeSelectList = resp.data
|
||||
this.courseTimeSelectList = resp.data.filter(item => !item.expired && item.endTime > Date.now())
|
||||
} else {
|
||||
this.$toast.fail("获取时段信息失败,请联系管理员")
|
||||
}
|
||||
|
||||
@@ -148,9 +148,30 @@ layout("/layouts/platform_h5.html"){
|
||||
})
|
||||
row.courseTimes = res.data
|
||||
}
|
||||
this.$refs.timesRef.onOpen(row)
|
||||
let timeQuotas = []
|
||||
if (row.courseIsLimitApply) {
|
||||
const res = await this.$axios.post('/platform/trainSignUp/apply/getCourseTimeSelectList', {courseId: row.id})
|
||||
if (res.code !== 0) {
|
||||
this.$toast(res.msg)
|
||||
return
|
||||
}
|
||||
timeQuotas = res.data
|
||||
}
|
||||
this.$refs.timesRef.onOpen(row, timeQuotas)
|
||||
},
|
||||
onApply(row) {
|
||||
const user = this.$store.state.user
|
||||
const missingFields = []
|
||||
if (!user?.unit?.name) missingFields.push("所属单位")
|
||||
if (!user?.union?.name) missingFields.push("所属工会")
|
||||
if (missingFields.length > 0) {
|
||||
vant.Dialog.alert({
|
||||
title: '提示',
|
||||
message: "您的" + missingFields.join("、") + "信息缺失,暂无法报名,请联系管理员完善人员信息",
|
||||
confirmButtonColor: '#1867b0'
|
||||
})
|
||||
return
|
||||
}
|
||||
const courseType = this.sourceTypeOptions.find((v) => v.id === row.courseType)
|
||||
this.$axios.post('/platform/trainSignUp/apply/validateSignUp', {
|
||||
courseId: row.id
|
||||
@@ -192,17 +213,19 @@ layout("/layouts/platform_h5.html"){
|
||||
}).catch(() => {})
|
||||
},
|
||||
calcSignUpCount(row) {
|
||||
if(!row.coursePeopleNumber || row.coursePeopleNumber === 0) {
|
||||
return "名额数不限制"
|
||||
const scope = row.quotaScope || "活动"
|
||||
if(!Number(row.coursePeopleNumber) && scope !== "本工会") {
|
||||
return "已报名" + (Number(row.hasRegisterNum) || 0) + "人"
|
||||
}
|
||||
let lave = row.coursePeopleNumber - (row.hasRegisterNum + row.courseReservedNumber)
|
||||
const remaining = Math.max(0, row.coursePeopleNumber - (row.hasRegisterNum + row.courseReservedNumber))
|
||||
if(row.courseIsLimitApply) {
|
||||
return "<span style='color: red'>余" + remaining + "</span>/" + row.coursePeopleNumber + "人"
|
||||
}
|
||||
let text = "<span style='color: red'>余" + remaining + "</span>/" + row.coursePeopleNumber + "人"
|
||||
if(row.reserveMode === 2) {
|
||||
let lave2 = row.waitingNum - row.hasWaitingNum
|
||||
return "<span style='color: red'>余" + lave +"</span>/" + row.coursePeopleNumber + "人"
|
||||
+ ",<span style='color: red'>候补余" + lave2 + "</span>/" + row.waitingNum + "人"
|
||||
} else {
|
||||
return "<span style='color: red'>余" + lave +"</span>/" + row.coursePeopleNumber + "人"
|
||||
text += ",活动候补余" + Math.max(0, row.waitingNum - row.hasWaitingNum) + "/" + row.waitingNum + "人"
|
||||
}
|
||||
return text
|
||||
},
|
||||
async onReady() {
|
||||
this.queryCourseAssort()
|
||||
|
||||
Reference in New Issue
Block a user