@dypnb/dev-tools 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,717 +1 @@
1
- import require$$0$1 from 'path';
2
- import require$$0 from 'fs';
3
- import { k as strCase, j as getDirname, e as getGlobalConfig, i as errorLog, l as log, s as successLog } from '../chunk-cb5f11a8.js';
4
- import 'os';
5
- import 'util';
6
- import 'tty';
7
- import 'child_process';
8
- import 'assert';
9
- import 'events';
10
- import 'buffer';
11
- import 'stream';
12
- import 'node:url';
13
- import 'node:path';
14
-
15
- // template.js
16
- var templateData = {
17
- tablePageTemplate: (config = {}) => {
18
- const {
19
- name
20
- } = config;
21
- const titlCease = strCase(name);
22
- return `<template>
23
- <div class="app-container">
24
- <CoustomTable
25
- :queryFormJson="queryFormJson"
26
- :pageButtonsJson="pageButtonsJson"
27
- :tableJson="tableJson"
28
- :tableData="tableData"
29
- @onPageButton="handlerPageButton"
30
- @onButton="handlerButton"
31
- @onSearch="handlerSearch"
32
- @onTableRowClick="handlerTableRowClick"
33
- >
34
- </CoustomTable>
35
-
36
- <CoustomFormDialog
37
- ref="formDialog"
38
- :visible.sync="dialogVisible"
39
- :dialogJson="dialogJson"
40
- :initData="initFormData"
41
- @onSubmit="handlerSubmit"
42
- ></CoustomFormDialog>
43
- </div>
44
- </template>
45
- <script>
46
- import CoustomTable from "@/components/CoustomTable";
47
- import CoustomFormDialog from "@/components/CoustomFormDialog";
48
- import { TableJson, QueryFormJson, PageButtonsJson, DialogJson } from "./constants";
49
- import {
50
- getDevApiIotClassesList,
51
- postDevApiIotClasses,
52
- getDevApiIotClassesClassId,
53
- deleteDevApiIotClassesClassId,
54
- putDevApiIotClasses
55
- } from "@/api/iot/classes-controller.js";
56
- import {
57
- getDevApiIotPackagesList,
58
- } from "@/api/iot/packages-controller.js";
59
- export default {
60
- name: '${titlCease}',
61
- components: {
62
- CoustomTable,
63
- CoustomFormDialog
64
- },
65
- data() {
66
- return {
67
- queryFormJson: QueryFormJson,
68
- pageButtonsJson: PageButtonsJson,
69
- tableJson: TableJson,
70
- dialogJson: DialogJson,
71
- tableData: [],
72
- // 总条数
73
- total: 0,
74
- // 查询参数
75
- queryParams: {
76
- pageNum: 1,
77
- pageSize: 10,
78
- },
79
- dialogVisible: false,
80
- initFormData: {},
81
- }
82
- },
83
- created() {
84
- },
85
- mounted() {
86
- this.getList();
87
- },
88
- computed: {
89
- packageName() {
90
- const { query } = this.$route;
91
- return query.packageName
92
- }
93
- },
94
- methods: {
95
- async getPackageData() {
96
- try {
97
- const { rows = [] } = await getDevApiIotPackagesList();
98
- return rows.map(item => {
99
- return {
100
- value: item.packageCode,
101
- label: item.packageDispname,
102
- }
103
- })
104
- } catch (error) {
105
- return []
106
- }
107
- },
108
-
109
- async handlerSubmit(formData) {
110
- let params = {
111
- ...formData,
112
- packageName: this.packageName
113
- };
114
- let msgText = '新增';
115
- let func = postDevApiIotClasses;
116
- if (this.dialogJson.type === 'Edit') {
117
- params.classId = this.initFormData.classId;
118
- msgText = '编辑';
119
- func = putDevApiIotClasses;
120
- }
121
- try {
122
- const { code } = await func(params);
123
- if (code === 200) {
124
- this.dialogVisible = false;
125
- this.getList();
126
- this.$modal.msgSuccess(msgText + "成功");
127
- }
128
- this.$refs.formDialog.resetLoading();
129
- } catch (error) {
130
- // 接口调用失败重置 loading
131
- this.$refs.formDialog.resetLoading();
132
- }
133
- },
134
-
135
- /** 查询表集合 */
136
- getList(queryParams = {}) {
137
- this.loading = true;
138
- let queryData = {
139
- ...queryParams,
140
- ...this.queryParams,
141
- packageName: this.packageName
142
- }
143
- getDevApiIotClassesList(queryData).then(response => {
144
- this.tableData = response.rows;
145
- this.total = response.total;
146
- this.loading = false;
147
- });
148
- },
149
-
150
- handlerTableRowClick(item) {
151
- console.log('object :>>item ', item);
152
- this.$router.push({
153
- path: '/iot/packages/classes/detail',
154
- query: {
155
- classId: item.classId
156
- }
157
- })
158
- },
159
-
160
- // 搜索事件
161
- handlerSearch(searchParams) {
162
- this.queryParams = {
163
- pageNum: 1,
164
- pageSize: 10,
165
- },
166
- this.getList(searchParams);
167
- },
168
-
169
- //新增按钮事件
170
- async handlerPageButton(item) {
171
- const { type } = item;
172
- if (type === 'Add') {
173
- this.initFormData = {};
174
- this.dialogJson.type = 'Add';
175
- const packageData = await this.getPackageData()
176
- this.$set(this.dialogJson.formJson.formItemJson[0], 'option',packageData )
177
- console.log('object :>> ', this.dialogJson);
178
- this.dialogVisible = true;
179
- }
180
-
181
- if (type === 'Delete') {
182
- const tableIds = row.tableId || this.ids;
183
- this.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function () {
184
- return delTable(tableIds);
185
- }).then(() => {
186
- this.getList();
187
- this.$modal.msgSuccess("删除成功");
188
- }).catch(() => { });
189
- }
190
- },
191
-
192
- async getInfo(id) {
193
- const { code, data } = await getDevApiIotClassesClassId(id);
194
- if (code === 200) {
195
-
196
- this.initFormData = data;
197
- this.dialogJson.type = 'Edit';
198
- this.dialogVisible = true;
199
- }
200
- },
201
-
202
- deleteItem(id) {
203
- this.$modal.confirm('是否确认删除该数据项?').then(function () {
204
- return deleteDevApiIotClassesClassId(id);
205
- }).then(() => {
206
- this.getList();
207
- this.$modal.msgSuccess("删除成功");
208
- }).catch(() => { });
209
- },
210
-
211
- handlerButton(btnItem) {
212
- const { row, item } = btnItem;
213
- const { type } = item;
214
- if (type === 'Edit') {
215
- this.getInfo(row.classId);
216
- }
217
-
218
- if (type === 'Delete') {
219
- this.deleteItem(row.classId);
220
- }
221
- },
222
- },
223
- }
224
- </script>
225
- <style scoped lang='scss'></style>`;
226
- },
227
- constantsTemplate: () => {
228
- return `export const QueryFormJson = {
229
- formOption: {
230
- inline: true,
231
- labelWidth: "100px",
232
- size: 'small',
233
- },
234
- formItemJson: [
235
- {
236
- label: "类中文名称",
237
- prop: "classDispname",
238
- type: "Input",
239
- isEnter: true,
240
- options: {
241
- clearable: true,
242
- placeholder: '请输入类名称',
243
- }
244
- }
245
- ],
246
- buttonJson: {
247
- type: 'Search',
248
- list: [
249
- {
250
- label: "搜索",
251
- type: 'Query',
252
- options: {
253
- icon: "el-icon-search",
254
- size: "mini",
255
- type: "primary"
256
- }
257
- },
258
- {
259
- label: "重置",
260
- type: 'Reset',
261
- options: {
262
- icon: "el-icon-refresh",
263
- size: "mini",
264
- }
265
- },
266
- ]
267
-
268
- }
269
- }
270
-
271
- export const PageButtonsJson = {
272
- rowJson: {
273
- gutter: 10,
274
- },
275
- buttonList: [
276
- {
277
- span: 1.5,
278
- label: '新增',
279
- permi: '',
280
- type: 'Add',
281
- options: [
282
- {
283
- icon: "el-icon-plus",
284
- plain: true,
285
- size: "mini",
286
- type: "primary",
287
- },
288
-
289
- ]
290
- }
291
- ]
292
- }
293
-
294
- export const TableJson = {
295
- columnJson: {
296
- showSelect: false,
297
- showIndex: true,
298
- data: [
299
- {
300
- type: "index",
301
- width: "55",
302
- align: "left",
303
- headerAlign: "left",
304
- label: "序号"
305
- },
306
- {
307
- align: "left",
308
- headerAlign: "left",
309
- label: "类中文名称",
310
- prop: "classDispname",
311
- showOverflowTooltip: true,
312
- isLink: true,
313
- },
314
- {
315
- align: "left",
316
- headerAlign: "left",
317
- label: "类英文名称",
318
- prop: "classCode",
319
- showOverflowTooltip: true,
320
- },
321
- {
322
- align: "left",
323
- headerAlign: "left",
324
- label: "类类型",
325
- prop: "classesType",
326
- showOverflowTooltip: true,
327
- },
328
- {
329
- align: "left",
330
- headerAlign: "left",
331
- label: "访问类型",
332
- prop: "accessType",
333
- showOverflowTooltip: true,
334
- },
335
- {
336
- align: "left",
337
- headerAlign: "left",
338
- label: "实例存储表名称",
339
- prop: "delFlag",
340
- showOverflowTooltip: true,
341
- },
342
- {
343
- align: "left",
344
- headerAlign: "left",
345
- label: "备注",
346
- prop: "remark",
347
- showOverflowTooltip: true,
348
- },
349
- {
350
- align: "left",
351
- headerAlign: "left",
352
- label: "创建时间",
353
- prop: "createTime",
354
- showOverflowTooltip: true,
355
- },
356
- {
357
- align: "center",
358
- headerAlign: "center",
359
- label: "操作",
360
- type: "func",
361
- buttonList: [
362
- {
363
- label: "编辑",
364
- type: 'Edit',
365
- permi: '',
366
- options: {
367
- icon: "el-icon-edit",
368
- size: "mini",
369
- type: "text",
370
- }
371
- },
372
- {
373
- label: "删除",
374
- type: 'Delete',
375
- permi: '',
376
- options: {
377
- icon: "el-icon-delete",
378
- size: "mini",
379
- type: "text",
380
- }
381
- },
382
- ],
383
- },
384
- ],
385
- },
386
- };
387
-
388
- export const DialogJson = {
389
- type: 'Add',
390
- title: "类",
391
- options: {
392
- width: "600px",
393
- appendToBody: true,
394
- destroyOnClose: true,
395
- closeOnClickModal: false,
396
- },
397
- buttonList: [
398
- {
399
- label: "确定",
400
- type: 'Ok',
401
- permi: '',
402
- options: {
403
- type: "primary",
404
- }
405
- },
406
- {
407
- label: "取消",
408
- type: 'Cancel',
409
- permi: '',
410
- options: {
411
- type: "",
412
- }
413
- },
414
- ],
415
- formJson: {
416
- // 表单设置
417
- formOption: {
418
- inline: false,
419
- labelWidth: "120px",
420
- size: 'small',
421
- },
422
- // 表单项
423
- formItemJson: [
424
- // {
425
- // label: "包编码",
426
- // prop: "packageCode",
427
- // type: "Select",
428
- // rules: [{ required: true, message: "请选择包编码", trigger: "change" }],
429
- // options: {
430
- // clearable: true,
431
- // placeholder: "请选择包编码",
432
- // },
433
- // option: [],
434
- // },
435
- {
436
- label: "类中文名称",
437
- prop: "classDispname",
438
- type: "Input",
439
- rules: [
440
- { required: true, message: '请输入类中文名称', trigger: 'blur' },
441
- ],
442
- options: {
443
- clearable: true,
444
- placeholder: '请输入类中文名称',
445
- }
446
- },
447
- {
448
- label: "类英文名称",
449
- prop: "className",
450
- type: "Input",
451
- rules: [
452
- { required: true, message: '请输入类英文名称', trigger: 'blur' },
453
- {
454
- required: true,
455
- validator: (rule, value, callback) => {
456
- const reg = /^[a-zA-Z]{1}\w*$/;
457
- if (!reg.test(value)) {
458
- callback(
459
- new Error(
460
- "请输入以字母(不区分大小写)、数字、下划线(_)随意组合的字符串"
461
- )
462
- );
463
- }
464
- callback();
465
- },
466
- trigger: ["blur"],
467
- },
468
- ],
469
- options: {
470
- clearable: true,
471
- placeholder: '请输入类英文名称',
472
- }
473
- },
474
- {
475
- label: "类类型",
476
- prop: "classesType",
477
- type: "Select",
478
- rules: [{ required: true, message: "请选择类类型", trigger: "change" }],
479
- options: {
480
- clearable: true,
481
- placeholder: "请选择类型",
482
- },
483
- option: [
484
- {
485
- value: '继承',
486
- label: '继承',
487
- },
488
- {
489
- value: '虚类',
490
- label: '虚类',
491
- },
492
- {
493
- value: '实体类',
494
- label: '实体类',
495
- },
496
- ],
497
- },
498
- {
499
- label: "继承父类code",
500
- prop: "classesExtends",
501
- type: "Input",
502
- rules: [
503
- { required: true, message: '请输入继承父类code', trigger: 'blur' },
504
- ],
505
- options: {
506
- clearable: true,
507
- placeholder: '请输入继承父类code',
508
- }
509
- },
510
- {
511
- label: "访问类型",
512
- prop: "accessType",
513
- type: "Select",
514
- rules: [{ required: true, message: "请选择访问类型", trigger: "change" }],
515
- options: {
516
- clearable: true,
517
- placeholder: "请选择访问类型",
518
- },
519
- option: [
520
- {
521
- value: 'default',
522
- label: 'default',
523
- },
524
- {
525
- value: 'public',
526
- label: 'public',
527
- },
528
- {
529
- value: 'protected',
530
- label: 'protected',
531
- },
532
- {
533
- value: 'private',
534
- label: 'private',
535
- },
536
- ],
537
- },
538
- {
539
- label: "实例存储表名称",
540
- prop: "objTableName",
541
- type: "Input",
542
- rules: [
543
- { required: true, message: '请输入实例存储表名称', trigger: 'blur' },
544
- ],
545
- options: {
546
- clearable: true,
547
- placeholder: '请输入实例存储表名称',
548
- }
549
- },
550
- {
551
- label: "视图样式",
552
- prop: "viewStyle",
553
- type: "Input",
554
- rules: [
555
- { required: false, message: '请输入视图样式', trigger: 'blur' },
556
- ],
557
- options: {
558
- clearable: true,
559
- placeholder: '请输入视图样式',
560
- }
561
- },
562
- {
563
- label: "备注",
564
- prop: "remark",
565
- type: "Input",
566
- rules: [],
567
- options: {
568
- clearable: true,
569
- placeholder: '请输入备注',
570
- type: 'textarea',
571
- row: 4
572
- }
573
- },
574
- ],
575
- }
576
-
577
- }`;
578
- }
579
- };
580
-
581
- // 导入模板
582
- var defaultConfig = {
583
- // 是否命令行创建
584
- isEnter: true,
585
- // 文件名
586
- name: 'genPageTable',
587
- // 默认 view 目录下生成,如果需要指定父目录则写入 fatherFileName
588
- path: 'dome',
589
- // 子文件配置
590
- child: [{
591
- name: 'index.vue',
592
- template: (params = {}) => {
593
- return templateData.tablePageTemplate({
594
- // 文件标题,替换模板
595
- title: 'pageTable',
596
- ...params
597
- });
598
- },
599
- templateConfig: {}
600
- }, {
601
- name: 'constants.js',
602
- template: (params = {}) => {
603
- return templateData.constantsTemplate({
604
- // 文件标题,替换模板
605
- title: 'pageTable',
606
- ...params
607
- });
608
- },
609
- templateConfig: {
610
- // 文件标题,替换模板
611
- title: ''
612
- }
613
- }]
614
- };
615
-
616
- const __dirname = getDirname();
617
- const resolve = (...file) => require$$0$1.resolve(__dirname, ...file);
618
-
619
- // 模板配置
620
- const globalConfig = await getGlobalConfig('genPageConfig');
621
- if (globalConfig) {
622
- errorLog('全局模板未配置,使用默认配置');
623
- }
624
- const config = globalConfig || defaultConfig;
625
-
626
- // 生成文件
627
- const generateFile = (path, data) => {
628
- if (require$$0.existsSync(path)) {
629
- errorLog(`${path}文件已存在`);
630
- return;
631
- }
632
- require$$0.writeFileSync(path, data, 'utf8', err => {
633
- if (err) {
634
- errorLog(err.message);
635
- reject(err);
636
- } else {
637
- resolve(true);
638
- }
639
- });
640
- };
641
- function dotExistDirectoryCreate(directory) {
642
- return new Promise(resolve => {
643
- mkdirs(directory, function () {
644
- resolve(true);
645
- });
646
- });
647
- }
648
- // 递归创建目录
649
- function mkdirs(directory, callback) {
650
- var exists = require$$0.existsSync(directory);
651
- if (exists) {
652
- callback();
653
- } else {
654
- mkdirs(require$$0$1.dirname(directory), function () {
655
- require$$0.mkdirSync(directory);
656
- callback();
657
- });
658
- }
659
- }
660
- async function genPageProcess(enterName) {
661
- // 组件名称
662
- const pageName = !enterName ? config.name : enterName;
663
- // Vue页面组件路径
664
- const pathStr = !config.path ? `${process.env.PWD}/src/views` : `${process.env.PWD}/src/views/${config.path}`;
665
- const pagePath = resolve(pathStr, pageName);
666
-
667
- // 判断组件文件夹是否存在
668
- const hasComponentExists = require$$0.existsSync(pagePath);
669
- if (hasComponentExists) {
670
- errorLog(`${pageName}页面已存在`);
671
- if (pageName) {
672
- process.stdin.emit('end');
673
- }
674
- return;
675
- } else {
676
- log(`正在生成${pageName}目录 ${pagePath}`);
677
- await dotExistDirectoryCreate(pagePath);
678
- }
679
- try {
680
- // // 获取组件名
681
- // if (enterName.includes('/')) {
682
- // const inputArr = enterName.split('/')
683
- // pageName = inputArr[inputArr.length - 1]
684
- // } else {
685
- // pageName = enterName
686
- // }
687
-
688
- config.child.forEach(item => {
689
- const filePath = resolve(pagePath, item.name);
690
- log(`正在生成子文件${item.name} ${filePath}`);
691
- generateFile(filePath, item.template({
692
- name: pageName
693
- }));
694
- });
695
- successLog('生成成功');
696
- } catch (e) {
697
- errorLog(e.message);
698
- }
699
- }
700
- function genPage() {
701
- if (!config.isEnter) {
702
- genPageProcess();
703
- } else {
704
- log('请输入要生成的页面组件名称、会生成在 views/目录下');
705
- process.stdin.on('data', async chunk => {
706
- // 组件名称
707
- const enterName = String(chunk).trim().toString();
708
- genPageProcess(enterName);
709
- process.stdin.emit('end');
710
- });
711
- process.stdin.on('end', () => {
712
- log('exit');
713
- process.exit();
714
- });
715
- }
716
- }
717
- genPage();
1
+ import n from"path";import e from"fs";import{k as t,j as a,e as s,i as o,l,s as i}from"../chunk-f4ef292d.js";import"os";import"util";import"tty";import"child_process";import"assert";import"events";import"buffer";import"stream";import"node:url";import"node:path";var r=(n={})=>{const{name:e}=n;return`<template>\n <div class="app-container">\n <CoustomTable\n :queryFormJson="queryFormJson"\n :pageButtonsJson="pageButtonsJson"\n :tableJson="tableJson"\n :tableData="tableData"\n @onPageButton="handlerPageButton"\n @onButton="handlerButton"\n @onSearch="handlerSearch"\n @onTableRowClick="handlerTableRowClick"\n >\n </CoustomTable>\n\n <CoustomFormDialog\n ref="formDialog"\n :visible.sync="dialogVisible"\n :dialogJson="dialogJson"\n :initData="initFormData"\n @onSubmit="handlerSubmit"\n ></CoustomFormDialog>\n </div>\n</template>\n<script>\nimport CoustomTable from "@/components/CoustomTable";\nimport CoustomFormDialog from "@/components/CoustomFormDialog";\nimport { TableJson, QueryFormJson, PageButtonsJson, DialogJson } from "./constants";\nimport { \n getDevApiIotClassesList, \n postDevApiIotClasses, \n getDevApiIotClassesClassId, \n deleteDevApiIotClassesClassId,\n putDevApiIotClasses\n } from "@/api/iot/classes-controller.js";\n import {\n getDevApiIotPackagesList,\n} from "@/api/iot/packages-controller.js";\nexport default {\n name: '${t(e)}',\n components: {\n CoustomTable,\n CoustomFormDialog\n },\n data() {\n return {\n queryFormJson: QueryFormJson,\n pageButtonsJson: PageButtonsJson,\n tableJson: TableJson,\n dialogJson: DialogJson,\n tableData: [],\n // 总条数\n total: 0,\n // 查询参数\n queryParams: {\n pageNum: 1,\n pageSize: 10,\n },\n dialogVisible: false,\n initFormData: {},\n }\n },\n created() {\n },\n mounted() {\n this.getList();\n },\n computed: {\n packageName() {\n const { query } = this.$route;\n return query.packageName\n }\n },\n methods: {\n async getPackageData() {\n try {\n const { rows = [] } = await getDevApiIotPackagesList();\n return rows.map(item => {\n return {\n value: item.packageCode,\n label: item.packageDispname,\n }\n })\n } catch (error) {\n return []\n }\n },\n\n async handlerSubmit(formData) {\n let params = {\n ...formData,\n packageName: this.packageName\n };\n let msgText = '新增';\n let func = postDevApiIotClasses;\n if (this.dialogJson.type === 'Edit') {\n params.classId = this.initFormData.classId;\n msgText = '编辑';\n func = putDevApiIotClasses;\n }\n try {\n const { code } = await func(params);\n if (code === 200) {\n this.dialogVisible = false;\n this.getList();\n this.$modal.msgSuccess(msgText + "成功");\n }\n this.$refs.formDialog.resetLoading();\n } catch (error) {\n // 接口调用失败重置 loading\n this.$refs.formDialog.resetLoading();\n }\n },\n\n /** 查询表集合 */\n getList(queryParams = {}) {\n this.loading = true;\n let queryData = {\n ...queryParams,\n ...this.queryParams,\n packageName: this.packageName\n }\n getDevApiIotClassesList(queryData).then(response => {\n this.tableData = response.rows;\n this.total = response.total;\n this.loading = false;\n });\n },\n\n handlerTableRowClick(item) {\n console.log('object :>>item ', item);\n this.$router.push({\n path: '/iot/packages/classes/detail',\n query: {\n classId: item.classId\n }\n })\n },\n\n // 搜索事件\n handlerSearch(searchParams) {\n this.queryParams = {\n pageNum: 1,\n pageSize: 10,\n },\n this.getList(searchParams);\n },\n\n //新增按钮事件\n async handlerPageButton(item) {\n const { type } = item;\n if (type === 'Add') {\n this.initFormData = {};\n this.dialogJson.type = 'Add';\n const packageData = await this.getPackageData()\n this.$set(this.dialogJson.formJson.formItemJson[0], 'option',packageData )\n console.log('object :>> ', this.dialogJson);\n this.dialogVisible = true;\n }\n\n if (type === 'Delete') {\n const tableIds = row.tableId || this.ids;\n this.$modal.confirm('是否确认删除表编号为"' + tableIds + '"的数据项?').then(function () {\n return delTable(tableIds);\n }).then(() => {\n this.getList();\n this.$modal.msgSuccess("删除成功");\n }).catch(() => { });\n }\n },\n\n async getInfo(id) {\n const { code, data } = await getDevApiIotClassesClassId(id);\n if (code === 200) {\n\n this.initFormData = data;\n this.dialogJson.type = 'Edit';\n this.dialogVisible = true;\n }\n },\n\n deleteItem(id) {\n this.$modal.confirm('是否确认删除该数据项?').then(function () {\n return deleteDevApiIotClassesClassId(id);\n }).then(() => {\n this.getList();\n this.$modal.msgSuccess("删除成功");\n }).catch(() => { });\n },\n\n handlerButton(btnItem) {\n const { row, item } = btnItem;\n const { type } = item;\n if (type === 'Edit') {\n this.getInfo(row.classId);\n }\n\n if (type === 'Delete') {\n this.deleteItem(row.classId);\n }\n },\n },\n}\n<\/script>\n<style scoped lang='scss'></style>`},p=()=>'export const QueryFormJson = {\n formOption: {\n inline: true,\n labelWidth: "100px",\n size: \'small\',\n },\n formItemJson: [\n {\n label: "类中文名称",\n prop: "classDispname",\n type: "Input",\n isEnter: true,\n options: {\n clearable: true,\n placeholder: \'请输入类名称\',\n }\n }\n ],\n buttonJson: {\n type: \'Search\',\n list: [\n {\n label: "搜索",\n type: \'Query\',\n options: {\n icon: "el-icon-search",\n size: "mini",\n type: "primary"\n }\n },\n {\n label: "重置",\n type: \'Reset\',\n options: {\n icon: "el-icon-refresh",\n size: "mini",\n }\n },\n ]\n\n }\n}\n\nexport const PageButtonsJson = {\n rowJson: {\n gutter: 10,\n },\n buttonList: [\n {\n span: 1.5,\n label: \'新增\',\n permi: \'\',\n type: \'Add\',\n options: [\n {\n icon: "el-icon-plus",\n plain: true,\n size: "mini",\n type: "primary",\n },\n \n ]\n }\n ]\n}\n\nexport const TableJson = {\n columnJson: {\n showSelect: false,\n showIndex: true,\n data: [\n {\n type: "index",\n width: "55",\n align: "left",\n headerAlign: "left",\n label: "序号" \n },\n {\n align: "left",\n headerAlign: "left",\n label: "类中文名称",\n prop: "classDispname",\n showOverflowTooltip: true,\n isLink: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "类英文名称",\n prop: "classCode",\n showOverflowTooltip: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "类类型",\n prop: "classesType",\n showOverflowTooltip: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "访问类型",\n prop: "accessType",\n showOverflowTooltip: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "实例存储表名称",\n prop: "delFlag",\n showOverflowTooltip: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "备注",\n prop: "remark",\n showOverflowTooltip: true,\n },\n {\n align: "left",\n headerAlign: "left",\n label: "创建时间",\n prop: "createTime",\n showOverflowTooltip: true,\n },\n {\n align: "center",\n headerAlign: "center",\n label: "操作",\n type: "func",\n buttonList: [\n {\n label: "编辑",\n type: \'Edit\',\n permi: \'\',\n options: {\n icon: "el-icon-edit",\n size: "mini",\n type: "text",\n }\n },\n {\n label: "删除",\n type: \'Delete\',\n permi: \'\',\n options: {\n icon: "el-icon-delete",\n size: "mini",\n type: "text",\n }\n },\n ],\n },\n ],\n },\n};\n\nexport const DialogJson = {\n type: \'Add\',\n title: "类",\n options: {\n width: "600px",\n appendToBody: true,\n destroyOnClose: true,\n closeOnClickModal: false,\n },\n buttonList: [\n {\n label: "确定",\n type: \'Ok\',\n permi: \'\',\n options: {\n type: "primary",\n }\n },\n {\n label: "取消",\n type: \'Cancel\',\n permi: \'\',\n options: {\n type: "",\n }\n },\n ],\n formJson: {\n // 表单设置\n formOption: {\n inline: false,\n labelWidth: "120px",\n size: \'small\',\n },\n // 表单项\n formItemJson: [\n // {\n // label: "包编码",\n // prop: "packageCode",\n // type: "Select",\n // rules: [{ required: true, message: "请选择包编码", trigger: "change" }],\n // options: {\n // clearable: true,\n // placeholder: "请选择包编码",\n // },\n // option: [],\n // },\n {\n label: "类中文名称",\n prop: "classDispname",\n type: "Input",\n rules: [\n { required: true, message: \'请输入类中文名称\', trigger: \'blur\' },\n ],\n options: {\n clearable: true,\n placeholder: \'请输入类中文名称\',\n }\n },\n {\n label: "类英文名称",\n prop: "className",\n type: "Input",\n rules: [\n { required: true, message: \'请输入类英文名称\', trigger: \'blur\' },\n {\n required: true,\n validator: (rule, value, callback) => {\n const reg = /^[a-zA-Z]{1}w*$/;\n if (!reg.test(value)) {\n callback(\n new Error(\n "请输入以字母(不区分大小写)、数字、下划线(_)随意组合的字符串"\n )\n );\n }\n callback();\n },\n trigger: ["blur"],\n },\n ],\n options: {\n clearable: true,\n placeholder: \'请输入类英文名称\',\n }\n },\n {\n label: "类类型",\n prop: "classesType",\n type: "Select",\n rules: [{ required: true, message: "请选择类类型", trigger: "change" }],\n options: {\n clearable: true,\n placeholder: "请选择类型",\n },\n option: [\n {\n value: \'继承\',\n label: \'继承\',\n },\n {\n value: \'虚类\',\n label: \'虚类\',\n },\n {\n value: \'实体类\',\n label: \'实体类\',\n },\n ],\n },\n {\n label: "继承父类code",\n prop: "classesExtends",\n type: "Input",\n rules: [\n { required: true, message: \'请输入继承父类code\', trigger: \'blur\' },\n ],\n options: {\n clearable: true,\n placeholder: \'请输入继承父类code\',\n }\n },\n {\n label: "访问类型",\n prop: "accessType",\n type: "Select",\n rules: [{ required: true, message: "请选择访问类型", trigger: "change" }],\n options: {\n clearable: true,\n placeholder: "请选择访问类型",\n },\n option: [\n {\n value: \'default\',\n label: \'default\',\n },\n {\n value: \'public\',\n label: \'public\',\n },\n {\n value: \'protected\',\n label: \'protected\',\n },\n {\n value: \'private\',\n label: \'private\',\n },\n ],\n },\n {\n label: "实例存储表名称",\n prop: "objTableName",\n type: "Input",\n rules: [\n { required: true, message: \'请输入实例存储表名称\', trigger: \'blur\' },\n ],\n options: {\n clearable: true,\n placeholder: \'请输入实例存储表名称\',\n }\n },\n {\n label: "视图样式",\n prop: "viewStyle",\n type: "Input",\n rules: [\n { required: false, message: \'请输入视图样式\', trigger: \'blur\' },\n ],\n options: {\n clearable: true,\n placeholder: \'请输入视图样式\',\n }\n },\n {\n label: "备注",\n prop: "remark",\n type: "Input",\n rules: [],\n options: {\n clearable: true,\n placeholder: \'请输入备注\',\n type: \'textarea\',\n row: 4\n }\n },\n ],\n }\n\n}',c={isEnter:!0,name:"genPageTable",path:"dome",child:[{name:"index.vue",template:(n={})=>r({title:"pageTable",...n}),templateConfig:{}},{name:"constants.js",template:(n={})=>p({title:"pageTable",...n}),templateConfig:{title:""}}]};const m=a(),u=(...e)=>n.resolve(m,...e),d=await s("genPageConfig");d&&o("全局模板未配置,使用默认配置");const g=d||c,h=(n,t)=>{e.existsSync(n)?o(`${n}文件已存在`):e.writeFileSync(n,t,"utf8",(n=>{n?(o(n.message),reject(n)):u(!0)}))};function b(n){return new Promise((e=>{f(n,(function(){e(!0)}))}))}function f(t,a){e.existsSync(t)?a():f(n.dirname(t),(function(){e.mkdirSync(t),a()}))}async function y(n){const t=n||g.name,a=g.path?`${process.env.PWD}/src/views/${g.path}`:`${process.env.PWD}/src/views`,s=u(a,t);if(e.existsSync(s))return o(`${t}页面已存在`),void(t&&process.stdin.emit("end"));l(`正在生成${t}目录 ${s}`),await b(s);try{g.child.forEach((n=>{const e=u(s,n.name);l(`正在生成子文件${n.name} ${e}`),h(e,n.template({name:t}))})),i("生成成功")}catch(n){o(n.message)}}g.isEnter?(l("请输入要生成的页面组件名称、会生成在 views/目录下"),process.stdin.on("data",(async n=>{y(String(n).trim().toString()),process.stdin.emit("end")})),process.stdin.on("end",(()=>{l("exit"),process.exit()}))):y();