From d07a03293dfe8a949d3544fde1d2e67be9f601e5 Mon Sep 17 00:00:00 2001 From: Shan Ao <178391389@qq.com> Date: Tue, 18 Feb 2025 16:29:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E4=BA=8B=E6=95=85?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E3=80=91=201.=20=E5=8E=BB=E6=8E=89=E5=87=BA?= =?UTF-8?q?=E6=8A=A5=E6=97=A5=E6=9C=9F=202.=20=E5=AF=BC=E5=85=A5=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=BB=8E1=E5=BC=A0=E6=94=B9=E4=B8=BA=E5=A4=9A?= =?UTF-8?q?=E5=BC=A0=203.=20=E5=AF=BC=E5=85=A5=E9=99=84=E4=BB=B6=E4=BB=8E1?= =?UTF-8?q?=E4=B8=AA=E6=94=B9=E4=B8=BA=E5=A4=9A=E4=B8=AA=204.=20=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E7=B1=BB=E5=9E=8B=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/event/components/addOrEdit.vue | 5 +- .../accident/records/components/addOrEdit.vue | 124 +++++++++--------- 2 files changed, 60 insertions(+), 69 deletions(-) diff --git a/src/views/accident/event/components/addOrEdit.vue b/src/views/accident/event/components/addOrEdit.vue index 0caef1d..b2bf752 100644 --- a/src/views/accident/event/components/addOrEdit.vue +++ b/src/views/accident/event/components/addOrEdit.vue @@ -219,7 +219,6 @@ export default { fileAddressList: fileAddressList } this.infoForm.incidentDate = new Date(data.info.incidentDate) - this.infoForm.reportDate = new Date(data.info.reportDate) }) } }, @@ -395,8 +394,7 @@ export default { analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 - creator: '', // 填表人 - reportDate: null // 报出日期 + creator: '' // 填表人 } }, @@ -409,7 +407,6 @@ export default { return false } this.infoForm.incidentDate = formatDate(this.infoForm.incidentDate, 'YYYY-MM-DD HH:mm:ss') - this.infoForm.reportDate = formatDate(this.infoForm.reportDate, 'YYYY-MM-DD HH:mm:ss') const params = { ...this.infoForm, photos: this.infoForm.fileList.map(item => item.remotePathName), diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index 9ebe882..487a78d 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -67,17 +67,6 @@ - - - { + const fileList = [] + if (data.info.photos != null && data.info.photos !== '') { + JSON.parse(data.info.photos).map((item) => { + fileList.push({ + name: 'photo', + url: config.fileUrl + item, + remotePathName: item + }) + }) + } + const fileAddressList = [] + if (data.info.attachmentAddress != null && data.info.attachmentAddress !== '') { + const names = data.info.attachmentNames == null ? [] : JSON.parse(data.info.attachmentNames) + const address = data.info.attachmentAddress == null ? [] : JSON.parse(data.info.attachmentAddress) + for (let i = 0; i < address.length; i++) { + fileAddressList.push({ + name: names[i] || '附件', + url: config.fileUrl + address[i], + remotePathName: address[i] + }) + } + } this.infoForm = { ...data.info, - fileList: [ - { - name: 'photo', - url: config.fileUrl + data.info.photos, - remotePathName: data.info.photos - } - ], - fileAddressList: [ - { - name: '附件', - url: config.fileUrl + data.info.attachmentAddress, - remotePathName: data.info.attachmentAddress - } - ] - } - const fileAddress = this.infoForm.fileAddressList[0].remotePathName - if (fileAddress == null || fileAddress === '') { - this.infoForm.fileAddressList = [] + fileList: fileList, + fileAddressList: fileAddressList } this.infoForm.incidentDate = new Date(data.info.incidentDate) - this.infoForm.reportDate = new Date(data.info.reportDate) - }).catch((e) => { }) } }, @@ -255,13 +247,13 @@ export default { /** * 文件列表移除文件时的钩子 */ - handleRemovePicture(file) { + handleRemovePicture(file, fileList) { if (file.remotePathName) { requestFN(`/accident/delete/photos`, { path: file.remotePathName }).then((res) => { if (res.result === 'success') { - this.infoForm.fileList = [] + this.infoForm.fileList = fileList this.$message({ message: '文件删除成功', type: 'info', @@ -275,13 +267,13 @@ export default { /** * 文件列表移除文件时的钩子 */ - handleRemoveAnnex(file) { + handleRemoveAnnex(file, fileList) { if (file.remotePathName) { requestFN(`/accident/delete/photos`, { path: file.remotePathName }).then((res) => { if (res.result === 'success') { - this.infoForm.fileAddressList = [] + this.infoForm.fileAddressList = fileList this.$message({ message: '文件删除成功', type: 'info', @@ -300,6 +292,17 @@ export default { this.dialogImageUrl = file.url }, + /** + * 点击文件列表中已上传的文件时的钩子 + */ + handleDownloadAnnex(file) { + var a = document.createElement('a') + var event = new MouseEvent('click') + a.download = file.name + a.href = file.url + a.dispatchEvent(event) + }, + /** * 文件上传失败时的钩子处理 */ @@ -340,14 +343,11 @@ export default { formData.append('file', file) upload('/accident/import/photos', formData).then((data) => { if (data.result === 'success') { - this.infoForm = { - ...this.infoForm, - fileList: [{ - name: file.name, - url: config.fileUrl + data.path, - remotePathName: data.path - }] - } + this.infoForm.fileList.push({ + name: file.name, + url: config.fileUrl + data.path, + remotePathName: data.path + }) } }) return false @@ -369,14 +369,11 @@ export default { formData.append('file', file) upload('/accident/import/photos', formData).then((data) => { if (data.result === 'success') { - this.infoForm = { - ...this.infoForm, - fileAddressList: [{ - name: file.name, - url: config.fileUrl + data.path, - remotePathName: data.path - }] - } + this.infoForm.fileAddressList.push({ + name: file.name, + url: config.fileUrl + data.path, + remotePathName: data.path + }) } }) return false @@ -416,8 +413,7 @@ export default { analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 - creator: '', // 填表人 - reportDate: null // 报出日期 + creator: '' // 填表人 } }, @@ -430,23 +426,21 @@ export default { return false } this.infoForm.incidentDate = formatDate(this.infoForm.incidentDate, 'YYYY-MM-DD HH:mm:ss') - this.infoForm.reportDate = formatDate(this.infoForm.reportDate, 'YYYY-MM-DD HH:mm:ss') - const address = this.infoForm.fileAddressList[0] const params = { ...this.infoForm, - photos: this.infoForm.fileList[0].remotePathName, - attachmentAddress: address == null ? '' : address.remotePathName, + photos: this.infoForm.fileList.map(item => item.remotePathName), + attachmentAddress: this.infoForm.fileAddressList.map(item => item.remotePathName), + attachmentNames: this.infoForm.fileAddressList.map(item => item.name), type: 2 } delete params.fileList requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) - .then((response) => { + .then(() => { // 删除成功后的处理 this.$message.success(this.tableName + '成功') this.infoForm = this.$options.data().infoForm this.$parent.activeName = 'List' - // eslint-disable-next-line handle-callback-err - }).catch((error) => { + }).catch(() => { this.$message.error(this.tableName + '失败') }) })