ol-base-components 2.7.7 → 2.7.9

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/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  二次封装的通用组件库,包含表格(Table)和表单(Form)等组件。
4
4
 
5
- - [在线演示](https://mqtt-a.vercel.app/home)
6
- - [在线文档](https://github.com/time202051/base-component)
5
+ <!-- - [在线演示](https://mqtt-a.vercel.app/home) -->
6
+
7
+ - [官网](https://time202051.github.io/baseCom.github.io/)
7
8
 
8
9
  ## 安装
9
10
 
@@ -162,58 +163,58 @@ npx add aaa -p src/view -u /api/app/business-report/stock-bIPaged-result -e /api
162
163
  </template>
163
164
 
164
165
  <script>
165
- export default {
166
- data() {
167
- return {
168
- formSearchData: {
169
- reset: true,
170
- expendShow: false,
171
- value: {
172
- WarehouseCode: null,
173
- WarehouseName: null,
174
- },
175
- tableSearch: [
176
- {
177
- label: "仓库编码",
178
- value: "WarehouseCode",
179
- inputType: "text",
180
- },
181
- {
182
- label: "仓库名称",
183
- value: "WarehouseName",
184
- inputType: "text",
185
- },
186
- ],
166
+ export default {
167
+ data() {
168
+ return {
169
+ formSearchData: {
170
+ reset: true,
171
+ expendShow: false,
172
+ value: {
173
+ WarehouseCode: null,
174
+ WarehouseName: null,
187
175
  },
188
- };
189
- },
190
- mounted() {
191
- this.getTable();
192
- },
193
- method: {
194
- getTable() {
195
- // this.get({
196
- // url: Basic.getWarehoseList,
197
- // isLoading: true,
198
- // data: Object.assign(this.formSearchData.value, {
199
- // Page: this.paginations.page,
200
- // MaxResultCount: this.paginations.limit,
201
- // }),
202
- // }).then((res) => {
203
- // this.tableData.rows = res.result.items;
204
- // this.paginations.total = res.result.totalCount;
205
- // this.tableData.emptyImg = true;
206
- // });
207
- },
208
- handleSearch(from) {
209
- var self = this;
210
- self.formSearchData.value = { ...from };
211
- self.paginations.page = 1;
212
- this.getTable(); // 获取表格数据
176
+ tableSearch: [
177
+ {
178
+ label: "仓库编码",
179
+ value: "WarehouseCode",
180
+ inputType: "text",
181
+ },
182
+ {
183
+ label: "仓库名称",
184
+ value: "WarehouseName",
185
+ inputType: "text",
186
+ },
187
+ ],
213
188
  },
214
- handleReset() {},
189
+ };
190
+ },
191
+ mounted() {
192
+ this.getTable();
193
+ },
194
+ method: {
195
+ getTable() {
196
+ // this.get({
197
+ // url: Basic.getWarehoseList,
198
+ // isLoading: true,
199
+ // data: Object.assign(this.formSearchData.value, {
200
+ // Page: this.paginations.page,
201
+ // MaxResultCount: this.paginations.limit,
202
+ // }),
203
+ // }).then((res) => {
204
+ // this.tableData.rows = res.result.items;
205
+ // this.paginations.total = res.result.totalCount;
206
+ // this.tableData.emptyImg = true;
207
+ // });
215
208
  },
216
- };
209
+ handleSearch(from) {
210
+ var self = this;
211
+ self.formSearchData.value = { ...from };
212
+ self.paginations.page = 1;
213
+ this.getTable(); // 获取表格数据
214
+ },
215
+ handleReset() {},
216
+ },
217
+ };
217
218
  </script>
218
219
  ```
219
220
 
@@ -246,102 +247,102 @@ npx add aaa -p src/view -u /api/app/business-report/stock-bIPaged-result -e /api
246
247
  </template>
247
248
 
248
249
  <script>
249
- export default {
250
- data() {
251
- return {
252
- multipleSelection: [],
253
- tableData: {
254
- loading: false,
255
- emptyImg: true,
256
- options: {
257
- selection: true, //多选框
258
- index: null, //序号
259
- headTool: true, //开启头部工具栏
260
- refreshBtn: true, //开启表格头部刷新按钮
261
- downloadBtn: true, //开启表格头部下载按钮
262
- }, //序号和复选框
263
- rows: [], //表数据
264
- columns: [
265
- {
266
- label: "",
267
- minWidth: "",
268
- type: "selection",
269
- show: true,
270
- },
271
- {
272
- prop: "warehouseCode",
273
- label: "仓库编码",
274
- minWidth: "",
275
- sortable: false,
276
- show: true,
277
- },
278
- {
279
- prop: "warehouseName",
280
- label: "仓库名称",
281
- minWidth: "",
282
- sortable: false,
283
- show: true,
284
- },
285
- {
286
- prop: "enabledDesc",
287
- label: "状态",
288
- minWidth: "",
289
- sortable: false,
290
- show: true,
291
- },
292
- {
293
- prop: "createdUser",
294
- label: "创建人",
295
- minWidth: "",
296
- sortable: false,
297
- show: true,
298
- },
299
- {
300
- prop: "createTime",
301
- label: "创建时间",
302
- minWidth: "",
303
- show: true,
304
- },
305
- {
306
- prop: "classes",
307
- label: "班次",
308
- minWidth: "",
309
- show: true,
310
- renderSlot: true,
311
- },
312
- {
313
- prop: "remark",
314
- label: "备注",
315
- minWidth: "",
316
- show: true,
317
- },
318
- ], //表头
319
- operates: [], //表格里面的操作按钮
320
- tableHeightDiff: 300,
321
- },
322
- paginations: {
323
- page: 1, //当前位于那页面
324
- total: 10, //总数
325
- limit: 30, //一页显示多少条
326
- pagetionShow: true,
327
- },
328
- };
329
- },
330
- methods: {
331
- SelectionChange(row) {
332
- this.multipleSelection = row;
333
- },
334
- handleSizeChange(val) {
335
- this.paginations.page = 1;
336
- this.paginations.limit = val;
337
- this.getTable();
250
+ export default {
251
+ data() {
252
+ return {
253
+ multipleSelection: [],
254
+ tableData: {
255
+ loading: false,
256
+ emptyImg: true,
257
+ options: {
258
+ selection: true, //多选框
259
+ index: null, //序号
260
+ headTool: true, //开启头部工具栏
261
+ refreshBtn: true, //开启表格头部刷新按钮
262
+ downloadBtn: true, //开启表格头部下载按钮
263
+ }, //序号和复选框
264
+ rows: [], //表数据
265
+ columns: [
266
+ {
267
+ label: "",
268
+ minWidth: "",
269
+ type: "selection",
270
+ show: true,
271
+ },
272
+ {
273
+ prop: "warehouseCode",
274
+ label: "仓库编码",
275
+ minWidth: "",
276
+ sortable: false,
277
+ show: true,
278
+ },
279
+ {
280
+ prop: "warehouseName",
281
+ label: "仓库名称",
282
+ minWidth: "",
283
+ sortable: false,
284
+ show: true,
285
+ },
286
+ {
287
+ prop: "enabledDesc",
288
+ label: "状态",
289
+ minWidth: "",
290
+ sortable: false,
291
+ show: true,
292
+ },
293
+ {
294
+ prop: "createdUser",
295
+ label: "创建人",
296
+ minWidth: "",
297
+ sortable: false,
298
+ show: true,
299
+ },
300
+ {
301
+ prop: "createTime",
302
+ label: "创建时间",
303
+ minWidth: "",
304
+ show: true,
305
+ },
306
+ {
307
+ prop: "classes",
308
+ label: "班次",
309
+ minWidth: "",
310
+ show: true,
311
+ renderSlot: true,
312
+ },
313
+ {
314
+ prop: "remark",
315
+ label: "备注",
316
+ minWidth: "",
317
+ show: true,
318
+ },
319
+ ], //表头
320
+ operates: [], //表格里面的操作按钮
321
+ tableHeightDiff: 300,
338
322
  },
339
- handleindexChange(val) {
340
- this.paginations.page = val;
341
- this.getTable();
323
+ paginations: {
324
+ page: 1, //当前位于那页面
325
+ total: 10, //总数
326
+ limit: 30, //一页显示多少条
327
+ pagetionShow: true,
342
328
  },
329
+ };
330
+ },
331
+ methods: {
332
+ SelectionChange(row) {
333
+ this.multipleSelection = row;
334
+ },
335
+ handleSizeChange(val) {
336
+ this.paginations.page = 1;
337
+ this.paginations.limit = val;
338
+ this.getTable();
343
339
  },
344
- };
340
+ handleindexChange(val) {
341
+ this.paginations.page = val;
342
+ this.getTable();
343
+ },
344
+ },
345
+ };
345
346
  </script>
346
347
  ```
347
348
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.7.7",
3
+ "version": "2.7.9",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
@@ -0,0 +1,100 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" viewBox="0 0 256 256" role="img" aria-labelledby="title desc">
2
+ <title id="title">Base Component - 极速CRUD生成</title>
3
+ <desc id="desc">日间/夜间径向背景;无四周渐变边环;闪电在下;CRUD图标去黑色分离层与外部阴影,保留轻微发光。</desc>
4
+ <defs>
5
+ <!-- 日/夜 背景 -->
6
+ <radialGradient id="bgDayRadial" cx="50%" cy="42%" r="80%">
7
+ <stop offset="0%" stop-color="#FFE3FF" stop-opacity="0.35"/>
8
+ <stop offset="50%" stop-color="#8EC5FF" stop-opacity="0.22"/>
9
+ <stop offset="100%" stop-color="#41D1FF" stop-opacity="0.12"/>
10
+ </radialGradient>
11
+ <radialGradient id="bgNightRadial" cx="50%" cy="42%" r="85%">
12
+ <stop offset="0%" stop-color="#1e1b4b" stop-opacity="0.70"/>
13
+ <stop offset="55%" stop-color="#0b1020" stop-opacity="0.60"/>
14
+ <stop offset="100%" stop-color="#020617" stop-opacity="0.55"/>
15
+ </radialGradient>
16
+
17
+ <!-- 其他渐变/效果 -->
18
+ <linearGradient id="bolt" x1="0" y1="0" x2="1" y2="1">
19
+ <stop offset="0%" stop-color="#fbbf24"/><stop offset="100%" stop-color="#fb7185"/>
20
+ </linearGradient>
21
+ <linearGradient id="crud" x1="0" y1="0" x2="1" y2="1">
22
+ <stop offset="0%" stop-color="#22d3ee"/><stop offset="100%" stop-color="#8b5cf6"/>
23
+ </linearGradient>
24
+ <filter id="glow" x="-50%" y="-50%" width="200%" height="200%">
25
+ <feGaussianBlur in="SourceGraphic" stdDeviation="3" result="b"/>
26
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
27
+ </filter>
28
+ <filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">
29
+ <feDropShadow dx="0" dy="2" stdDeviation="3" flood-color="#000" flood-opacity="0.35"/>
30
+ </filter>
31
+
32
+ <style><![CDATA[
33
+ /* 默认日间;加 class="theme-dark" 切夜间 */
34
+ .bg-night { display: none; }
35
+ svg.theme-dark .bg-day { display: none; }
36
+ svg.theme-dark .bg-night { display: inline; }
37
+ ]]></style>
38
+ </defs>
39
+
40
+ <!-- 背景:仅径向填充(无四周渐变边环) -->
41
+ <g class="bg-day">
42
+ <rect x="8" y="8" width="240" height="240" rx="28" fill="url(#bgDayRadial)"/>
43
+ </g>
44
+ <g class="bg-night">
45
+ <rect x="8" y="8" width="240" height="240" rx="28" fill="url(#bgNightRadial)"/>
46
+ </g>
47
+
48
+ <!-- 左侧列表线 -->
49
+ <g stroke="#34d399" stroke-width="6" stroke-linecap="round" opacity="0.9">
50
+ <line x1="20" y1="104" x2="84" y2="104"/>
51
+ <line x1="20" y1="132" x2="68" y2="132"/>
52
+ <line x1="20" y1="160" x2="56" y2="160"/>
53
+ </g>
54
+
55
+ <!-- 闪电(置底,不遮挡图标) -->
56
+ <path d="M168 44 L128 116 L184 116 L96 228 L128 148 L72 148 Z" fill="url(#bolt)" filter="url(#glow)"/>
57
+
58
+ <!-- 文档卡片(保留卡片阴影) -->
59
+ <g transform="translate(102,44) rotate(-8 64 84)" filter="url(#shadow)">
60
+ <rect x="0" y="0" width="128" height="168" rx="16" fill="rgba(229,231,235,0.08)" stroke="url(#crud)" stroke-width="5"/>
61
+ </g>
62
+
63
+ <!-- CRUD 图标(无黑色分离层,无外部阴影,保留轻微发光) -->
64
+ <g transform="translate(102,44) rotate(-8 64 84)">
65
+ <g stroke="url(#crud)" stroke-width="4.2" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.98" filter="url(#glow)">
66
+ <!-- Create: 加号 -->
67
+ <g transform="translate(18,44)">
68
+ <g fill="url(#crud)" stroke="none">
69
+ <rect x="18" y="7" width="6" height="28" rx="3"/>
70
+ <rect x="7" y="18" width="28" height="6" rx="3"/>
71
+ </g>
72
+ </g>
73
+ <!-- Read: 眼睛(无白点,渐变瞳孔) -->
74
+ <g transform="translate(74,40)">
75
+ <path d="M6 21c8-10 32-10 40 0c-8 10-32 10-40 0z"/>
76
+ <circle cx="26" cy="21" r="3.6" fill="url(#crud)" stroke="none" opacity="0.95"/>
77
+ </g>
78
+ <!-- Update: 修改 -->
79
+ <g transform="translate(18,98)">
80
+ <path d="M8 36l10-3l20-20c1.5-1.5 1.5-4 0-5.5v0c-1.5-1.5-4-1.5-5.5 0l-20 20l-3 10z"/>
81
+ <line x1="28" y1="12" x2="34" y2="18"/>
82
+ </g>
83
+ <!-- Delete: 垃圾桶 -->
84
+ <g transform="translate(74,96)">
85
+ <rect x="12" y="14" width="24" height="4" rx="2"/>
86
+ <rect x="20" y="10" width="8" height="4" rx="2"/>
87
+ <path d="M14 20h20l-2 22h-16l-2-22z"/>
88
+ <line x1="20" y1="24" x2="20" y2="36"/>
89
+ <line x1="28" y1="24" x2="28" y2="36"/>
90
+ </g>
91
+ </g>
92
+ </g>
93
+
94
+ <!-- 星点 -->
95
+ <g fill="#f59e0b" opacity="0.9">
96
+ <circle cx="92" cy="86" r="2.4"/>
97
+ <circle cx="98" cy="70" r="1.8"/>
98
+ <circle cx="78" cy="124" r="1.6"/>
99
+ </g>
100
+ </svg>
package/src/bin/add.js CHANGED
@@ -3,7 +3,7 @@ const { Command } = require("commander");
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
5
  const inquirer = require("inquirer");
6
- const vue2Template = require("./initTemplate");
6
+ const { vue2Template, vue2Form } = require("./initTemplate");
7
7
  const program = new Command();
8
8
 
9
9
  const spinnerChars = ["|", "/", "-", "\\"];
@@ -238,6 +238,10 @@ try {
238
238
  swaggerModule: moduleAnswer.swaggerModule,
239
239
  idField: idField,
240
240
  rowId,
241
+ hasDialog:
242
+ operationsAnswer.operations.includes("add") ||
243
+ operationsAnswer.operations.includes("edit") ||
244
+ operationsAnswer.operations.includes("detail"),
241
245
  };
242
246
 
243
247
  // 生成模板内容
@@ -247,42 +251,19 @@ try {
247
251
  const outputPath = path.join(dir, `index.vue`);
248
252
  fs.writeFileSync(outputPath, templateContent);
249
253
 
254
+ if (config.hasDialog) {
255
+ const srcDir = path.join(dir, "components");
256
+ fs.mkdirSync(srcDir, { recursive: true });
257
+ const formContent = vue2Form(moduleName, config);
258
+ const dialogPath = path.join(srcDir, `formModule.vue`);
259
+ fs.writeFileSync(dialogPath, formContent);
260
+ }
261
+
250
262
  // 停止加载动画
251
263
  stopSpinner();
252
264
 
253
265
  // 输出成功信息
254
266
  console.log(`✅ 模板已生成并保存到 ${outputPath}`);
255
- console.log(` 文件路径: ${outputPath}`);
256
-
257
- // 输出功能总结
258
- const features = [];
259
- if (exportAnswer.hasExport) features.push("导出功能");
260
- if (operationsAnswer.operations.includes("add")) features.push("新增功能");
261
- if (operationsAnswer.operations.includes("edit")) features.push("编辑功能");
262
- if (operationsAnswer.operations.includes("delete")) features.push("删除功能");
263
- if (operationsAnswer.operations.includes("detail")) features.push("详情功能");
264
-
265
- if (features.length > 0) {
266
- console.log(`🔧 已添加功能: ${features.join(", ")}`);
267
- }
268
-
269
- console.log(`📚 模块名: ${moduleAnswer.swaggerModule}`);
270
- if (idField) {
271
- console.log(`🆔 ID字段: ${idField}`);
272
- }
273
-
274
- // 显示接口地址预览
275
- if (operationsAnswer.operations.length > 0) {
276
- const pageUrl = pageUrlAnswer.pageUrl;
277
- const baseUrl = pageUrl.replace(/-paged-result.*$/, "").replace(/\/[^\/]*$/, "");
278
- console.log(`🔗 基础接口: ${baseUrl}`);
279
- if (addUrl) console.log(`➕ 新增接口: ${addUrl}`);
280
- if (editUrl) console.log(`✏️ 编辑接口: ${editUrl}`);
281
- if (deleteUrl) console.log(`��️ 删除接口: ${deleteUrl}`);
282
- if (detailUrl) console.log(`��️ 详情接口: ${detailUrl}`);
283
- }
284
-
285
- console.log("\n 模板生成完成!");
286
267
  } catch (error) {
287
268
  stopSpinner();
288
269
  console.error("❌ 发生错误:", error.message);
@@ -40,11 +40,17 @@ const vue2Template = (moduleName, config = {}) => {
40
40
 
41
41
  if (config.pageUrl) pageUrlKey = generateKeyName(config.pageUrl, "get");
42
42
  if (config.exportUrl) exportUrlKey = generateKeyName(config.exportUrl, "post");
43
- if (config.detailUrl) baseUrlKey = detailUrlKey = generateKeyName(config.detailUrl, "get");
44
- if (config.editUrl) baseUrlKey = editUrlKey = generateKeyName(config.editUrl, "put");
43
+ if (config.detailUrl) {
44
+ detailUrlKey = generateKeyName(config.detailUrl, "get");
45
+ baseUrlKey = `${detailUrlKey}CompleteUrl`; //补充后缀
46
+ }
47
+ if (config.editUrl) {
48
+ editUrlKey = generateKeyName(config.editUrl, "put");
49
+ baseUrlKey = `${editUrlKey}CompleteUrl`; //补充后缀
50
+ }
45
51
  if (config.addUrl) baseUrlKey = addUrlKey = generateKeyName(config.addUrl, "post");
46
52
  if (config.deleteUrl) deleteUrlKey = generateKeyName(config.deleteUrl, "delete");
47
- if (baseUrlKey) baseUrlKey = `${baseUrlKey}CompleteUrl`; //补充后缀
53
+
48
54
  // 生成导入语句
49
55
  const generateImports = () => {
50
56
  const imports = [];
@@ -59,30 +65,6 @@ const vue2Template = (moduleName, config = {}) => {
59
65
  // 生成方法
60
66
  const generateMethods = () => {
61
67
  const methods = [];
62
- if (config.hasAdd) {
63
- methods.push(`
64
- addBtnHandler() {
65
- this.form.type = 1;
66
- this.dialogVisible = true;
67
- }`);
68
- }
69
-
70
- if (config.hasEdit) {
71
- methods.push(`
72
- ${config.hasDetail ? `async ` : ``}editBtnHandler() {
73
- const data = this.multipleSelection;
74
- if(data.length !== 1) return this.$message.info("请选择一条数据");
75
- const row = data[0];
76
- this.form.type = 2;
77
- ${
78
- config.hasDetail
79
- ? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
80
- this.form.value = result || {};`
81
- : `this.form.value = { ...row };`
82
- }
83
- this.dialogVisible = true;
84
- }`);
85
- }
86
68
 
87
69
  // onCancel
88
70
  if (config.hasAdd || config.hasEdit || config.hasDetail) {
@@ -101,7 +83,7 @@ const vue2Template = (moduleName, config = {}) => {
101
83
  const res = await ${addUrlKey}(data);
102
84
  if(res.code !== 200) return;
103
85
  this.$message("新建成功");
104
- }else if(form.type === 2){
86
+ }else if (form.type === 2) {
105
87
  //编辑
106
88
  const res = await ${editUrlKey}(data['${config.rowId}'], data);
107
89
  if(res.code !== 200) return;
@@ -113,6 +95,45 @@ const vue2Template = (moduleName, config = {}) => {
113
95
  }`);
114
96
  }
115
97
 
98
+ if (config.hasAdd) {
99
+ methods.push(`
100
+ addBtnHandler() {
101
+ this.type = 1;
102
+ this.dialogVisible = true;
103
+ }`);
104
+ }
105
+
106
+ if (config.hasEdit) {
107
+ methods.push(`
108
+ ${config.hasDetail ? `async ` : ``}editBtnHandler() {
109
+ const data = this.multipleSelection;
110
+ if(data.length !== 1) return this.$message.info("请选择一条数据");
111
+ const row = data[0];
112
+ ${
113
+ config.hasDetail
114
+ ? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
115
+ this.formData = result || {};`
116
+ : `this.formData = { ...row };`
117
+ }
118
+ this.type = 2;
119
+ this.dialogVisible = true;
120
+ }`);
121
+ }
122
+
123
+ // 有详情
124
+ if (config.hasDetail) {
125
+ methods.push(`
126
+ async detailBtnHandler() {
127
+ const data = this.multipleSelection;
128
+ if(data.length !== 1) return this.$message.info("请选择一条数据");
129
+ const row = data[0];
130
+ const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
131
+ this.formData = result || {};
132
+ this.type = 0;
133
+ this.dialogVisible = true;
134
+ }`);
135
+ }
136
+
116
137
  if (config.hasDelete) {
117
138
  methods.push(`
118
139
  deleteBtnHandler() {
@@ -134,6 +155,25 @@ const vue2Template = (moduleName, config = {}) => {
134
155
  }`);
135
156
  }
136
157
 
158
+ if (config.hasExport) {
159
+ methods.push(`
160
+ export() {
161
+ const timer = this.formSearchData.value.createdTime;
162
+ this.formSearchData.value.BeginTime = timer ? timer[0] : "";
163
+ this.formSearchData.value.EndTime = timer ? timer[1] : "";
164
+ this.post({
165
+ url: ${config.swaggerModule}.${exportUrlKey},
166
+ isLoading: true,
167
+ responseType: "blob",
168
+ data: Object.assign(this.formSearchData.value, {
169
+ Page: this.paginations.page,
170
+ MaxResultCount: this.paginations.limit
171
+ })
172
+ }).then(res => {
173
+ this.fnexsl(res);
174
+ });
175
+ }`);
176
+ }
137
177
  return methods.join(",");
138
178
  };
139
179
 
@@ -163,12 +203,11 @@ const vue2Template = (moduleName, config = {}) => {
163
203
  @handleindexChange="handleindexChange"
164
204
  />
165
205
  ${
166
- config.hasAdd || config.hasEdit || config.hasDetail
206
+ config.hasDialog
167
207
  ? `<el-dialog :title="this.form.title" :visible.sync="dialogVisible" width="80%">
168
- <ol-form
208
+ <FormModule
169
209
  v-if="dialogVisible"
170
- :url="swaggerUrl.${baseUrlKey}"
171
- :form="form"
210
+ :formData="formData"
172
211
  @onCancel="onCancel"
173
212
  @onSubmit="onSubmit"
174
213
  />
@@ -180,8 +219,16 @@ const vue2Template = (moduleName, config = {}) => {
180
219
  <script>
181
220
  import { ${generateImports()} } from "@/api/modules";
182
221
  import { ${config.swaggerModule} } from '@/api/swagger';
222
+ ${config.hasDialog ? `import FormModule from "./components/formModule.vue"` : ""}
183
223
  export default {
184
224
  name: "${moduleName}",
225
+ ${
226
+ config.hasDialog
227
+ ? `components: {
228
+ FormModule
229
+ },`
230
+ : ""
231
+ }
185
232
  data() {
186
233
  return {
187
234
  swaggerUrl: ${config.swaggerModule},
@@ -217,17 +264,9 @@ export default {
217
264
  pagetionShow: true
218
265
  },
219
266
  ${
220
- config.hasAdd || config.hasEdit || config.hasDetail
221
- ? `form: {
222
- type: 0, // 0详情,1新增, 2编辑
223
- title: "",
224
- // 默认值
225
- defaultValue: {},
226
- value: {},
227
- model: [],
228
- rules: {},
229
- attrs: {},
230
- },
267
+ config.hasDialog
268
+ ? `type: 1,
269
+ formData: {},
231
270
  dialogVisible: false`
232
271
  : ""
233
272
  }
@@ -273,31 +312,97 @@ export default {
273
312
  this.paginations.page = val;
274
313
  this.init();
275
314
  },
276
- ${
277
- config.hasExport
278
- ? `export() {
279
- const timer = this.formSearchData.value.createdTime
280
- ;
281
- this.formSearchData.value.BeginTime = timer ? timer[0] : "";
282
- this.formSearchData.value.EndTime = timer ? timer[1] : "";
283
- this.post({
284
- url: ${config.swaggerModule}.${exportUrlKey},
285
- isLoading: true,
286
- responseType: "blob",
287
- data: Object.assign(this.formSearchData.value, {
288
- Page: this.paginations.page,
289
- MaxResultCount: this.paginations.limit
290
- })
291
- }).then(res => {
292
- this.fnexsl(res);
293
- });
294
- },`
295
- : ""
296
- }${generateMethods()}
315
+ ${generateMethods()}
316
+ }
317
+ }
318
+ </script>
319
+ `;
320
+ };
321
+
322
+ const vue2Form = (moduleName, config = {}) => {
323
+ let editUrlKey = "",
324
+ detailUrlKey = "",
325
+ baseUrlKey = "";
326
+
327
+ if (config.detailUrl) {
328
+ detailUrlKey = generateKeyName(config.detailUrl, "get");
329
+ baseUrlKey = `${detailUrlKey}CompleteUrl`; //补充后缀
330
+ }
331
+
332
+ if (config.editUrl) {
333
+ editUrlKey = generateKeyName(config.editUrl, "put");
334
+ baseUrlKey = `${editUrlKey}CompleteUrl`; //补充后缀
335
+ }
336
+
337
+ if (config.addUrl) baseUrlKey = generateKeyName(config.addUrl, "post");
338
+
339
+ return `<!--
340
+ Filename: ${moduleName}.vue
341
+ name: ${moduleName}
342
+ Created Date: ${new Date().toLocaleString()}
343
+ Author:
344
+ -->
345
+ <template>
346
+ <ol-form
347
+ :url="swaggerUrl.${baseUrlKey}"
348
+ :form="form"
349
+ @onCancel="onCancel"
350
+ @onSubmit="onSubmit"
351
+ />
352
+ </template>
353
+ <script>
354
+ import { ${config.swaggerModule} } from '@/api/swagger';
355
+ export default {
356
+ name: "${moduleName}Form",
357
+ props: {
358
+ formData: {
359
+ type: Object,
360
+ default: () => ({})
361
+ },
362
+ type: {
363
+ type: Number,
364
+ default: 1
365
+ }
366
+ },
367
+ data() {
368
+ return {
369
+ swaggerUrl: ${config.swaggerModule},
370
+ form: {
371
+ type: this.type, // 0详情,1新增, 2编辑
372
+ title: "",
373
+ defaultValue: {}, // 默认值
374
+ value: {},
375
+ model: [],
376
+ rules: {},
377
+ attrs: {},
378
+ }
379
+ }
380
+ },
381
+ watch: {
382
+ type: {
383
+ handler(val){
384
+ this.form.type = val;
385
+ },
386
+ immediate: true
387
+ }
388
+ },
389
+ created(){
390
+ this.form.value = { ...this.formData };
391
+ },
392
+ methods: {
393
+ onCancel() {
394
+ this.$emit("onCancel");
395
+ },
396
+ onSubmit({form, data}) {
397
+ this.$emit("onSubmit", { form, data });
398
+ }
297
399
  }
298
400
  }
299
401
  </script>
300
402
  `;
301
403
  };
302
404
 
303
- module.exports = vue2Template;
405
+ module.exports = {
406
+ vue2Template,
407
+ vue2Form,
408
+ };
@@ -65,7 +65,7 @@
65
65
  v-bind="item.props || {}"
66
66
  />
67
67
  <el-radio-group v-else-if="item.type == 'radio'" v-model="form.value[item.prop]">
68
- <el-radio v-for="ctem in item.child" :key="ctem.key" :label="ctem.key">{{
68
+ <el-radio v-for="ctem in item.children" :key="ctem.key" :label="ctem.key">{{
69
69
  ctem.value
70
70
  }}</el-radio>
71
71
  </el-radio-group>
@@ -86,14 +86,14 @@
86
86
  v-else-if="item.type == 'treeSelect'"
87
87
  v-model="form.value[item.prop]"
88
88
  v-bind="item.props || {}"
89
- :options="item.child"
89
+ :options="item.children"
90
90
  @getValue="item.change && item.change(form.value[item.prop])"
91
91
  />
92
92
  <!-- <el-select v-else-if="item.type == 'select'" v-model="form.value[item.prop]"
93
93
  :placeholder="`请选择${item.placeholder || item.label}`"
94
94
  :clearable="'clearable' in item ? item.clearable : true" :disabled="item.disabled || false"
95
95
  v-bind="item.props || {}" v-on="{ ...item.listeners, change: selectChangeHandle(item) }">
96
- <el-option v-for="(jtem, jindex) in item.child" :key="jindex" :label="jtem.value"
96
+ <el-option v-for="(jtem, jindex) in item.children" :key="jindex" :label="jtem.value"
97
97
  :value="jtem.key"></el-option>
98
98
  </el-select> -->
99
99
  <!-- v-on="{ ...item.listeners, change: (event) => selectChangeHandle(event,
@@ -118,7 +118,7 @@
118
118
  "
119
119
  >
120
120
  <el-option
121
- v-for="(jtem, jindex) in item.child"
121
+ v-for="(jtem, jindex) in item.children"
122
122
  :key="jindex"
123
123
  :label="jtem.value"
124
124
  :value="jtem.key"