From 54845b24224f6e703dbf8655e9496a97547117bc Mon Sep 17 00:00:00 2001 From: mengfanliang Date: Thu, 12 Sep 2024 11:40:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E8=AF=95=E4=BA=8B=E6=95=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=9B=9E=E6=98=BE=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/addOrEdit.vue | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index dd7cbac..03c30f1 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -54,11 +54,11 @@ - + - +
+ +
@@ -140,7 +142,7 @@ export default { seriouslyInjured: null, // 重伤人数 cause: '', // 事故起因 summary: '', // 事故概述 - photos: '', // 事故照片 + fileList: [], // 事故照片 analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 @@ -155,9 +157,6 @@ export default { tableName: '', /** 图片上传限制个数 */ limitNum: 1, - /** 图片 */ - fileList: [], - allowRemove: true, // 添加一个控制标志 /** 预览弹窗 */ dialogImgVisible: false, rules: { @@ -174,7 +173,7 @@ export default { seriouslyInjured: [{ required: true, message: '隐患类型不能为空', trigger: 'blur' }], cause: [{ required: true, message: '事故起因不能为空', trigger: 'blur' }], summary: [{ required: true, message: '事故概述不能为空', trigger: 'blur' }], - photos: [{ required: true, message: '事故照片不能为空', trigger: 'blur' }], + fileList: [{ required: true, message: '事故照片不能为空', trigger: 'blur' }], analysis: [{ required: true, message: '原因分析及责任认定不能为空', trigger: 'blur' }], suggestions: [{ required: true, message: '考核建议不能为空', trigger: 'blur' }], measures: [{ required: true, message: '整改措施不能为空', trigger: 'blur' }], @@ -199,8 +198,16 @@ export default { } else { // 若有数据项的ID, 则请求接口并回显表单 requestFN('/accident/' + id, {}).then((data) => { - this.infoForm = data.info - this.getFileImageBinaray(data.info.photos) + this.infoForm = { + ...data.info, + fileList: [ + { + name: 'photo', + url: config.fileUrl + data.info.photos, + remotePathName: data.info.photos + } + ] + } }).catch((e) => { }) } @@ -212,9 +219,11 @@ export default { */ handleRemovePicture(file) { if (file.remotePathName) { - requestFN(`/accident/delete/photos/${file.remotePathName}`).then((res) => { + requestFN(`/accident/delete/photos`, { + path: file.remotePathName + }).then((res) => { if (res.result === 'success') { - this.infoForm.photos = [] + this.infoForm.fileList = [] this.$message({ message: '文件删除成功', type: 'info', @@ -273,7 +282,14 @@ export default { formData.append('file', file) upload('/accident/import/photos', formData).then((data) => { if (data.result === 'success') { - this.infoForm.photos = data.path + this.infoForm = { + ...this.infoForm, + fileList: [{ + name: file.name, + url: config.fileUrl + data.path, + remotePathName: data.path + }] + } } }) return false @@ -310,7 +326,7 @@ export default { seriouslyInjured: null, // 重伤人数 cause: '', // 事故起因 summary: '', // 事故概述 - photos: [], // 事故照片 + fileList: [], // 事故照片 analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 @@ -325,8 +341,9 @@ export default { confirm() { const params = { ...this.infoForm, - photos: this.infoForm.photos[0].remotePathName + photos: this.infoForm.fileList[0].remotePathName } + delete params.fileList requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) .then((response) => { // 删除成功后的处理