fix: 参数配置修复根据规则取值导致的类型问题
This commit is contained in:
@@ -316,17 +316,21 @@ watch(
|
|||||||
function arrayEdit(rowIndex: Record<string, any>) {
|
function arrayEdit(rowIndex: Record<string, any>) {
|
||||||
const item = arrayState.data.find((s: any) => s.key === rowIndex.value);
|
const item = arrayState.data.find((s: any) => s.key === rowIndex.value);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
const from = arrayEditInit(item, arrayState.dataRule);
|
||||||
|
// 处理信息
|
||||||
const row: Record<string, any> = {};
|
const row: Record<string, any> = {};
|
||||||
for (const v of item.record) {
|
for (const v of from.record) {
|
||||||
|
if (Array.isArray(v.array)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
row[v.name] = Object.assign({}, v);
|
row[v.name] = Object.assign({}, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
modalState.from = row;
|
modalState.from = row;
|
||||||
modalState.type = 'arrayEdit';
|
modalState.type = 'arrayEdit';
|
||||||
modalState.title = `${treeState.selectNode.topDisplay} ${item.title}`;
|
modalState.title = `${treeState.selectNode.topDisplay} ${from.title}`;
|
||||||
modalState.key = item.key;
|
modalState.key = from.key;
|
||||||
modalState.data = item.record.filter((v: any) => !Array.isArray(v.array));
|
modalState.data = from.record.filter((v: any) => !Array.isArray(v.array));
|
||||||
modalState.visible = true;
|
modalState.visible = true;
|
||||||
|
|
||||||
// 关闭嵌套
|
// 关闭嵌套
|
||||||
@@ -433,13 +437,6 @@ function arrayAdd() {
|
|||||||
if (Array.isArray(v.array)) {
|
if (Array.isArray(v.array)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 根据规则类型转值
|
|
||||||
if (['enum', 'int'].includes(v.type)) {
|
|
||||||
v.value = Number(v.value);
|
|
||||||
}
|
|
||||||
if ('bool' === v.type) {
|
|
||||||
v.value = Boolean(v.value);
|
|
||||||
}
|
|
||||||
row[v.name] = Object.assign({}, v);
|
row[v.name] = Object.assign({}, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,17 +641,21 @@ function arrayChildExpandClose() {
|
|||||||
function arrayChildEdit(rowIndex: Record<string, any>) {
|
function arrayChildEdit(rowIndex: Record<string, any>) {
|
||||||
const item = arrayChildState.data.find((s: any) => s.key === rowIndex.value);
|
const item = arrayChildState.data.find((s: any) => s.key === rowIndex.value);
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
const from = arrayEditInit(item, arrayChildState.dataRule);
|
||||||
|
// 处理信息
|
||||||
const row: Record<string, any> = {};
|
const row: Record<string, any> = {};
|
||||||
for (const v of item.record) {
|
for (const v of from.record) {
|
||||||
|
if (Array.isArray(v.array)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
row[v.name] = Object.assign({}, v);
|
row[v.name] = Object.assign({}, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
modalState.from = row;
|
modalState.from = row;
|
||||||
modalState.type = 'arrayChildEdit';
|
modalState.type = 'arrayChildEdit';
|
||||||
modalState.title = `${arrayChildState.title} ${item.title}`;
|
modalState.title = `${arrayChildState.title} ${from.title}`;
|
||||||
modalState.key = item.key;
|
modalState.key = from.key;
|
||||||
modalState.data = item.record.filter((v: any) => !Array.isArray(v.array));
|
modalState.data = from.record.filter((v: any) => !Array.isArray(v.array));
|
||||||
modalState.visible = true;
|
modalState.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,6 +822,35 @@ function arrayChildAddOk(from: Record<string, any>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**多列表编辑行数据初始化 */
|
||||||
|
function arrayEditInit(data: Record<string, any>, dataRule: any) {
|
||||||
|
const dataFrom = data.record;
|
||||||
|
const ruleFrom = Object.assign({}, JSON.parse(JSON.stringify(dataRule)));
|
||||||
|
for (const row of ruleFrom.record) {
|
||||||
|
// 子嵌套的不初始
|
||||||
|
if (row.array) {
|
||||||
|
row.value = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 查找项的值
|
||||||
|
const item = dataFrom.find((s: any) => s.name === row.name);
|
||||||
|
if (!item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 根据规则类型转值
|
||||||
|
if (['enum', 'int'].includes(row.type)) {
|
||||||
|
row.value = Number(item.value);
|
||||||
|
} else if ('bool' === row.type) {
|
||||||
|
row.value = Boolean(item.value);
|
||||||
|
} else {
|
||||||
|
row.value = item.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ruleFrom.key = data.key;
|
||||||
|
ruleFrom.title = data.title;
|
||||||
|
return ruleFrom;
|
||||||
|
}
|
||||||
|
|
||||||
/**多列表新增行数据初始化 */
|
/**多列表新增行数据初始化 */
|
||||||
function arrayAddInit(data: any[], dataRule: any) {
|
function arrayAddInit(data: any[], dataRule: any) {
|
||||||
let newIndex = 0;
|
let newIndex = 0;
|
||||||
@@ -835,6 +865,11 @@ function arrayAddInit(data: any[], dataRule: any) {
|
|||||||
|
|
||||||
const ruleFrom = Object.assign({}, JSON.parse(JSON.stringify(dataRule)));
|
const ruleFrom = Object.assign({}, JSON.parse(JSON.stringify(dataRule)));
|
||||||
for (const row of ruleFrom.record) {
|
for (const row of ruleFrom.record) {
|
||||||
|
// 子嵌套的不初始
|
||||||
|
if (row.array) {
|
||||||
|
row.value = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const value = row.value;
|
const value = row.value;
|
||||||
if (row.name === 'index') {
|
if (row.name === 'index') {
|
||||||
if (newIndex !== 0) {
|
if (newIndex !== 0) {
|
||||||
@@ -850,10 +885,12 @@ function arrayAddInit(data: any[], dataRule: any) {
|
|||||||
ruleFrom.title = `Index-${newIndex}`;
|
ruleFrom.title = `Index-${newIndex}`;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 子嵌套的不初始
|
// 根据规则类型转值
|
||||||
if (row.array) {
|
if (['enum', 'int'].includes(row.type)) {
|
||||||
row.value = [];
|
row.value = Number(row.value);
|
||||||
continue;
|
}
|
||||||
|
if ('bool' === row.type) {
|
||||||
|
row.value = Boolean(row.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ruleFrom;
|
return ruleFrom;
|
||||||
@@ -1277,19 +1314,20 @@ onMounted(() => {
|
|||||||
v-model:expanded-row-keys="arrayState.arrayChildExpandKeys"
|
v-model:expanded-row-keys="arrayState.arrayChildExpandKeys"
|
||||||
>
|
>
|
||||||
<!-- 多列新增操作 -->
|
<!-- 多列新增操作 -->
|
||||||
<template #title v-if="treeState.selectNode.method !== 'get'">
|
<template #title>
|
||||||
<a-space :size="16" align="center">
|
<a-space :size="16" align="center">
|
||||||
<a-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click.prevent="arrayAdd()"
|
@click.prevent="arrayAdd()"
|
||||||
size="small"
|
size="small"
|
||||||
|
v-if="treeState.selectNode.method !== 'get'"
|
||||||
>
|
>
|
||||||
<template #icon> <PlusOutlined /> </template>
|
<template #icon> <PlusOutlined /> </template>
|
||||||
{{ t('common.addText') }}
|
{{ t('common.addText') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<TableColumnsDnd
|
<TableColumnsDnd
|
||||||
type="ghost"
|
type="ghost"
|
||||||
:columns="[...arrayState.columns]"
|
:columns="treeState.selectNode.method === 'get' ? [...arrayState.columns.filter((s:any)=>s.key !== 'index')] : arrayState.columns"
|
||||||
v-model:columns-dnd="arrayState.columnsDnd"
|
v-model:columns-dnd="arrayState.columnsDnd"
|
||||||
></TableColumnsDnd>
|
></TableColumnsDnd>
|
||||||
</a-space>
|
</a-space>
|
||||||
|
|||||||
Reference in New Issue
Block a user