ol-base-components 2.7.8 → 2.7.10

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.8",
3
+ "version": "2.7.10",
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,6 +251,14 @@ 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
 
@@ -65,36 +65,12 @@ const vue2Template = (moduleName, config = {}) => {
65
65
  // 生成方法
66
66
  const generateMethods = () => {
67
67
  const methods = [];
68
- if (config.hasAdd) {
69
- methods.push(`
70
- addBtnHandler() {
71
- this.form.type = 1;
72
- this.dialogVisible = true;
73
- }`);
74
- }
75
-
76
- if (config.hasEdit) {
77
- methods.push(`
78
- ${config.hasDetail ? `async ` : ``}editBtnHandler() {
79
- const data = this.multipleSelection;
80
- if(data.length !== 1) return this.$message.info("请选择一条数据");
81
- const row = data[0];
82
- this.form.type = 2;
83
- ${
84
- config.hasDetail
85
- ? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
86
- this.form.value = result || {};`
87
- : `this.form.value = { ...row };`
88
- }
89
- this.dialogVisible = true;
90
- }`);
91
- }
92
68
 
93
69
  // onCancel
94
70
  if (config.hasAdd || config.hasEdit || config.hasDetail) {
95
71
  methods.push(`
96
72
  onCancel() {
97
- this.dialogVisible = false;
73
+ this.formConfig.dialogVisible = false;
98
74
  }`);
99
75
  }
100
76
 
@@ -107,7 +83,7 @@ const vue2Template = (moduleName, config = {}) => {
107
83
  const res = await ${addUrlKey}(data);
108
84
  if(res.code !== 200) return;
109
85
  this.$message("新建成功");
110
- }else if(form.type === 2){
86
+ }else if (form.type === 2) {
111
87
  //编辑
112
88
  const res = await ${editUrlKey}(data['${config.rowId}'], data);
113
89
  if(res.code !== 200) return;
@@ -119,6 +95,49 @@ const vue2Template = (moduleName, config = {}) => {
119
95
  }`);
120
96
  }
121
97
 
98
+ if (config.hasAdd) {
99
+ methods.push(`
100
+ addBtnHandler() {
101
+ this.formConfig.title = "新增";
102
+ this.formConfig.type = 1;
103
+ this.formConfig.formData = {};
104
+ this.formConfig.dialogVisible = true;
105
+ }`);
106
+ }
107
+
108
+ if (config.hasEdit) {
109
+ methods.push(`
110
+ ${config.hasDetail ? `async ` : ``}editBtnHandler() {
111
+ const data = this.multipleSelection;
112
+ if(data.length !== 1) return this.$message.info("请选择一条数据");
113
+ const row = data[0];
114
+ ${
115
+ config.hasDetail
116
+ ? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
117
+ this.formConfig.formData = result || {};`
118
+ : `this.formConfig.formData = { ...row };`
119
+ }
120
+ this.formConfig.title = "编辑";
121
+ this.formConfig.type = 2;
122
+ this.formConfig.dialogVisible = true;
123
+ }`);
124
+ }
125
+
126
+ // 有详情
127
+ if (config.hasDetail) {
128
+ methods.push(`
129
+ async detailBtnHandler() {
130
+ const data = this.multipleSelection;
131
+ if(data.length !== 1) return this.$message.info("请选择一条数据");
132
+ const row = data[0];
133
+ const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
134
+ this.formConfig.formData = result || {};
135
+ this.formConfig.title = "详情";
136
+ this.formConfig.type = 0;
137
+ this.formConfig.dialogVisible = true;
138
+ }`);
139
+ }
140
+
122
141
  if (config.hasDelete) {
123
142
  methods.push(`
