From 6f12b91ea35c60608147af5627b025ff6bf7c4df Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 21 Dec 2022 16:02:56 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/views/monitor/datalog/DataLogCompa?= =?UTF-8?q?reModal.vue.=20async=20function=20initTableData()=20=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=80=83=E8=99=91=E5=BD=93=E5=89=8D=E5=90=8E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=B8=AD=E7=9A=84JSON=E5=AF=B9=E8=B1=A1=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E5=AE=8C=E5=85=A8=E5=8C=B9=E9=85=8D=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E3=80=82=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=8C=89=E5=AD=97=E6=AE=B5=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E8=BE=93=E5=87=BA=E7=9A=84=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric --- .../monitor/datalog/DataLogCompareModal.vue | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/views/monitor/datalog/DataLogCompareModal.vue b/src/views/monitor/datalog/DataLogCompareModal.vue index 2911c92..afb3cb3 100644 --- a/src/views/monitor/datalog/DataLogCompareModal.vue +++ b/src/views/monitor/datalog/DataLogCompareModal.vue @@ -127,15 +127,19 @@ async function initTableData() { console.info('params', params); queryCompareList(unref(params)).then((res) => { - console.info('test', res); dataVersion1Num.value = res[0].dataVersion; dataVersion2Num.value = res[1].dataVersion; let json1 = JSON.parse(res[0].dataContent); let json2 = JSON.parse(res[1].dataContent); + let data = []; + let fields = []; for (var item1 in json1) { + let matched = false; for (var item2 in json2) { if (item1 == item2) { + matched = true; + fields.push(item1); data.push({ code: item1, imgshow: '', @@ -144,8 +148,49 @@ }); } } + // some item1's field is not in item2. + if (matched == false) { + data.push({ + code: item1, + imgshow: '', + dataVersion1: json1[item1], + dataVersion2: '', + }); + } } - dataSource.value = data; + + for (var item2 in json2) { + let matched = false; + for (var item1 in json1) { + if (item1 == item2) { + matched = true; + } + } + // some item2's field is not in item1 + if (matched == false) { + fields.push(item2); + data.push({ + code: item2, + imgshow: '', + dataVersion1: '', + dataVersion2: json2[item2], + }); + } + } + + // sort the fields by name + fields.sort(); + let sortedData = []; + for (var field in fields) { + for (var d in data) { + if (data[d].code === fields[field]) { + sortedData.push(data[d]); + continue; + } + } + } + + dataSource.value = sortedData; }); } function handleChange1(value) { -- Gitee