mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 08:57:14 +08:00
refactor: 重构查询列映射信息列表接口,支持对已保存的列映射配置同步最新表结构
This commit is contained in:
@@ -42,12 +42,11 @@ export interface ColumnMappingRecord {
|
||||
showInQuery: boolean;
|
||||
formType: string;
|
||||
queryType: string;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export function listColumnMapping(tableName: string) {
|
||||
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}`);
|
||||
export function listColumnMapping(tableName: string, requireSync: boolean) {
|
||||
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}?requireSync=${requireSync}`);
|
||||
}
|
||||
|
||||
export interface GenConfigRecord {
|
||||
@@ -59,8 +58,8 @@ export interface GenConfigRecord {
|
||||
author: string;
|
||||
tablePrefix: string;
|
||||
isOverride: boolean;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export function getGenConfig(tableName: string) {
|
||||
|
@@ -126,17 +126,26 @@
|
||||
>
|
||||
<a-card title="字段配置" class="field-config">
|
||||
<template #extra>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
status="success"
|
||||
size="small"
|
||||
title="同步"
|
||||
disabled
|
||||
>
|
||||
<template #icon><icon-sync /></template>同步
|
||||
</a-button>
|
||||
</a-space>
|
||||
<a-popconfirm
|
||||
content="确定要同步最新数据表结构吗?同步后只要不点击确定保存,则不影响原有配置数据。"
|
||||
type="warning"
|
||||
@ok="handleRefresh(form.tableName)"
|
||||
>
|
||||
<a-tooltip content="同步最新数据表结构">
|
||||
<a-button
|
||||
type="primary"
|
||||
status="success"
|
||||
size="small"
|
||||
title="同步"
|
||||
:disabled="
|
||||
columnMappingList.length !== 0 &&
|
||||
columnMappingList[0].createTime === null
|
||||
"
|
||||
>
|
||||
<template #icon><icon-sync /></template>同步
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
<a-table
|
||||
ref="columnMappingRef"
|
||||
@@ -376,20 +385,40 @@
|
||||
tableComment = tableComment ? `(${tableComment})` : ' ';
|
||||
title.value = `${tableName}${tableComment}配置`;
|
||||
visible.value = true;
|
||||
// 查询列映射信息
|
||||
getColumnMappingList(tableName, false);
|
||||
// 查询生成配置
|
||||
getGenConfig(tableName).then((res) => {
|
||||
form.value = res.data;
|
||||
form.value.isOverride = false;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 同步
|
||||
*
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const handleRefresh = (tableName: string) => {
|
||||
getColumnMappingList(tableName, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询列映射信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param requireSync 是否需要同步
|
||||
*/
|
||||
const getColumnMappingList = (tableName: string, requireSync: boolean) => {
|
||||
// 查询列映射信息
|
||||
columnMappingLoading.value = true;
|
||||
listColumnMapping(tableName)
|
||||
listColumnMapping(tableName, requireSync)
|
||||
.then((res) => {
|
||||
columnMappingList.value = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
columnMappingLoading.value = false;
|
||||
});
|
||||
// 查询生成配置
|
||||
getGenConfig(tableName).then((res) => {
|
||||
form.value = res.data;
|
||||
form.value.isOverride = false;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user