ol-base-components 2.7.0 → 2.7.2
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 +1 -1
- package/src/bin/add.js +19 -7
- package/src/bin/initTemplate.js +8 -3
package/package.json
CHANGED
package/src/bin/add.js
CHANGED
|
@@ -51,7 +51,7 @@ try {
|
|
|
51
51
|
type: "input",
|
|
52
52
|
name: "pageUrl",
|
|
53
53
|
message: "请输入分页接口地址(必填):",
|
|
54
|
-
default: "/api/app/admission-info/
|
|
54
|
+
default: "/api/app/admission-info/paged-result",
|
|
55
55
|
validate: input => {
|
|
56
56
|
if (!input.trim()) {
|
|
57
57
|
return "分页接口地址不能为空";
|
|
@@ -106,6 +106,7 @@ try {
|
|
|
106
106
|
},
|
|
107
107
|
]);
|
|
108
108
|
|
|
109
|
+
let baseUrl = "";
|
|
109
110
|
let idField = "id";
|
|
110
111
|
let addUrl = "";
|
|
111
112
|
let editUrl = "";
|
|
@@ -114,12 +115,22 @@ try {
|
|
|
114
115
|
|
|
115
116
|
// 如果有新增/编辑/删除/详情功能,直接使用分页接口地址
|
|
116
117
|
if (operationsAnswer.operations.length > 0) {
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// baseUrl
|
|
119
|
+
const baseUrlAnswer = await inquirer.prompt([
|
|
120
|
+
{
|
|
121
|
+
type: "input",
|
|
122
|
+
name: "baseUrl",
|
|
123
|
+
message: "请输入操作接口的基础路径:",
|
|
124
|
+
default: "/api/app/admission-info/admission-info",
|
|
125
|
+
validate: input => {
|
|
126
|
+
if (!input.trim()) {
|
|
127
|
+
return "操作接口的基础路径不能为空";
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
]);
|
|
133
|
+
baseUrl = baseUrlAnswer.baseUrl;
|
|
123
134
|
|
|
124
135
|
// 询问ID字段名
|
|
125
136
|
const idFieldAnswer = await inquirer.prompt([
|
|
@@ -191,6 +202,7 @@ try {
|
|
|
191
202
|
pageUrl: pageUrlAnswer.pageUrl,
|
|
192
203
|
hasExport: exportAnswer.hasExport,
|
|
193
204
|
exportUrl: exportUrl,
|
|
205
|
+
baseUrl,
|
|
194
206
|
hasAdd: operationsAnswer.operations.includes("add"),
|
|
195
207
|
addUrl: addUrl,
|
|
196
208
|
hasEdit: operationsAnswer.operations.includes("edit"),
|
package/src/bin/initTemplate.js
CHANGED
|
@@ -38,6 +38,7 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
38
38
|
let editUrlKey = "";
|
|
39
39
|
let deleteUrlKey = "";
|
|
40
40
|
let detailUrlKey = "";
|
|
41
|
+
let baseUrlKey = "";
|
|
41
42
|
|
|
42
43
|
if (config.pageUrl) pageUrlKey = generateKeyName(config.pageUrl, "get");
|
|
43
44
|
if (config.exportUrl) exportUrlKey = generateKeyName(config.exportUrl, "post");
|
|
@@ -45,12 +46,12 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
45
46
|
if (config.editUrl) editUrlKey = generateKeyName(config.editUrl, "put");
|
|
46
47
|
if (config.deleteUrl) deleteUrlKey = generateKeyName(config.deleteUrl, "delete");
|
|
47
48
|
if (config.detailUrl) detailUrlKey = generateKeyName(config.detailUrl, "get");
|
|
48
|
-
|
|
49
|
+
if (config.baseUrl) baseUrlKey = generateKeyName(config.baseUrl, "post"); //这里先直接用新增接口的,后期可改为各自接口
|
|
49
50
|
// 生成导入语句
|
|
50
51
|
const generateImports = () => {
|
|
51
52
|
const imports = [];
|
|
52
53
|
if (config.pageUrl) imports.push(`${pageUrlKey}`);
|
|
53
|
-
if (config.addUrl) imports.push(`${addUrlKey}`);
|
|
54
|
+
if (config.addUrl || config.baseUrl) imports.push(`${addUrlKey}`);
|
|
54
55
|
if (config.editUrl) imports.push(`${editUrlKey}`);
|
|
55
56
|
if (config.deleteUrl) imports.push(`${deleteUrlKey}`);
|
|
56
57
|
if (config.detailUrl) imports.push(`${detailUrlKey}`);
|
|
@@ -178,7 +179,7 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
178
179
|
? `<el-dialog :title="this.form.title" :visible.sync="dialogVisible" width="80%">
|
|
179
180
|
<ol-form
|
|
180
181
|
v-if="dialogVisible"
|
|
181
|
-
:url="swaggerUrl.${
|
|
182
|
+
:url="swaggerUrl.${baseUrlKey}"
|
|
182
183
|
:form="form"
|
|
183
184
|
@onCancel="onCancel"
|
|
184
185
|
@onSubmit="onSubmit"
|
|
@@ -244,6 +245,9 @@ export default {
|
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
},
|
|
248
|
+
created() {
|
|
249
|
+
this.init()
|
|
250
|
+
},
|
|
247
251
|
methods: {
|
|
248
252
|
async init() {
|
|
249
253
|
const params = {
|
|
@@ -304,6 +308,7 @@ export default {
|
|
|
304
308
|
}${generateMethods()}
|
|
305
309
|
}
|
|
306
310
|
}
|
|
311
|
+
</script>
|
|
307
312
|
`;
|
|
308
313
|
};
|
|
309
314
|
|