style: 💄 组合式 API 顺序调整和移除无用引用
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { FormTypeEnum } from "@/enums/FormTypeEnum";
|
|
||||||
import { QueryTypeEnum } from "@/enums/QueryTypeEnum";
|
|
||||||
|
|
||||||
const GENERATOR_BASE_URL = "/api/v1/generator";
|
const GENERATOR_BASE_URL = "/api/v1/generator";
|
||||||
|
|
||||||
@@ -178,4 +176,7 @@ export interface FieldConfig {
|
|||||||
|
|
||||||
/** 字段排序 */
|
/** 字段排序 */
|
||||||
fieldSort?: number;
|
fieldSort?: number;
|
||||||
|
|
||||||
|
/** 字典类型 */
|
||||||
|
dictType?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
|
|
||||||
<div class="elTableCustom" v-show="active == 1">
|
<div class="elTableCustom" v-show="active == 1">
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="fieldLoading"
|
v-loading="loading"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
:element-loading-text="loadingText"
|
:element-loading-text="loadingText"
|
||||||
highlight--currentrow
|
highlight--currentrow
|
||||||
@@ -231,14 +231,19 @@
|
|||||||
v-model="scope.row.isRequired"
|
v-model="scope.row.isRequired"
|
||||||
:true-value="1"
|
:true-value="1"
|
||||||
:false-value="0"
|
:false-value="0"
|
||||||
:disabled="scope.row.isShowInForm !== 1"
|
v-if="scope.row.isShowInForm == 1"
|
||||||
/>
|
/>
|
||||||
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="查询方式" min-width="100">
|
<el-table-column label="查询方式" min-width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-select v-model="scope.row.queryType" placeholder="请选择">
|
<el-select
|
||||||
|
v-model="scope.row.queryType"
|
||||||
|
placeholder="请选择"
|
||||||
|
v-if="scope.row.isShowInQuery === 1"
|
||||||
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, key) in queryTypeOptions"
|
v-for="(item, key) in queryTypeOptions"
|
||||||
:key="key"
|
:key="key"
|
||||||
@@ -246,12 +251,17 @@
|
|||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="表单类型" min-width="110">
|
<el-table-column label="表单类型" min-width="110">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-select v-model="scope.row.formType" placeholder="请选择">
|
<el-select
|
||||||
|
v-model="scope.row.formType"
|
||||||
|
placeholder="请选择"
|
||||||
|
v-if="scope.row.isShowInForm === 1"
|
||||||
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, key) in formTypeOptions"
|
v-for="(item, key) in formTypeOptions"
|
||||||
:key="key"
|
:key="key"
|
||||||
@@ -259,12 +269,14 @@
|
|||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="字典类型" min-width="100">
|
<el-table-column label="字典类型" min-width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-select
|
<el-select
|
||||||
|
v-if="scope.row.formType === FormTypeEnum.SELECT.value"
|
||||||
v-model="scope.row.dictType"
|
v-model="scope.row.dictType"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
clearable
|
clearable
|
||||||
@@ -276,6 +288,7 @@
|
|||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -368,24 +381,25 @@ import DictAPI from "@/api/dict";
|
|||||||
import MenuAPI from "@/api/menu";
|
import MenuAPI from "@/api/menu";
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
const queryFormRef = ref(ElForm);
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const fieldLoading = ref(false);
|
|
||||||
const loadingText = ref("loading...");
|
|
||||||
const total = ref(0);
|
|
||||||
const queryParams = reactive<TablePageQuery>({
|
const queryParams = reactive<TablePageQuery>({
|
||||||
keywords: undefined,
|
keywords: undefined,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const loadingText = ref("loading...");
|
||||||
|
|
||||||
const pageData = ref<TablePageVO[]>([]);
|
const pageData = ref<TablePageVO[]>([]);
|
||||||
const formData = ref<GenConfigForm>({
|
const total = ref(0);
|
||||||
fieldConfigs: [],
|
|
||||||
});
|
|
||||||
const formTypeOptions: Record<string, OptionType> = FormTypeEnum;
|
const formTypeOptions: Record<string, OptionType> = FormTypeEnum;
|
||||||
const queryTypeOptions: Record<string, OptionType> = QueryTypeEnum;
|
const queryTypeOptions: Record<string, OptionType> = QueryTypeEnum;
|
||||||
const dictOptions = ref<OptionType[]>();
|
const dictOptions = ref<OptionType[]>();
|
||||||
const menuOptions = ref<OptionType[]>([]);
|
const menuOptions = ref<OptionType[]>([]);
|
||||||
|
const formData = ref<GenConfigForm>({
|
||||||
|
fieldConfigs: [],
|
||||||
|
});
|
||||||
|
|
||||||
const dialog = reactive({
|
const dialog = reactive({
|
||||||
visible: false,
|
visible: false,
|
||||||
@@ -410,9 +424,41 @@ interface TreeNode {
|
|||||||
content?: string;
|
content?: string;
|
||||||
children?: TreeNode[];
|
children?: TreeNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const treeData = ref<TreeNode[]>([]);
|
const treeData = ref<TreeNode[]>([]);
|
||||||
|
|
||||||
|
watch(active, (val) => {
|
||||||
|
if (val === 0) {
|
||||||
|
nextBtnText.value = "下一步,字段配置";
|
||||||
|
} else if (val === 1) {
|
||||||
|
prevBtnText.value = "上一步,基础配置";
|
||||||
|
nextBtnText.value = "下一步,确认生成";
|
||||||
|
} else if (val === 2) {
|
||||||
|
prevBtnText.value = "上一步,字段配置";
|
||||||
|
nextBtnText.value = "下载代码";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(copied, () => {
|
||||||
|
if (copied.value) {
|
||||||
|
ElMessage.success("复制成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formData.value.fieldConfigs as FieldConfig[],
|
||||||
|
(newVal: FieldConfig[]) => {
|
||||||
|
newVal.forEach((fieldConfig) => {
|
||||||
|
if (
|
||||||
|
fieldConfig.formType === FormTypeEnum.DATE_TIME.value ||
|
||||||
|
fieldConfig.formType === FormTypeEnum.DATE.value
|
||||||
|
) {
|
||||||
|
fieldConfig.queryType = QueryTypeEnum.BETWEEN.value as number;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const initSort = () => {
|
const initSort = () => {
|
||||||
if (sortFlag.value) {
|
if (sortFlag.value) {
|
||||||
return;
|
return;
|
||||||
@@ -455,13 +501,13 @@ function handlePrevClick() {
|
|||||||
fieldConfigs: [],
|
fieldConfigs: [],
|
||||||
};
|
};
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
fieldLoading.value = true;
|
loading.value = true;
|
||||||
GeneratorAPI.getGenConfig(currentTableName.value)
|
GeneratorAPI.getGenConfig(currentTableName.value)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
formData.value = data;
|
formData.value = data;
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
fieldLoading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
initSort();
|
initSort();
|
||||||
@@ -480,7 +526,7 @@ function handleNextClick() {
|
|||||||
ElMessage.error("表名不能为空");
|
ElMessage.error("表名不能为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fieldLoading.value = true;
|
loading.value = true;
|
||||||
loadingText.value = "代码生成中,请稍后...";
|
loadingText.value = "代码生成中,请稍后...";
|
||||||
GeneratorAPI.saveGenConfig(tableName, formData.value)
|
GeneratorAPI.saveGenConfig(tableName, formData.value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -490,7 +536,7 @@ function handleNextClick() {
|
|||||||
if (active.value++ >= 2) active.value = 2;
|
if (active.value++ >= 2) active.value = 2;
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
fieldLoading.value = false;
|
loading.value = false;
|
||||||
loadingText.value = "loading...";
|
loadingText.value = "loading...";
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -508,18 +554,6 @@ function handleNextClick() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(active, (val) => {
|
|
||||||
if (val === 0) {
|
|
||||||
nextBtnText.value = "下一步,字段配置";
|
|
||||||
} else if (val === 1) {
|
|
||||||
prevBtnText.value = "上一步,基础配置";
|
|
||||||
nextBtnText.value = "下一步,确认生成";
|
|
||||||
} else if (val === 2) {
|
|
||||||
prevBtnText.value = "上一步,字段配置";
|
|
||||||
nextBtnText.value = "下载代码";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 查询 */
|
/** 查询 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@@ -637,7 +671,6 @@ function buildTree(
|
|||||||
parts.forEach((part) => {
|
parts.forEach((part) => {
|
||||||
buffer.push(part);
|
buffer.push(part);
|
||||||
const currentPath = buffer.join(separator);
|
const currentPath = buffer.join(separator);
|
||||||
console.log("currentPath", currentPath);
|
|
||||||
if (specialPaths.includes(currentPath)) {
|
if (specialPaths.includes(currentPath)) {
|
||||||
mergedParts.push(currentPath);
|
mergedParts.push(currentPath);
|
||||||
buffer = [];
|
buffer = [];
|
||||||
@@ -700,6 +733,7 @@ function handleFileTreeNodeClick(data: TreeNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取文件树节点图标 */
|
||||||
function getFileTreeNodeIcon(label: string) {
|
function getFileTreeNodeIcon(label: string) {
|
||||||
if (label.endsWith(".java")) {
|
if (label.endsWith(".java")) {
|
||||||
return "java";
|
return "java";
|
||||||
@@ -719,18 +753,14 @@ function getFileTreeNodeIcon(label: string) {
|
|||||||
return "file";
|
return "file";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 一键复制 */
|
||||||
const handleCopyCode = () => {
|
const handleCopyCode = () => {
|
||||||
if (code.value) {
|
if (code.value) {
|
||||||
copy(code.value);
|
copy(code.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(copied, () => {
|
/** 组件挂载后执行 */
|
||||||
if (copied.value) {
|
|
||||||
ElMessage.success("复制成功");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
handleQuery();
|
handleQuery();
|
||||||
cmRef.value?.destroy();
|
cmRef.value?.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user