ap-dev 1.2.12 → 1.2.14

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.
@@ -0,0 +1,1028 @@
1
+ <template>
2
+ <ap-container>
3
+ <ap-aside margin="1111" width="230px">
4
+ <ap-aside-tree ref="cptTree" :options.sync="treeOptions">
5
+ <el-form slot="form" ref="tDevCpt" :inline="true" label-width="80px"
6
+ :model="tDevCptForm" :rules="tDevCptRules" class="ap-form">
7
+ <div class="ap-form-row">
8
+ <el-form-item label="父节点" prop='fdParentId'>
9
+ <el-select v-model="tDevCptForm.fdParentId" filterable placeholder="请选择父节点">
10
+ <el-option label="无" value=""/>
11
+ <el-option
12
+ v-for="item in parentList"
13
+ :key="item.fdId"
14
+ :label="item.fdName"
15
+ :value="item.fdId"
16
+ />
17
+ </el-select>
18
+ </el-form-item>
19
+ </div>
20
+ <div class="ap-form-row">
21
+ <el-form-item label='节点类型' prop='fdType'>
22
+ <el-select v-model="tDevCptForm.fdType" filterable placeholder="请选择类型">
23
+ <el-option key="1" label="Tab" :value=1></el-option>
24
+ <el-option key="2" label="组件分组" :value=2></el-option>
25
+ <el-option key="3" label="组件" :value=3></el-option>
26
+ </el-select>
27
+ </el-form-item>
28
+ <el-form-item label='语言' prop='fdLanguage'>
29
+ <el-select v-model="tDevCptForm.fdLanguage" filterable placeholder="请选择语言">
30
+ <el-option key="vue" label="vue" value="vue"></el-option>
31
+ <el-option key="java" label="java" value="java"></el-option>
32
+ <el-option key="abap" label="abap" value="abap"></el-option>
33
+ </el-select>
34
+ </el-form-item>
35
+ </div>
36
+ <div class="ap-form-row">
37
+ <el-form-item label='名称' prop='fdName'>
38
+ <el-input v-model='tDevCptForm.fdName'></el-input>
39
+ </el-form-item>
40
+ <el-form-item label='备注' prop='fdRemark'>
41
+ <el-input v-model='tDevCptForm.fdRemark'></el-input>
42
+ </el-form-item>
43
+ </div>
44
+ <el-form-item label='编码' prop='fdCode' v-if="tDevCptForm.fdType == 3">
45
+ <el-input v-model='tDevCptForm.fdCode'></el-input>
46
+ </el-form-item>
47
+ <el-form-item label='基础模板' prop='fdBaseId' v-if="tDevCptForm.fdType == 3">
48
+ <el-select v-model="tDevCptForm.fdBaseId" filterable placeholder="请选择基础模板">
49
+ <el-option label="无" value=""/>
50
+ <el-option
51
+ v-for="item in cptBaseList"
52
+ :key="item.fdId"
53
+ :label="item.fdName"
54
+ :value="item.fdId"
55
+ />
56
+ </el-select>
57
+ </el-form-item>
58
+ <el-form-item label='图标' prop='fdIcon' v-if="tDevCptForm.fdType == 3">
59
+ <el-input v-model='tDevCptForm.fdIcon'></el-input>
60
+ </el-form-item>
61
+ <el-form-item label='排序' prop='fdSort'>
62
+ <el-input v-model='tDevCptForm.fdSort'></el-input>
63
+ </el-form-item>
64
+ </el-form>
65
+ <span slot="tree" slot-scope="scope"
66
+ :style="scope.data.fdType == 3 ? 'color: #1682e6;font-size: 14px;':''">
67
+ <i :class="scope.data.fdIcon"/>
68
+ {{ scope.data.fdName }}
69
+ </span>
70
+ </ap-aside-tree>
71
+ </ap-aside>
72
+ <ap-split-panel></ap-split-panel>
73
+ <ap-container>
74
+ <ap-header margin="1110" height="30%">
75
+ <ap-table ref="tDevCptTemplateTableRef" :options.sync="tDevCptTemplateTable">
76
+ <template #slotTemplate="searchProps">
77
+ <el-input v-model="searchProps.rowData.fdTemplate" type="textarea" :rows=10></el-input>
78
+ </template>
79
+ <template #slotDefault="searchProps">
80
+ <el-input v-model="searchProps.rowData.fdDefault" type="textarea" :rows=10></el-input>
81
+ </template>
82
+ </ap-table>
83
+ </ap-header>
84
+ <ap-container>
85
+ <ap-header margin="0110" height="50%">
86
+ <ap-table ref="tDevCptParamTableRef" :options.sync="tDevCptParamTable">
87
+ <template #slotOption="searchProps">
88
+ <el-input v-model="searchProps.rowData.fdOption" type="textarea" :rows=5></el-input>
89
+ <span
90
+ style="color: #909399;">注1: 数组格式 [{label:"名字1", value:"值1"},{label:"名字2", value:"值2"}]</span><br>
91
+ <span style="color: #909399;">注2: 对象格式 {attr1:"属性1", attr2:"属性2"}</span><br>
92
+ </template>
93
+ </ap-table>
94
+ </ap-header>
95
+ <ap-main margin="0110">
96
+ <ap-table ref="tDevCptParamTemplateTableRef" :options.sync="tDevCptParamTemplateTable">
97
+ <template #slotTemplate="searchProps">
98
+ <!-- <el-input v-model="searchProps.rowData.fdTemplate" type="textarea" :rows=10></el-input>-->
99
+ <cpt-template v-model="searchProps.rowData.fdTemplate" :cptId="selectedCptId"></cpt-template>
100
+ </template>
101
+ <template #slotDefault="searchProps">
102
+ <el-input v-model="searchProps.rowData.fdDefault" type="textarea" :rows=10></el-input>
103
+ </template>
104
+ </ap-table>
105
+ </ap-main>
106
+ </ap-container>
107
+ </ap-container>
108
+ <el-dialog
109
+ title="提示"
110
+ :visible.sync="showCopyDialog"
111
+ width="30%">
112
+ <span>复制参数、复制参数模板</span>
113
+ <span slot="footer" class="dialog-footer">
114
+ <el-button type="primary" @click="doCopyParam()">仅复制参数</el-button>
115
+ <el-button type="primary" @click="doCopyParam('1')">复制参数和参数模板</el-button>
116
+ </span>
117
+ </el-dialog>
118
+ <el-dialog
119
+ title="参数脚本"
120
+ :visible.sync="showJsCodeDialog"
121
+ width="1500px">
122
+ <div style="width: 100%;height: 450px" class="flex-justify-start">
123
+ <div style="width: 400px;height: 100%">
124
+ <ap-aside-tree ref="cptParamTreeRef" :options.sync="cptParamTreeOptions">
125
+ <div slot="tree" slot-scope="scope" class="flex-justify-between" style="width: 100%">
126
+ <div>
127
+ <span @click="copyText(scope.data.fdName, $event)">{{ scope.data.fdName }} </span>
128
+ <span class="ap-color-blue"
129
+ @click="copyParamValue(scope.data.fdCode, $event)">{{ scope.data.fdCode }}</span>
130
+ </div>
131
+ <div style="margin-right: 10px">
132
+ <div class="ap-tag" style="font-size: 12px;padding: 2px 5px;"
133
+ @click="insertScript(scope.data)">
134
+ <span v-if="scope.data.fdShowType == 2">开</span>
135
+ <span v-else>不为空</span>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </ap-aside-tree>
140
+ </div>
141
+ <div class="flex-1" style="height: 100%;margin-left: 15px">
142
+ <ap-table ref="tDevCptScriptRef" :options.sync="tDevCptScriptOpt"></ap-table>
143
+ </div>
144
+ </div>
145
+ <span slot="footer" class="dialog-footer">
146
+ <el-button @click="showJsCodeDialog = false">取 消</el-button>
147
+ </span>
148
+ </el-dialog>
149
+ <el-dialog
150
+ title="参数编码/参数名称 批量更新"
151
+ :visible.sync="showHandleCptCodeDialog"
152
+ width="700px">
153
+ <el-form :model="replaceForm" label-width="100px" :inline="true" class="ap-form">
154
+ <div class="ap-form-row">
155
+ <el-form-item label='旧参数名称' prop='oldName'>
156
+ <el-input v-model='replaceForm.oldName'></el-input>
157
+ </el-form-item>
158
+ <el-form-item label='新参数名称' prop='newName'>
159
+ <el-input v-model='replaceForm.newName'></el-input>
160
+ </el-form-item>
161
+ </div>
162
+ <div class="ap-form-row">
163
+ <el-form-item label='旧参数编码' prop='oldCode'>
164
+ <el-input v-model='replaceForm.oldCode'></el-input>
165
+ </el-form-item>
166
+ <el-form-item label='新参数编码' prop='newCode'>
167
+ <el-input v-model='replaceForm.newCode'></el-input>
168
+ </el-form-item>
169
+ </div>
170
+ </el-form>
171
+ <span slot="footer" class="dialog-footer">
172
+ <el-button @click="showHandleCptCodeDialog = false">取 消</el-button>
173
+ <el-button type="primary" @click="replaceCptNameAndCode">确认替换</el-button>
174
+ </span>
175
+ </el-dialog>
176
+ </ap-container>
177
+ </template>
178
+
179
+ <script>
180
+ import clipboard from 'ap-util/util/ClipboardUtil'
181
+ import CptTemplate from './CptTemplate'
182
+
183
+ export default {
184
+ name: 'DevCpt',
185
+ components: {
186
+ CptTemplate
187
+ },
188
+ data() {
189
+
190
+ return {
191
+ // ----- 左侧树 -----
192
+ treeOptions: this.getTreeOption(),
193
+ parentList: [],
194
+ cptBaseList: [],
195
+ tDevCptForm: {},
196
+ tDevCptRules: {},
197
+ selectedCptId: "",
198
+ selectedCpt: {},
199
+ // ----- 右侧 -----
200
+ tDevCptTemplateTable: this.getCptTemplateTableOption(),
201
+ tDevCptParamTable: this.getCptParamTableOption(),
202
+ tDevCptParamTemplateTable: this.getCptParamTemplateTableOption(),
203
+ selectedParam: "",
204
+ template: "",
205
+ optionType: "",
206
+ showCopyDialog: false,
207
+ showHandleCptCodeDialog: false,
208
+ showJsCodeDialog: false,
209
+ replaceForm: {
210
+ oldName: "",
211
+ newName: "",
212
+ oldCode: "",
213
+ newCode: "",
214
+ },
215
+ cptParamTreeOptions: this.getCptParamTreeOptions(),
216
+ isErrorScript: "0",
217
+ tDevCptScriptOpt: this.getDevCptScriptOpt(),
218
+ insertScriptId: ""
219
+ }
220
+ },
221
+ mounted() {
222
+ this.getCptList();
223
+ this.getCptBaseList();
224
+ },
225
+ methods: {
226
+ // 左侧树:配置
227
+ getTreeOption() {
228
+ let treeOptions = {
229
+ title: "组件",
230
+ dialogWidth: "700px",
231
+ toolbarBtn: [{
232
+ icon: "el-icon-copy", onClick: () => {
233
+ this.copyCpt();
234
+ }
235
+ }, {
236
+ icon: "el-icon-bug", onClick: () => {
237
+ this.clearCpt();
238
+ }
239
+ }, "add", "edit", "del", "sort"],
240
+ dialogTitle: "组件信息",
241
+ sortByDrag: true,
242
+ onClick: (data, node, comp) => {
243
+ this.selectedCptId = data.fdId;
244
+ this.selectedCpt = data;
245
+ this.selectedParam = "";
246
+ this.$refs.tDevCptParamTableRef.refresh();
247
+ this.$refs.tDevCptTemplateTableRef.refresh();
248
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
249
+ },
250
+ loadOptions: {
251
+ url: "/apd/TDevCpt/getCptList",
252
+ treeKey: {
253
+ idKey: "fdId",
254
+ parentKey: "fdParentId",
255
+ childrenKey: "children",
256
+ label: "fdName"
257
+ },
258
+ success: (response) => {
259
+ },
260
+ },
261
+ editOptions: {
262
+ url: "/apd/TDevCpt/getTDevCptByFdId",
263
+ data: (node) => {
264
+ return {
265
+ fdId: node.fdId
266
+ }
267
+ },
268
+ success: (response) => {
269
+ this.tDevCptForm = response.data;
270
+ },
271
+ error() {
272
+ },
273
+ },
274
+ insertUrl: "/apd/TDevCpt/insertTDevCpt",
275
+ insertData: () => {
276
+ return this.tDevCptForm
277
+ },
278
+ updateUrl: "/apd/TDevCpt/updateTDevCpt",
279
+ updateData: () => {
280
+ return this.tDevCptForm
281
+ },
282
+ deleteUrl: "/apd/TDevCpt/deleteTDevCptByFdId",
283
+ deleteData: (node) => {
284
+ return {
285
+ fdId: node.fdId
286
+ }
287
+ },
288
+ updateSortUrl: '/apd/TDevCpt/updateTDevCptSort',
289
+ updateSortListUrl: '/apd/TDevCpt/updateTDevCptSortList',
290
+ sortByDrag: true,
291
+ resetForm: () => {
292
+ this.tDevCptForm = {
293
+ fdName: '',
294
+ fdType: '',
295
+ fdCode: '',
296
+ fdParentId: '',
297
+ fdBaseId: '',
298
+ fdLanguage: '',
299
+ fdIcon: '',
300
+ fdRemark: '',
301
+ fdSort: '',
302
+ };
303
+ },
304
+ afterOpenAddDialog: (node) => {
305
+ },
306
+ };
307
+
308
+ return treeOptions;
309
+ },
310
+ getCptList() {
311
+ this.$request({
312
+ url: '/apd/TDevCpt/getCptList',
313
+ method: 'post',
314
+ data: {}
315
+ }).then(response => {
316
+ this.parentList = response.data
317
+ })
318
+ },
319
+ getCptBaseList() {
320
+ this.$request({
321
+ url: '/apd/TDevCptBase/getTDevCptBaseList',
322
+ method: 'post',
323
+ data: {}
324
+ }).then(response => {
325
+ this.cptBaseList = response.data
326
+ })
327
+ },
328
+ // 右侧:组件模板表格
329
+ getCptTemplateTableOption() {
330
+ let tDevCptTemplateCols = [
331
+ {
332
+ prop: 'fdCptId',
333
+ label: '所属组件',
334
+ type: "select",
335
+ selectOptionsRemote: "cptList",
336
+ selectOptionsKey: {label: "fdName", value: "fdId"},
337
+ width: '80',
338
+ addDefaultValue: () => {
339
+ return this.selectedCptId;
340
+ }
341
+ }, {
342
+ prop: 'fdParamName',
343
+ label: '参数名',
344
+ type: 'input',
345
+ width: '90',
346
+ }, {
347
+ prop: 'fdTemplate',
348
+ label: '组件模板',
349
+ minWidth: '130',
350
+ type: "search",
351
+ searchTitle: "模板编辑",
352
+ searchSlot: 'slotTemplate',
353
+ searchConfirm: (row) => {
354
+ return true
355
+ },
356
+ searchClear: (row) => {
357
+ row.fdTemplate = '';
358
+ return true;
359
+ },
360
+ html: (value, row) => {
361
+ return this.handleTemplateHtml(value);
362
+ },
363
+ help: `1、参数格式:\${xxxx}<br> xxx只能是字母,默认空格连接<br>
364
+ 2、数组参数格式:\${xxxx#abc}<br>使用#连接,abc为自定义连接符。使用\\n表示换行<br>`
365
+ }, {
366
+ prop: 'fdAddScriptId',
367
+ label: '模板添加脚本',
368
+ width: '150',
369
+ type: "select",
370
+ selectClearable: true,
371
+ selectOptionsRemote: "scriptList",
372
+ selectOptionsKey: {label: "fdName", value: "fdId"},
373
+ selectHtml: (value, text, row) => {
374
+ return `<span class="ap-color-blue" title='${row.addScript}'>${text}</span>`
375
+ },
376
+ }, {
377
+ prop: 'fdDefault',
378
+ label: '默认模板',
379
+ minWidth: '70',
380
+ type: "search",
381
+ searchTitle: "模板编辑",
382
+ searchSlot: 'slotDefault',
383
+ searchConfirm: (row) => {
384
+ return true
385
+ },
386
+ searchClear: (row) => {
387
+ row.fdDefault = '';
388
+ return true;
389
+ },
390
+ }, {
391
+ prop: 'fdDefaultScriptId',
392
+ label: '默认模板使用脚本',
393
+ width: '150',
394
+ type: "select",
395
+ selectClearable: true,
396
+ selectOptionsRemote: "scriptList",
397
+ selectOptionsKey: {label: "fdName", value: "fdId"},
398
+ selectHtml: (value, text, row) => {
399
+ return `<span class="ap-color-blue" title='${row.defaultScript}'>${text}</span>`
400
+ }
401
+ }, {
402
+ prop: 'fdLeftSpace',
403
+ label: '左侧空格',
404
+ type: 'input',
405
+ width: '60',
406
+ }, {
407
+ prop: 'fdSort',
408
+ label: '排序',
409
+ type: 'input',
410
+ width: '60',
411
+ },
412
+ ];
413
+ let tDevCptTemplateTable = {
414
+ title: "组件模板",
415
+ columns: tDevCptTemplateCols,
416
+ dataUrl: "/apd/TDevCptTemplate/getTDevCptTemplateGridList",
417
+ saveUrl: "/apd/TDevCptTemplate/saveTDevCptTemplateGridData",
418
+ editPk: "fdId", //默认fdId
419
+ deletePk: "fdId", // 默认fdId
420
+ deleteUrl: "/apd/TDevCptTemplate/deleteTDevCptTemplateGridData",
421
+ toolbarBtn: [{
422
+ btnType: "primary", text: "脚本", icon: "el-icon-collection-tag", onClick: () => {
423
+ if (this.selectedCptId == null || this.selectedCptId == "") {
424
+ this.$message.error("请选择组件");
425
+ return;
426
+ }
427
+ if (this.$refs.tDevCptParamTableRef.getAddRowList().length > 0 ||
428
+ this.$refs.tDevCptParamTableRef.getEditRowList().length > 0 ||
429
+ this.$refs.tDevCptTemplateTableRef.getAddRowList().length > 0 ||
430
+ this.$refs.tDevCptTemplateTableRef.getEditRowList().length > 0 ||
431
+ this.$refs.tDevCptParamTemplateTableRef.getAddRowList().length > 0 ||
432
+ this.$refs.tDevCptParamTemplateTableRef.getEditRowList().length > 0) {
433
+ this.$message.error("请先保存数据");
434
+ return;
435
+ }
436
+
437
+ this.showJsCodeDialog = true;
438
+ this.$nextTick(() => {
439
+ this.$refs.tDevCptScriptRef.refresh();
440
+ this.$refs.cptParamTreeRef.reLoadTreeData();
441
+ })
442
+ }
443
+ }, "separator", {
444
+ btnType: "primary", text: "编码替换", icon: "el-icon-transfer", onClick: () => {
445
+ this.showHandleCptCodeDialog = true;
446
+ }
447
+ }, "separator", "add", "edit", "del", "refresh", "save"],
448
+ showPagination: false,
449
+ params: () => {
450
+ return {
451
+ cptId: this.selectedCptId
452
+ }
453
+ },
454
+ rowDblClickEvent: (row, column, event) => {
455
+ this.$refs.tDevCptTemplateTableRef.toggleEditRow(row);
456
+ },
457
+ };
458
+ return tDevCptTemplateTable;
459
+ },
460
+ // 右侧:组件参数表格
461
+ getCptParamTableOption() {
462
+ let tDevCptParamCols = [
463
+ {
464
+ prop: 'fdCptId',
465
+ label: '所属组件',
466
+ type: "select",
467
+ selectOptionsRemote: "cptList",
468
+ selectOptionsKey: {label: "fdName", value: "fdId"},
469
+ width: '80',
470
+ addDefaultValue: () => {
471
+ return this.selectedCptId;
472
+ }
473
+ }, {
474
+ prop: 'fdParentId',
475
+ label: '父参数',
476
+ type: "select",
477
+ selectOptionsRemote: "cptParamList",
478
+ selectOptionsKey: {label: "fdName", value: "fdId"},
479
+ width: '80',
480
+ }, {
481
+ prop: 'fdName',
482
+ label: '参数名称',
483
+ type: 'input',
484
+ width: '110',
485
+ }, {
486
+ prop: 'fdCode',
487
+ label: '参数编码',
488
+ type: 'input',
489
+ minWidth: '120',
490
+ help: `参数编码。<br>.value: 表示参数值<br>示例:"\${InputType.value}"<br>click点击可复制参数取值(如:"\${InputType.value}")`
491
+ }, {
492
+ prop: 'fdValue',
493
+ label: '默认值',
494
+ type: 'input',
495
+ width: '80',
496
+ showOverflowTooltip: true,
497
+ help: `默认值格式:<br>1、非数组参数:字符串<br>2、数组参数: 可执行js,格式:[{参数编码A:"参数值1"},{参数编码B:"参数值2"}]<br>示例:[{InputA:"add"},{InputB:"自定义",InputC:"按钮"}]`
498
+ }, {
499
+ prop: 'fdShowScriptId',
500
+ label: '显示条件脚本',
501
+ width: '130',
502
+ type: "select",
503
+ selectClearable: true,
504
+ selectOptionsRemote: "scriptList",
505
+ selectOptionsKey: {label: "fdName", value: "fdId"},
506
+ selectHtml: (value, text, row) => {
507
+ return `<span class="ap-color-blue" title='${row.showScript}'>${text}</span>`
508
+ },
509
+ help: `判断页面是否显示组件。为空,默认显示。<br>示例:"\${InputType.value}" == "textarea"`
510
+ }, {
511
+ prop: 'fdShowType',
512
+ label: '显示类型',
513
+ type: 'select',
514
+ width: '80',
515
+ selectOptions: [{label: "input", value: 1}, {label: "开关", value: 2}, {label: "下拉单选", value: 3},
516
+ {label: "数组参数", value: 4}, {label: "单选框", value: 5}, {label: "text", value: 6},
517
+ {label: "计数文本", value: 7}, {label: "分割线", value: 8}, {label: "文本信息", value: 9}],
518
+ }, {
519
+ prop: 'fdOption',
520
+ label: '值选项',
521
+ width: '100',
522
+ showOverflowTooltip: true,
523
+ type: "search",
524
+ searchTitle: "选项值",
525
+ searchSlot: 'slotOption',
526
+ searchConfirm: (row) => {
527
+ return true
528
+ },
529
+ searchClear: (row) => {
530
+ row.fdOption = '';
531
+ return true;
532
+ },
533
+ }, {
534
+ prop: 'fdMethodScriptId',
535
+ label: '参数值变化脚本',
536
+ width: '120',
537
+ type: "select",
538
+ selectClearable: true,
539
+ selectOptionsRemote: "scriptList",
540
+ selectOptionsKey: {label: "fdName", value: "fdId"},
541
+ selectHtml: (value, text, row) => {
542
+ return `<span class="ap-color-blue" title='${row.methodScript}'>${text}</span>`
543
+ },
544
+ help: `参数值修改时,调用方法,用于直接设定其他参数值。<br>示例:"\${InputType.value}" = "123"`
545
+ }, {
546
+ prop: 'fdPlaceholder',
547
+ label: '占位文本',
548
+ type: 'input',
549
+ width: '120',
550
+ showOverflowTooltip: true
551
+ }, {
552
+ prop: 'fdTab',
553
+ label: 'tab页',
554
+ type: 'input',
555
+ width: '60',
556
+ }, {
557
+ prop: 'fdTip',
558
+ label: '提示',
559
+ type: 'input',
560
+ minWidth: '120',
561
+ showOverflowTooltip: true
562
+ }, {
563
+ prop: 'fdRemark',
564
+ label: '备注',
565
+ type: 'input',
566
+ width: '80',
567
+ showOverflowTooltip: true,
568
+ }, {
569
+ prop: 'fdSort',
570
+ label: '排序',
571
+ type: 'input',
572
+ width: '50',
573
+ },
574
+ ];
575
+ let tDevCptParamTable = {
576
+ title: "参数",
577
+ columns: tDevCptParamCols,
578
+ dataUrl: "/apd/TDevCptParam/getTDevCptParamGridList",
579
+ saveUrl: "/apd/TDevCptParam/saveTDevCptParamGridData",
580
+ editPk: "fdId", //默认fdId
581
+ deletePk: "fdId", // 默认fdId
582
+ deleteUrl: "/apd/TDevCptParam/deleteTDevCptParamGridData",
583
+ sortUrl: "/apd/TDevCptParam/updateTDevCptParamSortList",
584
+ toolbarBtn: [{
585
+ btnType: "primary", text: "复制", icon: "el-icon-copy", onClick: () => {
586
+ this.copyParam()
587
+ }
588
+ }, "separator",
589
+ "sortAuto", "sortDown", "sortUp", "separator",
590
+ "add", "edit", "del", "refresh", "save"],
591
+ showPagination: false,
592
+ params: () => {
593
+ return {
594
+ cptId: this.selectedCptId
595
+ }
596
+ },
597
+ rowClickEvent: (row, column, event) => {
598
+ this.selectedParam = row.fdId;
599
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
600
+ },
601
+ rowDblClickEvent: (row, column, event) => {
602
+ this.$refs.tDevCptParamTableRef.toggleEditRow(row);
603
+ },
604
+ };
605
+ return tDevCptParamTable;
606
+ },
607
+ // 右侧:参数模板表格
608
+ getCptParamTemplateTableOption() {
609
+ let tDevCptParamTemplateCols = [
610
+ {
611
+ prop: 'fdParamId',
612
+ label: '所属参数',
613
+ type: "select",
614
+ selectOptionsRemote: "paramList",
615
+ selectOptionsKey: {label: "fdName", value: "fdId"},
616
+ width: '110',
617
+ addDefaultValue: () => {
618
+ return this.selectedParam;
619
+ }
620
+ }, {
621
+ prop: 'fdParamName',
622
+ label: '参数名',
623
+ type: 'input',
624
+ width: '80',
625
+ }, {
626
+ prop: 'fdTemplate',
627
+ label: '参数模板',
628
+ minWidth: '130',
629
+ showOverflowTooltip: true,
630
+ type: "search",
631
+ searchTitle: "模板编辑",
632
+ searchSlot: 'slotTemplate',
633
+ searchWidth:"1100px",
634
+ searchConfirm: (row) => {
635
+ return true
636
+ },
637
+ searchClear: (row) => {
638
+ row.fdTemplate = '';
639
+ return true;
640
+ },
641
+ html: (value, row) => {
642
+ return this.handleTemplateHtml(value);
643
+ },
644
+ help: `格式:参数格式必须为\${xxxx.xxx} 不能有空格`
645
+ }, {
646
+ prop: 'fdAddScriptId',
647
+ label: '模板添加脚本',
648
+ width: '150',
649
+ help: `判断是否添加模板。为空,表示默认添加。`,
650
+ type: "select",
651
+ selectClearable: true,
652
+ selectOptionsRemote: "scriptList",
653
+ selectOptionsKey: {label: "fdName", value: "fdId"},
654
+ selectHtml: (value, text, row) => {
655
+ return `<span class="ap-color-blue" title='${row.addScript}'>${text}</span>`
656
+ }
657
+ }, {
658
+ prop: 'fdDefault',
659
+ label: '默认模板',
660
+ minWidth: '70',
661
+ showOverflowTooltip: true,
662
+ type: "search",
663
+ searchTitle: "模板编辑",
664
+ searchSlot: 'slotDefault',
665
+ searchConfirm: (row) => {
666
+ return true
667
+ },
668
+ searchClear: (row) => {
669
+ row.fdDefault = '';
670
+ return true;
671
+ },
672
+ }, {
673
+ prop: 'fdDefaultScriptId',
674
+ label: '默认模板使用脚本',
675
+ width: '140',
676
+ help: `判断是否使用默认模板。为空,不使用默认模板。<br>示例:"\${InputSize.value}" != ""`,
677
+ type: "select",
678
+ selectClearable: true,
679
+ selectOptionsRemote: "scriptList",
680
+ selectOptionsKey: {label: "fdName", value: "fdId"},
681
+ selectHtml: (value, text, row) => {
682
+ return `<span class="ap-color-blue" title='${row.defaultScript}'>${text}</span>`
683
+ }
684
+ }, {
685
+ prop: 'fdLeftSpace',
686
+ label: '左侧空格',
687
+ type: 'input',
688
+ width: '60',
689
+ }
690
+ ];
691
+ let tDevCptParamTemplateTable = {
692
+ title: "参数模板",
693
+ columns: tDevCptParamTemplateCols,
694
+ dataUrl: "/apd/TDevCptParamTemplate/getTDevCptParamTemplateGridList",
695
+ saveUrl: "/apd/TDevCptParamTemplate/saveTDevCptParamTemplateGridData",
696
+ editPk: "fdId", //默认fdId
697
+ deletePk: "fdId", // 默认fdId
698
+ deleteUrl: "/apd/TDevCptParamTemplate/deleteTDevCptParamTemplateGridData",
699
+ sortUrl: "/apd/TDevCptParamTemplate/updateTDevCptParamTemplateSortList",
700
+ toolbarBtn: [{
701
+ btnType: "primary", text: "复制", icon: "el-icon-copy", onClick: () => {
702
+ this.doCopyParamTemplate()
703
+ }
704
+ }, "separator", "add", "edit", "del", "refresh", "save"],
705
+ showPagination: false,
706
+ params: () => {
707
+ return {
708
+ cptId: this.selectedCptId,
709
+ paramId: this.selectedParam
710
+ }
711
+ },
712
+ rowDblClickEvent: (row, column, event) => {
713
+ this.$refs.tDevCptParamTemplateTableRef.toggleEditRow(row);
714
+ },
715
+ };
716
+ return tDevCptParamTemplateTable;
717
+ },
718
+ replaceCptNameAndCode() {
719
+ let form = this.replaceForm;
720
+ form.cptId = this.selectedCptId
721
+ this.$request({
722
+ url: '/apd/TDevCpt/replaceCptNameAndCode',
723
+ method: 'post',
724
+ data: form
725
+ }).then(response => {
726
+ this.$message.success("替换成功");
727
+ this.$refs.tDevCptParamTableRef.refresh();
728
+ this.$refs.tDevCptTemplateTableRef.refresh();
729
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
730
+ this.showHandleCptCodeDialog = false;
731
+ })
732
+ },
733
+ handleTemplateHtml(str) {
734
+ if (str == null) {
735
+ return "";
736
+ }
737
+ str = str.replaceAll("<", "&lt;")
738
+ let html = `<div class="api-code" style="line-height: 14px;width: 100%; max-height: 80px;overflow: auto;">${str}</div>`;
739
+ return html;
740
+ },
741
+ clearCpt() {
742
+ this.$confirm(`清空无效组件配置(已删除组件的模板、脚本、参数、demo)?`, '提示', {
743
+ confirmButtonText: '清空',
744
+ cancelButtonText: '取消',
745
+ type: 'warning'
746
+ }).then(() => {
747
+ this.$request({
748
+ url: '/apd/TDevCpt/clearCpt',
749
+ method: 'post',
750
+ data: {}
751
+ }).then(response => {
752
+ this.$message.success("清空成功");
753
+ this.$refs.cptTree.reLoadTreeData();
754
+ })
755
+ })
756
+ },
757
+ copyCpt() {
758
+ if (this.selectedCptId == "" || this.selectedCptId == null) {
759
+ this.$message.error("请选择需要复制的行");
760
+ return;
761
+ }
762
+ this.$confirm(`确认复制【${this.selectedCpt.fdName}】组件?`, '提示', {
763
+ confirmButtonText: '复制',
764
+ cancelButtonText: '取消',
765
+ type: 'warning'
766
+ }).then(() => {
767
+ this.$request({
768
+ url: '/apd/TDevCpt/copyCpt',
769
+ method: 'post',
770
+ data: {
771
+ cptId: this.selectedCptId,
772
+ }
773
+ }).then(response => {
774
+ this.$message.success("复制成功");
775
+ this.$refs.cptTree.reLoadTreeData();
776
+ })
777
+ })
778
+ },
779
+ copyParam(type) {
780
+ this.showCopyDialog = true;
781
+ },
782
+ // 复制参数
783
+ doCopyParam(type) {
784
+ let selectedRows = this.$refs.tDevCptParamTableRef.getSelection();
785
+ if (selectedRows.length < 1) {
786
+ this.$message.error("请选择需要复制的行!");
787
+ return;
788
+ }
789
+ if (selectedRows.length > 1) {
790
+ this.$message.error("只能选择单行数据进行复制!");
791
+ return;
792
+ }
793
+
794
+ this.$request({
795
+ url: '/apd/TDevCptParam/copyParam',
796
+ method: 'post',
797
+ data: {
798
+ paramId: selectedRows[0].fdId,
799
+ copyTemplate: type
800
+ }
801
+ }).then(response => {
802
+ this.$message.success("复制成功");
803
+ this.$refs.tDevCptParamTableRef.refresh();
804
+ if (type == "1") {
805
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
806
+ }
807
+ this.showCopyDialog = false;
808
+ })
809
+
810
+ },
811
+ // 复制参数模板
812
+ doCopyParamTemplate() {
813
+ let selectedRows = this.$refs.tDevCptParamTemplateTableRef.getSelection();
814
+ if (selectedRows.length < 1) {
815
+ this.$message.error("请选择需要复制的行!");
816
+ return;
817
+ }
818
+ if (selectedRows.length > 1) {
819
+ this.$message.error("只能选择单行数据进行复制!");
820
+ return;
821
+ }
822
+
823
+ this.$request({
824
+ url: '/apd/TDevCptParam/copyParamTemplate',
825
+ method: 'post',
826
+ data: {
827
+ templateId: selectedRows[0].fdId,
828
+ }
829
+ }).then(response => {
830
+ this.$message.success("复制成功");
831
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
832
+ })
833
+
834
+ },
835
+ // 组件参数
836
+ getCptParamTreeOptions() {
837
+ let treeOptions = {
838
+ title: "组件参数",
839
+ initData: false,
840
+ onClick: (data, node, comp) => {
841
+ },
842
+ loadOptions: {
843
+ url: "/apd/TDevCptParam/getTDevCptParamList",
844
+ data: () => {
845
+ return {
846
+ cptId: this.selectedCptId
847
+ }
848
+ },
849
+ treeKey: {
850
+ idKey: "fdId",
851
+ parentKey: "fdParentId",
852
+ childrenKey: "children",
853
+ label: "fdName"
854
+ },
855
+ success: (response) => {
856
+ },
857
+ },
858
+ };
859
+
860
+ return treeOptions;
861
+ },
862
+ // 组件脚本
863
+ getDevCptScriptOpt() {
864
+ let columns = [
865
+ {
866
+ prop: 'fdName',
867
+ label: '名称',
868
+ type: 'input',
869
+ width: 150,
870
+ help: '参数- <br>显示- <br>显示事件- <br>显示方法-'
871
+ }, {
872
+ prop: 'fdCode',
873
+ label: '变量名',
874
+ type: 'input',
875
+ width: 100,
876
+ help: '模板中执行判断的变量名。<br>如<#if testName>'
877
+ }, {
878
+ prop: 'fdScript',
879
+ label: '脚本',
880
+ type: 'input',
881
+ help: 'js前段脚本。<br>示例:"\${InputSize.value}" != ""'
882
+ }, {
883
+ prop: 'fdComment',
884
+ label: '备注',
885
+ type: 'input',
886
+ width: 100,
887
+ }
888
+ ];
889
+ let tableOpt = {
890
+ title: "组件脚本",
891
+ columns: columns,
892
+ editPk: "fdId", //默认fdId
893
+ deletePk: "fdId", // 默认fdId
894
+ dataUrl: "/apd/TDevCptScript/getTDevCptScriptGridList",
895
+ saveUrl: "/apd/TDevCptScript/saveTDevCptScriptGridData",
896
+ deleteUrl: "/apd/TDevCptScript/deleteTDevCptScriptGridData",
897
+ toolbarBtn: [{
898
+ btnType: "primary", text: "异常筛选", icon: "el-icon-copy", onClick: () => {
899
+ this.isErrorScript = "1";
900
+ this.$refs.tDevCptScriptRef.refresh();
901
+ }
902
+ }, {
903
+ btnType: "primary", text: "复制", icon: "el-icon-copy", onClick: () => {
904
+ this.copyScript()
905
+ }
906
+ }, "separator", "add", "edit", "del", "cancel", "refresh", "save"],
907
+ initData: false, // 默认false
908
+ showPagination: false,
909
+ afterLoadData: () => {
910
+ this.isErrorScript = "0";
911
+ },
912
+ addDefaultObj: () => {
913
+ return {
914
+ fdCptId: this.selectedCptId
915
+ }
916
+ },
917
+ params: () => {
918
+ return {
919
+ cptId: this.selectedCptId,
920
+ isErrorScript: this.isErrorScript
921
+ }
922
+ },
923
+ rowDblClickEvent: (row, column, event) => {
924
+ this.$refs.tDevCptScriptRef.toggleEditRow(row);
925
+ },
926
+ afterSave: this.refreshScriptTable,
927
+ afterAll: () => {
928
+ if (this.insertScriptId == null || this.insertScriptId == "") {
929
+ return;
930
+ }
931
+ this.$refs.tDevCptScriptRef.toggleRowSelectionByRowKey(this.insertScriptId, true);
932
+ this.insertScriptId = "";
933
+ }
934
+ };
935
+ return tableOpt;
936
+ },
937
+ // 刷新脚本相关表格
938
+ refreshScriptTable() {
939
+ console.log("刷新外部表格");
940
+ this.$refs.tDevCptParamTableRef.refresh();
941
+ this.$refs.tDevCptTemplateTableRef.refresh();
942
+ this.$refs.tDevCptParamTemplateTableRef.refresh();
943
+ },
944
+ copyText(text, event) {
945
+ clipboard(text, event);
946
+ },
947
+ copyParamValue(code, event) {
948
+ let str = '"${' + code + '.value}"';
949
+ clipboard(str, event);
950
+ },
951
+ insertScript(data) {
952
+ let name = "";
953
+ if (data.fdName.indexOf("事件") > -1) {
954
+ name = "显示事件-" + data.fdName.replace("事件", "");
955
+ } else if (data.fdCode.indexOf("Method") > -1) {
956
+ name = "显示方法-" + data.fdName;
957
+ } else {
958
+ name = "显示-" + data.fdName;
959
+ }
960
+
961
+ let script = "";
962
+ if (data.fdShowType == 2) {
963
+ // 开
964
+ script = '"${' + data.fdCode + '.value}" == "1"';
965
+ } else {
966
+ // 不为空
967
+ script = '"${' + data.fdCode + '.value}" != ""';
968
+ }
969
+ let msg = `确定添加脚本?
970
+ <br><span style="font-weight: bold">名称:</span><span class="ap-color-blue">${name}</span>
971
+ <br><span style="font-weight: bold">脚本:</span><span class="ap-color-blue">${script}</span>`
972
+ this.$confirm(msg, '提示', {
973
+ confirmButtonText: '确定添加',
974
+ cancelButtonText: '取消',
975
+ dangerouslyUseHTMLString: true,
976
+ type: 'warning'
977
+ }).then(() => {
978
+ this.$request({
979
+ url: '/apd/TDevCptScript/insertTDevCptScript',
980
+ method: 'post',
981
+ data: {
982
+ fdCptId: this.selectedCptId,
983
+ fdName: name,
984
+ fdScript: script,
985
+ }
986
+ }).then(response => {
987
+ this.insertScriptId = response.data;
988
+ this.$message.success("添加成功:" + name);
989
+ this.$refs.tDevCptScriptRef.refresh();
990
+ this.refreshScriptTable();
991
+ })
992
+ }).catch(() => {
993
+ this.$message({
994
+ type: 'info',
995
+ message: '已取消添加'
996
+ });
997
+ });
998
+ },
999
+ // 复制参数模板
1000
+ copyScript() {
1001
+ let selectedRows = this.$refs.tDevCptScriptRef.getSelection();
1002
+ if (selectedRows.length < 1) {
1003
+ this.$message.error("请选择需要复制的行!");
1004
+ return;
1005
+ }
1006
+ if (selectedRows.length > 1) {
1007
+ this.$message.error("只能选择单行数据进行复制!");
1008
+ return;
1009
+ }
1010
+
1011
+ this.$request({
1012
+ url: '/apd/TDevCptScript/copyScript',
1013
+ method: 'post',
1014
+ data: {
1015
+ scriptId: selectedRows[0].fdId,
1016
+ }
1017
+ }).then(response => {
1018
+ this.$message.success("复制成功");
1019
+ this.$refs.tDevCptScriptRef.refresh();
1020
+ })
1021
+
1022
+ },
1023
+ }
1024
+ }
1025
+ </script>
1026
+
1027
+ <style scoped>
1028
+ </style>