ol-base-components 2.8.2 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -7
- package/scripts/install-vscode.js +58 -14
- package/src/vscode/extension.js +16 -2
- package/src/vscode/webview/panel.js +116 -94
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ol-base-components",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "src/package/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"lint": "vue-cli-service lint",
|
|
17
17
|
"add": "node src/bin/add.js",
|
|
18
18
|
"vscode:build": "node scripts/build-vscode.js",
|
|
19
|
-
"vscode:install": "node scripts/install-vscode.js"
|
|
19
|
+
"vscode:install": "node scripts/install-vscode.js",
|
|
20
|
+
"postinstall": "node scripts/auto-install.js"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"commander": "^14.0.0",
|
|
@@ -45,9 +46,9 @@
|
|
|
45
46
|
"vscode": {
|
|
46
47
|
"extension": {
|
|
47
48
|
"name": "vue-page-generator",
|
|
48
|
-
"displayName": "Vue
|
|
49
|
-
"description": "
|
|
50
|
-
"version": "0.0.
|
|
49
|
+
"displayName": "Vue 页面生成器",
|
|
50
|
+
"description": "配合ol-base-components组件使用, 无需联调的CRUD页面",
|
|
51
|
+
"version": "0.0.2",
|
|
51
52
|
"engines": {
|
|
52
53
|
"vscode": "^1.60.0"
|
|
53
54
|
},
|
|
@@ -59,8 +60,8 @@
|
|
|
59
60
|
"commands": [
|
|
60
61
|
{
|
|
61
62
|
"command": "vue-generator.createPage",
|
|
62
|
-
"title": "
|
|
63
|
-
"category": "Vue
|
|
63
|
+
"title": "生成 Vue 页面",
|
|
64
|
+
"category": "Vue 生成器"
|
|
64
65
|
}
|
|
65
66
|
],
|
|
66
67
|
"menus": {
|
|
@@ -14,18 +14,32 @@ function getVSCodeExtensionsPath() {
|
|
|
14
14
|
path.join(homeDir, ".vscode", "extensions"),
|
|
15
15
|
path.join(homeDir, ".cursor", "extensions"), // Cursor 扩展目录
|
|
16
16
|
path.join(homeDir, "AppData", "Roaming", "Cursor", "User", "extensions"), // Cursor 另一个可能的位置
|
|
17
|
+
path.join(homeDir, "AppData", "Local", "Cursor", "User", "extensions"), // Cursor 本地扩展目录
|
|
18
|
+
path.join(homeDir, "AppData", "Roaming", "Code", "User", "extensions"), // VSCode 扩展目录
|
|
19
|
+
path.join(
|
|
20
|
+
homeDir,
|
|
21
|
+
"AppData",
|
|
22
|
+
"Local",
|
|
23
|
+
"Programs",
|
|
24
|
+
"Microsoft VS Code",
|
|
25
|
+
"resources",
|
|
26
|
+
"app",
|
|
27
|
+
"extensions"
|
|
28
|
+
), // VSCode 系统扩展目录
|
|
17
29
|
];
|
|
18
30
|
case "darwin":
|
|
19
31
|
return [
|
|
20
32
|
path.join(homeDir, ".vscode", "extensions"),
|
|
21
33
|
path.join(homeDir, ".cursor", "extensions"),
|
|
22
34
|
path.join(homeDir, "Library", "Application Support", "Cursor", "User", "extensions"),
|
|
35
|
+
path.join(homeDir, "Library", "Application Support", "Code", "User", "extensions"),
|
|
23
36
|
];
|
|
24
37
|
case "linux":
|
|
25
38
|
return [
|
|
26
39
|
path.join(homeDir, ".vscode", "extensions"),
|
|
27
40
|
path.join(homeDir, ".cursor", "extensions"),
|
|
28
41
|
path.join(homeDir, ".config", "Cursor", "User", "extensions"),
|
|
42
|
+
path.join(homeDir, ".config", "Code", "User", "extensions"),
|
|
29
43
|
];
|
|
30
44
|
default:
|
|
31
45
|
throw new Error("Unsupported platform");
|
|
@@ -38,17 +52,29 @@ function installVSCodeExtension() {
|
|
|
38
52
|
const extensionsPaths = getVSCodeExtensionsPath();
|
|
39
53
|
const extensionName = "vue-page-generator";
|
|
40
54
|
|
|
55
|
+
console.log("�� 正在查找扩展目录...");
|
|
56
|
+
extensionsPaths.forEach((path, index) => {
|
|
57
|
+
console.log(` ${index + 1}. ${path} ${fs.existsSync(path) ? "✅ 存在" : "❌ 不存在"}`);
|
|
58
|
+
});
|
|
59
|
+
|
|
41
60
|
let installed = false;
|
|
42
61
|
|
|
43
62
|
for (const extensionsPath of extensionsPaths) {
|
|
44
63
|
if (fs.existsSync(extensionsPath)) {
|
|
64
|
+
console.log(`\n📁 使用扩展目录: ${extensionsPath}`);
|
|
65
|
+
|
|
45
66
|
const extensionDir = path.join(extensionsPath, extensionName);
|
|
46
67
|
|
|
47
|
-
//
|
|
48
|
-
if (
|
|
49
|
-
|
|
68
|
+
// 删除旧的扩展目录(如果存在)
|
|
69
|
+
if (fs.existsSync(extensionDir)) {
|
|
70
|
+
console.log("🗑️ 删除旧的扩展目录...");
|
|
71
|
+
fs.rmSync(extensionDir, { recursive: true, force: true });
|
|
50
72
|
}
|
|
51
73
|
|
|
74
|
+
// 创建扩展目录
|
|
75
|
+
fs.mkdirSync(extensionDir, { recursive: true });
|
|
76
|
+
console.log("📁 创建扩展目录:", extensionDir);
|
|
77
|
+
|
|
52
78
|
// 复制扩展文件
|
|
53
79
|
const srcDir = path.join(__dirname, "../src/vscode");
|
|
54
80
|
const files = ["extension.js"];
|
|
@@ -60,6 +86,8 @@ function installVSCodeExtension() {
|
|
|
60
86
|
if (fs.existsSync(srcFile)) {
|
|
61
87
|
fs.copyFileSync(srcFile, destFile);
|
|
62
88
|
console.log(`✅ 复制文件: ${file}`);
|
|
89
|
+
} else {
|
|
90
|
+
console.log(`❌ 源文件不存在: ${srcFile}`);
|
|
63
91
|
}
|
|
64
92
|
});
|
|
65
93
|
|
|
@@ -78,26 +106,35 @@ function installVSCodeExtension() {
|
|
|
78
106
|
if (fs.existsSync(panelFile)) {
|
|
79
107
|
fs.copyFileSync(panelFile, panelDestFile);
|
|
80
108
|
console.log("✅ 复制文件: webview/panel.js");
|
|
109
|
+
} else {
|
|
110
|
+
console.log("❌ 源文件不存在: webview/panel.js");
|
|
81
111
|
}
|
|
112
|
+
} else {
|
|
113
|
+
console.log("❌ webview 目录不存在:", webviewSrcDir);
|
|
82
114
|
}
|
|
83
115
|
|
|
84
116
|
// 创建 package.json
|
|
85
117
|
const packageJson = {
|
|
86
118
|
name: extensionName,
|
|
87
|
-
displayName: "Vue
|
|
88
|
-
description: "
|
|
119
|
+
displayName: "Vue 页面生成器",
|
|
120
|
+
description: "从 Swagger API 生成 Vue CRUD 页面",
|
|
89
121
|
version: "0.0.1",
|
|
90
122
|
engines: {
|
|
91
123
|
vscode: "^1.60.0",
|
|
92
124
|
},
|
|
93
|
-
activationEvents: ["onCommand:vue-generator.createPage"],
|
|
125
|
+
activationEvents: ["onCommand:vue-generator.createPage", "onCommand:vue-generator.test"],
|
|
94
126
|
main: "./extension.js",
|
|
95
127
|
contributes: {
|
|
96
128
|
commands: [
|
|
97
129
|
{
|
|
98
130
|
command: "vue-generator.createPage",
|
|
99
|
-
title: "
|
|
100
|
-
category: "Vue
|
|
131
|
+
title: "生成 Vue 页面",
|
|
132
|
+
category: "Vue 生成器",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
command: "vue-generator.test",
|
|
136
|
+
title: "测试 Vue 生成器",
|
|
137
|
+
category: "Vue 生成器",
|
|
101
138
|
},
|
|
102
139
|
],
|
|
103
140
|
menus: {
|
|
@@ -105,7 +142,7 @@ function installVSCodeExtension() {
|
|
|
105
142
|
{
|
|
106
143
|
command: "vue-generator.createPage",
|
|
107
144
|
group: "navigation",
|
|
108
|
-
when: "
|
|
145
|
+
when: "resourceFolder",
|
|
109
146
|
},
|
|
110
147
|
],
|
|
111
148
|
},
|
|
@@ -120,20 +157,27 @@ function installVSCodeExtension() {
|
|
|
120
157
|
console.log("请重启 Cursor 以激活扩展。");
|
|
121
158
|
console.log("安装位置:", extensionDir);
|
|
122
159
|
|
|
160
|
+
// 显示扩展目录内容
|
|
161
|
+
console.log("\n📁 扩展目录内容:");
|
|
162
|
+
const extensionFiles = fs.readdirSync(extensionDir);
|
|
163
|
+
extensionFiles.forEach(file => {
|
|
164
|
+
const filePath = path.join(extensionDir, file);
|
|
165
|
+
const stats = fs.statSync(filePath);
|
|
166
|
+
console.log(` - ${file} ${stats.isDirectory() ? "(目录)" : "(文件)"}`);
|
|
167
|
+
});
|
|
168
|
+
|
|
123
169
|
installed = true;
|
|
124
170
|
break;
|
|
125
171
|
}
|
|
126
172
|
}
|
|
127
173
|
|
|
128
174
|
if (!installed) {
|
|
129
|
-
console.log("❌ 未找到 VSCode 或 Cursor 扩展目录");
|
|
130
|
-
console.log("
|
|
131
|
-
extensionsPaths.forEach(path => {
|
|
132
|
-
console.log(" -", path);
|
|
133
|
-
});
|
|
175
|
+
console.log("\n❌ 未找到 VSCode 或 Cursor 扩展目录");
|
|
176
|
+
console.log("请确保已安装 VSCode 或 Cursor 编辑器。");
|
|
134
177
|
}
|
|
135
178
|
} catch (error) {
|
|
136
179
|
console.error("❌ 安装失败:", error.message);
|
|
180
|
+
console.error("错误详情:", error.stack);
|
|
137
181
|
process.exit(1);
|
|
138
182
|
}
|
|
139
183
|
}
|
package/src/vscode/extension.js
CHANGED
|
@@ -2,17 +2,31 @@ const vscode = require("vscode");
|
|
|
2
2
|
const { GeneratorPanel } = require("./webview/panel");
|
|
3
3
|
|
|
4
4
|
function activate(context) {
|
|
5
|
-
console.log("Vue
|
|
5
|
+
console.log("🎉 Vue 页面生成器扩展已激活!");
|
|
6
|
+
|
|
7
|
+
// 显示通知确认扩展已激活
|
|
8
|
+
vscode.window.showInformationMessage("Vue 页面生成器扩展已激活!");
|
|
6
9
|
|
|
7
10
|
// 注册右键菜单命令
|
|
8
11
|
const disposable = vscode.commands.registerCommand("vue-generator.createPage", uri => {
|
|
12
|
+
console.log("命令被调用,URI:", uri);
|
|
13
|
+
vscode.window.showInformationMessage("生成 Vue 页面命令被调用!");
|
|
9
14
|
GeneratorPanel.createOrShow(context.extensionUri, uri);
|
|
10
15
|
});
|
|
11
16
|
|
|
12
17
|
context.subscriptions.push(disposable);
|
|
18
|
+
|
|
19
|
+
// 注册一个测试命令
|
|
20
|
+
const testDisposable = vscode.commands.registerCommand("vue-generator.test", () => {
|
|
21
|
+
vscode.window.showInformationMessage("Vue 页面生成器测试命令工作正常!");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
context.subscriptions.push(testDisposable);
|
|
13
25
|
}
|
|
14
26
|
|
|
15
|
-
function deactivate() {
|
|
27
|
+
function deactivate() {
|
|
28
|
+
console.log("Vue 页面生成器扩展已停用");
|
|
29
|
+
}
|
|
16
30
|
|
|
17
31
|
module.exports = {
|
|
18
32
|
activate,
|
|
@@ -4,22 +4,28 @@ const fs = require("fs");
|
|
|
4
4
|
|
|
5
5
|
// 复用现有的模板生成逻辑
|
|
6
6
|
function generateKeyName(url, method) {
|
|
7
|
+
// 移除前缀 "/api/app"
|
|
7
8
|
const cleanedUrl = url.replace(/\/api\/app/, "");
|
|
8
9
|
const arr = cleanedUrl.split("/");
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// 处理 {xxx} 转换为 ByXxx
|
|
12
|
+
const processedArr = arr.map(
|
|
13
|
+
item =>
|
|
14
|
+
item
|
|
15
|
+
.replace(/{(.*?)}/, (_, param) => `By${param.charAt(0).toUpperCase() + param.slice(1)}`) // 处理 {xxx}
|
|
16
|
+
.replace(/[-_]/g, "") // 去除 - 和 _
|
|
14
17
|
);
|
|
15
18
|
|
|
19
|
+
// 删除第一个空项
|
|
16
20
|
if (processedArr[0] === "") {
|
|
17
21
|
processedArr.shift();
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
// 去重和拼接相邻相同的项
|
|
20
25
|
const resultArr = [];
|
|
21
26
|
for (let i = 0; i < processedArr.length; i++) {
|
|
22
27
|
if (i === 0 || processedArr[i] !== processedArr[i - 1]) {
|
|
28
|
+
// 将每项首字母大写
|
|
23
29
|
const capitalizedItem = processedArr[i].charAt(0).toUpperCase() + processedArr[i].slice(1);
|
|
24
30
|
resultArr.push(capitalizedItem);
|
|
25
31
|
}
|
|
@@ -28,29 +34,30 @@ function generateKeyName(url, method) {
|
|
|
28
34
|
return `${method.toLowerCase()}${key}`;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const vue2Template = (moduleName, config = {}) => {
|
|
38
|
+
// 生成各种接口的key名称
|
|
33
39
|
let pageUrlKey = "",
|
|
34
40
|
exportUrlKey = "",
|
|
35
41
|
addUrlKey = "",
|
|
36
42
|
editUrlKey = "",
|
|
37
43
|
deleteUrlKey = "",
|
|
38
44
|
detailUrlKey = "",
|
|
39
|
-
baseUrlKey = "";
|
|
45
|
+
baseUrlKey = ""; //接口选择优先级:新增 > 编辑 > 详情
|
|
40
46
|
|
|
41
47
|
if (config.pageUrl) pageUrlKey = generateKeyName(config.pageUrl, "get");
|
|
42
48
|
if (config.exportUrl) exportUrlKey = generateKeyName(config.exportUrl, "post");
|
|
43
49
|
if (config.detailUrl) {
|
|
44
50
|
detailUrlKey = generateKeyName(config.detailUrl, "get");
|
|
45
|
-
baseUrlKey = `${detailUrlKey}CompleteUrl`;
|
|
51
|
+
baseUrlKey = `${detailUrlKey}CompleteUrl`; //补充后缀
|
|
46
52
|
}
|
|
47
53
|
if (config.editUrl) {
|
|
48
54
|
editUrlKey = generateKeyName(config.editUrl, "put");
|
|
49
|
-
baseUrlKey = `${editUrlKey}CompleteUrl`;
|
|
55
|
+
baseUrlKey = `${editUrlKey}CompleteUrl`; //补充后缀
|
|
50
56
|
}
|
|
51
57
|
if (config.addUrl) baseUrlKey = addUrlKey = generateKeyName(config.addUrl, "post");
|
|
52
58
|
if (config.deleteUrl) deleteUrlKey = generateKeyName(config.deleteUrl, "delete");
|
|
53
59
|
|
|
60
|
+
// 生成导入语句
|
|
54
61
|
const generateImports = () => {
|
|
55
62
|
const imports = [];
|
|
56
63
|
if (config.pageUrl) imports.push(`${pageUrlKey}`);
|
|
@@ -61,13 +68,46 @@ function vue2Template(moduleName, config) {
|
|
|
61
68
|
return imports.join(", ");
|
|
62
69
|
};
|
|
63
70
|
|
|
71
|
+
// 生成方法
|
|
64
72
|
const generateMethods = () => {
|
|
65
73
|
const methods = [];
|
|
74
|
+
|
|
75
|
+
// onCancel
|
|
76
|
+
if (config.hasAdd || config.hasEdit || config.hasDetail) {
|
|
77
|
+
methods.push(`
|
|
78
|
+
onCancel() {
|
|
79
|
+
this.formConfig.dialogVisible = false;
|
|
80
|
+
}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// onSubmit
|
|
84
|
+
if (config.hasAdd || config.hasEdit) {
|
|
85
|
+
methods.push(`
|
|
86
|
+
async onSubmit({ form, data }) {
|
|
87
|
+
if(form.type === 1){
|
|
88
|
+
//新建
|
|
89
|
+
const res = await ${addUrlKey}(data);
|
|
90
|
+
if(res.code !== 200) return;
|
|
91
|
+
this.$message("新建成功");
|
|
92
|
+
}else if (form.type === 2) {
|
|
93
|
+
//编辑
|
|
94
|
+
const res = await ${editUrlKey}(data['${config.rowId}'], data);
|
|
95
|
+
if(res.code !== 200) return;
|
|
96
|
+
this.$message("编辑成功");
|
|
97
|
+
this.init();
|
|
98
|
+
};
|
|
99
|
+
this.init();
|
|
100
|
+
this.onCancel()
|
|
101
|
+
}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
66
104
|
if (config.hasAdd) {
|
|
67
105
|
methods.push(`
|
|
68
106
|
addBtnHandler() {
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
107
|
+
this.formConfig.title = "新增";
|
|
108
|
+
this.formConfig.type = 1;
|
|
109
|
+
this.formConfig.formData = {};
|
|
110
|
+
this.formConfig.dialogVisible = true;
|
|
71
111
|
}`);
|
|
72
112
|
}
|
|
73
113
|
|
|
@@ -80,23 +120,27 @@ function vue2Template(moduleName, config) {
|
|
|
80
120
|
${
|
|
81
121
|
config.hasDetail
|
|
82
122
|
? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
|
|
83
|
-
|
|
84
|
-
: `this.formData = { ...row };`
|
|
123
|
+
this.formConfig.formData = result || {};`
|
|
124
|
+
: `this.formConfig.formData = { ...row };`
|
|
85
125
|
}
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
126
|
+
this.formConfig.title = "编辑";
|
|
127
|
+
this.formConfig.type = 2;
|
|
128
|
+
this.formConfig.dialogVisible = true;
|
|
88
129
|
}`);
|
|
89
130
|
}
|
|
90
131
|
|
|
132
|
+
// 有详情
|
|
91
133
|
if (config.hasDetail) {
|
|
92
|
-
methods.push(`
|
|
134
|
+
methods.push(`
|
|
135
|
+
async detailBtnHandler() {
|
|
93
136
|
const data = this.multipleSelection;
|
|
94
137
|
if(data.length !== 1) return this.$message.info("请选择一条数据");
|
|
95
138
|
const row = data[0];
|
|
96
139
|
const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
|
|
97
|
-
this.formData = result || {};
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
140
|
+
this.formConfig.formData = result || {};
|
|
141
|
+
this.formConfig.title = "详情";
|
|
142
|
+
this.formConfig.type = 0;
|
|
143
|
+
this.formConfig.dialogVisible = true;
|
|
100
144
|
}`);
|
|
101
145
|
}
|
|
102
146
|
|
|
@@ -121,31 +165,25 @@ function vue2Template(moduleName, config) {
|
|
|
121
165
|
}`);
|
|
122
166
|
}
|
|
123
167
|
|
|
124
|
-
if (config.
|
|
125
|
-
methods.push(`
|
|
126
|
-
onCancel() {
|
|
127
|
-
this.dialogVisible = false;
|
|
128
|
-
}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (config.hasAdd || config.hasEdit) {
|
|
168
|
+
if (config.hasExport) {
|
|
132
169
|
methods.push(`
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
170
|
+
export() {
|
|
171
|
+
const timer = this.formSearchData.value.createdTime;
|
|
172
|
+
this.formSearchData.value.BeginTime = timer ? timer[0] : "";
|
|
173
|
+
this.formSearchData.value.EndTime = timer ? timer[1] : "";
|
|
174
|
+
this.post({
|
|
175
|
+
url: ${config.swaggerModule}.${exportUrlKey},
|
|
176
|
+
isLoading: true,
|
|
177
|
+
responseType: "blob",
|
|
178
|
+
data: Object.assign(this.formSearchData.value, {
|
|
179
|
+
Page: this.paginations.page,
|
|
180
|
+
MaxResultCount: this.paginations.limit
|
|
181
|
+
})
|
|
182
|
+
}).then(res => {
|
|
183
|
+
this.fnexsl(res);
|
|
184
|
+
});
|
|
185
|
+
}`);
|
|
147
186
|
}
|
|
148
|
-
|
|
149
187
|
return methods.join(",");
|
|
150
188
|
};
|
|
151
189
|
|
|
@@ -176,10 +214,11 @@ function vue2Template(moduleName, config) {
|
|
|
176
214
|
/>
|
|
177
215
|
${
|
|
178
216
|
config.hasDialog
|
|
179
|
-
? `<el-dialog :title="
|
|
217
|
+
? `<el-dialog :title="formConfig.title" :visible.sync="formConfig.dialogVisible" width="80%">
|
|
180
218
|
<FormModule
|
|
181
|
-
v-if="dialogVisible"
|
|
182
|
-
:formData="formData"
|
|
219
|
+
v-if="formConfig.dialogVisible"
|
|
220
|
+
:formData="formConfig.formData"
|
|
221
|
+
:type="formConfig.type"
|
|
183
222
|
@onCancel="onCancel"
|
|
184
223
|
@onSubmit="onSubmit"
|
|
185
224
|
/>
|
|
@@ -205,39 +244,44 @@ export default {
|
|
|
205
244
|
return {
|
|
206
245
|
swaggerUrl: ${config.swaggerModule},
|
|
207
246
|
multipleSelection: [],
|
|
247
|
+
// 查询表单
|
|
208
248
|
formSearchData: {
|
|
209
|
-
reset: true,
|
|
210
|
-
expendShow: true,
|
|
249
|
+
reset: true, // 重置
|
|
250
|
+
expendShow: true, // 展开
|
|
211
251
|
value: {},
|
|
212
252
|
tableSearch: []
|
|
213
253
|
},
|
|
254
|
+
// 表格数据
|
|
214
255
|
tableData: {
|
|
215
256
|
loading: false,
|
|
216
257
|
emptyImg: true,
|
|
217
258
|
options: {
|
|
218
|
-
selection: true,
|
|
219
|
-
index: null,
|
|
220
|
-
headTool: true,
|
|
221
|
-
refreshBtn: true,
|
|
222
|
-
downloadBtn: true
|
|
223
|
-
},
|
|
224
|
-
rows: [],
|
|
259
|
+
selection: true, // 多选框
|
|
260
|
+
index: null, // 序号
|
|
261
|
+
headTool: true, // 开启头部工具栏
|
|
262
|
+
refreshBtn: true, // 开启表格头部刷新按钮
|
|
263
|
+
downloadBtn: true // 开启表格头部下载按钮
|
|
264
|
+
}, // 序号和复选框
|
|
265
|
+
rows: [], // 表数据
|
|
225
266
|
columns: [],
|
|
226
267
|
operatesAttrs: {},
|
|
227
|
-
operates: [],
|
|
268
|
+
operates: [], // 表格里面的操作按钮
|
|
228
269
|
tableHeightDiff: 330
|
|
229
270
|
},
|
|
230
271
|
paginations: {
|
|
231
|
-
page: 1,
|
|
232
|
-
total: 10,
|
|
233
|
-
limit: 30,
|
|
272
|
+
page: 1, // 当前位于那页面
|
|
273
|
+
total: 10, // 总数
|
|
274
|
+
limit: 30, // 一页显示多少条
|
|
234
275
|
pagetionShow: true
|
|
235
276
|
},
|
|
236
277
|
${
|
|
237
278
|
config.hasDialog
|
|
238
|
-
? `
|
|
239
|
-
|
|
240
|
-
|
|
279
|
+
? `formConfig: {
|
|
280
|
+
type: 1,
|
|
281
|
+
formData: {},
|
|
282
|
+
title:"",
|
|
283
|
+
dialogVisible: false
|
|
284
|
+
}`
|
|
241
285
|
: ""
|
|
242
286
|
}
|
|
243
287
|
}
|
|
@@ -281,47 +325,26 @@ export default {
|
|
|
281
325
|
handleindexChange(val) {
|
|
282
326
|
this.paginations.page = val;
|
|
283
327
|
this.init();
|
|
284
|
-
}
|
|
285
|
-
${
|
|
286
|
-
config.hasExport
|
|
287
|
-
? `export() {
|
|
288
|
-
const timer = this.formSearchData.value.createdTime;
|
|
289
|
-
this.formSearchData.value.BeginTime = timer ? timer[0] : "";
|
|
290
|
-
this.formSearchData.value.EndTime = timer ? timer[1] : "";
|
|
291
|
-
this.post({
|
|
292
|
-
url: ${config.swaggerModule}.${exportUrlKey},
|
|
293
|
-
isLoading: true,
|
|
294
|
-
responseType: "blob",
|
|
295
|
-
data: Object.assign(this.formSearchData.value, {
|
|
296
|
-
Page: this.paginations.page,
|
|
297
|
-
MaxResultCount: this.paginations.limit
|
|
298
|
-
})
|
|
299
|
-
}).then(res => {
|
|
300
|
-
this.fnexsl(res);
|
|
301
|
-
});
|
|
302
|
-
},`
|
|
303
|
-
: ""
|
|
304
|
-
}${generateMethods()}
|
|
328
|
+
},${generateMethods()}
|
|
305
329
|
}
|
|
306
330
|
}
|
|
307
331
|
</script>
|
|
308
332
|
`;
|
|
309
|
-
}
|
|
333
|
+
};
|
|
310
334
|
|
|
311
|
-
|
|
312
|
-
function vue2Form(moduleName, config) {
|
|
335
|
+
const vue2Form = (moduleName, config = {}) => {
|
|
313
336
|
let editUrlKey = "",
|
|
314
337
|
detailUrlKey = "",
|
|
315
338
|
baseUrlKey = "";
|
|
316
339
|
|
|
317
340
|
if (config.detailUrl) {
|
|
318
341
|
detailUrlKey = generateKeyName(config.detailUrl, "get");
|
|
319
|
-
baseUrlKey = `${detailUrlKey}CompleteUrl`;
|
|
342
|
+
baseUrlKey = `${detailUrlKey}CompleteUrl`; //补充后缀
|
|
320
343
|
}
|
|
321
344
|
|
|
322
345
|
if (config.editUrl) {
|
|
323
346
|
editUrlKey = generateKeyName(config.editUrl, "put");
|
|
324
|
-
baseUrlKey = `${editUrlKey}CompleteUrl`;
|
|
347
|
+
baseUrlKey = `${editUrlKey}CompleteUrl`; //补充后缀
|
|
325
348
|
}
|
|
326
349
|
|
|
327
350
|
if (config.addUrl) baseUrlKey = generateKeyName(config.addUrl, "post");
|
|
@@ -334,7 +357,6 @@ function vue2Form(moduleName, config) {
|
|
|
334
357
|
-->
|
|
335
358
|
<template>
|
|
336
359
|
<ol-form
|
|
337
|
-
v-if="dialogVisible"
|
|
338
360
|
:url="swaggerUrl.${baseUrlKey}"
|
|
339
361
|
:form="form"
|
|
340
362
|
@onCancel="onCancel"
|
|
@@ -359,9 +381,9 @@ export default {
|
|
|
359
381
|
return {
|
|
360
382
|
swaggerUrl: ${config.swaggerModule},
|
|
361
383
|
form: {
|
|
362
|
-
type: this.type,
|
|
384
|
+
type: this.type, // 0详情,1新增, 2编辑
|
|
363
385
|
title: "",
|
|
364
|
-
defaultValue: {},
|
|
386
|
+
defaultValue: {}, // 默认值
|
|
365
387
|
value: {},
|
|
366
388
|
model: [],
|
|
367
389
|
rules: {},
|
|
@@ -378,7 +400,7 @@ export default {
|
|
|
378
400
|
}
|
|
379
401
|
},
|
|
380
402
|
created(){
|
|
381
|
-
|
|
403
|
+
if(this.type !== 1) this.form.value = { ...this.formData };
|
|
382
404
|
},
|
|
383
405
|
methods: {
|
|
384
406
|
onCancel() {
|
|
@@ -391,7 +413,7 @@ export default {
|
|
|
391
413
|
}
|
|
392
414
|
</script>
|
|
393
415
|
`;
|
|
394
|
-
}
|
|
416
|
+
};
|
|
395
417
|
|
|
396
418
|
class GeneratorPanel {
|
|
397
419
|
static currentPanel = undefined;
|
|
@@ -473,13 +495,13 @@ class GeneratorPanel {
|
|
|
473
495
|
fs.writeFileSync(formPath, formContent);
|
|
474
496
|
}
|
|
475
497
|
|
|
476
|
-
vscode.window.showInformationMessage(`✅
|
|
498
|
+
vscode.window.showInformationMessage(`✅ 页面模板已成功生成并保存到 ${outputDir}`);
|
|
477
499
|
|
|
478
500
|
// 打开生成的文件
|
|
479
501
|
const document = await vscode.workspace.openTextDocument(mainPath);
|
|
480
502
|
vscode.window.showTextDocument(document);
|
|
481
503
|
} catch (error) {
|
|
482
|
-
vscode.window.showErrorMessage(`❌
|
|
504
|
+
vscode.window.showErrorMessage(`❌ 生成过程中发生错误:${error.message}`);
|
|
483
505
|
}
|
|
484
506
|
}
|
|
485
507
|
|