diff --git a/src/views/modules/heart/actinfo-add-or-update.vue b/src/views/modules/heart/actinfo-add-or-update.vue index ea352ae2..c9a11e3f 100644 --- a/src/views/modules/heart/actinfo-add-or-update.vue +++ b/src/views/modules/heart/actinfo-add-or-update.vue @@ -289,12 +289,12 @@ export default { return { visible: false, dataForm: { - id:"", + id: '', title: '', headPic: '', signupStartTime: '', signupEndTime: '', - actQuotaCategory:'1', + actQuotaCategory: '1', actStartTime: '', actEndTime: '', actAddress: '', @@ -317,88 +317,87 @@ export default { deptId: '', punishmentPoints: '', reward: '', - isBanner:"1", + isBanner: '1', actUserDefaultState: '1', - bannerUrl:"" + bannerUrl: '' }, - isSignupEndTime: { - disabledDate(time) { - return time < Date.now() - 8.64e7;//8.64e7=1000*60*60*24一天 + isSignupEndTime: { + disabledDate (time) { + return time < Date.now() - 8.64e7 // 8.64e7=1000*60*60*24一天 + } + }, + isImgRequired: true, + mapSelectVisible: false, + signInIsAble: true, + isAble: false, + loading: false, + // 富文本 + quillEditor: null, + quillEditorToolbarOptions: [ + ['bold', 'italic', 'underline', 'strike'], + ['blockquote', 'code-block', 'image'], + [{ 'header': 1 }, { 'header': 2 }], + [{ 'list': 'ordered' }, { 'list': 'bullet' }], + [{ 'script': 'sub' }, { 'script': 'super' }], + [{ 'indent': '-1' }, { 'indent': '+1' }], + [{ 'direction': 'rtl' }], + [{ 'size': ['small', false, 'large', 'huge'] }], + [{ 'header': [1, 2, 3, 4, 5, 6, false] }], + [{ 'color': [] }, { 'background': [] }], + [{ 'font': [] }], + [{ 'align': [] }], + ['clean'] + ], + uploadUrl: '', + pickerBeginDateBefore: { + disabledDate: (time) => { + let beginDateVal = this.dataForm.actStartTime + if (beginDateVal) { + return time.getTime() > new Date(beginDateVal).getTime() + } + } + }, + pickerBeginSignInDateAfter: { + disabledDate: (time) => { + let EndDateVal = this.dataForm.signinEndTime + if (EndDateVal) { + return time.getTime() < new Date(EndDateVal).getTime() } - }, - isImgRequired: true, - mapSelectVisible:false, - signInIsAble: true, - isAble: false, - loading: false, - // 富文本 - quillEditor: null, - quillEditorToolbarOptions: [ - ['bold', 'italic', 'underline', 'strike'], - ['blockquote', 'code-block', 'image'], - [{ 'header': 1 }, { 'header': 2 }], - [{ 'list': 'ordered' }, { 'list': 'bullet' }], - [{ 'script': 'sub' }, { 'script': 'super' }], - [{ 'indent': '-1' }, { 'indent': '+1' }], - [{ 'direction': 'rtl' }], - [{ 'size': ['small', false, 'large', 'huge'] }], - [{ 'header': [1, 2, 3, 4, 5, 6, false] }], - [{ 'color': [] }, { 'background': [] }], - [{ 'font': [] }], - [{ 'align': [] }], - ['clean'] - ], - uploadUrl: '', - pickerBeginDateBefore: { - disabledDate: (time) => { - let beginDateVal = this.dataForm.actStartTime - if (beginDateVal) { - return time.getTime() > new Date(beginDateVal).getTime() - } - - } - }, - pickerBeginSignInDateAfter: { - disabledDate: (time) => { - let EndDateVal = this.dataForm.signinEndTime - if (EndDateVal) { - return time.getTime() < new Date(EndDateVal).getTime() - } - } - }, - pickerBeginDateAfter: { - disabledDate: (time) => { - let EndDateVal = this.dataForm.actEndTime - if (EndDateVal) { - return time.getTime() < new Date(EndDateVal).getTime() - } - } } + }, + pickerBeginDateAfter: { + disabledDate: (time) => { + let EndDateVal = this.dataForm.actEndTime + if (EndDateVal) { + return time.getTime() < new Date(EndDateVal).getTime() + } + } + } } }, - created () { - this.$http - .get(`/sys/user/deptOptions/getByLoginUser`) - .then(({ data: res }) => { - if (res.code !== 0) { - return this.$message.error(res.msg) - } - this.options = res.data.options - }) - .catch(() => {}) - this.visible = true - this.$nextTick(() => { - // 富文本 - this.hideUpload = false - this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` - if (this.quillEditor) { - this.quillEditor.deleteText(0, this.quillEditor.getLength()) - } else { - this.quillEditorHandle() - } - // 富文本end - }) - }, + created () { + this.$http + .get(`/sys/user/deptOptions/getByLoginUser`) + .then(({ data: res }) => { + if (res.code !== 0) { + return this.$message.error(res.msg) + } + this.options = res.data.options + }) + .catch(() => {}) + this.visible = true + this.$nextTick(() => { + // 富文本 + this.hideUpload = false + this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` + if (this.quillEditor) { + this.quillEditor.deleteText(0, this.quillEditor.getLength()) + } else { + this.quillEditorHandle() + } + // 富文本end + }) + }, computed: { dataRule () { return { @@ -525,10 +524,9 @@ export default { } }, backToActList () { - this.$emit('refreshDataList') - this.$parent.selectComponent = 'ActInfoList' - this.$router.push({ path: '/heart-actinfo'}) - + this.$emit('refreshDataList') + this.$parent.selectComponent = 'ActInfoList' + this.$router.push({ path: '/heart-actinfo'}) }, init () { this.visible = true @@ -539,60 +537,60 @@ export default { } }) }, - position(position){ - if(position.type == 1 ){ - this.dataForm.actAddress = position.address; - this.dataForm.actLatitude = position.latitude; - this.dataForm.actLongitude = position.longitude; - this.dataForm.signinAddress = position.address; - this.dataForm.signinLatitude = position.latitude; - this.dataForm.signinLongitude = position.longitude; - } else { - this.dataForm.signinAddress = position.address; - this.dataForm.signinLatitude = position.latitude; - this.dataForm.signinLongitude = position.longitude; + position(position){ + if(position.type == 1 ){ + this.dataForm.actAddress = position.address + this.dataForm.actLatitude = position.latitude + this.dataForm.actLongitude = position.longitude + this.dataForm.signinAddress = position.address + this.dataForm.signinLatitude = position.latitude + this.dataForm.signinLongitude = position.longitude + } else { + this.dataForm.signinAddress = position.address + this.dataForm.signinLatitude = position.latitude + this.dataForm.signinLongitude = position.longitude + } + }, + // 富文本编辑器 + quillEditorHandle () { + this.quillEditor = new Quill('#J_quillEditor', { + modules: { + toolbar: this.quillEditorToolbarOptions + }, + theme: 'snow' + }) + this.quillEditor.container.style.height = `${300}px` + // // 自定义上传图片功能 (使用element upload组件) + this.quillEditor.getModule('toolbar').addHandler('image', () => { + this.$refs.uploadBtn.$el.click() + }) + // 监听内容变化,动态赋值 + this.quillEditor.on('text-change', () => { + this.dataForm.actContent = this.quillEditor.root.innerHTML + if ((this.dataForm.actContent).length > 10000) { + return this.$message.error('您输入的的内容已超过字数') } - }, - // 富文本编辑器 - quillEditorHandle () { - this.quillEditor = new Quill('#J_quillEditor', { - modules: { - toolbar: this.quillEditorToolbarOptions - }, - theme: 'snow' - }) - this.quillEditor.container.style.height = `${300}px` - // // 自定义上传图片功能 (使用element upload组件) - this.quillEditor.getModule('toolbar').addHandler('image', () => { - this.$refs.uploadBtn.$el.click() - }) - // 监听内容变化,动态赋值 - this.quillEditor.on('text-change', () => { - this.dataForm.actContent = this.quillEditor.root.innerHTML - if ((this.dataForm.actContent).length > 10000) { - return this.$message.error('您输入的的内容已超过字数') - } - }) - }, - // 上传图片之前 (富文本) - uploadBeforeUploadHandle (file) { - if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { - this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) - return false - } - }, - // 上传图片成功 (富文本) - uploadSuccessHandle (res, file, fileList) { - if (res.code !== 0) { - return this.$message.error(res.msg) - } - this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) - }, - setRegistTime () { - this.dataForm.newsReleaseStartTime = this.time[0] - this.dataForm.newsReleaseEndTime = this.time[1] - }, - // 上传图片ends + }) + }, + // 上传图片之前 (富文本) + uploadBeforeUploadHandle (file) { + if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { + this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) + return false + } + }, + // 上传图片成功 (富文本) + uploadSuccessHandle (res, file, fileList) { + if (res.code !== 0) { + return this.$message.error(res.msg) + } + this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.url) + }, + setRegistTime () { + this.dataForm.newsReleaseStartTime = this.time[0] + this.dataForm.newsReleaseEndTime = this.time[1] + }, + // 上传图片ends // 获取信息 getInfo () { this.$http.get(`/heart/actinfo/${this.dataForm.id}`).then(({ data: res }) => { @@ -607,30 +605,26 @@ export default { }, // 表单提交 dataFormSubmitHandle: debounce(function () { - if (this.dataForm.isActQuota == 0){ - this.dataForm.actQuota = 0 - } + if (this.dataForm.isActQuota == 0){ + this.dataForm.actQuota = 0 + } this.$refs['dataForm'].validate((valid) => { if (!valid) { return false } - var signUpEndTime = new Date(Date.parse(this.dataForm.signupEndTime)); - var actStarTime = new Date(Date.parse(this.dataForm.actStartTime)); - var actEndTime = new Date(Date.parse(this.dataForm.actEndTime)); - var signinEndTime = new Date(Date.parse(this.dataForm.signinEndTime)); - if (signUpEndTime > actStarTime) { - - return this.$message.error('活动开始时间必须大于报名截止时间。'); - } - if (actEndTime < actStarTime) { - - return this.$message.error('活动结束时间必须大于活动开始时间。'); - } - if (signinEndTime < actEndTime) { - - return this.$message.error('签到结束时间必须大于活动结束时间。'); - } - + var signUpEndTime = new Date(Date.parse(this.dataForm.signupEndTime)) + var actStarTime = new Date(Date.parse(this.dataForm.actStartTime)) + var actEndTime = new Date(Date.parse(this.dataForm.actEndTime)) + var signinEndTime = new Date(Date.parse(this.dataForm.signinEndTime)) + if (signUpEndTime > actStarTime) { + return this.$message.error('活动开始时间必须大于报名截止时间.') + } + if (actEndTime < actStarTime) { + return this.$message.error('活动结束时间必须大于活动开始时间.') + } + if (signinEndTime < actEndTime) { + return this.$message.error('签到结束时间必须大于活动结束时间.') + } this.isAble = true this.$http[!this.dataForm.id ? 'post' : 'put']('/heart/actinfo/', this.dataForm).then(({ data: res }) => { this.isAble = false @@ -647,34 +641,36 @@ export default { } }) this.$parent.selectComponent = 'ActInfoList' - this.$router.push({ path: '/heart-actinfo'}) + this.$router.push({ + path: '/heart-actinfo' + }) }).catch(() => {}) }) }, 1000, { 'leading': true, 'trailing': false }), - handleAvatarActSuccess (res, file) { - this.loading = false - this.dataForm.headPic = res.data.url - }, - handleAvatarBannerSuccess (res, file) { - this.loading = false - this.dataForm.bannerUrl = res.data.url - }, - beforeAvatarUpload (file) { - this.loading = true - }, - handelError () { - this.loading = false - }, - mapSelectHandle (type) { - this.mapSelectVisible = true - this.$nextTick(() => { - this.$refs.mapSelect.init(type,this.dataForm.clockRadius) - }) - } + handleAvatarActSuccess (res, file) { + this.loading = false + this.dataForm.headPic = res.data.url + }, + handleAvatarBannerSuccess (res, file) { + this.loading = false + this.dataForm.bannerUrl = res.data.url + }, + beforeAvatarUpload (file) { + this.loading = true + }, + handelError () { + this.loading = false + }, + mapSelectHandle (type) { + this.mapSelectVisible = true + this.$nextTick(() => { + this.$refs.mapSelect.init(type, this.dataForm.clockRadius) + }) + } }, components: { - MapSelect - } + MapSelect + } }