@dypnb/dev-tools 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,568 +0,0 @@
1
- import { strCase } from "../utils/index.js";
2
-
3
- // template.js
4
- export default {
5
- tablePageTemplate: (config = {}) => {
6
- const { name } = config;
7
- const titlCease = strCase(name);
8
- return `<template>
9
- <div class="app-container">
10
- <CoustomTable
11
- :queryFormJson="queryFormJson"
12
- :pageButtonsJson="pageButtonsJson"
13
- :tableJson="tableJson"
14
- :tableData="tableData"
15
- @onPageButton="handlerPageButton"
16
- @onButton="handlerButton"
17
- @onSearch="handlerSearch"
18
- @onTableRowClick="handlerTableRowClick"
19
- >
20
- </CoustomTable>
21
-
22
- <CoustomFormDialog
23
- ref="formDialog"
24
- :visible.sync="dialogVisible"
25
- :dialogJson="dialogJson"
26
- :initData="initFormData"
27
- @onSubmit="handlerSubmit"
28
- ></CoustomFormDialog>
29
- </div>
30
- </template>
31
- <script>
32
- import CoustomTable from "@/components/CoustomTable";
33
- import CoustomFormDialog from "@/components/CoustomFormDialog";
34
- import { TableJson, QueryFormJson, PageButtonsJson, DialogJson } from "./constants";
35
- import {
36
- getDevApiIotClassesList,
37
- postDevApiIotClasses,
38
- getDevApiIotClassesClassId,
39
- deleteDevApiIotClassesClassId,
40
- putDevApiIotClasses
41
- } from "@/api/iot/classes-controller.js";
42
- import {
43
- getDevApiIotPackagesList,
44
- } from "@/api/iot/packages-controller.js";
45
- export default {
46
- name: '${titlCease}',
47
- components: {
48
- CoustomTable,
49
- CoustomFormDialog
50
- },
51
- data() {
52
- return {
53
- queryFormJson: QueryFormJson,
54
- pageButtonsJson: PageButtonsJson,
55
- tableJson: TableJson,
56
- dialogJson: DialogJson,
57
- tableData: [],
58
- // 总条数
59
- total: 0,
60
- // 查询参数
61
- queryParams: {
62
- pageNum: 1,
63
- pageSize: 10,
64
- },
65
- dialogVisible: false,
66
- initFormData: {},
67
- }
68
- },
69
- created() {
70
- },
71
- mounted() {
72
- this.getList();
73
- },
74
- computed: {
75
- packageName() {
76
- const { query } = this.$route;
77
- return query.packageName
78
- }
79
- },
80
- methods: {
81
- async getPackageData() {
82
- try {
83
- const { rows = [] } = await getDevApiIotPackagesList();
84
- return rows.map(item => {
85
- return {
86
- value: item.packageCode,
87
- label: item.packageDispname,
88
- }
89
- })
90
- } catch (error) {
91
- return []
92
- }
93
- },
94
-
95
- async handlerSubmit(formData) {
96
- let params = {
97
- ...formData,
98
- packageName: this.packageName
99
- };
100
- let msgText = '新增';
101
- let func = postDevApiIotClasses;
102
- if (this.dialogJson.type === 'Edit') {
103
- params.classId = this.initFormData.classId;
104
- msgText = '编辑';
105
- func = putDevApiIotClasses;
106
- }
107
- try {
108
- const { code } = await func(params);
109
- if (code === 200) {
110
- this.dialogVisible = false;
111
- this.getList();
112
- this.$modal.msgSuccess(msgText + "成功");
113
- }
114
- this.$refs.formDialog.resetLoading();
115
- } catch (error) {
116
- // 接口调用失败重置 loading
117
- this.$refs.formDialog.resetLoading();
118
- }
119
- },
120
-
121
- /** 查询表集合 */
122
- getList(queryParams = {}) {
123
- this.loading = true;
124
- let queryData = {
125
- ...queryParams,
126
- ...this.queryParams,
127
- packageName: this.packageName
128
- }
129
- getDevApiIotClassesList(queryData).then(response => {
130
- this.tableData = response.rows;
131
- this.total = response.total;
132
- this.loading = false;
133
- });
134
- },
135
-
136
- handlerTableRowClick(item) {
137
- console.log('object :>>item ', item);
138
- this.$router.push({
139
- path: '/iot/packages/classes/detail',
140
- query: {
141
- classId: item.classId
142
- }
143
- })
144
- },
145
-
146
- // 搜索事件
147
- handlerSearch(searchParams) {
148
- this.queryParams = {
149
- pageNum: 1,
150
- pageSize: 10,
151
- },
152
- this.getList(searchParams);
153
- },
154
-
155
- //新增按钮事件
156
- async handlerPageButton(item) {
157
- const { type } = item;
158
- if (type === 'Add') {
159
- this.initFormData = {};
160
- this.dialogJson.type = 'Add';
161
- const packageData = await this.getPackageData()
162
- this.$set(this.dialogJson.formJson.formItemJson[0], 'option',packageData )
163
- console.log('object :>> ', this.dialogJson);
164
- this.dialogVisible = true;
165
- }
166
-
167
- if (type === 'Delete') {
168
- const tableIds = row.tableId || this.ids;
169
- this.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function () {
170
- return delTable(tableIds);
171
- }).then(() => {
172
- this.getList();
173
- this.$modal.msgSuccess("删除成功");
174
- }).catch(() => { });
175
- }
176
- },
177
-
178
- async getInfo(id) {
179
- const { code, data } = await getDevApiIotClassesClassId(id);
180
- if (code === 200) {
181
-
182
- this.initFormData = data;
183
- this.dialogJson.type = 'Edit';
184
- this.dialogVisible = true;
185
- }
186
- },
187
-
188
- deleteItem(id) {
189
- this.$modal.confirm('是否确认删除该数据项?').then(function () {
190
- return deleteDevApiIotClassesClassId(id);
191
- }).then(() => {
192
- this.getList();
193
- this.$modal.msgSuccess("删除成功");
194
- }).catch(() => { });
195
- },
196
-
197
- handlerButton(btnItem) {
198
- const { row, item } = btnItem;
199
- const { type } = item;
200
- if (type === 'Edit') {
201
- this.getInfo(row.classId);
202
- }
203
-
204
- if (type === 'Delete') {
205
- this.deleteItem(row.classId);
206
- }
207
- },
208
- },
209
- }
210
- </script>
211
- <style scoped lang='scss'></style>`
212
- },
213
-
214
- constantsTemplate: () => {
215
- return `export const QueryFormJson = {
216
- formOption: {
217
- inline: true,
218
- labelWidth: "100px",
219
- size: 'small',
220
- },
221
- formItemJson: [
222
- {
223
- label: "类中文名称",
224
- prop: "classDispname",
225
- type: "Input",
226
- isEnter: true,
227
- options: {
228
- clearable: true,
229
- placeholder: '请输入类名称',
230
- }
231
- }
232
- ],
233
- buttonJson: {
234
- type: 'Search',
235
- list: [
236
- {
237
- label: "搜索",
238
- type: 'Query',
239
- options: {
240
- icon: "el-icon-search",
241
- size: "mini",
242
- type: "primary"
243
- }
244
- },
245
- {
246
- label: "重置",
247
- type: 'Reset',
248
- options: {
249
- icon: "el-icon-refresh",
250
- size: "mini",
251
- }
252
- },
253
- ]
254
-
255
- }
256
- }
257
-
258
- export const PageButtonsJson = {
259
- rowJson: {
260
- gutter: 10,
261
- },
262
- buttonList: [
263
- {
264
- span: 1.5,
265
- label: '新增',
266
- permi: '',
267
- type: 'Add',
268
- options: [
269
- {
270
- icon: "el-icon-plus",
271
- plain: true,
272
- size: "mini",
273
- type: "primary",
274
- },
275
-
276
- ]
277
- }
278
- ]
279
- }
280
-
281
- export const TableJson = {
282
- columnJson: {
283
- showSelect: false,
284
- showIndex: true,
285
- data: [
286
- {
287
- type: "index",
288
- width: "55",
289
- align: "left",
290
- headerAlign: "left",
291
- label: "序号"
292
- },
293
- {
294
- align: "left",
295
- headerAlign: "left",
296
- label: "类中文名称",
297
- prop: "classDispname",
298
- showOverflowTooltip: true,
299
- isLink: true,
300
- },
301
- {
302
- align: "left",
303
- headerAlign: "left",
304
- label: "类英文名称",
305
- prop: "classCode",
306
- showOverflowTooltip: true,
307
- },
308
- {
309
- align: "left",
310
- headerAlign: "left",
311
- label: "类类型",
312
- prop: "classesType",
313
- showOverflowTooltip: true,
314
- },
315
- {
316
- align: "left",
317
- headerAlign: "left",
318
- label: "访问类型",
319
- prop: "accessType",
320
- showOverflowTooltip: true,
321
- },
322
- {
323
- align: "left",
324
- headerAlign: "left",
325
- label: "实例存储表名称",
326
- prop: "delFlag",
327
- showOverflowTooltip: true,
328
- },
329
- {
330
- align: "left",
331
- headerAlign: "left",
332
- label: "备注",
333
- prop: "remark",
334
- showOverflowTooltip: true,
335
- },
336
- {
337
- align: "left",
338
- headerAlign: "left",
339
- label: "创建时间",
340
- prop: "createTime",
341
- showOverflowTooltip: true,
342
- },
343
- {
344
- align: "center",
345
- headerAlign: "center",
346
- label: "操作",
347
- type: "func",
348
- buttonList: [
349
- {
350
- label: "编辑",
351
- type: 'Edit',
352
- permi: '',
353
- options: {
354
- icon: "el-icon-edit",
355
- size: "mini",
356
- type: "text",
357
- }
358
- },
359
- {
360
- label: "删除",
361
- type: 'Delete',
362
- permi: '',
363
- options: {
364
- icon: "el-icon-delete",
365
- size: "mini",
366
- type: "text",
367
- }
368
- },
369
- ],
370
- },
371
- ],
372
- },
373
- };
374
-
375
- export const DialogJson = {
376
- type: 'Add',
377
- title: "类",
378
- options: {
379
- width: "600px",
380
- appendToBody: true,
381
- destroyOnClose: true,
382
- closeOnClickModal: false,
383
- },
384
- buttonList: [
385
- {
386
- label: "确定",
387
- type: 'Ok',
388
- permi: '',
389
- options: {
390
- type: "primary",
391
- }
392
- },
393
- {
394
- label: "取消",
395
- type: 'Cancel',
396
- permi: '',
397
- options: {
398
- type: "",
399
- }
400
- },
401
- ],
402
- formJson: {
403
- // 表单设置
404
- formOption: {
405
- inline: false,
406
- labelWidth: "120px",
407
- size: 'small',
408
- },
409
- // 表单项
410
- formItemJson: [
411
- // {
412
- // label: "包编码",
413
- // prop: "packageCode",
414
- // type: "Select",
415
- // rules: [{ required: true, message: "请选择包编码", trigger: "change" }],
416
- // options: {
417
- // clearable: true,
418
- // placeholder: "请选择包编码",
419
- // },
420
- // option: [],
421
- // },
422
- {
423
- label: "类中文名称",
424
- prop: "classDispname",
425
- type: "Input",
426
- rules: [
427
- { required: true, message: '请输入类中文名称', trigger: 'blur' },
428
- ],
429
- options: {
430
- clearable: true,
431
- placeholder: '请输入类中文名称',
432
- }
433
- },
434
- {
435
- label: "类英文名称",
436
- prop: "className",
437
- type: "Input",
438
- rules: [
439
- { required: true, message: '请输入类英文名称', trigger: 'blur' },
440
- {
441
- required: true,
442
- validator: (rule, value, callback) => {
443
- const reg = /^[a-zA-Z]{1}\w*$/;
444
- if (!reg.test(value)) {
445
- callback(
446
- new Error(
447
- "请输入以字母(不区分大小写)、数字、下划线(_)随意组合的字符串"
448
- )
449
- );
450
- }
451
- callback();
452
- },
453
- trigger: ["blur"],
454
- },
455
- ],
456
- options: {
457
- clearable: true,
458
- placeholder: '请输入类英文名称',
459
- }
460
- },
461
- {
462
- label: "类类型",
463
- prop: "classesType",
464
- type: "Select",
465
- rules: [{ required: true, message: "请选择类类型", trigger: "change" }],
466
- options: {
467
- clearable: true,
468
- placeholder: "请选择类型",
469
- },
470
- option: [
471
- {
472
- value: '继承',
473
- label: '继承',
474
- },
475
- {
476
- value: '虚类',
477
- label: '虚类',
478
- },
479
- {
480
- value: '实体类',
481
- label: '实体类',
482
- },
483
- ],
484
- },
485
- {
486
- label: "继承父类code",
487
- prop: "classesExtends",
488
- type: "Input",
489
- rules: [
490
- { required: true, message: '请输入继承父类code', trigger: 'blur' },
491
- ],
492
- options: {
493
- clearable: true,
494
- placeholder: '请输入继承父类code',
495
- }
496
- },
497
- {
498
- label: "访问类型",
499
- prop: "accessType",
500
- type: "Select",
501
- rules: [{ required: true, message: "请选择访问类型", trigger: "change" }],
502
- options: {
503
- clearable: true,
504
- placeholder: "请选择访问类型",
505
- },
506
- option: [
507
- {
508
- value: 'default',
509
- label: 'default',
510
- },
511
- {
512
- value: 'public',
513
- label: 'public',
514
- },
515
- {
516
- value: 'protected',
517
- label: 'protected',
518
- },
519
- {
520
- value: 'private',
521
- label: 'private',
522
- },
523
- ],
524
- },
525
- {
526
- label: "实例存储表名称",
527
- prop: "objTableName",
528
- type: "Input",
529
- rules: [
530
- { required: true, message: '请输入实例存储表名称', trigger: 'blur' },
531
- ],
532
- options: {
533
- clearable: true,
534
- placeholder: '请输入实例存储表名称',
535
- }
536
- },
537
- {
538
- label: "视图样式",
539
- prop: "viewStyle",
540
- type: "Input",
541
- rules: [
542
- { required: false, message: '请输入视图样式', trigger: 'blur' },
543
- ],
544
- options: {
545
- clearable: true,
546
- placeholder: '请输入视图样式',
547
- }
548
- },
549
- {
550
- label: "备注",
551
- prop: "remark",
552
- type: "Input",
553
- rules: [],
554
- options: {
555
- clearable: true,
556
- placeholder: '请输入备注',
557
- type: 'textarea',
558
- row: 4
559
- }
560
- },
561
- ],
562
- }
563
-
564
- }`
565
- }
566
- }
567
-
568
-