From 3d576a33ca9c30d9d9593de791e3f3ab4e6dd851 Mon Sep 17 00:00:00 2001 From: wangpeng Date: Fri, 30 Aug 2024 18:22:13 +0800 Subject: [PATCH 01/13] =?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 991ef9ea5201920cc7f807d39d27a7c5213b3267 Mon Sep 17 00:00:00 2001 From: shanao Date: Fri, 6 Sep 2024 16:19:59 +0800 Subject: [PATCH 02/13] =?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 d07eaa7cfc554d2d785b5025a82520bfc2eca1df Mon Sep 17 00:00:00 2001 From: mengfanliang Date: Mon, 9 Sep 2024 15:17:43 +0800 Subject: [PATCH 06/13] =?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 --- package.json | 2 +- .../accident/records/components/addOrEdit.vue | 249 ++++++++++++++---- .../accident/records/components/list.vue | 54 ++-- src/views/accident/records/index.vue | 4 +- 4 files changed, 235 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index b674980..1e8818a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "", "private": true, "scripts": { - "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 192.168.0.125", + "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "unit": "jest --config test/unit/jest.conf.js --coverage", "e2e": "node test/e2e/runner.js", 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 f7cb02d6814c0e1496b6b7484fb6ee125f93d0cc Mon Sep 17 00:00:00 2001 From: shanao Date: Mon, 9 Sep 2024 18:04:04 +0800 Subject: [PATCH 07/13] =?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 4933738b6dcd6b827345e6b1f48a981ff222c7b0 Mon Sep 17 00:00:00 2001 From: shanao Date: Tue, 10 Sep 2024 14:09:40 +0800 Subject: [PATCH 08/13] =?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 ce40b8f1942541de09a9dad25983d56a65a3edfc Mon Sep 17 00:00:00 2001 From: shanao Date: Thu, 12 Sep 2024 10:18:12 +0800 Subject: [PATCH 09/13] =?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 --- src/views/accident/records/components/addOrEdit.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index dd7cbac..ff38c7c 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -59,6 +59,7 @@ ref="upload" :disabled="isDisabled" :file-list.sync="fileList" + :src="config.fileUrl + infoForm.photos" :multiple="false" :auto-upload="true" :limit="limitNum" @@ -323,9 +324,10 @@ export default { * 表单确认按钮 */ confirm() { + console.log('ok >>>>' + this.infoForm.photos) const params = { - ...this.infoForm, - photos: this.infoForm.photos[0].remotePathName + ...this.infoForm + // photos: this.infoForm.photos[0].remotePathName } requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) .then((response) => { From b29e9ed249922c10c176f0d037868001df68e6f7 Mon Sep 17 00:00:00 2001 From: mengfanliang Date: Thu, 12 Sep 2024 11:40:32 +0800 Subject: [PATCH 10/13] =?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 +++++++++++++------ static/config.js | 3 +- 2 files changed, 34 insertions(+), 16 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) => { // 删除成功后的处理 diff --git a/static/config.js b/static/config.js index bd63d19..fab4348 100644 --- a/static/config.js +++ b/static/config.js @@ -5,7 +5,8 @@ const config = { qyurl: 'http://192.168.0.45:8080/', // 企业前台 adminurl: 'https://www.qdkjchina.com/qa-prevention-admin/', // 正式 - fileUrl: 'https://qgqy.qhdsafety.com/file/', // 附件服务器地址 + // fileUrl: 'https://qgqy.qhdsafety.com/file/', // 附件服务器地址 + fileUrl: 'https://wwag.qhdsafety.com/file/', // 附件服务器地址 weburlWaiwang: 'https://skqhdg.porthebei.com:9004/', // 服务器外网地址 httpurlWaiwang: 'https://skqhdg.porthebei.com:9004/qa-prevention-gwj/', // , fileUrlWaiwang: 'https://skqhdg.porthebei.com:9004/file/', // 服务器外网 附件地址, From 270d0d3c86554c545d21e28cc80f52d6f679f596 Mon Sep 17 00:00:00 2001 From: shanao Date: Thu, 12 Sep 2024 14:10:14 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=83=A8?= =?UTF-8?q?=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 | 21 +++++++++++-------- src/views/accident/records/index.vue | 2 -- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 72c4fd7..2fa4053 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -11,13 +11,15 @@ + end-placeholder="结束日期" + /> @@ -64,10 +66,11 @@ v-loading="listLoading" ref="multipleTable" :data="varList" - border tooltip-effect="dark" style="width: 100%" - @selection-change="handleSelectionChange"> + border + @selection-change="handleSelectionChange" + > @@ -177,7 +180,7 @@ export default { * 表格行选择器处理 */ handleSelectionChange(val) { - this.multipleSelection.push(val) + this.multipleSelection = val }, /** @@ -264,7 +267,7 @@ export default { // 获取选中的行数据 const selectedRows = this.multipleSelection // 如果没有选中任何行,则提示用户 - if (selectedRows.length === 0) { + if (this.multipleSelection === '' || selectedRows.length === 0) { this.$message.warning('请选择要删除的行') return } @@ -275,15 +278,16 @@ export default { type: 'warning' }).then(() => { // 获取所有选中行的 ID - const ids = selectedRows.map(row => row.id).join(',') - + let ids = '' + selectedRows.forEach(row => { ids += row.id + ',' }) // 发送批量删除请求 const url = '/accident/delete/' + '' + ids requestFN(url).then((response) => { // 删除成功后的处理 this.$message.success('删除成功') + this.searchList() // eslint-disable-next-line handle-callback-err - }).catch((error) => { + }).catch(() => { this.$message.error('删除失败') }) }).catch(() => { @@ -292,7 +296,6 @@ export default { message: '已取消删除' }) }) - this.searchList() }, /** diff --git a/src/views/accident/records/index.vue b/src/views/accident/records/index.vue index 92c63da..33eb176 100644 --- a/src/views/accident/records/index.vue +++ b/src/views/accident/records/index.vue @@ -2,7 +2,6 @@
-
@@ -14,7 +13,6 @@ export default { components: { List: List, Add: Add - // Detail: Detail }, data() { return { From 8062274b39ad6cadc2ef642be1192e61d3e2bae9 Mon Sep 17 00:00:00 2001 From: shanao Date: Thu, 12 Sep 2024 17:32:07 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/accident/records/components/list.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/accident/records/components/list.vue b/src/views/accident/records/components/list.vue index 2fa4053..4bd8c47 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -158,12 +158,13 @@ export default { if (dates != null && dates.length === 2) { this.searchForm.startTime = dates[0] this.searchForm.endTime = dates[1] + delete this.searchForm.incidentDates } const url = '/accident/page?showCount=' + this.listQuery.limit + '¤tPage=' + this.listQuery.page requestFN(url, { ...this.searchForm }).then((data) => { this.listLoading = false this.varList = data.varList - this.total = data.page.totalResult + this.listQuery.total = data.page.totalResult }).catch((e) => { this.listLoading = false }) From 0f75e526dec67ef9dc43f4805aed17600e7022ed Mon Sep 17 00:00:00 2001 From: shanao Date: Fri, 13 Sep 2024 17:18:25 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/records/components/addOrEdit.vue | 49 ++++++++++--------- .../accident/records/components/list.vue | 24 ++++++--- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/views/accident/records/components/addOrEdit.vue b/src/views/accident/records/components/addOrEdit.vue index 03c30f1..9b3f0c1 100644 --- a/src/views/accident/records/components/addOrEdit.vue +++ b/src/views/accident/records/components/addOrEdit.vue @@ -30,13 +30,12 @@ + /> - + @@ -90,11 +89,9 @@ @@ -162,8 +159,7 @@ export default { rules: { incidentNumber: [{ required: true, message: '事故案号不能为空', trigger: 'blur' }], incidentName: [{ required: true, message: '事故名称不能为空', trigger: 'blur' }], - HIDDENTYPE: [{ required: true, message: '事故类型不能为空', trigger: 'blur' }], - incidentType: [{ required: true, message: '隐患类型不能为空', trigger: 'blur' }], + incidentType: [{ required: true, message: '事故类型不能为空', trigger: 'blur' }], incidentLevel: [{ required: true, message: '事故级别不能为空', trigger: 'blur' }], incidentNature: [{ required: true, message: '事故性质不能为空', trigger: 'blur' }], location: [{ required: true, message: '事故发生地点不能为空', trigger: 'blur' }], @@ -339,21 +335,26 @@ export default { * 表单确认按钮 */ confirm() { - const params = { - ...this.infoForm, - photos: this.infoForm.fileList[0].remotePathName - } - delete params.fileList - requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) - .then((response) => { - // 删除成功后的处理 - this.$message.success(this.tableName + '成功') - this.infoForm = this.$options.data().infoForm - this.$parent.activeName = 'List' - // eslint-disable-next-line handle-callback-err - }).catch((error) => { - this.$message.error(this.tableName + '失败') - }) + this.$refs.form.validate(valid => { + if (!valid) { + return false + } + const params = { + ...this.infoForm, + photos: this.infoForm.fileList[0].remotePathName + } + delete params.fileList + requestFN('/accident' + (this.tableName === '修改' ? '/update' : '/save'), params) + .then((response) => { + // 删除成功后的处理 + this.$message.success(this.tableName + '成功') + 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 4bd8c47..b2e52e8 100644 --- a/src/views/accident/records/components/list.vue +++ b/src/views/accident/records/components/list.vue @@ -4,16 +4,16 @@ - + - + - + - + @@ -53,7 +53,6 @@ 新增 全部导出 - 刷新 批量删除 @@ -74,7 +73,11 @@ - + + +