From 22f9415a4028221cb8de6852b7dd921bdc27593e Mon Sep 17 00:00:00 2001 From: fanluyan <754122931@qq.com> Date: Fri, 26 Jul 2024 15:23:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/rptparam/index.vue | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/views/rptparam/index.vue b/src/views/rptparam/index.vue index f3f365df..67475ff3 100644 --- a/src/views/rptparam/index.vue +++ b/src/views/rptparam/index.vue @@ -181,13 +181,22 @@ export default { }, computed: { preprocessedData() { + const rptOptionsParamIndices = new Set( + this.rptOptions.map((option) => option.paramindex) + ); + return this.bindInfoArray.map((item) => { const matchedItem2 = this.previewData.find( - (item2) => item2.colname === item.name + (item2) => + item2.colname === item.name && + rptOptionsParamIndices.has(item2.paramindex) ); + + // 如果没有找到匹配项,或者匹配项的 paramindex 不在 rptOptions 中,则返回一个默认对象 + // 但根据你的要求,这里我们只关心 colname 和 paramindex 的双重匹配 return { ...item, // 保留原始item的所有属性 - matchedItem2: matchedItem2 || { colname: "", paramindex: "" }, // 如果没有找到匹配项,则返回一个默认对象 + matchedItem2: matchedItem2 || { colname: "", paramindex: "" }, // 如果没有找到双重匹配的项,则返回一个默认对象 }; }); }, @@ -244,7 +253,7 @@ export default { } this.currentNodeKey = data.id; this.rptOptions = []; - this.getRptInfo(); + this.getiedList(); }, @@ -254,6 +263,7 @@ export default { .then((res) => { console.log(res); this.iedOptions = res.data; + this.getRptInfo(); }) .catch((err) => { console.log(err); //代码错误、请求失败捕获 @@ -277,11 +287,14 @@ export default { .then((res) => { console.log(res); this.ljOptions = res.data; + console.log("获取逻辑", this.icdid); if (this.icdid !== null) { - this.ljName = this.ljOptions.find( - (item) => item.id === this.icdid - ).paramIndex; - this.getlistRpt(this.ljName); + this.ljName = + this.ljOptions.find((item) => item.id === this.icdid) + ?.paramIndex || ""; + if (this.ljName !== "") { + this.getlistRpt(this.ljName); + } } else { this.ljName = ""; } @@ -296,7 +309,9 @@ export default { console.log(this.ljOptions.find((item) => item.paramIndex === val)); this.icdid = this.ljOptions.find((item) => item.paramIndex === val).id; this.warnMsg = ""; + console.log("我是监听", this.preprocessedData); this.getlistRpt(this.ljName); + // }, //获取可用rpt getlistRpt(val) { @@ -326,7 +341,6 @@ export default { }) .then((res) => { this.bindInfo = res.data; - if (res.data.columnList != null) { this.bindInfoArray = res.data.columnList; this.previewData = res.data.rptList;