Files
UNION_NJUST/src/main/resources/static/components/activity/school/AddActivity.vue
T

1563 lines
63 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<el-steps :active="active" finish-status="success" simple>
<el-step title="活动信息"></el-step>
<el-step title="项目信息"></el-step>
</el-steps>
<div v-if="active===0" style="margin-top: 20px">
<el-form ref="activityForm" :model="form" :rules="formRules" label-position="top"
label-width="120px"
label-suffix=":">
<vi-title title="填写活动信息"></vi-title>
<!-- 沿用入口只用于创建活动,独占首行,宽度与下方单个表单字段一致。 -->
<el-row gutter="40" v-if="!form.id">
<el-col :span="8">
<el-form-item label="沿用之前活动">
<el-select v-model="reuseActivityId" clearable filterable
:loading="reuseLoading" :disabled="formLoading"
placeholder="请选择要沿用的活动" @change="reuseActivityChange"
style="width: 100%">
<el-option v-for="item in reuseActivityOptions" :key="item.id"
:label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row gutter="40">
<el-col :span="8">
<el-form-item prop="activityLevel" label="活动级别">
<el-radio-group v-model="form.activityLevel" @change="activityLevelChange">
<template v-if="is_sysadmin">
<el-radio :label="40001" border>校级</el-radio>
<el-radio :label="40002" border>部门工会</el-radio>
<el-radio :label="40003" border>社团或协会</el-radio>
</template>
<template v-if="!is_sysadmin">
<el-radio :label="40001" border v-if="is_a06">校级</el-radio>
<el-radio v-if="is_union" :label="40002" border>部门工会</el-radio>
<el-radio :label="40003" border v-if="is_club">社团或协会</el-radio>
</template>
</el-radio-group>
</el-form-item>
</el-col>
<!-- <el-col :span="8">
<el-form-item prop="planId" label="活动计划">
<el-select v-model="form.planId" placeholder="请选择活动计划" clearable style="width: 100%">
<el-option
v-for="item in planList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>-->
<el-col :span="8">
<el-form-item prop="name" label="活动名称">
<el-input maxlength="50" placeholder="请填写活动名称" v-model="form.name"
type="text"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="activityCode" label="活动编号">
<el-input maxlength="50" disabled v-model="form.activityCode"
type="text"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row gutter="40">
<el-col :span="8">
<el-form-item prop="unitSponsor" label="主办单位">
<el-select v-model="form.unitSponsor" clearable filterable multiple
placeholder="请选择主办单位"
style="width: 100%">
<el-option
v-for="item in unitOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="undertakeUnit" label="承办单位">
<el-select v-model="form.undertakeUnit" clearable filterable multiple
placeholder="请选择承办单位"
style="width: 100%">
<el-option
v-for="item in unitOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="unitJointly" label="协办单位">
<el-select v-model="form.unitJointly" multiple placeholder="请选择协办单位" filterable
clearable
style="width: 100%">
<el-option
v-for="item in unitOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="address" label="活动地址">
<el-input maxlength="100" placeholder="请填写活动地址" v-model="form.address"
type="text"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="applyTime" label="报名日期">
<el-date-picker
style="width: 100%"
v-model="form.applyTime"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm"
range-separator="-"
start-placeholder="开始时间"
end-placeholder="结束时间">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="time" label="活动时间">
<el-date-picker
style="width: 100%"
v-model="form.time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm"
range-separator="-"
start-placeholder="开始时间"
end-placeholder="结束时间">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="activityGroupId" label="可报名人员范围">
<el-select v-model="form.activityGroupId" clearable filterable
placeholder="请选择可报名人员范围"
style="width: 100%">
<el-option v-for="item in activityGroupList"
:value="item.groupId"
:key="item.groupId"
:label="item.groupName"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="funding" label="经费预算">
<el-input-number style="width: 100%" v-model="form.funding"
placeholder="请填写活动经费预算" controls-position="right" precision="2"
:max="1000000000"></el-input-number>
</el-form-item>
</el-col>
<el-col v-if="form.activityLevel===40003||(form.activityLevel===40001&&is_club)"
:span="8">
<el-form-item prop="belongClubId" label="活动所属协会">
<el-select v-model="form.belongClubId" placeholder="请选择活动所属协会" filterable clearable
style="width: 100%">
<el-option
v-for="item in clubOptions"
:key="item.stid"
:label="item.name"
:value="item.stid">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row gutter="40">
<!-- <el-col :span="8">
<el-form-item prop="gameStyle" label="活动方式">
<el-radio-group v-model="form.gameStyle" @change="gameChange">
<el-radio :label="1" border>竞赛类</el-radio>
<el-radio :label="2" border>非竞赛类</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="personType" label="报名人员类型">
<el-radio-group v-model="form.personType">
<el-radio :label="1" border>会员</el-radio>
<el-radio :label="2" border>所有教职工</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="activityLevel" label="活动级别">
<el-radio-group v-model="form.activityLevel" @change="activityLevelChange">
<el-radio :label="1" border>校级</el-radio>
<el-radio :label="2" border>部门工会</el-radio>
<el-radio :label="3" border>社团或协会</el-radio>
</el-radio-group>
</el-form-item>
</el-col>-->
<el-col :span="8">
<el-form-item prop="applyType" label="活动类型">
<el-radio-group v-model="form.applyType" @change="applyTypeChange">
<el-radio :label="1" border>单一团体赛</el-radio>
<el-radio :label="2" border :disabled="form.activityLevel!==40001">综合赛</el-radio>
<el-radio :label="3" border>个人赛</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="applyWay" label="报名方式">
<el-checkbox-group v-model="form.applyWay" @change="applyWayChange">
<el-checkbox :disabled="form.activityLevel!==40001" :label="2" border>基层工会报名
</el-checkbox>
<el-checkbox :label="1" border>个人报名</el-checkbox>
<!-- <el-checkbox :label="3" border>小程序报名</el-checkbox>-->
</el-checkbox-group>
</el-form-item>
</el-col>
<!-- <el-col :span="8">
<el-form-item prop="restrictRegNumber" label="每人限报项目数">
<el-input v-model="form.restrictRegNumber" placeholder="请填写每人限报项目数"></el-input>
</el-form-item>
</el-col>-->
</el-row>
<el-row>
<!-- <el-col :span="24">
<el-form-item prop="eventsIds" label="活动项目">
<el-select v-model="form.eventsIds" placeholder="请选择活动项目" filterable multiple
style="width: 100%" class="act_event" @remove-tag="eventRemoveTag">
<el-option
v-for="item in events"
:key="item.id"
:label="item.allName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>-->
<el-col :span="24">
<el-transfer
@right-check-change="rightCheckChange"
@change="rightChange"
ref="transfer"
:titles="['可选择项目', '当前选择']"
filterable
:props="{key: 'id',label: 'allName'}"
:filter-method="filterMethod"
:right-default-checked="rightChecked"
v-model="form.eventsIds"
:data="events">
</el-transfer>
</el-col>
</el-row>
<el-row gutter="40" v-if="form.gameStyle===1&&!form.applyWay.includes(3)">
<el-col :span="24">
<el-form-item :prop="form.gameStyle===1?'athleteQualification':'-'" label="运动员资格">
<div id="athleteQualification"></div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :prop="form.gameStyle===1?'registrationMethod':'-'" label="报名方法">
<div id="registrationMethod"></div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :prop="form.gameStyle===1?'competitionMethod':'-'" label="竞赛方法">
<div id="competitionMethod"></div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :prop="form.gameStyle===1?'rewardMethod':'-'" label="奖励方法">
<div id="rewardMethod"></div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :prop="form.gameStyle===1?'precautions':'-'" label="注意事项">
<div id="precautions"></div>
</el-form-item>
</el-col>
</el-row>
<el-row gutter="40" v-if="form.gameStyle===2||form.applyWay.includes(3)">
<el-col :span="24">
<el-form-item :prop="form.gameStyle===2?'eventNotification':'-'" label="活动通知">
<div id="eventNotification"></div>
</el-form-item>
</el-col>
</el-row>
<el-form-item prop="files" label="封面图" v-if="form.applyWay.includes(1)">
<file-upload :files.sync="form.image" :max="1" :type="['jpg', 'jpeg', 'png']"
card></file-upload>
</el-form-item>
</el-form>
</div>
<div v-if="active===1" style="margin-top: 20px">
<el-form ref="eventForm" :model="eventForm" :rules="formRules" label-position="top"
label-width="120px"
label-suffix=":" :key="new Date().getTime()">
<template v-if="projectType==='2'">
<vi-title title="领队、教练信息"></vi-title>
<el-row gutter="40">
<el-col :span="12">
<el-form-item prop="leanderNum" label="领队人数(可兼运动员)">
<el-input-number style="width: 100%" v-model="eventForm.leanderNum"
placeholder="请填写领队人数" controls-position="right" precision="0"
:max="100000" :min="0"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="coachNum" label="教练人数(可兼运动员)">
<el-input-number style="width: 100%" v-model="eventForm.coachNum"
placeholder="请填写教练人数" controls-position="right" precision="0"
:max="100000" :min="0"></el-input-number>
</el-form-item>
</el-col>
</el-row>
</template>
<template>
<vi-title title="项目报名信息"></vi-title>
<span style="position: relative;left: 65px;top: 33px;color: red">每设置一个项目,需要保存项目信息</span>
<el-row gutter="40">
<el-col :span="12">
<el-form-item label="比赛项目">
<el-select v-model="eventForm.checkedEventId" filterable
placeholder="请选择活动项目" @change="eventChange"
clearable
style="width: 100%">
<el-option
v-for="item in checkedEvents"
:key="item.id"
:label="item.allName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col v-if="eventForm.checkedEventId==='allItems'||projectType==='1'" :span="6">
<el-form-item label="年龄限制功能">
<el-button type="primary" @click="doAssignmentDate">根据比赛项目基础表统赋</el-button>
</el-form-item>
</el-col>
<el-col v-if="projectType==='2'&&form.applyType===2" :span="6">
<el-form-item label="是否只需报领队" class="isLeaderColor">
<el-checkbox v-model="eventForm.isLeader" @change="isLeaderChange">是否只需报领队
</el-checkbox>
</el-form-item>
</el-col>
<el-col v-if="eventForm.checkedEventId==='allItems'||projectType==='1'" :span="6">
<el-form-item label="运动员数量限制模式">
<el-radio-group v-model="eventForm.applyUserModel" @input="applyUserModelInput">
<el-radio-button :label="1">固定</el-radio-button>
<el-radio-button :label="2">分配模式</el-radio-button>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row v-show="eventForm.applyUserModel!==2" gutter="40">
<el-col :span="8">
<el-form-item :label="projectType==='1'?'每队(项)运动员最多人数':'每队(项)运动员人数'"
prop="athletesMaxNum">
<el-input-number style="width: 100%" v-model="eventForm.athletesMaxNum"
placeholder="请填写每队运动员人数" controls-position="right" precision="0"
:max="1000000000" :min="0"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8" v-if="form.applyType===2&&projectType==='1'">
<el-form-item prop="restrictRegNumber" label="每人限报项目">
<el-input-number style="width: 100%" v-model="eventForm.restrictRegNumber"
placeholder="请填写每人限报项目数" controls-position="right" precision="0"
:max="1000000000" :min="0"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8"
v-if="form.applyType===3||form.applyType===2&&projectType==='1'&&eventForm.checkedEventId!='allItems'">
<el-form-item prop="ageDate" label="年龄限制范围">
<el-date-picker
@change="ageDateChange"
style="width: 100%;z-index: 1"
v-model="eventForm.ageDate"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy 年 MM 月 dd 日"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
</el-col>
<el-col v-if="form.applyType===1||(form.applyType===2&&projectType==='2')" :span="12">
<el-form-item label="替补最多人数" prop="substituteNum">
<el-input-number style="width: 100%" v-model="eventForm.substituteNum"
controls-position="right" placeholder="请填写替补最多人数" precision="0"
:max="100000" :min="0"></el-input-number>
</el-form-item>
</el-col>
<el-col v-if="form.applyType===1||(form.applyType===2&&projectType==='2')" :span="8">
<el-form-item prop="restrictMaxNum" label="每队最多人数">
<el-input-number style="width: 100%"
:value="eventForm.leanderNum+eventForm.coachNum+eventForm.athletesMaxNum+(eventForm.substituteNum?eventForm.substituteNum:0)"
placeholder="请填写每队最多人数" controls-position="right" precision="0"
:max="100000" :min="0" disabled></el-input-number>
</el-form-item>
</el-col>
<el-col v-if="form.applyType===1||(form.applyType===2&&projectType==='2')" :span="8">
<el-form-item prop="restrictMinNum" label="每队最少人数">
<el-input-number :value="eventForm.athletesMaxNum"
controls-position="right"
disabled placeholder="请填写每队最少人数" precision="0"
style="width: 100%"
:max="100000" :min="0"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8" v-if="form.applyType===1||(form.applyType===2&&projectType==='2')">
<el-form-item label="最多创建几队(如需修改,请先删掉项目,在重新添加项目后,再修改队数)" prop="restrictTotalTeam"
 class="restrictTotalTeam">
