feat: ✨ 代码生成配置
This commit is contained in:
@@ -15,7 +15,7 @@ class DatabaseAPI {
|
|||||||
/** 获取代码生成预览数据 */
|
/** 获取代码生成预览数据 */
|
||||||
static getTableColumns(tableName: string) {
|
static getTableColumns(tableName: string) {
|
||||||
return request<any, TableColumnVO[]>({
|
return request<any, TableColumnVO[]>({
|
||||||
url: `${DATABASE_BASE_URL}/${tableName}/columns`,
|
url: `${DATABASE_BASE_URL}/table/${tableName}/columns`,
|
||||||
method: "get",
|
method: "get",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import "animate.css";
|
|||||||
import { InstallCodemirro } from "codemirror-editor-vue3";
|
import { InstallCodemirro } from "codemirror-editor-vue3";
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
// 注册插件
|
||||||
app.use(setupPlugins);
|
app.use(setupPlugins);
|
||||||
app.use(InstallCodemirro);
|
app.use(InstallCodemirro);
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|||||||
@@ -51,16 +51,16 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
@click="handlePreview(scope.row.tableName)"
|
@click="handleOpenDialog('config', scope.row.tableName)"
|
||||||
>
|
>
|
||||||
<i-ep-View />
|
<i-ep-View />
|
||||||
预览
|
配置
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
@click="handlePreview(scope.row.tableName)"
|
@click="handleOpenDialog('preview', scope.row.tableName)"
|
||||||
>
|
>
|
||||||
<i-ep-MagicStick />
|
<i-ep-MagicStick />
|
||||||
生成
|
生成
|
||||||
@@ -84,6 +84,7 @@
|
|||||||
@close="handleCloseDialog"
|
@close="handleCloseDialog"
|
||||||
size="80%"
|
size="80%"
|
||||||
>
|
>
|
||||||
|
<div v-if="dialog.type === 'preview'">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-tree :data="[{ value: 'Controller', label: 'Controller' }]" />
|
<el-tree :data="[{ value: 'Controller', label: 'Controller' }]" />
|
||||||
@@ -101,6 +102,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="dialog.type === 'config'">
|
||||||
|
<el-tabs type="border-card">
|
||||||
|
<el-tab-pane label="User">基础信息</el-tab-pane>
|
||||||
|
<el-tab-pane label="Config">字段配置</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="handleCloseDialog">取 消</el-button>
|
<el-button @click="handleCloseDialog">取 消</el-button>
|
||||||
@@ -165,6 +173,7 @@ const queryParams = reactive<TablePageQuery>({
|
|||||||
const pageData = ref<TablePageVO[]>([]);
|
const pageData = ref<TablePageVO[]>([]);
|
||||||
|
|
||||||
const dialog = reactive({
|
const dialog = reactive({
|
||||||
|
type: "",
|
||||||
visible: false,
|
visible: false,
|
||||||
title: "",
|
title: "",
|
||||||
});
|
});
|
||||||
@@ -188,22 +197,24 @@ function handleResetQuery() {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePreview(tableName: string) {
|
|
||||||
DatabaseAPI.getPreviewData(tableName).then((data) => {
|
|
||||||
dialog.title = `预览 ${tableName}`;
|
|
||||||
code.value = data[0].content;
|
|
||||||
|
|
||||||
console.log("data", data);
|
|
||||||
handleOpenDialog();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCloseDialog() {
|
function handleCloseDialog() {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOpenDialog() {
|
/** 打开弹窗 */
|
||||||
|
function handleOpenDialog(type: string, tableName: string) {
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
|
dialog.type = type;
|
||||||
|
if (type === "preview") {
|
||||||
|
DatabaseAPI.getPreviewData(tableName).then((data) => {
|
||||||
|
dialog.title = `预览 ${tableName}`;
|
||||||
|
code.value = data[0].content;
|
||||||
|
});
|
||||||
|
} else if (type === "config") {
|
||||||
|
DatabaseAPI.getTableColumns(tableName).then((data) => {
|
||||||
|
dialog.title = `配置 ${tableName}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {}
|
function handleSubmit() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user