124
143
  deleteBtnHandler() {
@@ -140,6 +159,25 @@ const vue2Template = (moduleName, config = {}) => {
140
159
  }`);
141
160
  }
142
161
 
162
+ if (config.hasExport) {
163
+ methods.push(`
164
+ export() {
165
+ const timer = this.formSearchData.value.createdTime;
166
+ this.formSearchData.value.BeginTime = timer ? timer[0] : "";
167
+ this.formSearchData.value.EndTime = timer ? timer[1] : "";
168
+ this.post({
169
+ url: ${config.swaggerModule}.${exportUrlKey},
170
+ isLoading: true,
171
+ responseType: "blob",
172
+ data: Object.assign(this.formSearchData.value, {
173
+ Page: this.paginations.page,
174
+ MaxResultCount: this.paginations.limit
175
+ })
176
+ }).then(res => {
177
+ this.fnexsl(res);
178
+ });
179
+ }`);
180
+ }
143
181
  return methods.join(",");
144
182
  };
145
183
 
@@ -169,12 +207,12 @@ const vue2Template = (moduleName, config = {}) => {
169
207
  @handleindexChange="handleindexChange"
170
208
  />
171
209
  ${
172
- config.hasAdd || config.hasEdit || config.hasDetail
173
- ? `<el-dialog :title="this.form.title" :visible.sync="dialogVisible" width="80%">
174
- <ol-form
175
- v-if="dialogVisible"
176
- :url="swaggerUrl.${baseUrlKey}"
177
- :form="form"
210
+ config.hasDialog
211
+ ? `<el-dialog :title="formConfig.title" :visible.sync="formConfig.dialogVisible" width="80%">
212
+ <FormModule
213
+ v-if="formConfig.dialogVisible"
214
+ :formData="formConfig.formData"
215
+ :type="formConfig.type"
178
216
  @onCancel="onCancel"
179
217
  @onSubmit="onSubmit"
180
218
  />
@@ -186,8 +224,16 @@ const vue2Template = (moduleName, config = {}) => {
186
224
  <script>
187
225
  import { ${generateImports()} } from "@/api/modules";
188
226
  import { ${config.swaggerModule} } from '@/api/swagger';
227
+ ${config.hasDialog ? `import FormModule from "./components/formModule.vue"` : ""}
189
228
  export default {
190
229
  name: "${moduleName}",
230
+ ${
231
+ config.hasDialog
232
+ ? `components: {
233
+ FormModule
234
+ },`
235
+ : ""
236
+ }
191
237
  data() {
192
238
  return {
193
239
  swaggerUrl: ${config.swaggerModule},
@@ -223,18 +269,13 @@ export default {
223
269
  pagetionShow: true
224
270
  },
225
271
  ${
226
- config.hasAdd || config.hasEdit || config.hasDetail
227
- ? `form: {
228
- type: 0, // 0详情,1新增, 2编辑
229
- title: "",
230
- // 默认值
231
- defaultValue: {},
232
- value: {},
233
- model: [],
234
- rules: {},
235
- attrs: {},
236
- },
237
- dialogVisible: false`
272
+ config.hasDialog
273
+ ? `formConfig: {
274
+ type: 1,
275
+ formData: {},
276
+ title:"",
277
+ dialogVisible: false
278
+ }`
238
279
  : ""
239
280
  }
240
281
  }
@@ -279,31 +320,97 @@ export default {
279
320
  this.paginations.page = val;
280
321
  this.init();
281
322
  },
282
- ${
283
- config.hasExport
284
- ? `export() {
285
- const timer = this.formSearchData.value.createdTime
286
- ;
287
- this.formSearchData.value.BeginTime = timer ? timer[0] : "";
288
- this.formSearchData.value.EndTime = timer ? timer[1] : "";
289
- this.post({
290
- url: ${config.swaggerModule}.${exportUrlKey},
291
- isLoading: true,
292
- responseType: "blob",
293
- data: Object.assign(this.formSearchData.value, {
294
- Page: this.paginations.page,
295
- MaxResultCount: this.paginations.limit
296
- })
297
- }).then(res => {
298
- this.fnexsl(res);
299
- });
300
- },`
301
- : ""
302
- }${generateMethods()}
323
+ ${generateMethods()}
303
324
  }
304
325
  }
305
326
  </script>
306
327
  `;
307
328
  };
308
329
 
309
- module.exports = vue2Template;
330
+ const vue2Form = (moduleName, config = {}) => {
331
+ let editUrlKey = "",
332
+ detailUrlKey = "",
333
+ baseUrlKey = "";
334
+
335
+ if (config.detailUrl) {
336
+ detailUrlKey = generateKeyName(config.detailUrl, "get");
337
+ baseUrlKey = `${detailUrlKey}CompleteUrl`; //补充后缀
338
+ }
339
+
340
+ if (config.editUrl) {
341
+ editUrlKey = generateKeyName(config.editUrl, "put");
342
+ baseUrlKey = `${editUrlKey}CompleteUrl`; //补充后缀
343
+ }
344
+
345
+ if (config.addUrl) baseUrlKey = generateKeyName(config.addUrl, "post");
346
+
347
+ return `<!--
348
+ Filename: ${moduleName}.vue
349
+ name: ${moduleName}
350
+ Created Date: ${new Date().toLocaleString()}
351
+ Author:
352
+ -->
353
+ <template>
354
+ <ol-form
355
+ :url="swaggerUrl.${baseUrlKey}"
356
+ :form="form"
357
+ @onCancel="onCancel"
358
+ @onSubmit="onSubmit"
359
+ />
360
+ </template>
361
+ <script>
362
+ import { ${config.swaggerModule} } from '@/api/swagger';
363
+ export default {
364
+ name: "${moduleName}Form",
365
+ props: {
366
+ formData: {
367
+ type: Object,
368
+ default: () => ({})
369
+ },
370
+ type: {
371
+ type: Number,
372
+ default: 1
373
+ }
374
+ },
375
+ data() {
376
+ return {
377
+ swaggerUrl: ${config.swaggerModule},
378
+ form: {
379
+ type: this.type, // 0详情,1新增, 2编辑
380
+ title: "",
381
+ defaultValue: {}, // 默认值
382
+ value: {},
383
+ model: [],
384
+ rules: {},
385
+ attrs: {},
386
+ }
387
+ }
388
+ },
389
+ watch: {
390
+ type: {
391
+ handler(val){
392
+ this.form.type = val;
393
+ },
394
+ immediate: true
395
+ }
396
+ },
397
+ created(){
398
+ if(this.type !== 1) this.form.value = { ...this.formData };
399
+ },
400
+ methods: {
401
+ onCancel() {
402
+ this.$emit("onCancel");
403
+ },
404
+ onSubmit({form, data}) {
405
+ this.$emit("onSubmit", { form, data });
406
+ }
407
+ }
408
+ }
409
+ </script>
410
+ `;
411
+ };
412
+
413
+ module.exports = {
414
+ vue2Template,
415
+ vue2Form,
416
+ };
@@ -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"