fix: 🐛 代码生成步骤条显示状态不正确问题修复

This commit is contained in:
ray
2024-07-29 13:04:29 +08:00
parent 334393bbde
commit 6ea3a4747d

View File

@@ -82,7 +82,7 @@
</el-steps>
<div class="mt-5">
<el-form v-show="active == 1" :model="formData" :label-width="100">
<el-form v-show="active == 0" :model="formData" :label-width="100">
<el-row>
<el-col :span="12">
<el-form-item label="表名">
@@ -124,7 +124,7 @@
</el-form>
<el-table
v-show="active == 2"
v-show="active == 1"
v-loading="loading"
:element-loading-text="loadingText"
highlight--currentrow
@@ -253,7 +253,8 @@
</template>
</el-table-column>
</el-table>
<el-row v-show="active == 3">
<el-row v-show="active == 2">
<el-col :span="6">
<el-scrollbar max-height="72vh">
<el-tree
@@ -293,13 +294,13 @@
</div>
<template #footer>
<el-button type="success" @click="handlePrevClick" v-if="active !== 1">
<el-button type="success" @click="handlePrevClick" v-if="active !== 0">
<el-icon><Back /></el-icon>
{{ prevBtnText }}
</el-button>
<el-button type="primary" @click="handleNextClick">
{{ nextBtnText }}
<el-icon v-if="active !== 3"><Right /></el-icon>
<el-icon v-if="active !== 2"><Right /></el-icon>
<el-icon v-else><Download /></el-icon>
</el-button>
</template>
@@ -357,14 +358,22 @@ const cmOptions: EditorConfiguration = {
const prevBtnText = ref("");
const nextBtnText = ref("下一步,字段配置");
const active = ref(1);
const active = ref(0);
interface TreeNode {
label: string;
content?: string;
children?: TreeNode[];
}
const treeData = ref<TreeNode[]>([]);
function handlePrevClick() {
if (active.value-- <= 1) active.value = 1;
if (active.value-- <= 0) active.value = 0;
}
function handleNextClick() {
if (active.value === 2) {
if (active.value === 1) {
// 保存生成配置
const tableName = formData.value.tableName;
if (!tableName) {
@@ -378,24 +387,24 @@ function handleNextClick() {
handlePreview(tableName);
})
.then(() => {
if (active.value++ >= 3) active.value = 3;
if (active.value++ >= 2) active.value = 2;
})
.finally(() => {
loading.value = false;
loadingText.value = "loading...";
});
} else {
if (active.value++ >= 3) active.value = 3;
if (active.value++ >= 2) active.value = 2;
}
}
watch(active, (val) => {
if (val === 1) {
if (val === 0) {
nextBtnText.value = "下一步,字段配置";
} else if (val === 2) {
} else if (val === 1) {
prevBtnText.value = "上一步,基础配置";
nextBtnText.value = "下一步,确认生成";
} else if (val === 3) {
} else if (val === 2) {
prevBtnText.value = "上一步,字段配置";
nextBtnText.value = "下载代码";
}
@@ -424,14 +433,6 @@ function handleCloseDialog() {
dialog.visible = false;
}
interface TreeNode {
label: string;
content?: string;
children?: TreeNode[];
}
const treeData = ref<TreeNode[]>([]);
/** 打开弹窗 */
function handleOpenDialog(tableName: string) {
dialog.visible = true;
@@ -439,10 +440,10 @@ function handleOpenDialog(tableName: string) {
dialog.title = `${tableName} 代码生成`;
formData.value = data;
if (formData.value.id) {
active.value = 3;
active.value = 2;
handlePreview(tableName);
} else {
active.value = 1;
active.value = 0;
}
});
}
@@ -485,11 +486,11 @@ function buildTree(
// 定义特殊路径
// TODO: 如果菜单有多个节点,需要将此菜单作为独立一级的节点,而不是合并到上一级。 按照此规则, com.youlai.system 则是三个节点,而不是合并到一起,但是这里需要将 com.youlai.system 合并到一起,所以需要特殊处理
const specialPaths = [
"com\\youlai\\system",
"src\\main",
"src/main",
"java",
"youlai-boot",
"vue3-element-admin",
"com/youlai/system",
];
// 检查路径中的特殊部分并合并它们
@@ -499,6 +500,7 @@ function buildTree(
parts.forEach((part) => {
buffer.push(part);
const currentPath = buffer.join(separator);
console.log("currentPath", currentPath);
if (specialPaths.includes(currentPath)) {
mergedParts.push(currentPath);
buffer = [];