From cdd6ca0354d3a114bff4ea86e4bb6eeda3cda8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 6 Feb 2025 18:03:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=AE=BE=E5=A4=87=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/manage/informationAdd.vue | 91 ++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 7 deletions(-) diff --git a/pages/manage/informationAdd.vue b/pages/manage/informationAdd.vue index 61c10c9..a6be95d 100644 --- a/pages/manage/informationAdd.vue +++ b/pages/manage/informationAdd.vue @@ -90,6 +90,24 @@ {{ time1 || '' }} + + + + * + 设备附件 + + + + + { + // 如果是相对路径,添加域名 + file.url = this.baseImageUrl + '/' + file.url; + return file; + }); + } // this.maneizhi = this.box.type this.time = this.box.validTime this.time1 = this.box.nextCheckTime } - if (this.box.type){ + if (this.box.type) { const data = this.columns[0] const index = data.findIndex(item => item.value === this.box.type) - if (index !== -1){ + if (index !== -1) { this.typeName = data[index].label } } @@ -228,9 +258,14 @@ export default { // icon:'none' // }) - + this.box.fileList = this.fileList3.map(file => { + // 去掉域名,返回相对路径 + if (file.url && file.url.startsWith(this.baseImageUrl)) { + file.url = file.url.replace(this.baseImageUrl, ''); + } + return file; + }); if (this.type == 'add') { - let res = await request({ url: '/system/equInfo/add', method: 'post', @@ -274,6 +309,48 @@ export default { }) }, + // 删除图片 + deletePic(event) { + this[`fileList${event.name}`].splice(event.index, 1); + }, + // 新增图片 + async afterRead(event) { + // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式 + let lists = [].concat(event.file); + let fileListLen = this[`fileList${event.name}`].length; + lists.map((item) => { + this[`fileList${event.name}`].push({ + ...item, + status: "uploading", + message: "上传中", + }); + }); + for (let i = 0; i < lists.length; i++) { + const result = await this.uploadFilePromise(lists[i].url); + let item = this[`fileList${event.name}`][fileListLen]; + this[`fileList${event.name}`].splice( + fileListLen, + 1, + Object.assign(item, { + status: "success", + message: "", + url: result, + }) + ); + fileListLen++; + } + console.log('现在文件集合', this[`fileList${event.name}`]) + }, + uploadFilePromise(url) { + return new Promise((resolve, reject) => { + upload({ + url: '/common/upload', + filePath: url, + }).then((res) => { + resolve(res.data.url); + }) + }); + }, }