mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-13 02:57:13 +08:00
refactor: 优化代码生成配置相关表名、 API 地址及相关描述
1、列映射表重命名为字段配置表
This commit is contained in:
@@ -29,7 +29,7 @@ export function listTable(params: TableParam) {
|
||||
});
|
||||
}
|
||||
|
||||
export interface ColumnMappingRecord {
|
||||
export interface FieldConfigRecord {
|
||||
tableName: string;
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
@@ -45,8 +45,8 @@ export interface ColumnMappingRecord {
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export function listColumnMapping(tableName: string, requireSync: boolean) {
|
||||
return axios.get<ColumnMappingRecord[]>(`${BASE_URL}/column/${tableName}?requireSync=${requireSync}`);
|
||||
export function listFieldConfig(tableName: string, requireSync: boolean) {
|
||||
return axios.get<FieldConfigRecord[]>(`${BASE_URL}/field/${tableName}?requireSync=${requireSync}`);
|
||||
}
|
||||
|
||||
export interface GenConfigRecord {
|
||||
@@ -63,14 +63,14 @@ export interface GenConfigRecord {
|
||||
}
|
||||
|
||||
export function getGenConfig(tableName: string) {
|
||||
return axios.get<GenConfigRecord>(`${BASE_URL}/table/${tableName}`);
|
||||
return axios.get<GenConfigRecord>(`${BASE_URL}/config/${tableName}`);
|
||||
}
|
||||
|
||||
export interface GeneratorConfigRecord {
|
||||
genConfig: GenConfigRecord;
|
||||
columnMappings: ColumnMappingRecord[];
|
||||
fieldConfigs: FieldConfigRecord[];
|
||||
}
|
||||
|
||||
export function saveConfig(tableName: string, req: GeneratorConfigRecord) {
|
||||
return axios.post(`${BASE_URL}/table/${tableName}`, req);
|
||||
return axios.post(`${BASE_URL}/config/${tableName}`, req);
|
||||
}
|
||||
|
@@ -28,24 +28,6 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<!-- 操作栏 -->
|
||||
<div class="header-operation">
|
||||
<a-row>
|
||||
<a-col :span="12">
|
||||
<a-space>
|
||||
<a-button type="primary" @click="toGenerate(ids[0])">
|
||||
<template #icon><icon-robot-add /></template>代码生成
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<right-toolbar
|
||||
v-model:show-query="showQuery"
|
||||
@refresh="getList"
|
||||
/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表区域 -->
|
||||
@@ -54,11 +36,6 @@
|
||||
row-key="tableName"
|
||||
:data="tableList"
|
||||
:loading="loading"
|
||||
:row-selection="{
|
||||
type: 'checkbox',
|
||||
showCheckedAll: true,
|
||||
onlyCurrent: false,
|
||||
}"
|
||||
:pagination="{
|
||||
showTotal: true,
|
||||
showPageSize: true,
|
||||
@@ -71,7 +48,6 @@
|
||||
size="large"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<template #columns>
|
||||
<a-table-column title="序号">
|
||||
@@ -103,13 +79,20 @@
|
||||
type="text"
|
||||
size="small"
|
||||
title="生成"
|
||||
@click="toGenerate(record.tableName)"
|
||||
@click="handleGenerate(record.tableName)"
|
||||
>
|
||||
<template #icon><icon-robot-add /></template>生成
|
||||
</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
<template #pagination-left>
|
||||
<a-tooltip content="刷新">
|
||||
<div class="action-icon" @click="handleQuery">
|
||||
<icon-refresh size="18" />
|
||||
</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
@@ -138,8 +121,8 @@
|
||||
size="small"
|
||||
title="同步"
|
||||
:disabled="
|
||||
columnMappingList.length !== 0 &&
|
||||
columnMappingList[0].createTime === null
|
||||
fieldConfigList.length !== 0 &&
|
||||
fieldConfigList[0].createTime === null
|
||||
"
|
||||
>
|
||||
<template #icon><icon-sync /></template>同步
|
||||
@@ -148,9 +131,9 @@
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
<a-table
|
||||
ref="columnMappingRef"
|
||||
:data="columnMappingList"
|
||||
:loading="columnMappingLoading"
|
||||
ref="fieldConfigRef"
|
||||
:data="fieldConfigList"
|
||||
:loading="fieldConfigLoading"
|
||||
:pagination="false"
|
||||
:bordered="false"
|
||||
size="large"
|
||||
@@ -307,10 +290,10 @@
|
||||
import {
|
||||
TableRecord,
|
||||
TableParam,
|
||||
ColumnMappingRecord,
|
||||
FieldConfigRecord,
|
||||
GenConfigRecord,
|
||||
listTable,
|
||||
listColumnMapping,
|
||||
listFieldConfig,
|
||||
getGenConfig,
|
||||
GeneratorConfigRecord,
|
||||
saveConfig,
|
||||
@@ -323,16 +306,13 @@
|
||||
);
|
||||
|
||||
const tableList = ref<TableRecord[]>([]);
|
||||
const columnMappingList = ref<ColumnMappingRecord[]>([]);
|
||||
const fieldConfigList = ref<FieldConfigRecord[]>([]);
|
||||
const total = ref(0);
|
||||
const ids = ref<Array<string>>([]);
|
||||
const title = ref('');
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const showQuery = ref(true);
|
||||
const loading = ref(false);
|
||||
const visible = ref(false);
|
||||
const columnMappingLoading = ref(false);
|
||||
const fieldConfigLoading = ref(false);
|
||||
|
||||
const data = reactive({
|
||||
// 查询参数
|
||||
@@ -344,6 +324,7 @@
|
||||
},
|
||||
// 表单数据
|
||||
form: {} as GenConfigRecord,
|
||||
// 代码生成配置数据
|
||||
config: {} as GeneratorConfigRecord,
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
@@ -385,8 +366,8 @@
|
||||
tableComment = tableComment ? `(${tableComment})` : ' ';
|
||||
title.value = `${tableName}${tableComment}配置`;
|
||||
visible.value = true;
|
||||
// 查询列映射信息
|
||||
getColumnMappingList(tableName, false);
|
||||
// 查询字段配置
|
||||
getFieldConfig(tableName, false);
|
||||
// 查询生成配置
|
||||
getGenConfig(tableName).then((res) => {
|
||||
form.value = res.data;
|
||||
@@ -400,24 +381,23 @@
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const handleRefresh = (tableName: string) => {
|
||||
getColumnMappingList(tableName, true);
|
||||
getFieldConfig(tableName, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询列映射信息
|
||||
* 查询字段配置
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param requireSync 是否需要同步
|
||||
*/
|
||||
const getColumnMappingList = (tableName: string, requireSync: boolean) => {
|
||||
// 查询列映射信息
|
||||
columnMappingLoading.value = true;
|
||||
listColumnMapping(tableName, requireSync)
|
||||
const getFieldConfig = (tableName: string, requireSync: boolean) => {
|
||||
fieldConfigLoading.value = true;
|
||||
listFieldConfig(tableName, requireSync)
|
||||
.then((res) => {
|
||||
columnMappingList.value = res.data;
|
||||
fieldConfigList.value = res.data;
|
||||
})
|
||||
.finally(() => {
|
||||
columnMappingLoading.value = false;
|
||||
fieldConfigLoading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -427,7 +407,7 @@
|
||||
const handleOk = () => {
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
config.value.columnMappings = columnMappingList.value;
|
||||
config.value.fieldConfigs = fieldConfigList.value;
|
||||
config.value.genConfig = form.value;
|
||||
saveConfig(form.value.tableName, config.value).then((res) => {
|
||||
handleCancel();
|
||||
@@ -444,29 +424,18 @@
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
proxy.$refs.formRef?.resetFields();
|
||||
columnMappingList.value = [];
|
||||
fieldConfigList.value = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 代码生成
|
||||
* 生成代码
|
||||
*
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
const toGenerate = (tableName: string) => {
|
||||
const handleGenerate = (tableName: string) => {
|
||||
proxy.$message.info('功能尚在开发中');
|
||||
};
|
||||
|
||||
/**
|
||||
* 已选择的数据行发生改变时触发
|
||||
*
|
||||
* @param rowKeys ID 列表
|
||||
*/
|
||||
const handleSelectionChange = (rowKeys: Array<any>) => {
|
||||
ids.value = rowKeys;
|
||||
single.value = rowKeys.length !== 1;
|
||||
multiple.value = !rowKeys.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@@ -517,4 +486,13 @@
|
||||
:deep(.gen-config.arco-form) {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.action-icon {
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.action-icon:hover {
|
||||
color: #0960bd;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user