Skip to content

Commit

Permalink
Merge pull request #57 from ywywZhou/decision_export_import_bugfix
Browse files Browse the repository at this point in the history
fix: 决策表导入导出验收问题修复 --story=120516746
  • Loading branch information
luofann authored Nov 7, 2024
2 parents d2162cf + ba89944 commit 38a2a31
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
20 changes: 12 additions & 8 deletions frontend/src/components/DecisionTable/ImportExport/ExportBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/components/DecisionTable/ImportExport/ImportBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
});
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
:style="{ width: `${widthMap[item.type]}px` }"
:class="['header-cell', { 'index-header': item.type === 'index' }]">
<template v-if="item.type === 'index'">
<span>{{ 'U' }}</span>
<i
v-bk-tooltips="$t('需保证有且仅有一条规则被命中')"
class="common-icon-info" />
Expand Down Expand Up @@ -128,6 +127,7 @@
.index-header {
position: sticky;
left: 0;
justify-content: space-around;
z-index: 5;
padding: 0 12px;
background: #fafbfd;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/config/i18n/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const cn = {
关联流程: '关联流程',
描述: '描述',
规则配置: '规则配置',
'Unique:需保证有且仅有一条规则被命中': 'Unique:需保证有且仅有一条规则被命中',
需保证有且仅有一条规则被命中: '需保证有且仅有一条规则被命中',
'该决策表已被流程中的节点引用,仅支持修改规则,不支持修改字段(修改字段需要修改节点引用后重新保存流程)。': '该决策表已被流程中的节点引用,仅支持修改规则,不支持修改字段(修改字段需要修改节点引用后重新保存流程)。',
'{0}成功': '{0}成功',
新建: '新建',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/config/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const en = {
关联流程: 'Related Process',
描述: 'Description',
规则配置: 'Rule Configuration',
'Unique:需保证有且仅有一条规则被命中': 'Unique: Ensure that one and only one rule is hit',
需保证有且仅有一条规则被命中: 'Ensure that one and only one rule is hit',
'该决策表已被流程中的节点引用,仅支持修改规则,不支持修改字段(修改字段需要修改节点引用后重新保存流程)。': 'This decision table is referenced by a node in a process. Only rule modifications are supported, not field modifications (field modifications require updating the node references and saving the process again).',
'{0}成功': '{0} Successful',
新建: 'Add',
Expand Down

0 comments on commit 38a2a31

Please sign in to comment.