|
@@ -20,8 +20,8 @@
|
|
|
<el-option v-for="item in typeOptions" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
|
|
<el-option v-for="item in typeOptions" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="活动分类" prop="categoryId">
|
|
|
|
|
- <el-select v-model="basicForm.categoryId" placeholder="请选择活动分类" class="select-box" style="width: 440px;">
|
|
|
|
|
|
|
+ <el-form-item label="活动分类" prop="categoryIdsArr">
|
|
|
|
|
+ <el-select v-model="basicForm.categoryIdsArr" placeholder="请选择活动分类(可多选)" class="select-box" style="width: 440px;" multiple collapse-tags>
|
|
|
<el-option v-for="item in categoryOptions" :key="item.id" :label="item.categoryName" :value="item.id"></el-option>
|
|
<el-option v-for="item in categoryOptions" :key="item.id" :label="item.categoryName" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -234,6 +234,8 @@ const getInitialBasicForm = () => ({
|
|
|
id: '',
|
|
id: '',
|
|
|
typeId: '',
|
|
typeId: '',
|
|
|
categoryId: '',
|
|
categoryId: '',
|
|
|
|
|
+ categoryIds: '',
|
|
|
|
|
+ categoryIdsArr: [],
|
|
|
activityName: '',
|
|
activityName: '',
|
|
|
signupStartEnd: [],
|
|
signupStartEnd: [],
|
|
|
signupStartTime: '',
|
|
signupStartTime: '',
|
|
@@ -302,6 +304,9 @@ export default {
|
|
|
categoryId: [
|
|
categoryId: [
|
|
|
{ required: true, message: '请选择活动分类', trigger: 'change' }
|
|
{ required: true, message: '请选择活动分类', trigger: 'change' }
|
|
|
],
|
|
],
|
|
|
|
|
+ categoryIdsArr: [
|
|
|
|
|
+ { required: true, type: 'array', min: 1, message: '请选择至少一个活动分类', trigger: 'change' }
|
|
|
|
|
+ ],
|
|
|
activityName: [
|
|
activityName: [
|
|
|
{ required: true, message: '请输入活动名称', trigger: 'blur' }
|
|
{ required: true, message: '请输入活动名称', trigger: 'blur' }
|
|
|
],
|
|
],
|
|
@@ -424,6 +429,14 @@ export default {
|
|
|
if (res.code !== 0) return this.$message.error(res.msg)
|
|
if (res.code !== 0) return this.$message.error(res.msg)
|
|
|
// this.basicForm = { ...this.basicForm, ...res.data }
|
|
// this.basicForm = { ...this.basicForm, ...res.data }
|
|
|
this.updateObjectFromSource(this.basicForm, res.data)
|
|
this.updateObjectFromSource(this.basicForm, res.data)
|
|
|
|
|
+ // 解析后端存的 CSV(category_ids)到数组供 el-select multiple 使用
|
|
|
|
|
+ if (res.data.categoryIds) {
|
|
|
|
|
+ this.basicForm.categoryIdsArr = res.data.categoryIds.split(',').map(Number).filter(n => !isNaN(n))
|
|
|
|
|
+ } else if (res.data.categoryId) {
|
|
|
|
|
+ this.basicForm.categoryIdsArr = [res.data.categoryId]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.basicForm.categoryIdsArr = []
|
|
|
|
|
+ }
|
|
|
this.activityDetailsTemp = res.data.activityDetails
|
|
this.activityDetailsTemp = res.data.activityDetails
|
|
|
this.basicForm.signupStartEnd = [this.basicForm.signupStartTime, this.basicForm.signupEndTime]
|
|
this.basicForm.signupStartEnd = [this.basicForm.signupStartTime, this.basicForm.signupEndTime]
|
|
|
this.basicForm.activityStartEnd = [this.basicForm.activityStartTime, this.basicForm.activityEndTime]
|
|
this.basicForm.activityStartEnd = [this.basicForm.activityStartTime, this.basicForm.activityEndTime]
|
|
@@ -464,6 +477,13 @@ export default {
|
|
|
getEditor (val) {
|
|
getEditor (val) {
|
|
|
this.basicForm.activityDetails = val
|
|
this.basicForm.activityDetails = val
|
|
|
},
|
|
},
|
|
|
|
|
+ // 把 el-select multiple 的数组(categoryIdsArr)同步到后端期望的字段:
|
|
|
|
|
+ // categoryId = 第一个(主分类,兼容 JOIN), categoryIds = CSV(供筛选/详情)
|
|
|
|
|
+ syncCategoryIds () {
|
|
|
|
|
+ const arr = this.basicForm.categoryIdsArr || []
|
|
|
|
|
+ this.basicForm.categoryId = arr.length > 0 ? arr[0] : null
|
|
|
|
|
+ this.basicForm.categoryIds = arr.join(',')
|
|
|
|
|
+ },
|
|
|
getTypeOptions () {
|
|
getTypeOptions () {
|
|
|
this.$http.get('/core/activity/type/page', { params: { page: 1, limit: -1 } }).then(res => {
|
|
this.$http.get('/core/activity/type/page', { params: { page: 1, limit: -1 } }).then(res => {
|
|
|
this.typeOptions = res.data.data.list.filter(l => l.enable === 1) || []
|
|
this.typeOptions = res.data.data.list.filter(l => l.enable === 1) || []
|
|
@@ -623,6 +643,8 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
handleTempSave () {
|
|
handleTempSave () {
|
|
|
|
|
+ // 同步 categoryIdsArr 到 categoryId(主分类)/categoryIds(CSV)字段再校验
|
|
|
|
|
+ this.syncCategoryIds()
|
|
|
if (this.basicForm.signupStartTime && this.basicForm.signupEndTime && (Date.parse(this.basicForm.signupStartTime) > Date.parse(this.basicForm.signupEndTime))) return this.$message.error('报名结束时间不能小于报名开始时间')
|
|
if (this.basicForm.signupStartTime && this.basicForm.signupEndTime && (Date.parse(this.basicForm.signupStartTime) > Date.parse(this.basicForm.signupEndTime))) return this.$message.error('报名结束时间不能小于报名开始时间')
|
|
|
if (this.basicForm.signupEndTime && (Date.parse(this.basicForm.signupEndTime) < Date.parse(new Date()))) return this.$message.error('报名结束时间不能小于当前时间')
|
|
if (this.basicForm.signupEndTime && (Date.parse(this.basicForm.signupEndTime) < Date.parse(new Date()))) return this.$message.error('报名结束时间不能小于当前时间')
|
|
|
if (this.basicForm.signupEndTime && this.basicForm.activityStartTime && (Date.parse(this.basicForm.signupEndTime) > Date.parse(this.basicForm.activityStartTime))) return this.$message.error('活动开始时间不能小于报名结束时间')
|
|
if (this.basicForm.signupEndTime && this.basicForm.activityStartTime && (Date.parse(this.basicForm.signupEndTime) > Date.parse(this.basicForm.activityStartTime))) return this.$message.error('活动开始时间不能小于报名结束时间')
|
|
@@ -664,6 +686,8 @@ export default {
|
|
|
}).catch(() => { this.autoSaving = false })
|
|
}).catch(() => { this.autoSaving = false })
|
|
|
},
|
|
},
|
|
|
handleSave () {
|
|
handleSave () {
|
|
|
|
|
+ // 同步 categoryIdsArr 到 categoryId(主分类)/categoryIds(CSV)字段再校验
|
|
|
|
|
+ this.syncCategoryIds()
|
|
|
this.$refs.moreRef.validate(valid => {
|
|
this.$refs.moreRef.validate(valid => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
if (this.moreForm.recruitmentFlag === 1) {
|
|
if (this.moreForm.recruitmentFlag === 1) {
|