diff --git a/src/api/generator.ts b/src/api/generator.ts
index 4686ad22..1f716a91 100644
--- a/src/api/generator.ts
+++ b/src/api/generator.ts
@@ -38,6 +38,14 @@ class GeneratorAPI {
method: "get",
});
}
+
+ /** 重置代码配置 */
+ static resetGenConfig(tableName: string) {
+ return request({
+ url: `${GENERATOR_BASE_URL}/${tableName}/config`,
+ method: "delete",
+ });
+ }
}
export default GeneratorAPI;
diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue
index fc4ae20c..016b9ab7 100644
--- a/src/views/generator/index.vue
+++ b/src/views/generator/index.vue
@@ -54,7 +54,17 @@
@click="handleOpenDialog(scope.row.tableName)"
>
- 生成
+ 生成代码
+
+
+
+
+ 重置配置
@@ -72,7 +82,7 @@
@@ -452,10 +462,6 @@ function handleResetQuery() {
handleQuery();
}
-function handleCloseDialog() {
- dialog.visible = false;
-}
-
/** 打开弹窗 */
function handleOpenDialog(tableName: string) {
dialog.visible = true;
@@ -463,16 +469,32 @@ function handleOpenDialog(tableName: string) {
// 获取字典数据
DictAPI.getList().then((data) => {
dictOptions.value = data;
+ loading.value = true;
- GeneratorAPI.getGenConfig(tableName).then((data) => {
- dialog.title = `${tableName} 代码生成`;
- formData.value = data;
- if (formData.value.id) {
- active.value = 2;
- handlePreview(tableName);
- } else {
- active.value = 0;
- }
+ GeneratorAPI.getGenConfig(tableName)
+ .then((data) => {
+ dialog.title = `${tableName} 代码生成`;
+ formData.value = data;
+ if (formData.value.id) {
+ active.value = 2;
+ handlePreview(tableName);
+ } else {
+ active.value = 0;
+ }
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+ });
+}
+
+/** 重置配置 */
+function handleResetConfig(tableName: string) {
+ ElMessageBox.confirm("确定要重置配置吗?", "提示", {
+ type: "warning",
+ }).then(() => {
+ GeneratorAPI.resetGenConfig(tableName).then(() => {
+ handleQuery();
});
});
}