From 071fe616cadff66e9d90b1a7c0a50c635d1646c7 Mon Sep 17 00:00:00 2001 From: guoyuepeng <770272267@qq.com> Date: Fri, 6 Sep 2024 14:24:12 +0800 Subject: [PATCH 01/10] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/corpInfo/user/components/edit.vue | 2 +- src/views/corpInfo/user/components/list.vue | 6 +++--- src/views/corpInfo/userCenter/components/list.vue | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/views/corpInfo/user/components/edit.vue b/src/views/corpInfo/user/components/edit.vue index 7240fca..21765ab 100644 --- a/src/views/corpInfo/user/components/edit.vue +++ b/src/views/corpInfo/user/components/edit.vue @@ -812,7 +812,7 @@ export default { DUTIES_ID: [{ required: true, message: '请选择岗位', trigger: 'change' }], SORT: [{ required: true, message: '请输入排序', trigger: 'blur' }], NATION: [{ required: false, trigger: 'blur' }], - SEX: [{ required: false, trigger: 'blur' }], + SEX: [{ required: false, trigger: 'blur' }], // / dsfsdfsd POLITICAL_OUTLOOK: [{ required: true, message: '政治面貌不能为空', trigger: 'blur' }], DATE_OF_BIRTH: [{ required: true, message: '请选择出生年月', trigger: 'blur' }], DEGREE_OF_EDUCATION: [{ required: true, message: '文化程度不能为空', trigger: 'blur' }], diff --git a/src/views/corpInfo/user/components/list.vue b/src/views/corpInfo/user/components/list.vue index 5cf7dbb..de867a0 100644 --- a/src/views/corpInfo/user/components/list.vue +++ b/src/views/corpInfo/user/components/list.vue @@ -50,9 +50,9 @@ - - - + + + 导出 diff --git a/src/views/corpInfo/userCenter/components/list.vue b/src/views/corpInfo/userCenter/components/list.vue index 5902be6..7a22021 100644 --- a/src/views/corpInfo/userCenter/components/list.vue +++ b/src/views/corpInfo/userCenter/components/list.vue @@ -48,10 +48,10 @@ 一键密码重置 - - - - + + + + 导出 From f58761937fd3113446d1e52eccf454cc1f4c77f1 Mon Sep 17 00:00:00 2001 From: wangpeng Date: Fri, 30 Aug 2024 18:22:13 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BA=8B=E6=95=85=E8=B0=83=E6=9F=A5?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/list.vue | 469 ++++++++++++++++++ src/views/accident/records/index.vue | 35 ++ 2 files changed, 504 insertions(+) create mode 100644 src/views/accident/records/components/list.vue create mode 100644 src/views/accident/records/index.vue diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue new file mode 100644 index 0000000..2b2468b --- /dev/null +++ b/src/views/accident/records/components/list.vue @@ -0,0 +1,469 @@ + + + + + diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue new file mode 100644 index 0000000..979de3a --- /dev/null +++ b/src/views/accident/records/index.vue @@ -0,0 +1,35 @@ + + + + + From f921dd8c526a5270135d0236875047f3ca9ec1bc Mon Sep 17 00:00:00 2001 From: shanao Date: Fri, 6 Sep 2024 16:19:59 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BA=8B=E6=95=85=E8=B0=83=E6=9F=A5?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/list.vue | 72 +++++++++---------- src/views/accident/records/index.vue | 9 ++- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 2b2468b..b6e23c9 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -8,9 +8,9 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + 查询 @@ -101,25 +100,30 @@ - - - - - - - + + + + + - - - - - - - + + + + + + @@ -452,11 +456,7 @@ export default { this.$parent.activeName = 'Detail' this.$parent.hiddenId = id }, - translate(id, list) { - for (let i = 0; i < list.length; i++) { - if (list[i].BIANMA === id || list[i].value === id || list[i].id === id) return list[i].NAME || list[i].label - } - }, + formatDate(date, format) { return formatDate(date, format) } diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue index 979de3a..f128cfc 100644 --- a/src/views/accident/records/index.vue +++ b/src/views/accident/records/index.vue @@ -2,18 +2,17 @@
- +
+ + diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index b6e23c9..dcc6e09 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -1,27 +1,29 @@ - + diff --git a/src/views/accident/records/components/list_demo.vue b/src/views/accident/records/components/list_demo.vue new file mode 100644 index 0000000..b6e23c9 --- /dev/null +++ b/src/views/accident/records/components/list_demo.vue @@ -0,0 +1,469 @@ + + + + + diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue index f128cfc..2b09927 100644 --- a/src/views/accident/records/index.vue +++ b/src/views/accident/records/index.vue @@ -1,17 +1,19 @@ diff --git a/src/views/accident/records/components/list_demo.vue b/src/views/accident/records/components/list_demo.vue index b6e23c9..f93c79d 100644 --- a/src/views/accident/records/components/list_demo.vue +++ b/src/views/accident/records/components/list_demo.vue @@ -1,4 +1,4 @@ - + diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 0ef47bc..3e10e21 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -49,7 +49,7 @@ - 新增 + 新增 导出 全部导出 刷新 @@ -76,8 +76,8 @@ @@ -179,13 +179,17 @@ export default { }, /** - * 新增 + * 跳转页面 */ - handleAddNew() { + goView(id, name) { + this.$parent.id = id + this.$parent.tableName = name this.$parent.activeName = 'AddOrEdit' }, - // 删除行数据 + /** + * 删除行数据 + */ deleteRow(id) { if (id === null || id === '') { this.$message.warning('请选择要删除的行') diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue index 2b09927..20a3876 100644 --- a/src/views/accident/records/index.vue +++ b/src/views/accident/records/index.vue @@ -19,7 +19,8 @@ export default { data() { return { activeName: 'List', - hiddenId: '' + id: '', + tableName: '' } }, watch: { From 06920346f87b2af3882bb668a833bc507be367dc Mon Sep 17 00:00:00 2001 From: mengfanliang Date: Mon, 9 Sep 2024 15:17:43 +0800 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20=E4=BA=8B=E6=95=85=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=9F=A5=E8=AF=A2=E6=A8=A1=E5=9D=97=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/addOrEdit.vue | 249 ++++++++++++++---- .../accident/records/components/list.vue | 54 ++-- src/views/accident/records/index.vue | 4 +- 3 files changed, 234 insertions(+), 73 deletions(-) diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index a9c6e14..c2b6983 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -4,96 +4,105 @@ ref="form" :model="infoForm" :rules="rules" - label-width="110px" - style="width: 800px" + label-width="180px" + style="width: 900px" > - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - + + format="yyyy-MM-dd HH:mm:ss" + value-format="yyyy-MM-dd HH:mm:ss" + /> + + + +
import { requestFN } from '../../../../utils/request' +import { upload } from '@/utils/upload' export default { data() { return { + config: config, infoForm: { id: '', // 主键ID incidentNumber: '', // 事故案号 @@ -128,7 +139,7 @@ export default { seriouslyInjured: null, // 重伤人数 cause: '', // 事故起因 summary: '', // 事故概述 - photos: '', // 事故照片 + photos: [], // 事故照片 analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 @@ -141,8 +152,13 @@ export default { /** 事故等级 */ incidentLevels: [], tableName: '', - /** 图片文件 */ - image: null, + /** 图片上传限制个数 */ + limitNum: 1, + /** 预览图片地址 */ + dialogImageUrl: '', + allowRemove: true, // 添加一个控制标志 + /** 预览弹窗 */ + dialogImgVisible: false, rules: { incidentNumber: [{ required: true, message: '事故案号不能为空', trigger: 'blur' }], incidentName: [{ required: true, message: '事故名称不能为空', trigger: 'blur' }], @@ -167,6 +183,12 @@ export default { } }, + computed: { + isDisabled() { + return this.$parent.tableName === '查看' + } + }, + created() { this.getDict() const id = this.$parent.id @@ -174,39 +196,154 @@ export default { if (id == null || id === '') { this.infoForm = this.$options.data().infoForm } else { + // 若有数据项的ID, 则请求接口并回显表单 requestFN('/accident/' + id, {}).then((data) => { this.infoForm = data.info + this.getFileImageBinaray(data.info.photos) }).catch((e) => { - this.listLoading = false }) } }, methods: { - handleRemovePicture() {}, + /** + * 文件列表移除文件时的钩子 + */ + handleRemovePicture(file) { + if (file.remotePathName) { + requestFN(`/accident/delete/photos/${file.remotePathName}`).then((res) => { + if (res.result === 'success') { + this.infoForm.photos = [] + this.$message({ + message: '文件删除成功', + type: 'info', + duration: 2000 + }) + } + }) + } + }, - handleChangeIMG() {}, + /** + * 单独查询图片流文件 + */ + getFileImageBinaray(fileName) { + requestFN(`/accident/view/photos`, { path: fileName }).then((res) => { + console.log('res :>> ', res) + }) + }, - handlePictureCardPreview() {}, + /** + * 点击文件列表中已上传的文件时的钩子 + */ + handlePictureCardPreview(file) { + this.dialogImgVisible = true + this.dialogImageUrl = file.url + }, + + /** + * 文件上传失败时的钩子处理 + */ + handleError(err, file, fileList) { + this.$message({ + message: `${file.name}上传失败, 请稍后重试`, + type: 'error', + duration: 2000 + }) + }, + + /** + * 文件超出个数限制的钩子处理 + */ + handleExceed(files, fileList) { + this.$message.warning(`当前限制选择 ${this.limitNum} 个文件,本次选择了 ${files.length} 个文件`) + }, + + /** + * 上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传。 + */ + beforeAccidentUpload(file) { + if (!file) { + this.$message({ + message: '请上传图片', + type: 'error' + }) + return false + } + const types = ['image/jpeg', 'image/jpg', 'image/png'] + const isImage = types.includes(file.type) + if (!isImage) { + this.$message.error('上传图片只能是 JPG、JPEG、PNG 格式!') + return false + } else { + const formData = new FormData() + formData.append('file', file) + upload('/accident/import/photos', formData).then((data) => { + if (data.result === 'success') { + this.infoForm.photos = [{ + name: file.name, + url: URL.createObjectURL(file), + remotePathName: data.path + }] + } + }) + return false + } + }, - beforeHiddenUpload() {}, /** * 返回到列表页面 */ goBack() { + this.handleResetInitForm() + this.image = [] + this.dialogImageUrl = '' this.$parent.activeName = 'List' }, + /** + * 表单清空处理 + */ + handleResetInitForm() { + this.infoForm = { + id: '', // 主键ID + incidentNumber: '', // 事故案号 + incidentName: '', // 事故名称 + incidentType: null, // 事故类型 + companyName: '', // 所属公司 + incidentLevel: '', // 事故级别 + incidentNature: '', // 事故性质 + location: '', // 事故发生地点 + incidentDate: null, // 事故发生时间 + directLoss: '', // 直接经济损失(万元) + injured: null, // 受伤人数 + fatalities: null, // 死亡人数 + seriouslyInjured: null, // 重伤人数 + cause: '', // 事故起因 + summary: '', // 事故概述 + photos: [], // 事故照片 + analysis: '', // 原因分析及责任认定 + suggestions: '', // 考核建议 + measures: '', // 整改措施 + creator: '', // 填表人 + reportDate: null // 报出日期 + } + }, + /** * 表单确认按钮 */ confirm() { - requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), this.infoForm) + const params = { + ...this.infoForm, + photos: this.infoForm.photos[0].remotePathName + } + requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) .then((response) => { // 删除成功后的处理 this.$message.success(this.tableName + '成功') - this.getList() // 重新获取数据 this.infoForm = this.$options.data().infoForm + this.$parent.activeName = 'List' // eslint-disable-next-line handle-callback-err }).catch((error) => { this.$message.error(this.tableName + '失败') diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 3e10e21..92478ea 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -7,7 +7,7 @@ - + 新增 - 导出 全部导出 刷新 批量删除 @@ -74,16 +73,17 @@ - +
+
@@ -101,6 +101,7 @@ export default { data() { return { + config: config, // 搜索查询条件 searchForm: { /** 事故名称 */ @@ -118,6 +119,8 @@ export default { /** 事故等级 */ incidentLevel: '' }, + /** 当前选中行 */ + multipleSelection: [], /** 列表加载态 */ listLoading: false, /** 源列表数据项 */ @@ -179,7 +182,7 @@ export default { }, /** - * 跳转页面 + * 跳转查看详情页面 */ goView(id, name) { this.$parent.id = id @@ -187,6 +190,15 @@ export default { this.$parent.activeName = 'AddOrEdit' }, + /** + * 跳转修改页面 + */ + goEdit(id, name) { + this.$parent.id = id + this.$parent.tableName = name + this.$parent.activeName = 'AddOrEdit' + }, + /** * 删除行数据 */ @@ -207,6 +219,7 @@ export default { requestFN(url).then((response) => { // 删除成功后的处理 this.$message.success('删除成功') + this.searchList() // eslint-disable-next-line handle-callback-err }).catch((error) => { this.$message.error('删除失败') @@ -217,18 +230,24 @@ export default { message: '已取消删除' }) }) - this.searchList() }, - /** - * 导出 - */ - handleExport() {}, - /** * 全部导出 */ - handleAllExport() {}, + handleAllExport() { + this.$confirm('确定要下载excel模板吗?', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.listLoading = false + window.open(config.templatefileUrl + 'template/limitSpace.xls') + }).catch(() => { + this.listLoading = false + }) + this.listLoading = false + }, /** * 刷新 @@ -236,7 +255,7 @@ export default { handleRefresh() { this.searchForm = this.$options.data().searchForm this.searchList() - this.toggleSelection() + // this.toggleSelection() }, /** @@ -264,7 +283,6 @@ export default { requestFN(url).then((response) => { // 删除成功后的处理 this.$message.success('删除成功') - this.searchList() // 重新获取数据 // eslint-disable-next-line handle-callback-err }).catch((error) => { this.$message.error('删除失败') @@ -302,4 +320,8 @@ export default { } - + diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue index 20a3876..92c63da 100644 --- a/src/views/accident/records/index.vue +++ b/src/views/accident/records/index.vue @@ -26,7 +26,9 @@ export default { watch: { activeName(val) { if (val === 'List') { - this.$refs.List.getList() + this.$nextTick(() => { + this.$refs.List.searchList() + }) } } } From a116151652d4390144c4687faf3cf01258efdd88 Mon Sep 17 00:00:00 2001 From: shanao Date: Mon, 9 Sep 2024 18:04:04 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=BF=98=E6=B2=A1?= =?UTF-8?q?=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/addOrEdit.vue | 41 +++++++------------ .../accident/records/components/list.vue | 3 +- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index c2b6983..dd7cbac 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -8,19 +8,19 @@ style="width: 900px" > - + - + - + - + @@ -58,7 +58,7 @@ - + @@ -100,16 +100,17 @@ - + -
+
返回 + @click="goBack">返回 + 确 定
@@ -139,7 +140,7 @@ export default { seriouslyInjured: null, // 重伤人数 cause: '', // 事故起因 summary: '', // 事故概述 - photos: [], // 事故照片 + photos: '', // 事故照片 analysis: '', // 原因分析及责任认定 suggestions: '', // 考核建议 measures: '', // 整改措施 @@ -154,8 +155,8 @@ export default { tableName: '', /** 图片上传限制个数 */ limitNum: 1, - /** 预览图片地址 */ - dialogImageUrl: '', + /** 图片 */ + fileList: [], allowRemove: true, // 添加一个控制标志 /** 预览弹窗 */ dialogImgVisible: false, @@ -224,15 +225,6 @@ export default { } }, - /** - * 单独查询图片流文件 - */ - getFileImageBinaray(fileName) { - requestFN(`/accident/view/photos`, { path: fileName }).then((res) => { - console.log('res :>> ', res) - }) - }, - /** * 点击文件列表中已上传的文件时的钩子 */ @@ -244,6 +236,7 @@ export default { /** * 文件上传失败时的钩子处理 */ + // eslint-disable-next-line handle-callback-err handleError(err, file, fileList) { this.$message({ message: `${file.name}上传失败, 请稍后重试`, @@ -280,11 +273,7 @@ export default { formData.append('file', file) upload('/accident/import/photos', formData).then((data) => { if (data.result === 'success') { - this.infoForm.photos = [{ - name: file.name, - url: URL.createObjectURL(file), - remotePathName: data.path - }] + this.infoForm.photos = data.path } }) return false diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 92478ea..066c430 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -101,7 +101,6 @@ export default { data() { return { - config: config, // 搜索查询条件 searchForm: { /** 事故名称 */ @@ -242,7 +241,7 @@ export default { type: 'warning' }).then(() => { this.listLoading = false - window.open(config.templatefileUrl + 'template/limitSpace.xls') + window.open(config.httpurl + '/export/excel') }).catch(() => { this.listLoading = false }) From 164f70a0a44d5f6de2f9f7a4a2fcc1bf269b03d3 Mon Sep 17 00:00:00 2001 From: shanao Date: Tue, 10 Sep 2024 14:09:40 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/list.vue | 2 +- .../accident/records/components/list_demo.vue | 469 ------------------ 2 files changed, 1 insertion(+), 470 deletions(-) delete mode 100644 src/views/accident/records/components/list_demo.vue diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 066c430..72c4fd7 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -241,7 +241,7 @@ export default { type: 'warning' }).then(() => { this.listLoading = false - window.open(config.httpurl + '/export/excel') + window.location.href = config.httpurl + '/accident/export/excel' }).catch(() => { this.listLoading = false }) diff --git a/src/views/accident/records/components/list_demo.vue b/src/views/accident/records/components/list_demo.vue deleted file mode 100644 index f93c79d..0000000 --- a/src/views/accident/records/components/list_demo.vue +++ /dev/null @@ -1,469 +0,0 @@ -<0template> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 查询 - - - 重置 - - - 添加 - - - 批量删除 - - - - - - - - - 刷新 - - - - - - - - - - - - - - - - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - From 54845b24224f6e703dbf8655e9496a97547117bc Mon Sep 17 00:00:00 2001 From: mengfanliang Date: Thu, 12 Sep 2024 11:40:32 +0800 Subject: [PATCH 10/10] =?UTF-8?q?feat:=20=E8=B0=83=E8=AF=95=E4=BA=8B?= =?UTF-8?q?=E6=95=85=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=9B=9E=E6=98=BE=E8=B7=AF=E5=BE=84=E9=97=AE?= =?UTF-8?q?=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) => { // 删除成功后的处理