From a63727057c8285c9c9fb76f79c3ce9a335bb38fd Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Thu, 27 Jul 2023 15:21:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:http=E6=95=B0=E6=8D=AE=E9=9B=86=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E8=BE=93=E5=87=BA=E5=AD=97=E6=AE=B5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/HttpEditForm.vue | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 41f63167..c9b32439 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -979,6 +979,8 @@ export default { this.replaceParams(this.dataForm.config.paramsList) axiosFormatting({ ...this.newDataForm.config }).then((res) => { this.dataPreviewList = res.data.list + // 获取数据后更新输出字段 + this.updateOoutputFieldList(this.dataPreviewList) console.log(res) }) } else { @@ -991,6 +993,8 @@ export default { } datasetExecuteTest(executeParams).then(res => { this.dataPreviewList = res.data.data.list + // 获取数据后更新输出字段 + this.updateOoutputFieldList(this.dataPreviewList) this.$message.success('解析并执行成功') }).catch((e) => { @@ -998,6 +1002,46 @@ export default { } } }, + updateOoutputFieldList (dataList) { + if (dataList && dataList.length) { + const newList = Object.keys(dataList?.[0])?.map(key => { + return { + fieldName: key, + fieldDesc: '' + } + }) + this.outputFieldList = this.compareArr(newList, this.outputFieldList) + } else { + this.outputFieldList = [] + } + }, + // 用来对两个数组进行对比 + compareArr (newList, oldList) { + // 创建一个空数组,用于存储最终的结果 + const result = [] + + // 遍历A数组中的每个对象 + for (const objA of newList) { + let found = false // 标志变量,用于表示是否在B数组中找到对应的属性 + + // 遍历B数组中的每个对象 + for (const objB of oldList) { + if (objA.fieldName === objB.fieldName) { + // 如果A和B中的fieldName相同,则将B中该属性的属性值赋值给A,并将该对象添加到结果数组中 + objA.fieldDesc = objB.fieldDesc + result.push(objA) + found = true + break + } + } + + // 如果在B数组中没有找到对应的属性,则直接将该对象添加到结果数组中 + if (!found) { + result.push(objA) + } + } + return result + }, // 清空分类 clearType () { this.typeName = ''