ol-base-components 2.7.8 → 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 +145 -144
- package/package.json +1 -1
- package/src/assets/olBaseComponentsLogo.svg +100 -0
- package/src/bin/add.js +13 -1
- package/src/bin/initTemplate.js +161 -62
- package/src/package/form/src/index.vue +4 -4
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
二次封装的通用组件库,包含表格(Table)和表单(Form)等组件。
|
|
4
4
|
|
|
5
|
-
- [在线演示](https://mqtt-a.vercel.app/home)
|
|
6
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
@@ -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
|
|
package/src/bin/initTemplate.js
CHANGED
|
@@ -65,30 +65,6 @@ 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) {
|
|
@@ -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,45 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
119
95
|
}`);
|
|
120
96
|
}
|
|
121
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
|
+
|
|
122
137
|
if (config.hasDelete) {
|
|
123
138
|
methods.push(`
|
|
124
139
|
deleteBtnHandler() {
|
|
@@ -140,6 +155,25 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
140
155
|
}`);
|
|
141
156
|
}
|
|
142
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
|
+
}
|
|
143
177
|
return methods.join(",");
|
|
144
178
|
};
|
|
145
179
|
|
|
@@ -169,12 +203,11 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
169
203
|
@handleindexChange="handleindexChange"
|
|
170
204
|
/>
|
|
171
205
|
${
|
|
172
|
-
config.
|
|
206
|
+
config.hasDialog
|
|
173
207
|
? `<el-dialog :title="this.form.title" :visible.sync="dialogVisible" width="80%">
|
|
174
|
-
<
|
|
208
|
+
<FormModule
|
|
175
209
|
v-if="dialogVisible"
|
|
176
|
-
:
|
|
177
|
-
:form="form"
|
|
210
|
+
:formData="formData"
|
|
178
211
|
@onCancel="onCancel"
|
|
179
212
|
@onSubmit="onSubmit"
|
|
180
213
|
/>
|
|
@@ -186,8 +219,16 @@ const vue2Template = (moduleName, config = {}) => {
|
|
|
186
219
|
<script>
|
|
187
220
|
import { ${generateImports()} } from "@/api/modules";
|
|
188
221
|
import { ${config.swaggerModule} } from '@/api/swagger';
|
|
222
|
+
${config.hasDialog ? `import FormModule from "./components/formModule.vue"` : ""}
|
|
189
223
|
export default {
|
|
190
224
|
name: "${moduleName}",
|
|
225
|
+
${
|
|
226
|
+
config.hasDialog
|
|
227
|
+
? `components: {
|
|
228
|
+
FormModule
|
|
229
|
+
},`
|
|
230
|
+
: ""
|
|
231
|
+
}
|
|
191
232
|
data() {
|
|
192
233
|
return {
|
|
193
234
|
swaggerUrl: ${config.swaggerModule},
|
|
@@ -223,17 +264,9 @@ export default {
|
|
|
223
264
|
pagetionShow: true
|
|
224
265
|
},
|
|
225
266
|
${
|
|
226
|
-
config.
|
|
227
|
-
? `
|
|
228
|
-
|
|
229
|
-
title: "",
|
|
230
|
-
// 默认值
|
|
231
|
-
defaultValue: {},
|
|
232
|
-
value: {},
|
|
233
|
-
model: [],
|
|
234
|
-
rules: {},
|
|
235
|
-
attrs: {},
|
|
236
|
-
},
|
|
267
|
+
config.hasDialog
|
|
268
|
+
? `type: 1,
|
|
269
|
+
formData: {},
|
|
237
270
|
dialogVisible: false`
|
|
238
271
|
: ""
|
|
239
272
|
}
|
|
@@ -279,31 +312,97 @@ export default {
|
|
|
279
312
|
this.paginations.page = val;
|
|
280
313
|
this.init();
|
|
281
314
|
},
|
|
282
|
-
${
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
+
}
|
|
303
399
|
}
|
|
304
400
|
}
|
|
305
401
|
</script>
|
|
306
402
|
`;
|
|
307
403
|
};
|
|
308
404
|
|
|
309
|
-
module.exports =
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
121
|
+
v-for="(jtem, jindex) in item.children"
|
|
122
122
|
:key="jindex"
|
|
123
123
|
:label="jtem.value"
|
|
124
124
|
:value="jtem.key"
|