From ba89944389dba3472a0c354cc8fe7ed18b36475b Mon Sep 17 00:00:00 2001 From: v_xugzhou <941071842@qq.com> Date: Thu, 7 Nov 2024 10:59:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=B3=E7=AD=96=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=E9=AA=8C=E6=94=B6=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20--story=3D120516746=20#=20Reviewed,=20tran?= =?UTF-8?q?saction=20id:=2023089?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DecisionTable/ImportExport/ExportBtn.vue | 20 +++++++++++-------- .../DecisionTable/ImportExport/ImportBtn.vue | 16 +++++++++++++-- .../DecisionTable/components/TableHeader.vue | 2 +- frontend/src/config/i18n/cn.js | 2 +- frontend/src/config/i18n/en.js | 2 +- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/DecisionTable/ImportExport/ExportBtn.vue b/frontend/src/components/DecisionTable/ImportExport/ExportBtn.vue index 9967c26..2aeedae 100644 --- a/frontend/src/components/DecisionTable/ImportExport/ExportBtn.vue +++ b/frontend/src/components/DecisionTable/ImportExport/ExportBtn.vue @@ -42,23 +42,27 @@ horizontal: 'center', // 水平居中 vertical: 'center', // 垂直居中 }, - border: { - top: { style: 'thin', color: { rgb: '000000' } }, - bottom: { style: 'thin', color: { rgb: '000000' } }, - left: { style: 'thin', color: { rgb: '000000' } }, - right: { style: 'thin', color: { rgb: '000000' } }, - }, + border: ['top', 'bottom', 'left', 'right'].reduce((acc, side) => { + acc[side] = { style: 'thin', color: { rgb: '000000' } }; + return acc; + }, {}), }; // 定义表头和注释 const headers = [ { label: 'Input', - children: inputs.map(item => ({ label: `${item.name}(${item.id})`, description: JSON.stringify(item) })), + children: inputs.map((item) => { + const { id, name, ...rest } = item; + return { label: `${name}(${id})`, description: JSON.stringify(rest) }; + }), }, { label: 'Output', - children: outputs.map(item => ({ label: `${item.name}(${item.id})`, description: JSON.stringify(item) })), + children: outputs.map((item) => { + const { id, name, ...rest } = item; + return { label: `${name}(${id})`, description: JSON.stringify(rest) }; + }), }, ]; const data = records.reduce((acc, cur) => { diff --git a/frontend/src/components/DecisionTable/ImportExport/ImportBtn.vue b/frontend/src/components/DecisionTable/ImportExport/ImportBtn.vue index 4e0496b..e7b8ebd 100644 --- a/frontend/src/components/DecisionTable/ImportExport/ImportBtn.vue +++ b/frontend/src/components/DecisionTable/ImportExport/ImportBtn.vue @@ -71,6 +71,7 @@ const inputs = []; const outputs = []; const records = []; + console.log(jsonData, sheetValue); const result = jsonData.some((row, rIndex) => { // 类型 if (rIndex === 0) return false; @@ -114,7 +115,13 @@ }, getHeader(row, sheetValue) { const header = []; + const titleRegex = /^([^\(]+)\(([^)]+)\)$/; const result = row.every((cell) => { + if (!titleRegex.test(cell)) { + this.showMessage(`表格【${cell}】列标题数据结构不对`); + return false; + } + const comment = sheetValue.find(value => Object.prototype.toString.call(value) === '[object Object]' && value.v === cell); if (!comment || !comment.c) { @@ -127,7 +134,12 @@ this.showMessage(`表格【${cell}】列的配置注释不是json格式`); return false; } - header.push(JSON.parse(t)); + const [, name, id] = cell.match(titleRegex); + header.push({ + id, + name, + ...JSON.parse(t), + }); return true; }); @@ -154,7 +166,7 @@ // 生成record if (col.from === 'outputs') { - outputs[col.id] = value; + outputs[col.id] = value.trim(); } if (col.from === 'inputs') { inputs.conditions.push({ diff --git a/frontend/src/components/DecisionTable/components/TableHeader.vue b/frontend/src/components/DecisionTable/components/TableHeader.vue index ae07410..6cdb1bd 100644 --- a/frontend/src/components/DecisionTable/components/TableHeader.vue +++ b/frontend/src/components/DecisionTable/components/TableHeader.vue @@ -7,7 +7,6 @@ :style="{ width: `${widthMap[item.type]}px` }" :class="['header-cell', { 'index-header': item.type === 'index' }]">