体育报名外援优化;体育服装管理整改,关联选择活动;比赛名称录入可选工会补全;沿用保存活动bug修复
This commit is contained in:
@@ -649,7 +649,6 @@ module.exports = {
|
||||
applyTime: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
unitSponsor: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
// unitJointly: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
time: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
activityGroupId: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
gameStyle: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
applyWay: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
||||
@@ -777,7 +776,8 @@ module.exports = {
|
||||
},
|
||||
// 合并当前所选项目与已沿用配置;新增选择使用原有默认值,已移除项目不再提交。
|
||||
buildReuseEvents() {
|
||||
return this.events.filter((event) => this.form.eventsIds.includes(event.id)).map((event) => {
|
||||
const selectedIds = this.form.eventsIds || []
|
||||
return this.events.filter((event) => selectedIds.includes(event.id)).map((event) => {
|
||||
const existing = this.checkedEventInfo.find((config) => config.eventId === event.id)
|
||||
const config = existing ? clone(existing) : {
|
||||
eventId: event.id, projectType: event.projectType, leanderNum: 0, coachNum: 0,
|
||||
@@ -792,7 +792,7 @@ module.exports = {
|
||||
return config
|
||||
})
|
||||
},
|
||||
// isSave 区分保存和提交;新接口返回新活动ID,保存成功后转入该新活动的编辑状态。
|
||||
// isSave 区分保存草稿和提交;草稿跳过字段校验,提交仍校验报名、活动及项目配置。
|
||||
doReuseAdd(isSave) {
|
||||
if (this.formLoading || this.reuseLoading) return
|
||||
if (!this.reuseReady) {
|
||||
@@ -801,70 +801,66 @@ module.exports = {
|
||||
}
|
||||
const save = () => {
|
||||
const form = clone(this.form)
|
||||
if (!form.applyTime || form.applyTime.length !== 2 || !form.time || form.time.length !== 2) {
|
||||
this.$message.warning('请重新填写报名日期和活动时间')
|
||||
return
|
||||
}
|
||||
if (moment(form.time[0]).valueOf() <= moment(form.applyTime[0]).valueOf()) {
|
||||
this.$message.error('活动时间必须晚于报名时间')
|
||||
return
|
||||
}
|
||||
if (!form.eventsIds.length) {
|
||||
this.$message.warning('请选择活动项目')
|
||||
return
|
||||
}
|
||||
if (this.getArrDifference(form.unitJointly, form.unitSponsor).length === 0) {
|
||||
this.$message.error('协办单位里存在主办单位')
|
||||
return
|
||||
if (!isSave) {
|
||||
if (!form.applyTime || form.applyTime.length !== 2 || !form.applyTime[0] || !form.applyTime[1]) {
|
||||
this.$message.warning('请填写报名日期')
|
||||
return
|
||||
}
|
||||
if (!form.time || form.time.length !== 2 || !form.time[0] || !form.time[1]) {
|
||||
this.$message.warning('请填写活动时间')
|
||||
return
|
||||
}
|
||||
if (moment(form.time[0]).valueOf() <= moment(form.applyTime[0]).valueOf()) {
|
||||
this.$message.error('活动时间必须晚于报名时间')
|
||||
return
|
||||
}
|
||||
if (!form.eventsIds || !form.eventsIds.length) {
|
||||
this.$message.warning('请选择活动项目')
|
||||
return
|
||||
}
|
||||
if (this.getArrDifference(form.unitJointly || [], form.unitSponsor || []).length === 0) {
|
||||
this.$message.error('协办单位里存在主办单位')
|
||||
return
|
||||
}
|
||||
}
|
||||
this.$set(form, 'id', null)
|
||||
this.$set(form, 'isSave', isSave)
|
||||
this.$set(form, 'applyStartTime', form.applyTime[0])
|
||||
this.$set(form, 'applyEndTime', form.applyTime[1])
|
||||
this.$set(form, 'startTime', form.time[0])
|
||||
this.$set(form, 'endTime', form.time[1])
|
||||
this.$set(form, 'isSave', isSave ? 1 : 0)
|
||||
// 草稿可没有报名和活动时间,缺失时明确传 null,避免复制旧活动日期。
|
||||
this.$set(form, 'applyStartTime', form.applyTime && form.applyTime[0] && form.applyTime[1] ? form.applyTime[0] : null)
|
||||
this.$set(form, 'applyEndTime', form.applyTime && form.applyTime[0] && form.applyTime[1] ? form.applyTime[1] : null)
|
||||
this.$set(form, 'startTime', form.time && form.time[0] && form.time[1] ? form.time[0] : null)
|
||||
this.$set(form, 'endTime', form.time && form.time[0] && form.time[1] ? form.time[1] : null)
|
||||
this.$set(this, 'formLoading', true)
|
||||
const loading = this.$loading({lock: true, text: '正在提交...', background: COVER_LAYER_COLOR})
|
||||
return $.post('/platform/activity/school/info/mange/doReuseAdd', {
|
||||
const loading = this.$loading({lock: true, text: isSave ? '正在保存...' : '正在提交...', background: COVER_LAYER_COLOR})
|
||||
const request = $.post('/platform/activity/school/info/mange/doReuseAdd', {
|
||||
sourceId: this.reuseActivityId, data: JSON.stringify(form), events: JSON.stringify(this.buildReuseEvents())
|
||||
}).then((resp) => {
|
||||
})
|
||||
// jQuery 1.x 的 then 回调抛错后可能中断后续回调;直接监听请求结束以关闭遮罩。
|
||||
request.always(() => {
|
||||
this.$set(this, 'formLoading', false)
|
||||
loading.close()
|
||||
})
|
||||
return request.then((resp) => {
|
||||
if (resp.code !== 0) {
|
||||
this.$message.error(resp.msg)
|
||||
return
|
||||
}
|
||||
if (isSave) {
|
||||
this.$message.success('保存成功')
|
||||
window.location.href = '/platform/activity/school/info/mange'
|
||||
return
|
||||
}
|
||||
this.$set(this.form, 'id', resp.data)
|
||||
this.$set(this, 'reuseActivityId', null)
|
||||
if (isSave) {
|
||||
this.$emit('flush')
|
||||
this.$message.success('保存成功')
|
||||
// 保存后读取新项目主键,后续编辑必须更新新活动的项目,不能继续使用空主键。
|
||||
return $.post('/platform/activity/school/info/mange/findOne', {id: resp.data}).then((saved) => {
|
||||
if (saved.code !== 0) {
|
||||
this.$message.error('活动已保存,回显失败,请从活动列表重新打开')
|
||||
return
|
||||
}
|
||||
const configs = (saved.data.schoolEvents || []).map((event) => {
|
||||
this.$set(event, 'unionLimit', this.reuseArray(event.unionLimit))
|
||||
this.$set(event, 'ageDate', event.startAgeDate ? [event.startAgeDate, event.endAgeDate] : [])
|
||||
return event
|
||||
})
|
||||
this.$set(this, 'checkedEventInfo', configs)
|
||||
this.$set(this, 'checkedEventInfo2', clone(configs))
|
||||
this.$set(this, 'eventsIds', clone(this.form.eventsIds))
|
||||
const selected = configs.find((event) => event.eventId === this.eventForm.checkedEventId)
|
||||
if (selected) {
|
||||
this.$set(this, 'eventForm', Object.assign({}, selected, {checkedEventId: selected.eventId}))
|
||||
}
|
||||
})
|
||||
}
|
||||
this.$emit('flip')
|
||||
}).fail(() => {
|
||||
}, () => {
|
||||
this.$message.error('请求失败,请检查活动列表后重试')
|
||||
}).always(() => {
|
||||
this.$set(this, 'formLoading', false)
|
||||
loading.close()
|
||||
})
|
||||
}
|
||||
if (isSave) {
|
||||
if (this.$refs.activityForm) this.$refs.activityForm.clearValidate()
|
||||
return save()
|
||||
}
|
||||
if (this.$refs.activityForm) {
|
||||
this.$refs.activityForm.validate((valid) => {
|
||||
if (valid) save()
|
||||
@@ -1110,7 +1106,8 @@ module.exports = {
|
||||
return
|
||||
}
|
||||
|
||||
if (moment(this.form.time[0]).valueOf() <= moment(this.form.applyTime[0]).valueOf()) {
|
||||
// 活动时间可在保存草稿后补填;已填写时仍需晚于报名开始时间。
|
||||
if (this.form.time && this.form.time[0] && this.form.time[1] && moment(this.form.time[0]).valueOf() <= moment(this.form.applyTime[0]).valueOf()) {
|
||||
this.$notify.error({title: '错误', message: '活动时间必须晚于报名时间'});
|
||||
return
|
||||
}
|
||||
@@ -1247,7 +1244,7 @@ module.exports = {
|
||||
this.clubOptions = await getClubsByRole()
|
||||
this.eventsIds = clone(JSON.parse(v.eventsIds))
|
||||
v.applyTime = [v.applyStartTime, v.applyEndTime]
|
||||
v.time = [v.startTime, v.endTime]
|
||||
this.$set(v, 'time', v.startTime && v.endTime ? [v.startTime, v.endTime] : null)
|
||||
v.eventsIds = JSON.parse(v.eventsIds)
|
||||
v.applyWay = JSON.parse(v.applyWay)
|
||||
v.unitSponsor = JSON.parse(v.unitSponsor)
|
||||
@@ -1323,6 +1320,12 @@ module.exports = {
|
||||
if (this.reuseLoading || this.formLoading) return
|
||||
if (this.reuseActivityId && !this.form.id) return this.doReuseAdd(false)
|
||||
|
||||
// 提交会开放活动,必须先补齐活动时间;仅保存草稿允许留空。
|
||||
if (!this.form.time || this.form.time.length !== 2 || !this.form.time[0] || !this.form.time[1]) {
|
||||
this.$message.warning('请填写活动时间后再提交')
|
||||
return
|
||||
}
|
||||
|
||||
const deleteEventIds = this.eventsIds.filter(v => !this.form.eventsIds.includes(v))
|
||||
const {data} = await $.get(loc() + "/getEventApply", {
|
||||
activityId: this.form.id,
|
||||
@@ -1340,8 +1343,10 @@ module.exports = {
|
||||
await this.doOperate()
|
||||
}
|
||||
},
|
||||
async doSave() {
|
||||
doSave() {
|
||||
if (this.reuseLoading || this.formLoading) return
|
||||
// 保存草稿不触发表单必填校验;下一步和提交仍按各自规则处理。
|
||||
if (this.$refs.activityForm) this.$refs.activityForm.clearValidate()
|
||||
if (this.reuseActivityId && !this.form.id) return this.doReuseAdd(true)
|
||||
let url = this.form.id ? "/doEdit" : "/doAdd"
|
||||
|
||||
@@ -1364,25 +1369,32 @@ module.exports = {
|
||||
const form = clone(this.form)
|
||||
form.restrictMaxNum = form.leanderNum + form.coachNum + form.athletesMaxNum + form.substituteNum
|
||||
form.restrictMinNum = form.athletesMaxNum
|
||||
form.isSave = true
|
||||
form.isSave = 1
|
||||
|
||||
const {time, applyTime} = form
|
||||
if (applyTime && applyTime.length) {
|
||||
if (applyTime && applyTime.length === 2 && applyTime[0] && applyTime[1]) {
|
||||
form.applyStartTime = applyTime[0]
|
||||
form.applyEndTime = applyTime[1]
|
||||
form.applyTime = undefined
|
||||
} else {
|
||||
form.applyStartTime = null
|
||||
form.applyEndTime = null
|
||||
}
|
||||
|
||||
if (time && time.length) {
|
||||
if (time && time.length === 2 && time[0] && time[1]) {
|
||||
form.startTime = time[0]
|
||||
form.endTime = time[1]
|
||||
form.time = undefined
|
||||
} else {
|
||||
// 清空已有活动时间时显式传 null,避免编辑草稿时沿用旧值。
|
||||
form.startTime = null
|
||||
form.endTime = null
|
||||
}
|
||||
|
||||
if (this.eventForm.checkedEventId == "allItems") {
|
||||
events = events.filter(v => v.projectType == 1 && v.id != "allItems")
|
||||
|
||||
} else {
|
||||
} else if (this.eventForm.checkedEventId) {
|
||||
this.$set(this.eventForm, "activityId", this.form.id)
|
||||
this.$set(this.eventForm, "eventId", this.eventForm.checkedEventId)
|
||||
if (this.eventForm.ageDate && this.eventForm.ageDate.length > 0) {
|
||||
@@ -1391,26 +1403,29 @@ module.exports = {
|
||||
}
|
||||
events = this.eventForm
|
||||
}
|
||||
this.$set(this, 'formLoading', true)
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在提交...',
|
||||
text: '正在保存...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: COVER_LAYER_COLOR
|
||||
});
|
||||
|
||||
const resp = await $.post("/platform/activity/school/info/mange" + url, {
|
||||
return $.post("/platform/activity/school/info/mange" + url, {
|
||||
data: JSON.stringify(form),
|
||||
events: JSON.stringify(events)
|
||||
})
|
||||
|
||||
closeLoadingFunc(loading, resp, async (data) => {
|
||||
|
||||
this.$emit('flush')
|
||||
if (!this.form.id) form.id = data
|
||||
await this.openEdit(form, false)
|
||||
|
||||
}, (data, msg) => {
|
||||
this.$message.error(msg);
|
||||
}).then((resp) => {
|
||||
if (resp.code === 0) {
|
||||
this.$message.success('保存成功')
|
||||
window.location.href = '/platform/activity/school/info/mange'
|
||||
} else {
|
||||
this.$message.error(resp.msg)
|
||||
}
|
||||
}, () => {
|
||||
this.$message.error('保存失败,请检查活动列表后重试')
|
||||
}).always(() => {
|
||||
this.$set(this, 'formLoading', false)
|
||||
loading.close()
|
||||
})
|
||||
},
|
||||
examineTrans(form) {
|
||||
|
||||
Reference in New Issue
Block a user