|
@@ -0,0 +1,367 @@
|
|
|
+<template>
|
|
|
+ <div class="edit-contest">
|
|
|
+ <Form :model="signInfo" :label-width="80" ref="signInfo" :rules="editDataRule">
|
|
|
+ <FormItem label="报名人数">
|
|
|
+ <InputNumber :min="limitMin" v-model="signInfo.limit" />
|
|
|
+ <span>
|
|
|
+ <Icon type="md-alert" color="#ffad16" size="17" />
|
|
|
+ 0:默认不限制
|
|
|
+ </span>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="报名时间" prop="signEtime">
|
|
|
+ <DatePicker v-model="actAllTime[0]" :editable="false" @on-change="data => getCreateTime(data, 0)" type="datetimerange" :options="beforeToday" format="yyyy-MM-dd HH:mm" :placeholder="$t('train.create.timeHolder')" style="width: 500px"></DatePicker>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ <template v-if="conModules.includes('upload')">
|
|
|
+ <Form :model="uploadInfo" :label-width="80" ref="uploadInfo" :rules="editDataRule">
|
|
|
+ <FormItem label="上传时间" prop="uploadEtime">
|
|
|
+ <DatePicker v-model="actAllTime[1]" ref="workPicker" :editable="false" @on-change="data => getCreateTime(data, 1)" type="datetimerange" :options="beforeToday" format="yyyy-MM-dd HH:mm" :placeholder="$t('train.create.timeHolder')" style="width: 500px"></DatePicker>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="文件类型" v-if="uploadInfo?.fileType" prop="fileType">
|
|
|
+ <div class="tab-check">
|
|
|
+ <div v-for="(item, index) in fileType" :key="index" class="file-box">
|
|
|
+ <Checkbox v-model="item.isCheck">
|
|
|
+ {{ item.label }}
|
|
|
+ </Checkbox>
|
|
|
+ <div v-if="item.isCheck">
|
|
|
+ <Select v-model="formatType[index]" multiple size="small" style="width: 400px" placeholder="不限格式">
|
|
|
+ <Option v-for="(format, index) in item.format" :value="format" :key="index">{{ format }}</Option>
|
|
|
+ </Select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="文件说明">
|
|
|
+ <Input v-special-char type="textarea" v-model="uploadInfo.updateDesc" placeholder="请输入作品要求..." />
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ </template>
|
|
|
+ <template v-if="conModules.includes('review')">
|
|
|
+ <Form :model="reviewInfo" :label-width="80" ref="reviewInfo" :rules="editDataRule">
|
|
|
+ <FormItem label="评审时间" prop="reviewEtime">
|
|
|
+ <DatePicker v-model="actAllTime[2]" ref="reviewPicker" :editable="false" @on-change="data => getCreateTime(data, 2)" type="datetimerange" :options="beforeToday" format="yyyy-MM-dd HH:mm" :placeholder="$t('train.create.timeHolder')" style="width: 500px"></DatePicker>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ </template>
|
|
|
+ <template v-if="conModules.includes('score')">
|
|
|
+ <Form :model="scoreInfo" :label-width="80" ref="scoreInfo" :rules="editDataRule">
|
|
|
+ <FormItem label="公示时间" prop="scoreEtime">
|
|
|
+ <DatePicker v-model="actAllTime[3]" ref="scorePicker" :editable="false" @on-change="data => getCreateTime(data, 3)" type="datetimerange" :options="beforeToday" format="yyyy-MM-dd HH:mm" :placeholder="$t('train.create.timeHolder')" style="width: 500px"></DatePicker>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ </template>
|
|
|
+ <Button type="success" long @click="saveInfo()">保存</Button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ actInfo: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ contestInfo: {
|
|
|
+ type: Object,
|
|
|
+ defualt: () => {
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editModal: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ const validateFileType = (rule, value, callback) => {
|
|
|
+ if(this.fileType.find(item => item.isCheck)) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('Please enter your password'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const validateDate = (rule, value, callback) => {
|
|
|
+ console.log(rule, value);
|
|
|
+ if(value != '' && value != null && value != undefined) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请选择时间'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ signInfo: {},
|
|
|
+ uploadInfo: {},
|
|
|
+ reviewInfo: {},
|
|
|
+ scoreInfo: {},
|
|
|
+ actAllTime: [[], [], [], []],
|
|
|
+ editDataRule: {
|
|
|
+ signEtime: [{ required: true, type: 'number', message: '请选择活动时间', trigger: 'blur', validator: validateDate }],
|
|
|
+ uploadEtime: [{ required: true, type: 'number', message: '请选择活动时间', trigger: 'blur', validator: validateDate }],
|
|
|
+ reviewEtime: [{ required: true, type: 'number', message: '请选择活动时间', trigger: 'blur', validator: validateDate }],
|
|
|
+ scoreEtime: [{ required: true, type: 'number', message: '请选择活动时间', trigger: 'blur', validator: validateDate }],
|
|
|
+ fileType: [{ required: true, message: '请选择填报信息', trigger: 'blur', validator: validateFileType }],
|
|
|
+ },
|
|
|
+ fileType: [
|
|
|
+ {
|
|
|
+ value: 'documentType',
|
|
|
+ label: '文档类',
|
|
|
+ isCheck: false,
|
|
|
+ format: ['doc', 'docx', 'txt', 'ppt', 'pptx', 'xls', 'xlsx', 'pdf']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'audio',
|
|
|
+ label: '音频类',
|
|
|
+ isCheck: false,
|
|
|
+ format: ['mp3', 'wav', 'wma']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'video',
|
|
|
+ label: '视频类',
|
|
|
+ isCheck: false,
|
|
|
+ format: ['mp4', 'webm']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'img',
|
|
|
+ label: '图片类',
|
|
|
+ isCheck: false,
|
|
|
+ format: ['jpg', 'jpeg', 'png', 'gif']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'winrar',
|
|
|
+ label: '压缩包类',
|
|
|
+ isCheck: false,
|
|
|
+ format: ['zip', 'rar', '7zip']
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ formatType: [[], [], [], [], []],
|
|
|
+ beforeToday: {},
|
|
|
+ conModules: [],
|
|
|
+ limitMin: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ editModal: {
|
|
|
+ handler(n, o) {
|
|
|
+ if(n) {
|
|
|
+ this.conModules = this.contestInfo.modules
|
|
|
+ this.signInfo = {
|
|
|
+ signStime: this.contestInfo.sign.stime,
|
|
|
+ signEtime: this.contestInfo.sign.etime,
|
|
|
+ limit: this.contestInfo.sign.limit,
|
|
|
+ }
|
|
|
+ this.actAllTime = [[], [], [], []]
|
|
|
+ this.actAllTime[0].push(this.$tools.formatTime(this.contestInfo.sign.stime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ this.actAllTime[0].push(this.$tools.formatTime(this.contestInfo.sign.etime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ if(this.contestInfo.modules.includes('upload')) {
|
|
|
+ this.uploadInfo = {
|
|
|
+ uploadStime: this.contestInfo.upload.stime,
|
|
|
+ uploadEtime: this.contestInfo.upload.etime,
|
|
|
+ updateDesc: this.contestInfo.upload.desc,
|
|
|
+ }
|
|
|
+ if(this.contestInfo.upload.type === 'file') {
|
|
|
+ this.uploadInfo.fileType = this._.cloneDeep(this.contestInfo.upload.fileType)
|
|
|
+ this.uploadInfo.fileType.forEach(item => {
|
|
|
+ this.fileType.forEach((file, index) => {
|
|
|
+ if(file.format.includes(item)) {
|
|
|
+ file.isCheck = true
|
|
|
+ this.formatType[index].push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.formatType = this.formatType.map((item, index) => {
|
|
|
+ item = item.length === this.fileType[index].format.length ? [] : item
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.actAllTime[1].push(this.$tools.formatTime(this.contestInfo.upload.stime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ this.actAllTime[1].push(this.$tools.formatTime(this.contestInfo.upload.etime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ }
|
|
|
+ if(this.contestInfo.modules.includes('review')) {
|
|
|
+ this.reviewInfo = {
|
|
|
+ reviewStime: this.contestInfo.review.stime,
|
|
|
+ reviewEtime: this.contestInfo.review.etime
|
|
|
+ }
|
|
|
+ this.actAllTime[2].push(this.$tools.formatTime(this.contestInfo.review.stime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ this.actAllTime[2].push(this.$tools.formatTime(this.contestInfo.review.etime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ }
|
|
|
+ if(this.contestInfo.modules.includes('score')) {
|
|
|
+ this.scoreInfo = {
|
|
|
+ scoreStime: this.contestInfo.score.stime,
|
|
|
+ scoreEtime: this.contestInfo.score.etime
|
|
|
+ }
|
|
|
+ this.actAllTime[3].push(this.$tools.formatTime(this.contestInfo.score.stime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ this.actAllTime[3].push(this.$tools.formatTime(this.contestInfo.score.etime, 'yyyy-MM-dd hh:mm'))
|
|
|
+ }
|
|
|
+ // 处理时间显示
|
|
|
+ let that = this
|
|
|
+ this.beforeToday = {
|
|
|
+ disabledDate (date) {
|
|
|
+ return (date && date.valueOf() < that.actInfo.stime) || (date && date.valueOf() > that.actInfo.etime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 'signInfo.signStime': {
|
|
|
+ handler(n, o) {
|
|
|
+ /* if(this.conModules.includes('upload')) this.$refs.workPicker.handleClear()
|
|
|
+ if(this.conModules.includes('review')) this.$refs.reviewPicker.handleClear()
|
|
|
+ if(this.conModules.includes('score')) this.$refs.scorePicker.handleClear()
|
|
|
+ this.actAllTime = [[], [], [], []] */
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getCreateTime(data, index) {
|
|
|
+ console.log(data);
|
|
|
+ let times = data.filter(item => {
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ this.signInfo.signStime = times.length > 1 ? (new Date(times[0])).getTime() : null
|
|
|
+ this.signInfo.signEtime = times.length > 1 ? (new Date(times[1])).getTime() : null
|
|
|
+ this.actAllTime = [[], [], [], []]
|
|
|
+ this.actAllTime[0] = times
|
|
|
+ break
|
|
|
+ case 1:
|
|
|
+ if(times.length > 1 && !this.signInfo.signEtime) {
|
|
|
+ // this.$refs.workPicker.handleClear()
|
|
|
+ this.$Message.warning('请先设置报名时间')
|
|
|
+ this.actAllTime.splice(1, 1, [])
|
|
|
+ }
|
|
|
+ if(times.length > 1 && (new Date(times[1])).getTime() < this.signInfo.signEtime) {
|
|
|
+ this.$Message.warning('上传结束时间不能早于报名时间')
|
|
|
+ this.actAllTime.splice(1, 1, [])
|
|
|
+ }
|
|
|
+ this.uploadInfo.uploadStime = times.length > 1 ? (new Date(times[0])).getTime() : null
|
|
|
+ this.uploadInfo.uploadEtime = times.length > 1 ? (new Date(times[1])).getTime() : null
|
|
|
+
|
|
|
+ this.actAllTime.splice(2, 1, [])
|
|
|
+ this.actAllTime.splice(3, 1, [])
|
|
|
+ break
|
|
|
+ case 2:
|
|
|
+ if(times.length > 1 && (!this.signInfo.signEtime || !this.uploadInfo.uploadEtime)) {
|
|
|
+ this.$Message.warning('请先设置报名时间、上传时间')
|
|
|
+ this.actAllTime.splice(2, 1, [])
|
|
|
+ }
|
|
|
+ if(times.length > 1 && (new Date(times[0])).getTime() < this.signInfo.signEtime || (new Date(times[0])).getTime() < this.uploadInfo.uploadEtime) {
|
|
|
+ this.$Message.warning('评审必须在报名、上传结束后进行')
|
|
|
+ this.actAllTime.splice(2, 1, [])
|
|
|
+ }
|
|
|
+ this.reviewInfo.reviewStime = times.length > 1 ? (new Date(times[0])).getTime() : null
|
|
|
+ this.reviewInfo.reviewEtime = times.length > 1 ? (new Date(times[1])).getTime() : null
|
|
|
+ this.actAllTime.splice(3, 1, [])
|
|
|
+ break
|
|
|
+ case 3:
|
|
|
+ if(times.length > 1 && !this.reviewInfo.reviewEtime) {
|
|
|
+ this.$Message.warning('请先设置评审时间')
|
|
|
+ this.actAllTime.splice(3, 1, [])
|
|
|
+ }
|
|
|
+ if(times.length > 1 && (new Date(times[0])).getTime() < this.reviewInfo.reviewEtime) {
|
|
|
+ this.$Message.warning('公示必须在评审结束后进行')
|
|
|
+ this.actAllTime.splice(3, 1, [])
|
|
|
+ }
|
|
|
+ this.scoreInfo.scoreStime = times.length > 1 ? (new Date(times[0])).getTime() : null
|
|
|
+ this.scoreInfo.scoreEtime = times.length > 1 ? (new Date(times[1])).getTime() : null
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ },
|
|
|
+ saveInfo() {
|
|
|
+ let saving = true
|
|
|
+ this.$refs['signInfo'].validate((valid) => {
|
|
|
+ console.log(valid);
|
|
|
+ if (!valid) {
|
|
|
+ saving = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs['uploadInfo'].validate((valid) => {
|
|
|
+ console.log(valid);
|
|
|
+ if (!valid) {
|
|
|
+ saving = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs['reviewInfo'].validate((valid) => {
|
|
|
+ console.log(valid);
|
|
|
+ if (!valid) {
|
|
|
+ saving = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs['scoreInfo'].validate((valid) => {
|
|
|
+ console.log(valid);
|
|
|
+ if (!valid) {
|
|
|
+ saving = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(!saving) {
|
|
|
+ this.$Message.error('请完善信息!');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let params = {
|
|
|
+ grant_type: 'update-contest-base',
|
|
|
+ activityId: this.actInfo.id,
|
|
|
+ contestUpdate: {}
|
|
|
+ }
|
|
|
+ params.contestUpdate = {
|
|
|
+ signStime: this.signInfo.signStime,
|
|
|
+ signEtime: this.signInfo.signEtime,
|
|
|
+ signStime: this.signInfo.signStime,
|
|
|
+ limit: this.signInfo.limit,
|
|
|
+ uploadStime: this.uploadInfo.uploadStime,
|
|
|
+ uploadEtime: this.uploadInfo.uploadEtime,
|
|
|
+ updateDesc: this.uploadInfo.updateDesc,
|
|
|
+ }
|
|
|
+ if(this.contestInfo.upload.type === 'file') {
|
|
|
+ params.contestUpdate.fileType = []
|
|
|
+ this.fileType.forEach((item, index) => {
|
|
|
+ if(item.isCheck) {
|
|
|
+ if(this.formatType[index].length) {
|
|
|
+ params.contestUpdate.fileType = params.contestUpdate.fileType.concat(this.formatType[index])
|
|
|
+ } else {
|
|
|
+ params.contestUpdate.fileType = params.contestUpdate.fileType.concat(item.format)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(this.conModules.includes('review')) {
|
|
|
+ params.contestUpdate.reviewStime = this.reviewInfo.reviewStime
|
|
|
+ params.contestUpdate.reviewEtime = this.reviewInfo.reviewEtime
|
|
|
+ }
|
|
|
+ if(this.conModules.includes('score')) {
|
|
|
+ params.contestUpdate.scoreStime = this.scoreInfo.scoreStime
|
|
|
+ params.contestUpdate.scoreEtime = this.scoreInfo.scoreEtime
|
|
|
+ }
|
|
|
+ this.$api.areaActivity.manageAct(params).then(res => {
|
|
|
+ if(res.code === 200) {
|
|
|
+ this.$Message.success("保存成功")
|
|
|
+ this.$emit('saveContest', res?.activity)
|
|
|
+ } else {
|
|
|
+ this.$Message.warning("保存失败")
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ // this.isLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.edit-contest {
|
|
|
+
|
|
|
+ .tab-check {
|
|
|
+ margin-bottom: 15px;
|
|
|
+ .file-box {
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ &>label {
|
|
|
+ width: 100px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|