Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 联表数据切换数据源逻辑优化 --story=120610588 #511

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@
} = useRequest(StrategyManageService.fetchTable, {
defaultValue: [],
onSuccess: () => {
if (tableData.value.length && !modelValue.value.rt_id) {
// EventLog 默认使用第一个rt_id(只有一个)
// 额外传递system_ids参数,只有EventLog才需要
modelValue.value.rt_id = tableData.value[0]?.value;
}
// EventLog 默认使用第一个rt_id(只有一个)
// 额外传递system_ids参数,只有EventLog才需要
modelValue.value.rt_id = tableData.value[0]?.value;
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
if (val && val.length) {
isError.value = false;
}
}, {
immediate: true,
});

defineExpose<Expose>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,25 @@
const getLeftTableFields = (id: string) => {
StrategyManageService.fetchTableRtFields({
table_id: id,
}).then(data => leftFieldsList.value = data);
}).then((data) => {
leftFieldsList.value = data;
linkFields.value = linkFields.value.map(item => ({
right_field: item.right_field,
left_field: leftFieldsList.value.find(fieldItem => fieldItem.value === item.left_field) ? item.left_field : '',
}));
});
};

const getRightTableFields = (id: string) => {
StrategyManageService.fetchTableRtFields({
table_id: id,
}).then(data => rightFieldsList.value = data);
}).then((data) => {
rightFieldsList.value = data;
linkFields.value = linkFields.value.map(item => ({
left_field: item.left_field,
right_field: rightFieldsList.value.find(fieldItem => fieldItem.value === item.right_field) ? item.right_field : '',
}));
});
};

// 新增
Expand All @@ -150,38 +162,28 @@

// 获取左边表字段
watch(() => props.leftTableRtId, (data) => {
// 切换rt_id,清空字段输入
if (leftFieldsList.value.length) {
linkFields.value = linkFields.value?.map(field => ({
...field,
left_field: '',
}));
}
// 获取表字段
if (data && data.length) {
const id = Array.isArray(data) ? data[data.length - 1] : data;
getLeftTableFields(id);
} else {
leftFieldsList.value = [];
}
}, {
immediate: true,
});

// 获取右边表字段
watch(() => props.rightTableRtId, (data) => {
// 切换rt_id,清空字段输入
if (rightFieldsList.value.length) {
linkFields.value = linkFields.value?.map(field => ({
...field,
right_field: '',
}));
}
// 获取表字段
if (data && data.length) {
const id = Array.isArray(data) ? data[data.length - 1] : data;
getRightTableFields(id);
} else {
rightFieldsList.value = [];
}
}, {
immediate: true,
});

defineExpose<Exposes>({
Expand Down
Loading