<el-input-number style="width: 100%" v-model="eventForm.restrictTotalTeam"
placeholder="请填写最多创建几队" controls-position="right" precision="0"
:max="100000" :min="1"></el-input-number>
</el-form-item>
</el-col>
<el-col v-if="form.applyType===1||(form.applyType===2&&projectType==='2'&&!eventForm.isLeader)"
:span="8">
<el-form-item
label="每队男运动员最少人数(若不填值,报名数量不限;如为0,表示不允许报名)"
prop="restrictBoyNum">
<el-input v-model="eventForm.restrictBoyNum" placeholder="请填写男运动员人数"
style="width: 100%" type="number"></el-input>
</el-form-item>
</el-col>
<el-col v-if="form.applyType===1||(form.applyType===2&&projectType==='2'&&!eventForm.isLeader)"
:span="8">
<el-form-item
label="每队女运动员最少人数(若不填值,报名数量不限;如为0,表示不允许报名)"
prop="restrictGirlNum">
<el-input v-model="eventForm.restrictGirlNum" placeholder="请填写女运动员人数"
style="width: 100%"
type="number"></el-input>
</el-form-item>
</el-col>
<el-col :span="8" v-if="form.applyType===1">
<el-form-item prop="deputyDirectorNum" label="每队副处长(级)以上最少人数">
<el-input-number style="width: 100%" v-model="eventForm.deputyDirectorNum"
controls-position="right" placeholder="请填写每队副处长(级)以上最少人数"
precision="0"
:max="100000" :min="0"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row v-show="eventForm.applyUserModel===2" gutter="40">
<el-card style="margin-left: 20px;margin-right: 60px">
<vi-title2 title="分段设置">
<template #func>
<el-button size="small" type="primary" @click="unionLimitQuickSetting">
应用分段设置
</el-button>
</template>
</vi-title2>
<el-row v-for="(item,index) in unionUserNumCalc" :gutter="20" class="mb5">
<el-col :span="7">
<el-input-number v-model="item.startNum" :min="1" :precision="0" :step="1"
controls-position="right" placeholder="请输入最小人数"
style="width: 100%"></el-input-number>
</el-col>
<el-col :span="7">
<el-input-number v-model="item.endNum" :min="1" :precision="0" :step="1"
controls-position="right" placeholder="请输入最大人数"
style="width: 100%"></el-input-number>
</el-col>
<el-col :span="6">
<el-input-number v-model="item.resultNum" :min="1" :precision="0" :step="1"
controls-position="right" placeholder="请输入限制人数"
style="width: 100%"></el-input-number>
</el-col>
<el-col :span="4" class="text-right">
<el-button icon="el-icon-plus"
@click="unionUserNumCalc.push({startNum:1,endNum:1,resultNum:1})"></el-button>
<el-button :disabled="unionUserNumCalc.length===1" icon="el-icon-minus"
@click="unionUserNumCalc.splice(index,1)"></el-button>
</el-col>
</el-row>
<el-row class="mt10">
<div v-for="(item,index) in unionUserNumCalcTips" class="text-danger">
<span class="mr10">({{ index + 1 }}).</span> {{ item }}
</div>
</el-row>
<vi-title2 class="mt20" title="比例设置">
<template #func>
一键比例:
<el-input-number v-model="unionUserNumOneKeyRatio" :max="100" :min="0"
:precision="0"
:step="1"
placeholder="请输入一键比例"
size="small"></el-input-number>
<el-button class="ml5" size="small" type="primary" @click="applyScaleSettings">
应用比例设置
</el-button>
</template>
</vi-title2>
<el-table :data="eventForm.unionLimit" max-height="500px">
<el-table-column label="部门工会" prop="unionname"></el-table-column>
<el-table-column label="人数" prop="teacherCount"></el-table-column>
<el-table-column label="比例(%)" prop="ratio">
<template scope="{row}">
<el-input-number v-model="row.ratio" :max="100" :min="0" :precision="0"
:step="1"
controls-position="right"></el-input-number>
</template>
</el-table-column>
<el-table-column label="限制人数" prop="limitCount">
<template scope="{row}">
<el-input-number v-model="row.limitCount" :max="row.teacherCount" :min="0" :precision="0"
:step="1" controls-position="right"
@change="calSummaryCount"></el-input-number>
</template>
</el-table-column>
</el-table>
<el-row class="mt20" justify="end" type="flex">
<div class="text-danger"
style="width: 100%;font-size: 18px;display: flex;align-items: center;font-weight: bold">
限制总人数:{{ summaryCount }}人
</div>
<el-button type="danger" @click="clearUnionLimit">清空部门工会人数限制</el-button>
</el-row>
</el-card>
</el-row>
</template>
</el-form>
</div>
<el-row style="margin: 40px 0;text-align: right" v-if="!form.applyWay.includes(3)">
<el-button type="primary" @click="prev" :disabled="active===0">上一步</el-button>
<el-button type="primary" @click="next" v-if="active <= 0">下一步</el-button>
<el-button type="primary" @click="saveEvent" v-else> 保存项目信息</el-button>
</el-row>
</div>
</template>
<script>
let E = window.wangEditor
const editors = {}
module.exports = {
props: {
form: {
type: Object,
default: {},
},
is_club: {type: Boolean, default: false,},
is_union: {type: Boolean, default: false,},
is_sysadmin: {type: Boolean, default: false,},
is_a06: {type: Boolean, default: false,}
},
components: {
'file-upload': httpVueLoader('/components/plugins/FileUpload.vue'),
},
computed: {
unionUserNumCalcTips() {
return this.unionUserNumCalc.map(v => {
return (v.startNum ? v.startNum : '?') + '-' + (v.endNum ? v.endNum : '?') + '人的部门工会,限报' + (v.resultNum ? v.resultNum : '?') + '人'
})
},
},
data() {
return {
unionUserNumOneKeyRatio: null,
summaryCount: 0,
unionUserNumCalc: [{startNum: 1, endNum: 1, resultNum: 1}],
activityGroupList: [],
active: 0,
eventForm: {
isLeader: false,
},
eventsIds: [],
rightChecked: [],
checkedEventInfo: [],
checkedEventInfo2: [],
checkedEvents: [],
unitOptions: [],
clubOptions: [],
planList: [],
events: [],
projectType: "",
reuseActivityId: null,
reuseActivityOptions: [],
reuseLoading: false,
reuseReady: false,
formLoading: false,
reuseRequestId: 0,
formRules: {
name: [{required: true, message: '必填', trigger: ['blur', 'change']}],
address: [{required: true, message: '必填', trigger: ['blur', 'change']}],
typeId: [{required: true, message: '必填', trigger: ['blur', 'change']}],
eventsIds: [{required: true, message: '必填', trigger: ['blur', 'change']}],
applyTime: [{required: true, message: '必填', trigger: ['blur', 'change']}],
unitSponsor: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// unitJointly: [{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']}],
restrictTotalPeople: [{required: true, message: '必填', trigger: ['blur', 'change']}],
restrictTotalTeam: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// registrationMethod: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// competitionMethod: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// rewardMethod: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// precautions: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// eventNotification: [{required: true, message: '必填', trigger: ['blur', 'change']}],
personType: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// athleteQualification: [{required: true, message: '必填', trigger: ['blur', 'change']}],
activityLevel: [{required: true, message: '必填', trigger: ['blur', 'change']}],
// belongClubId: [{required: true, message: '必填', trigger: ['blur', 'change']}],
applyType: [{required: true, message: '必填', trigger: ['blur', 'change']}],
athletesMaxNum: [{required: true, message: '必填', trigger: ['blur', 'change']}],
restrictRegNumber: [{required: true, message: '必填', trigger: ['blur', 'change']}],
}
}
},
methods: {
// 下拉接口无参数;data 为当前管理范围内的 {id, name} 数组。
getReuseActivityOptions() {
return $.post('/platform/activity/school/info/mange/getReuseActivityOptions').then((resp) => {
if (resp.code === 0) {
this.$set(this, 'reuseActivityOptions', resp.data || [])
} else {
this.$message.error(resp.msg)
}
}).fail(() => {
this.$message.error('历史活动列表加载失败,请重新打开创建活动')
})
},
// JSON 列可能返回字符串、数组或空值,统一转成独立数组,避免修改来源数据。
reuseArray(value) {
let data = value
try {
data = typeof value === 'string' ? JSON.parse(value || '[]') : value
} catch (error) {
this.$message.warning('历史活动存在无法读取的配置,请检查并重新填写')
return []
}
return Array.isArray(data) ? clone(data) : []
},
// id 为来源活动ID;响应包含活动字段和 schoolEvents,不携带旧主键进入新增保存。
reuseActivityChange(id) {
const requestId = ++this.reuseRequestId
this.$set(this, 'reuseReady', false)
if (!id) {
this.$set(this, 'reuseLoading', false)
this.openAdd()
return
}
this.$set(this, 'reuseLoading', true)
return $.post('/platform/activity/school/info/mange/findReuseActivity', {id}).then((resp) => {
if (requestId !== this.reuseRequestId) return
if (resp.code !== 0) {
this.$message.error(resp.msg)
return
}
const form = clone(resp.data)
// 项目列表及编号按沿用活动的实际类型加载,旧日期要求重新填写。
return $.when(
$.post('/platform/activity/common/getEvents', {type: form.applyType}),
$.post('/platform/activity/apply/generateActivityCode', {activity_type: form.activityLevel}),
$.post('/platform/vi/common/getClubsByRole')
).then((eventResponse, codeResponse, clubResponse) => {
if (requestId !== this.reuseRequestId) return
// 当前项目使用 jQuery 1.x;when 返回每个请求的 [data, status, xhr]。
const responses = [eventResponse[0], codeResponse[0], clubResponse[0]]
const failed = responses.find((response) => response.code !== 0)
if (failed) {
this.$message.error(failed.msg)
return
}
const events = responses[0].data || []
const selectedIds = this.reuseArray(form.eventsIds)
const availableIds = selectedIds.filter((eventId) => events.some((event) => event.id === eventId))
if (availableIds.length !== selectedIds.length) {
this.$message.warning('历史活动中已停用或不存在的项目未沿用,请检查活动项目')
}
;['applyWay', 'unitSponsor', 'undertakeUnit', 'unitJointly', 'image'].forEach((key) => {
this.$set(form, key, this.reuseArray(form[key]))
})
const configs = (form.schoolEvents || []).filter((event) => availableIds.includes(event.eventId)).map((event) => {
const config = clone(event)
this.$set(config, 'id', null)
this.$set(config, 'activityId', null)
this.$set(config, 'unionLimit', this.reuseArray(config.unionLimit))
this.$set(config, 'ageDate', config.startAgeDate ? [config.startAgeDate, config.endAgeDate] : [])
return config
})
;['id', 'foundDate', 'applyStartTime', 'applyEndTime', 'startTime', 'endTime'].forEach((key) => this.$set(form, key, null))
this.$set(form, 'schoolEvents', [])
this.$set(form, 'close', false)
this.$set(form, 'activityCode', responses[1].data)
this.$set(form, 'activityLevel', Number(form.activityLevel))
this.$set(form, 'activityGroupId', form.activityGroupId ? Number(form.activityGroupId) : null)
this.$set(form, 'applyTime', [])
this.$set(form, 'time', [])
this.$set(form, 'eventsIds', availableIds)
this.$set(this, 'events', events)
this.$set(this, 'clubOptions', responses[2].data || [])
this.$set(this, 'form', form)
this.$set(this, 'eventsIds', [])
this.$set(this, 'checkedEventInfo', configs)
this.$set(this, 'checkedEventInfo2', clone(configs))
this.$set(this, 'eventForm', {})
this.$set(this, 'checkedEvents', [])
this.$set(this, 'rightChecked', [])
this.$set(this, 'reuseReady', true)
this.$nextTick(() => {
this.initEditor()
if (this.$refs.activityForm) this.$refs.activityForm.clearValidate()
})
})
}).fail(() => {
if (requestId === this.reuseRequestId) {
this.$message.error('沿用活动加载失败,请重新选择活动')
}
}).always(() => {
if (requestId === this.reuseRequestId) this.$set(this, 'reuseLoading', false)
})
},
// 合并当前所选项目与已沿用配置;新增选择使用原有默认值,已移除项目不再提交。
buildReuseEvents() {
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,
athletesMaxNum: event.projectType === '1' ? 3 : null,
restrictRegNumber: event.projectType === '1' ? 2 : null,
restrictTotalTeam: 1, substituteNum: 0, applyUserModel: 1
}
this.$set(config, 'id', null)
this.$set(config, 'activityId', null)
this.$set(config, 'startAgeDate', config.ageDate && config.ageDate.length ? config.ageDate[0] : null)
this.$set(config, 'endAgeDate', config.ageDate && config.ageDate.length ? config.ageDate[1] : null)
return config
})
},
// isSave 区分保存草稿和提交;草稿跳过字段校验,提交仍校验报名、活动及项目配置。
doReuseAdd(isSave) {
if (this.formLoading || this.reuseLoading) return
if (!this.reuseReady) {
this.$message.warning('请重新选择并加载沿用活动')
return
}
const save = () => {
const form = clone(this.form)
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 ? 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: 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())
})
// 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)
this.$emit('flip')
}, () => {
this.$message.error('请求失败,请检查活动列表后重试')
})
}
if (isSave) {
if (this.$refs.activityForm) this.$refs.activityForm.clearValidate()
return save()
}
if (this.$refs.activityForm) {
this.$refs.activityForm.validate((valid) => {
if (valid) save()
})
} else {
return save()
}
},
async applyUserModelInput(val) {
if (val === 2) {
if (!this.eventForm.unionLimit || this.eventForm.unionLimit.length === 0) {
const resp = await $.get(loc() + '/getUnionLimit', {activityScopeId: this.eventForm.activityGroupId})
if (resp.code === 0) {
this.$set(this.eventForm, 'unionLimit', resp.data)
}
}
this.summaryCount = this.eventForm.unionLimit.reduce((prev, curr) => {
const value = Number(curr.limitCount);
if (!isNaN(value)) {
return prev + curr.limitCount;
} else {
return prev;
}
}, 0)
}
},
calSummaryCount() {
const array = this.eventForm.unionLimit
if (array) {
this.summaryCount = array.reduce((prev, curr) => {
const value = Number(curr.limitCount);
if (!isNaN(value)) {
return prev + curr.limitCount;
} else {
return prev;
}
}, 0)
}
},
//应用比例设置
applyScaleSettings() {
this.eventForm.unionLimit.forEach(v => {
v.limitCount = parseFloat((v.teacherCount * this.unionUserNumOneKeyRatio / 100).toFixed(0))
if (v.ratio) {
v.limitCount = parseFloat((v.teacherCount * v.ratio / 100).toFixed(0))
}
})
this.calSummaryCount()
},
unionLimitQuickSetting() {
console.log(1111111111)
this.unionUserNumCalc.forEach((v, i) => {
const startNum = v.startNum
const endNum = v.endNum
const resultNum = v.resultNum
if (startNum > endNum) {
this.$message.warning('第' + (i + 1) + '行设置错误')
} else {
this.eventForm.unionLimit.forEach(x => {
if (x.teacherCount >= startNum && x.teacherCount <= endNum) {
x.limitCount = resultNum
}
})
this.calSummaryCount()
}
})
},
async clearUnionLimit() {
const confirm = await this.$confirm('确定要清空部门工会人数限制吗, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
if ('confirm' === confirm) {
this.eventForm.unionLimit = []
this.unionUserNumOneKeyRatio = null
this.unionUserNumCalc = [{}]
await this.applyUserModelInput(2)
}
},
ageDateChange() {
this.$set(this.eventForm, "startAgeDate", null)
this.$set(this.eventForm, "endAgeDate", null)
},
async doAssignmentDate() {
await this.saveEvent()
const form = clone(this.form)
const loading = this.$loading({
lock: true,
text: '正在提交...',
spinner: 'el-icon-loading',
background: COVER_LAYER_COLOR
});
const resp = await $.post(loc() + "/doAssignmentDate", {
eventIds: JSON.stringify(this.checkedEventInfo.map(v => v.id)),
events: JSON.stringify(this.checkedEventInfo)
})
closeLoadingFunc(loading, resp, async (data) => {
await this.openEdit(this.form, false)
}, (data, msg) => {
this.$message.error(msg);
})
},
filterMethod(query, item) {
return item.allName.indexOf(query) > -1;
},
rightChange(v) {
},
rightCheckChange(v, v2) {
this.rightChecked = v
},
/* async eventRemoveTag(val) {
this.$confirm('确定要删除该活动吗?', '提示', {
type: 'warning'
}).then(async () => {
const {data} = await $.get(loc() + "/getEventApply", {activityId: this.form.id, eventId: val})
if (data > 0) {
}
}).catch(() => {
this.form.eventsIds.push(val)
console.log(this.form.eventsIds)
});
},*/
async applyTypeChange(applyType) {
this.form.eventsIds = []
if (applyType === 1) {
this.events = await activity.getEvents(1)
} else if (applyType === 2) {
this.events = await activity.getEvents(2)
} else {
this.events = await activity.getEvents(3)
}
},
initCheckedEventInfo() {
this.checkedEventInfo = this.checkedEvents.map(v => {
v.eventId = v.id
if (v.projectType === '1') {
v.athletesMaxNum = 3
v.restrictRegNumber = 2
v.leanderNum = 0
v.coachNum = 0
v.applyUserModel = 1
} else if (v.projectType === '2') {
v.leanderNum = 0
v.coachNum = 0
v.restrictTotalTeam = 1
}
return v
})
},
applyWayChange() {
this.$nextTick(() => {
this.initEditor()
})
},
async eventChange(val) {
const data = this.checkedEventInfo.find(v => v.eventId === val)
const resp = await $.get("/platform/activity/school/info/mange/getEventData", {id: val})
await this.$nextTick()
if (data) {
data.applyUserModel = data.applyUserModel ? data.applyUserModel : 1
this.eventForm = clone(data)
this.projectType = data.projectType
} else {
this.eventForm = {
projectType: resp.data.projectType,
leanderNum: 0,
coachNum: 0,
athletesMaxNum: resp.data.projectType == 1 ? 3 : null,
restrictTotalTeam: 1,
substituteNum: 0,
restrictRegNumber: resp.data.projectType == 1 ? 2 : null,
isLeader: false,
applyUserModel: 1
}
this.projectType = resp.data.projectType
}
this.$set(this.eventForm, "checkedEventId", val)
},
async saveEvent() {
const data = clone(this.eventForm)
if (data.checkedEventId === 'allItems') {
this.checkedEventInfo.forEach(v => {
if (v.projectType === '1') {
v.applyUserModel = this.eventForm.applyUserModel
v.athletesMaxNum = data.athletesMaxNum
v.restrictRegNumber = data.restrictRegNumber
v.unionLimit = data.unionLimit
}
})
} else {
const info = this.checkedEventInfo.find(v => v.eventId === data.checkedEventId)
if (info != null) {
const index = this.checkedEventInfo.findIndex(v => v.eventId === data.checkedEventId)
this.checkedEventInfo.splice(index, 1)
if (info.projectType === '1') {
this.$set(this.eventForm, "athletesMaxNum", data.athletesMaxNum)
this.$set(this.eventForm, "restrictRegNumber", data.restrictRegNumber)
}
this.$set(this.eventForm, "checkedEventId", info.eventId)
}
data.eventId = data.checkedEventId
this.checkedEventInfo.push(data)
}
await this.doSave()
}
,
prev() {
this.active--
this.$nextTick(() => {
this.initEditor()
})
},
getArrDifference(arr1, arr2) {
return arr1.concat(arr2).filter(function (v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});
},
next() {
if (this.reuseLoading || this.formLoading) return
if (this.reuseActivityId && !this.reuseReady) {
this.$message.warning('请重新选择并加载沿用活动')
return
}
this.$refs["activityForm"].validate(async (valid) => {
const form = clone(this.form)
if (!valid) {
this.$notify.warning({title: '警告', message: '存在未填的必填项'});
return
}
const arrDifference = this.getArrDifference(this.form.unitJointly, this.form.unitSponsor);
if (arrDifference.length === 0) {
this.$notify.error({title: '错误', message: '协办单位里存在主办单位'});
return
}
// 活动时间可在保存草稿后补填;已填写时仍需晚于报名开始时间。
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
}
if (form.applyWay.includes(3) && !form.image) {
this.$notify.error({title: '错误', message: '请上传小程序活动封面图'});
return
}
if (this.form.eventsIds.length === 0) {
this.$notify.error({title: '错误', message: '请选择项目'});
return
}
this.checkedEvents = this.events.filter(v => this.form.eventsIds.some(x => x === v.id))
if (this.form.applyType === 2 && !this.checkedEvents.find(v => v.id === "allItems")) {
const data = this.checkedEventInfo2.find(v => v.projectType === '1')
const item = {
id: "allItems",
eventId: "allItems",
allName: "所有单项",
projectType: "1",
applyUserModel: 1,
athletesMaxNum: data ? data.athletesMaxNum : 3,
restrictRegNumber: data ? data.restrictRegNumber : 2,
}
this.checkedEventInfo.unshift(item)
this.checkedEvents.unshift(item)
}
this.eventForm.checkedEventId = this.checkedEvents[0].id
this.projectType = this.checkedEvents[0].projectType
if (this.reuseActivityId && !form.id) {
// 新活动也保留沿用配置,不能因尚无活动ID而恢复为默认人数。
const allItems = this.checkedEventInfo.find((event) => event.eventId === 'allItems')
const configs = this.buildReuseEvents()
if (allItems) configs.unshift(clone(allItems))
this.$set(this, 'checkedEventInfo', configs)
} else if (!form.id || this.checkedEventInfo2.length <= 0) {
this.eventForm = {
checkedEventId: this.checkedEvents[0].id,
leanderNum: 0,
coachNum: 0,
athletesMaxNum: 3,
substituteNum: 0
}
this.initCheckedEventInfo()
}
this.eventChange(this.checkedEvents[0].id)
this.active++
})
}
,
async activityLevelChange() {
this.form.planId = null
this.planList = await activity.getSchoolActivityPlan(this.form.activityLevel)
const data = await this.getActivityCode(this.form.activityLevel)
this.$set(this.form, "activityCode", data)
if (this.form.activityLevel !== 40001) {
this.$set(this.form, "applyWay", [1])
this.$set(this.form, "applyType", 1)
} else {
this.$set(this.form, "applyWay", [2])
}
if (this.form.activityLevel === 40003 || (this.form.activityLevel === 40001 && this.is_club)) {
this.clubOptions = await getClubsByRole()
if (this.clubOptions && this.clubOptions.length > 0) {
this.$set(this.form, "belongClubId", this.clubOptions[0].stid)
}
}
await this.applyTypeChange(this.form.applyType)
this.$forceUpdate();
}
,
async openAdd() {
this.reuseRequestId++
this.$set(this, 'reuseLoading', false)
this.$set(this, 'reuseReady', false)
this.$set(this, 'reuseActivityId', null)
this.$set(this, 'checkedEventInfo', [])
this.$set(this, 'checkedEventInfo2', [])
this.$set(this, 'eventsIds', [])
this.getReuseActivityOptions()
this.events = await activity.getEvents(2)
this.planList = await activity.getSchoolActivityPlan(this.form.activityLevel)
await this.getActivityGroup()
this.active = 0
this.eventForm = {}
this.$nextTick(async () => {
if (this.$refs['activityForm']) {
this.$refs['activityForm'].resetFields()
}
this.initEditor()
const data = await this.getActivityCode(40001)
this.form = {
planId: '',
gameStyle: 1,
applyWay: [2],
eventsIds: [],
unitJointly: [],
undertakeUnit: [],
applyType: 2,
activityCode: data,
activityLevel: 40001,
}
await this.activityLevelChange()
})
},
async getActivityCode(activity_type) {
const {data} = await $.get('/platform/activity/apply/generateActivityCode', {activity_type: activity_type})
return data;
},
async openEdit(row, flag) {
this.reuseRequestId++
this.$set(this, 'reuseLoading', false)
this.$set(this, 'reuseActivityId', null)
this.active = flag ? 0 : this.active
await this.applyTypeChange(row.applyType)
this.planList = await activity.getSchoolActivityPlan(1)
await this.getActivityGroup()
const {id} = row
this.$set(row, "loading", true)
const resp = await $.get("/platform/activity/school/info/mange/findOne", {id})
requestLaterFun(resp, async (v) => {
this.$set(row, "loading", false)
this.clubOptions = await getClubsByRole()
this.eventsIds = clone(JSON.parse(v.eventsIds))
v.applyTime = [v.applyStartTime, v.applyEndTime]
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)
v.undertakeUnit = this.reuseArray(v.undertakeUnit)
v.unitJointly = JSON.parse(v.unitJointly)
v.activityGroupId = parseInt(v.activityGroupId)
v.activityLevel = parseInt(v.activityLevel)
if (v.image && v.image.length > 0) v.image = JSON.parse(v.image)
this.form = clone(v)
this.checkedEventInfo = clone(v.schoolEvents)
this.checkedEventInfo2 = v.schoolEvents
this.checkedEventInfo.map(v => {
if (v.unionLimit) {
v.unionLimit = JSON.parse(v.unionLimit)
}
if (v.startAgeDate) {
this.$set(v, "ageDate", [v.startAgeDate, v.endAgeDate])
this.$set(this.eventForm, "ageDate", [v.startAgeDate, v.endAgeDate])
}
})
const data = v.schoolEvents.find(v => v.projectType === '1')
if (this.form.applyType === 2 && !v.schoolEvents.some(v => v.eventId === "allItems")) {
const item = {
id: "allItems",
eventId: "allItems",
allName: "所有单项",
projectType: "1",
athletesMaxNum: data ? data.athletesMaxNum : 3,
restrictRegNumber: data ? data.restrictRegNumber : 2,
}
this.checkedEventInfo.unshift(item)
}
this.$nextTick(async () => {
this.initEditor()
})
})
},
async doOperate() {
const method = this.form.id ? "/doEdit" : "/doAdd"
const form = clone(this.form)
const events = clone(this.checkedEventInfo)
form.restrictMaxNum = form.leanderNum + form.coachNum + form.athletesMaxNum + form.substituteNum
form.restrictMinNum = form.athletesMaxNum
form.isSave = false
this.examineTrans(form)
const loading = this.$loading({
lock: true,
text: '正在提交...',
spinner: 'el-icon-loading',
background: COVER_LAYER_COLOR
});
const resp = await $.post(base + "/platform/activity/school/info/mange" + method, {
data: JSON.stringify(form),
events: JSON.stringify(events)
})
closeLoadingFunc(loading, resp, async () => {
this.$emit('flip')
window.location.reload();
}, (data, msg) => {
this.$notify.error({title: '错误', message: msg});
})
}
,
async operate() {
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,
eventId: JSON.stringify(deleteEventIds)
})
if (data.length > 0) {
this.$confirm(data.map(v => v.allname).join(",") + '项目下有报名人员是否要删除?', '提示', {
type: 'warning'
}).then(async () => {
await this.doOperate()
}).catch(() => {
});
} else {
await this.doOperate()
}
},
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"
this.checkedEventInfo.forEach(v => {
if (this.eventForm.projectType === '1' && this.eventForm.eventId === 'eventId') {
v.athletesMaxNum = this.checkedEventInfo[0].athletesMaxNum
v.restrictRegNumber = this.checkedEventInfo[0].restrictRegNumber
}
if (v.ageDate && v.ageDate.length > 0) {
v.startAgeDate = v.ageDate[0]
v.endAgeDate = v.ageDate[1]
} else {
v.startAgeDate = null
v.endAgeDate = null
}
})
let events = clone(this.checkedEventInfo)
const form = clone(this.form)
form.restrictMaxNum = form.leanderNum + form.coachNum + form.athletesMaxNum + form.substituteNum
form.restrictMinNum = form.athletesMaxNum
form.isSave = 1
const {time, applyTime} = form
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 === 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 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) {
this.$set(this.eventForm, "startAgeDate", this.eventForm.ageDate[0])
this.$set(this.eventForm, "endAgeDate", this.eventForm.ageDate[1])
}
events = this.eventForm
}
this.$set(this, 'formLoading', true)
const loading = this.$loading({
lock: true,
text: '正在保存...',
spinner: 'el-icon-loading',
background: COVER_LAYER_COLOR
});
return $.post("/platform/activity/school/info/mange" + url, {
data: JSON.stringify(form),
events: JSON.stringify(events)
}).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) {
const {unitJointly, unitSponsor, time, applyTime, applyWay, image} = form
const arrDifference = this.getArrDifference(unitJointly, unitSponsor);
if (arrDifference.length === 0) {
this.$notify.error({title: '错误', message: '协办单位里存在主办单位'});
return
}
if (moment(time[0]).valueOf() <= moment(applyTime[0]).valueOf()) {
this.$notify.error({title: '错误', message: '活动时间必须晚于报名时间'});
return
}
if (applyWay.includes(3) && !image) {
this.$notify.error({title: '错误', message: '请上传小程序活动封面图'});
return
}
if (applyTime && applyTime.length) {
form.applyStartTime = applyTime[0]
form.applyEndTime = applyTime[1]
form.applyTime = undefined
}
if (time && time.length) {
form.startTime = time[0]
form.endTime = time[1]
form.time = undefined
}
},
initEditor() {
let keys = ['athleteQualification', 'registrationMethod', 'competitionMethod', 'rewardMethod', 'precautions', 'eventNotification']
keys.forEach(key => {
$("#" + key).html("")
editors[key] = new E('#' + key)
editors[key].config.onchange = (html) => {
this.form[key] = html
}
editors[key].create()
if (this.form[key]) {
editors[key].txt.html(this.form[key])
}
})
},
isLeaderChange() {
this.$set(this.eventForm, "leanderNum", 1)
this.$set(this.eventForm, "coachNum", 0)
this.$set(this.eventForm, "substituteNum", 0)
this.$set(this.eventForm, "athletesMaxNum", 0)
this.$set(this.eventForm, "restrictBoyNum", 0)
this.$set(this.eventForm, "restrictGirlNum", 0)
},
async getActivityGroup() {
const {data} = await $.get('/platform/activity/basic/scope/getActivityUserScopeGroup')
this.activityGroupList = data
},
async initCnd() {
const userState = await getDictByCode('userState')
const personType = await getDictByCode('personType')
const userStateOptions = userState.map(v => {
return {label: v.name, value: v.name}
})
const personTypeOptions = personType.map(v => {
return {label: v.name, value: v.name}
})
this.fields = [
{
label: '性别',
value: 'sex',
type: "select",
options: [{label: '男', value: '男'}, {label: '女', value: '女'}]
},
{label: '在职状态', value: 'userState', type: "select", options: userStateOptions},
{label: '人员类型', value: 'personType', type: "select", options: personTypeOptions},
]
},
},
async created() {
await this.initCnd()
const clubs = await getClubs()
const units = await getUnits(null)
this.unitOptions = clubs.concat(units)
}
}
</script>
<style>
.el-transfer {
display: flex;
align-items: center;
}
.el-transfer-panel {
width: unset !important;
flex: 2 !important;
}
.el-transfer-panel__body {
}
.el-transfer__buttons {
flex: 1 !important;
text-align: center;
}
#athleteQualification > div {
z-index: 1 !important;
}
.act_event .el-select__tags .el-tag {
color: #409eff;
}
.act_event .el-select__tags .el-tag.el-tag--info .el-tag__close {
color: red;
background-color: #ffffff;
}
.isLeaderColor .el-form-item__label {
color: white;
}
.restrictTotalTeam .el-form-item__label {
color: red;
}
</style>