From 54383da57038c39107e6f1865ebd7b8f581fd659 Mon Sep 17 00:00:00 2001 From: zyd Date: Sun, 28 Aug 2022 21:01:40 +0800 Subject: [PATCH] =?UTF-8?q?=20fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomFormComponents/File.vue | 54 ++++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/components/CustomFormComponents/File.vue b/src/components/CustomFormComponents/File.vue index 4dc120d31..f0488b990 100644 --- a/src/components/CustomFormComponents/File.vue +++ b/src/components/CustomFormComponents/File.vue @@ -366,27 +366,39 @@ export default { obj.name = file.response.data.oldFileName obj.response.data = file.response.data this.showFileList.push(obj) - // this.value += res.data.id + ',' - this.$emit('input', this.value ? (this.value + ','+ res.data.id + ',').replaceAll(",,",',') : (this.value+ res.data.id + ',').replaceAll(',,',',')) - this.$emit('success') - this.$message({ - message: '文件上传成功', - type: 'success' - }) - switch (this.config.attrField) { - case 'recordsAttr': - this.$emit('recordsAttrTime', res.data.uploadTime) - break - case 'signAttr': - this.$emit('signAttrTime', res.data.uploadTime) - break - case 'otherAttr': - this.$emit('otherAttrTime', res.data.uploadTime) - break - } - // 国内外标准法规返回文件上传成功状态 - this.$emit('fileSuccess', true) - // this.importModalshowflagtemp = false + let attrIds="" + if(this.value != null && this.value !== ''){ + let attrArray= this.value.split(',') + // 方法二:filter方法 [推荐写法] + let attrIdsArray = attrArray.filter((s) => { + return s && s.trim(); // 注:IE9(不包含IE9)以下的版本没有trim()方法 + }); + attrIdsArray.push(res.data.id); + console.log(attrIdsArray) + attrIds = attrIdsArray.join(',')+"," + }else{ + attrIds =res.data.id+"," + } + this.$emit('input', attrIds) + this.$emit('success') + this.$message({ + message: '文件上传成功', + type: 'success' + }) + switch (this.config.attrField) { + case 'recordsAttr': + this.$emit('recordsAttrTime', res.data.uploadTime) + break + case 'signAttr': + this.$emit('signAttrTime', res.data.uploadTime) + break + case 'otherAttr': + this.$emit('otherAttrTime', res.data.uploadTime) + break + } + // 国内外标准法规返回文件上传成功状态 + this.$emit('fileSuccess', true) + // this.importModalshowflagtemp = false } else { this.$message({ message: res.message,