diff --git a/src/views/modules/events/item-deal-detail-view.vue b/src/views/modules/events/item-deal-detail-view.vue index 3dfbebdb..3bb9218f 100644 --- a/src/views/modules/events/item-deal-detail-view.vue +++ b/src/views/modules/events/item-deal-detail-view.vue @@ -150,6 +150,27 @@ show-word-limit placeholder="请您选择居民诉求的处理情况及答复意见,向居民公开展示"> + + + + + + + +
1~3张图
+
+ + + + +
1~3张图
+
@@ -244,6 +283,8 @@ import 'element-ui/lib/theme-chalk/timeline.css' import 'element-ui/lib/theme-chalk/timeline-item.css' import 'element-ui/lib/theme-chalk/image.css' import debounce from 'lodash/debounce' +import Cookies from 'js-cookie' +import 'quill/dist/quill.snow.css' export default { name: 'itemDealDetailView', data () { @@ -282,12 +323,23 @@ export default { outHandleAdvice: '', handleCategory: '', deptResultDTOS: [], - evaluateDeptDTOS: [] + evaluateDeptDTOS: [], + handleImagesPC: [], + outHandleImagesPC: [], + handleImages: [], + outHandleImages: [] }, deptResultDTOSVisible: false, evaluateDeptDTOSVisible: false, timeLineList: [], - options: [] + options: [], + loading: false, + loadingIn: false, + uploadUrl: '', + hideUploadOut: false, + hideUploadIn: false, + dialogImageUrl: '', + dialogVisible: false } }, mounted () { @@ -399,7 +451,103 @@ export default { } } }, + created: function () { + this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadImg?token=${Cookies.get('token')}` + this.uploadFileUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/uploadAllFile?token=${Cookies.get('token')}` + }, methods: { + beforeAvatarUpload (file) { + if (this.postDataForm.outHandleImagesPC.length === 3) { + this.$message.error('最多上传3张图片!') + return false + } + this.loading = true + this.isAble = true + const isJPG = file.type === 'image/jpeg' + const isPNG = file.type === 'image/png' + // 判断是否符合格式要求 + if (!isJPG && !isPNG) { + this.$message.error('上传文件必须是jpg、png格式!') + this.loading = false + this.isAble = false + return false + } + }, + handleAvatarSuccess (res, file) { + this.loading = false + this.isAble = false + if (res === null || res.data === null || res.data.imgUrl === null) { + this.$message.error('文件上传失败!') + return false + } + this.postDataForm.outHandleImagesPC.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1, recordType: 1, fileName: res.data.fileName }) + this.hideUploadOut = this.postDataForm.outHandleImagesPC.length >= 3 + }, + handelError () { + this.loading = false + this.loadingIn = false + this.isAble = false + this.$message.error('上传文件失败!') + }, + handleRemove (file, fileList) { + for (var i = 0; i < this.postDataForm.outHandleImagesPC.length; i++) { + let item = this.postDataForm.outHandleImagesPC[i] + if (item.url === file.url) { + this.postDataForm.outHandleImagesPC.splice(i, 1) + } + } + this.hideUploadOut = this.postDataForm.outHandleImagesPC.length >= 3 + }, + handlePictureCardPreview (file) { + this.dialogImageUrl = file.url + this.dialogVisible = true + }, + beforeAvatarUploadIn (file) { + if (this.postDataForm.handleImagesPC.length === 3) { + this.$message.error('最多上传3张图片!') + return false + } + this.loadingIn = true + this.isAble = true + const isJPG = file.type === 'image/jpeg' + const isPNG = file.type === 'image/png' + // 判断是否符合格式要求 + if (!isJPG && !isPNG) { + this.$message.error('上传文件必须是jpg、png格式!') + this.loadingIn = false + this.isAble = false + return false + } + }, + handleAvatarSuccessIn (res, file) { + this.loadingIn = false + this.isAble = false + if (res === null || res.data === null || res.data.imgUrl === null) { + this.$message.error('文件上传失败!') + return false + } + this.postDataForm.handleImagesPC.push({ url: res.data.imgUrl, thumbnail: res.data.thumbnail, fileType: 1, recordType: 1, fileName: res.data.fileName }) + this.hideUploadIn = this.postDataForm.handleImagesPC.length >= 3 + }, + handelErrorIn () { + this.loading = false + this.loadingIn = false + this.isAble = false + this.$message.error('上传文件失败!') + }, + handleRemoveIn (file, fileList) { + for (var i = 0; i < this.postDataForm.handleImagesPC.length; i++) { + let item = this.postDataForm.handleImagesPC[i] + if (item.url === file.url) { + this.postDataForm.handleImagesPC.splice(i, 1) + } + } + this.hideUploadIn = this.postDataForm.handleImagesPC.length >= 3 + }, + handlePictureCardPreviewIn (file) { + this.dialogImageUrl = file.url + this.dialogVisible = true + }, backToItemDeal () { this.$parent.selectComponent = 'ItemDeal' }, @@ -533,7 +681,7 @@ export default { }) }).catch(() => { }) }).catch(() => { - + }) }, pageSizeChangeHandleNew (val) { @@ -600,6 +748,18 @@ export default { this.postDataForm.evaluateDeptDTOS = [] } this.isAble = true + + + // 将对象遍历成数组 + for (let oimg = 0; oimg < this.postDataForm.outHandleImagesPC.length; oimg++) { + this.postDataForm.outHandleImages[oimg] = this.postDataForm.outHandleImagesPC[oimg].url + } + for (let himg = 0; himg < this.postDataForm.handleImagesPC.length; himg++) { + this.postDataForm.handleImages[himg] = this.postDataForm.handleImagesPC[himg].url + } + console.log(this.postDataForm) + return false + this.$http['post']( '/events/item/itemHandleSubmit', this.postDataForm).then(({ data: res }) => { if (res.code !== 0) { @@ -623,6 +783,12 @@ export default { } + +