From 18e677ee362f56b26ee8bcdb19d56f9153006879 Mon Sep 17 00:00:00 2001 From: "maxw@mesnac.com" Date: Thu, 28 Nov 2024 18:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw-ui/src/views/dms/knowledgeRepair/index.vue | 21 ++++++++++++++++++- hw-ui/src/views/dms/konwledgeMaint/index.vue | 21 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/hw-ui/src/views/dms/knowledgeRepair/index.vue b/hw-ui/src/views/dms/knowledgeRepair/index.vue index c80a3c32..9742069d 100644 --- a/hw-ui/src/views/dms/knowledgeRepair/index.vue +++ b/hw-ui/src/views/dms/knowledgeRepair/index.vue @@ -268,7 +268,7 @@ export default { this.isCommonName = true; const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'; // 允许JPG和PNG格式 const isLt2M = file.size / 1024 / 1024 < 2; - //判断是否有相同的图片,如何有即提示并添加失败 + // 判断是否有相同的图片,如何有即提示并添加失败 if(this.fileListPut.length > 0){ this.fileListPut.forEach((item,index)=>{ if(item.name == file.name){ @@ -287,6 +287,11 @@ export default { }, //图片上传删除 handleRemove(file, fileList) { + const url = file.url; + console.log(url); + const i = this.imgAddress.findIndex((x)=> x.url === url); + this.imgAddress.splice(i,1); + console.log(this.imgAddress) //根据传进来删除的file里图片,同时删除保存在fileListPut的相同图片 if(this.fileListPut.length > 0){ this.fileListPut = this.fileListPut.filter((item, index)=>{ @@ -311,6 +316,7 @@ export default { //往此数组中保存当前图片对象 this.fileListPut.push(currentFile); console.log(this.fileListPut) + console.log(this.imgAddress) }, @@ -372,6 +378,9 @@ export default { }, /** 新增按钮操作 */ handleAdd() { + console.log(this.imgAddress.length) + this.imgAddress.length=0; + // this.form.fileUrls.length=0; this.fileListShow = []; this.reset(); this.open = true; @@ -379,9 +388,14 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.reset(); const knowledgeRepairId = row.knowledgeRepairId || this.ids getKnowledgeRepair(knowledgeRepairId).then(response => { + console.log(response.data.systemFiles) + for (let element of response.data.systemFiles) { + this.imgAddress.push(element.url) + } this.form = response.data; this.fileListShow = response.data.systemFiles console.log(this.fileListShow) @@ -394,13 +408,18 @@ export default { this.$refs["form"].validate(valid => { if (valid) { if (this.form.knowledgeRepairId != null) { + this.form.fileUrls = []; this.form.fileUrls = this.imgAddress; + console.log(this.form.fileUrls) updateKnowledgeRepair(this.form).then(response => { this.$modal.msgSuccess("修改成功"); + this.imgAddress.length = 0; + this.form.fileUrls.length=0; this.open = false; this.getList(); }); } else { + // this.form.fileUrls.length=0; this.form.fileUrls = this.imgAddress; addKnowledgeRepair(this.form).then(response => { this.$modal.msgSuccess("新增成功"); diff --git a/hw-ui/src/views/dms/konwledgeMaint/index.vue b/hw-ui/src/views/dms/konwledgeMaint/index.vue index edce086c..386faa5c 100644 --- a/hw-ui/src/views/dms/konwledgeMaint/index.vue +++ b/hw-ui/src/views/dms/konwledgeMaint/index.vue @@ -329,6 +329,11 @@ export default { }, //图片上传删除 handleRemove(file, fileList) { + const url = file.url; + console.log(url); + const i = this.imgAddress.findIndex((x)=> x.url === url); + this.imgAddress.splice(i,1); + console.log(this.imgAddress) //根据传进来删除的file里图片,同时删除保存在fileListPut的相同图片 if(this.fileListPut.length > 0){ this.fileListPut = this.fileListPut.filter((item, index)=>{ @@ -353,6 +358,7 @@ export default { //往此数组中保存当前图片对象 this.fileListPut.push(currentFile); console.log(this.fileListPut) + console.log(this.imgAddress) }, @@ -427,6 +433,8 @@ export default { }, /** 新增按钮操作 */ handleAdd() { + console.log(this.imgAddress.length) + this.imgAddress.length=0; this.reset(); this.fileListShow = []; this.open = true; @@ -437,8 +445,13 @@ export default { this.reset(); const knowledgeMaintId = row.knowledgeMaintId || this.ids getKonwledgeMaint(knowledgeMaintId).then(response => { + console.log(response.data.systemFiles) + for (let element of response.data.systemFiles) { + this.imgAddress.push(element.url) + } this.form = response.data; this.fileListShow = response.data.systemFiles + console.log(this.fileListShow) this.open = true; this.title = "修改保养知识库"; }); @@ -448,21 +461,23 @@ export default { this.$refs["form"].validate(valid => { if (valid) { if (this.form.knowledgeMaintId != null) { + this.form.fileUrls = []; this.form.fileUrls = this.imgAddress; updateKonwledgeMaint(this.form).then(response => { this.$modal.msgSuccess("修改成功"); + this.imgAddress.length = 0; + this.form.fileUrls.length=0; this.open = false; + // this.imgAddress.length = 0; this.getList(); }); } else { this.form.fileUrls = this.imgAddress; - addKonwledgeMaint(this.form).then(response => { - this.$modal.msgSuccess("新增成功"); + this.imgAddress.length = 0; this.open = false; console.log(this.imgAddress) - this.imgAddress.length = 0; this.getList(); }); }