ap-dev 1.2.12 → 1.2.13
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/dev/ApiPanel/modules/ApiGrid.vue +1423 -1423
- package/dev/ComponentsPanel/index.vue +646 -61
- package/dev/ComponentsPanel/indexback0704.vue +775 -0
- package/dev/ComponentsPanel/old.vue +191 -0
- package/dev/ConfigPanel/DevCpt.vue +736 -0
- package/dev/ConfigPanel/DevCptBase.vue +210 -0
- package/dev/ConfigPanel/index.vue +41 -12
- package/dev/base/VueRender.vue +13 -6
- package/dev/dev/index.vue +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,775 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex flex-pack-center" style="height: 100%;height: 100%;margin-top: 5px;">
|
|
3
|
+
<!--左侧面板-->
|
|
4
|
+
<div class="dev-container dev-left-panel">
|
|
5
|
+
<el-tabs value="name0" :stretch="true">
|
|
6
|
+
<template v-for="(tab,cptIndex) in cptList">
|
|
7
|
+
<el-tab-pane v-if="tab.fdType == 1" :label="tab.fdName" :name="'name' + cptIndex">
|
|
8
|
+
<template v-for="menu in tab.children">
|
|
9
|
+
<el-collapse value="itemName">
|
|
10
|
+
<el-collapse-item v-if="menu.fdType == 2" :title="menu.fdName" name="itemName">
|
|
11
|
+
<template slot="title">
|
|
12
|
+
<span class="dev-collapse-title">{{ menu.fdName }}</span>
|
|
13
|
+
</template>
|
|
14
|
+
<template v-for="(item,index) in menu.children">
|
|
15
|
+
<div v-if="item.fdType == 3" class="dev-panel-item">
|
|
16
|
+
<div class="dev-comp-item" :data-type="item.fdId"
|
|
17
|
+
@click="clickItemEvent(item.fdId)">
|
|
18
|
+
<i :class="item.fdIcon"/> {{ item.fdName }}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
</el-collapse-item>
|
|
23
|
+
</el-collapse>
|
|
24
|
+
</template>
|
|
25
|
+
</el-tab-pane>
|
|
26
|
+
</template>
|
|
27
|
+
</el-tabs>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<!--中间面板-->
|
|
31
|
+
<div class="flex-1 flex flex-direction-column" style="overflow: auto;">
|
|
32
|
+
<ap-container>
|
|
33
|
+
<ap-header margin="0111" height="40%" style="overflow: auto;">
|
|
34
|
+
<template v-if="showItem">
|
|
35
|
+
<!-- <dynamic-item/>-->
|
|
36
|
+
<vue-render :options.sync="vueCode"></vue-render>
|
|
37
|
+
</template>
|
|
38
|
+
<template v-else>
|
|
39
|
+
组件加载中...
|
|
40
|
+
</template>
|
|
41
|
+
</ap-header>
|
|
42
|
+
<ap-main margin="0101" style="overflow: auto;background-color: #f9f2f4;">
|
|
43
|
+
<div style="position: relative;float: right;">
|
|
44
|
+
<el-button-group>
|
|
45
|
+
<el-button icon="el-icon-copy" @click="copyCode($event)">复制</el-button>
|
|
46
|
+
</el-button-group>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="dev-code">
|
|
49
|
+
{{ template }}
|
|
50
|
+
</div>
|
|
51
|
+
</ap-main>
|
|
52
|
+
</ap-container>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<!--右侧面板-->
|
|
56
|
+
<div class="dev-container dev-right-panel flex flex-direction-column">
|
|
57
|
+
<div class="flex-1" style="overflow: auto">
|
|
58
|
+
<el-tabs value="name0" :stretch="true">
|
|
59
|
+
<template v-for="(tab,paramIndex) in paramTabList">
|
|
60
|
+
<el-tab-pane :label="tab" :name="'name' + paramIndex" style="padding-left: 10px;">
|
|
61
|
+
<template v-for="param in paramList">
|
|
62
|
+
<el-form v-if="param.fdTab == tab" label-position="left" label-width="130px">
|
|
63
|
+
<template
|
|
64
|
+
v-if="checkShowCondition(param) && (param.fdParentId == null || param.fdParentId == '')">
|
|
65
|
+
<el-form-item v-if="param.fdShowType == 1" :label="param.fdName"
|
|
66
|
+
:prop="param.fdAttrName">
|
|
67
|
+
<el-input v-model="param.value" :placeholder="param.fdPlaceholder"
|
|
68
|
+
style="width: 280px;" @input="changeEvent(param)"/>
|
|
69
|
+
</el-form-item>
|
|
70
|
+
|
|
71
|
+
<el-form-item v-if="param.fdShowType == 2" :label="param.fdName"
|
|
72
|
+
:prop="param.fdAttrName">
|
|
73
|
+
<el-switch v-model="param.value" active-value="1" inactive-value="0"
|
|
74
|
+
@change="changeEvent(param)"/>
|
|
75
|
+
</el-form-item>
|
|
76
|
+
|
|
77
|
+
<el-form-item v-if="param.fdShowType == 3" :label="param.fdName"
|
|
78
|
+
:prop="param.fdAttrName">
|
|
79
|
+
<el-select v-model="param.value" @input="changeEvent(param)">
|
|
80
|
+
<template v-for="option in handelOption(param)">
|
|
81
|
+
<el-option :label="option.label" :value="option.value"/>
|
|
82
|
+
</template>
|
|
83
|
+
</el-select>
|
|
84
|
+
</el-form-item>
|
|
85
|
+
|
|
86
|
+
<el-form-item v-if="param.fdShowType == 4" :label="param.fdName"
|
|
87
|
+
:prop="param.fdAttrName">
|
|
88
|
+
<el-button size="mini" type="primary" plain @click="openDialog(param)"
|
|
89
|
+
style="padding: 4px 10px;"><i class="el-icon-s-tools"/> 配置
|
|
90
|
+
</el-button>
|
|
91
|
+
<template v-for="item in handelArrValue(param)">
|
|
92
|
+
<el-input :value="item" :readonly="true" style="width: 280px">
|
|
93
|
+
<el-button slot="append" icon="el-icon-edit-outline" @click="openEditDialog(param)"></el-button>
|
|
94
|
+
</el-input>
|
|
95
|
+
</template>
|
|
96
|
+
</el-form-item>
|
|
97
|
+
|
|
98
|
+
<el-form-item v-if="param.fdShowType == 5" :label="param.fdName"
|
|
99
|
+
:prop="param.fdAttrName">
|
|
100
|
+
<el-radio-group v-model="param.value" @change="changeEvent(param)">
|
|
101
|
+
<template v-for="option in handelOption(param)">
|
|
102
|
+
<el-radio :label="option.value">{{ option.label }}</el-radio>
|
|
103
|
+
</template>
|
|
104
|
+
</el-radio-group>
|
|
105
|
+
</el-form-item>
|
|
106
|
+
|
|
107
|
+
<el-form-item v-if="param.fdShowType == 6" :label="param.fdName"
|
|
108
|
+
:prop="param.fdAttrName">
|
|
109
|
+
<el-input type="textarea" v-model="param.value"
|
|
110
|
+
:placeholder="param.fdPlaceholder" :rows="2" style="width: 280px;"
|
|
111
|
+
@input="changeEvent(param)"/>
|
|
112
|
+
</el-form-item>
|
|
113
|
+
|
|
114
|
+
<el-form-item v-if="param.fdShowType == 7" :label="param.fdName"
|
|
115
|
+
:prop="param.fdAttrName">
|
|
116
|
+
<el-input-number v-model="param.value" @change="changeEvent(param)"
|
|
117
|
+
:min="handelOptionObj(param).min"
|
|
118
|
+
:max="handelOptionObj(param).max"
|
|
119
|
+
label="描述文字"></el-input-number>
|
|
120
|
+
</el-form-item>
|
|
121
|
+
|
|
122
|
+
<div v-if="param.fdShowLine == 1" class="ap-split-line"/>
|
|
123
|
+
</template>
|
|
124
|
+
</el-form>
|
|
125
|
+
</template>
|
|
126
|
+
</el-tab-pane>
|
|
127
|
+
</template>
|
|
128
|
+
</el-tabs>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<!-- 数组参数弹框 -->
|
|
133
|
+
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px">
|
|
134
|
+
<template v-for="param in paramList">
|
|
135
|
+
<el-form label-position="left" label-width="120px">
|
|
136
|
+
<template v-if="checkShowCondition(param) && (param.fdParentId == currentArrayParam.fdId)">
|
|
137
|
+
<el-form-item v-if="param.fdShowType == 1" :label="param.fdName" :prop="param.fdAttrName">
|
|
138
|
+
<el-input v-model="param.value" :placeholder="param.fdPlaceholder" style="width: 440px;"
|
|
139
|
+
@input="changeEvent(param)"/>
|
|
140
|
+
</el-form-item>
|
|
141
|
+
|
|
142
|
+
<el-form-item v-if="param.fdShowType == 2" :label="param.fdName" :prop="param.fdAttrName">
|
|
143
|
+
<el-switch v-model="param.value" active-value="1" inactive-value="0"
|
|
144
|
+
@change="changeEvent(param)"/>
|
|
145
|
+
</el-form-item>
|
|
146
|
+
|
|
147
|
+
<el-form-item v-if="param.fdShowType == 3" :label="param.fdName" :prop="param.fdAttrName">
|
|
148
|
+
<el-select v-model="param.value" @input="changeEvent(param)">
|
|
149
|
+
<template v-for="option in handelOption(param)">
|
|
150
|
+
<el-option :label="option.label" :value="option.value"/>
|
|
151
|
+
</template>
|
|
152
|
+
</el-select>
|
|
153
|
+
</el-form-item>
|
|
154
|
+
|
|
155
|
+
<el-form-item v-if="param.fdShowType == 4" :label="param.fdName" :prop="param.fdAttrName">
|
|
156
|
+
<el-button size="mini" type="primary" plain @click="openDialog(param)"><i
|
|
157
|
+
class="el-icon-plus"/></el-button>
|
|
158
|
+
<template v-for="item in param.arrValue">
|
|
159
|
+
<el-input :value="item">
|
|
160
|
+
<el-button slot="append" icon="el-icon-search" @click="openEditDialog(param)"></el-button>
|
|
161
|
+
</el-input>
|
|
162
|
+
</template>
|
|
163
|
+
</el-form-item>
|
|
164
|
+
|
|
165
|
+
<el-form-item v-if="param.fdShowType == 5" :label="param.fdName" :prop="param.fdAttrName">
|
|
166
|
+
<el-radio-group v-model="param.value" @change="changeEvent(param)">
|
|
167
|
+
<template v-for="option in handelOption(param)">
|
|
168
|
+
<el-radio :label="option.value">{{ option.label }}</el-radio>
|
|
169
|
+
</template>
|
|
170
|
+
</el-radio-group>
|
|
171
|
+
</el-form-item>
|
|
172
|
+
|
|
173
|
+
<el-form-item v-if="param.fdShowType == 6" :label="param.fdName" :prop="param.fdAttrName">
|
|
174
|
+
<el-input type="textarea" v-model="param.value" :placeholder="param.fdPlaceholder" :rows="4"
|
|
175
|
+
style="width: 440px;" @input="changeEvent(param)"/>
|
|
176
|
+
</el-form-item>
|
|
177
|
+
|
|
178
|
+
<el-form-item v-if="param.fdShowType == 7" :label="param.fdName" :prop="param.fdAttrName">
|
|
179
|
+
<el-input-number v-model="param.value" @change="changeEvent(param)"
|
|
180
|
+
:min="handelOptionObj(param).min" :max="handelOptionObj(param).max"
|
|
181
|
+
label="描述文字"></el-input-number>
|
|
182
|
+
</el-form-item>
|
|
183
|
+
|
|
184
|
+
<div v-if="param.fdShowLine == 1" class="ap-split-line"/>
|
|
185
|
+
</template>
|
|
186
|
+
</el-form>
|
|
187
|
+
</template>
|
|
188
|
+
<span slot="footer">
|
|
189
|
+
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
190
|
+
<el-button type="danger" @click="delArrayParam">删 除</el-button>
|
|
191
|
+
<el-button type="primary" @click="saveArrayParam">确 定</el-button>
|
|
192
|
+
</span>
|
|
193
|
+
</el-dialog>
|
|
194
|
+
</div>
|
|
195
|
+
</template>
|
|
196
|
+
|
|
197
|
+
<script>
|
|
198
|
+
import VueRender from './../base/VueRender'
|
|
199
|
+
import clipboard from 'ap-util/util/ClipboardUtil'
|
|
200
|
+
import {convertToTreeData} from 'ap-util/util/DataUtil'
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
export default {
|
|
204
|
+
name: 'ComponentsPanel',
|
|
205
|
+
components: {
|
|
206
|
+
VueRender: VueRender
|
|
207
|
+
},
|
|
208
|
+
data() {
|
|
209
|
+
return {
|
|
210
|
+
showItem: true,
|
|
211
|
+
vueCode: '',
|
|
212
|
+
cptList: [], // 组件清单列表
|
|
213
|
+
cptInfo: {}, // 组件信息
|
|
214
|
+
baseInfo: {}, // 组件基础模板信息
|
|
215
|
+
cptTemplateList: [], // 组件模板列表
|
|
216
|
+
cptTemplateObj: {}, // 组件模板对象
|
|
217
|
+
paramTabList: [], // 参数页签列表
|
|
218
|
+
paramList: [], // 参数列表
|
|
219
|
+
paramObj: [], // 参数对象
|
|
220
|
+
paramTemplateList: [], // 参数模板列表
|
|
221
|
+
paramTemplateObj: {}, // 参数模板对象
|
|
222
|
+
template: '', // 代码
|
|
223
|
+
|
|
224
|
+
dialogTitle: '',
|
|
225
|
+
dialogVisible: false,
|
|
226
|
+
currentArrayParam: {}, // 当前数组参数
|
|
227
|
+
currentArrayParamObj: {}, // 当前数组参数:保留参数信息用于编辑
|
|
228
|
+
arrayParamList: [], // 数组参数列表
|
|
229
|
+
arrayParamTemplateList: [], // 数组参数模板列表
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
computed: {},
|
|
233
|
+
created() {
|
|
234
|
+
this.getDevCpt();
|
|
235
|
+
},
|
|
236
|
+
methods: {
|
|
237
|
+
getDevCpt() {
|
|
238
|
+
this.$request({
|
|
239
|
+
url: '/apd/cpt/TDevCpt/getCptList',
|
|
240
|
+
method: 'post',
|
|
241
|
+
data: {}
|
|
242
|
+
}).then(response => {
|
|
243
|
+
this.cptList = convertToTreeData(response.data, {
|
|
244
|
+
idKey: 'fdId',
|
|
245
|
+
parentKey: 'fdParentId',
|
|
246
|
+
childrenKey: 'children'
|
|
247
|
+
});
|
|
248
|
+
})
|
|
249
|
+
},
|
|
250
|
+
clickItemEvent(id) {
|
|
251
|
+
this.$request({
|
|
252
|
+
url: '/apd/cpt/TDevCpt/getDevCptInfo',
|
|
253
|
+
method: 'post',
|
|
254
|
+
data: {
|
|
255
|
+
id: id
|
|
256
|
+
}
|
|
257
|
+
}).then(response => {
|
|
258
|
+
let data = response.data;
|
|
259
|
+
this.getParamTabList(data.paramList);
|
|
260
|
+
this.cptInfo = data.cptInfo;
|
|
261
|
+
this.baseInfo = data.baseInfo;
|
|
262
|
+
this.paramList = this.initParam(data.paramList);
|
|
263
|
+
this.paramTemplateList = data.paramTemplateList;
|
|
264
|
+
this.cptTemplateList = data.cptTemplateList;
|
|
265
|
+
this.renderTemplate();
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
getParamTabList(list) {
|
|
269
|
+
let tabNameList = [];
|
|
270
|
+
for (let i = 0; i < list.length; i++) {
|
|
271
|
+
tabNameList.push(list[i].fdTab);
|
|
272
|
+
}
|
|
273
|
+
this.paramTabList = Array.from(new Set(tabNameList));
|
|
274
|
+
},
|
|
275
|
+
// 参数选项值转为数组
|
|
276
|
+
handelOption(param) {
|
|
277
|
+
let options = param.fdOption;
|
|
278
|
+
if (options == null || options == "") {
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
let res = [];
|
|
282
|
+
let opts = options.split("##");
|
|
283
|
+
for (let i = 0; i < opts.length; i++) {
|
|
284
|
+
let opt = opts[i].split("::");
|
|
285
|
+
let valueStr = opt.length > 1 ? opt[1] : opt[0];
|
|
286
|
+
res.push({
|
|
287
|
+
label: opt[0],
|
|
288
|
+
value: valueStr
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
return res;
|
|
292
|
+
},
|
|
293
|
+
// 参数选项值转为对象
|
|
294
|
+
handelOptionObj(param) {
|
|
295
|
+
let opts = this.handelOption(param);
|
|
296
|
+
let res = {};
|
|
297
|
+
for (let i = 0; i < opts.length; i++) {
|
|
298
|
+
res[opts.label] = opts.value;
|
|
299
|
+
}
|
|
300
|
+
return res;
|
|
301
|
+
},
|
|
302
|
+
// 初始化参数信息:value
|
|
303
|
+
initParam(paramList) {
|
|
304
|
+
// 处理参数的fdValue
|
|
305
|
+
for (let i = 0; i < paramList.length; i++) {
|
|
306
|
+
this.handelValue(paramList[i]);
|
|
307
|
+
}
|
|
308
|
+
return paramList;
|
|
309
|
+
},
|
|
310
|
+
// 初始设定参数的value:fdValue转为value
|
|
311
|
+
handelValue(param) {
|
|
312
|
+
let fdValue = param.fdValue;
|
|
313
|
+
// 字符串形式
|
|
314
|
+
if (param.fdShowType != 4) {
|
|
315
|
+
param.value = fdValue;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 数组形式
|
|
320
|
+
if (fdValue == null || fdValue == "") {
|
|
321
|
+
param.arrValue = [];
|
|
322
|
+
param.value = "";
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
let res = [];
|
|
326
|
+
let opts = fdValue.split("##");
|
|
327
|
+
for (let i = 0; i < opts.length; i++) {
|
|
328
|
+
let opt = opts[i].split("::");
|
|
329
|
+
if (opt.length <= 1) {
|
|
330
|
+
// 字符串参数
|
|
331
|
+
res.push(opt[0]);
|
|
332
|
+
} else {
|
|
333
|
+
// 对象参数
|
|
334
|
+
let obj = {};
|
|
335
|
+
obj[opt[0]] = opt[1];
|
|
336
|
+
res.push(obj);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
param.arrValue = res;
|
|
340
|
+
param.value = `[ ${res.join(", ")} ]`;
|
|
341
|
+
},
|
|
342
|
+
handelArrValue(param) {
|
|
343
|
+
// 替换参数
|
|
344
|
+
let value = this.replaceTemplateParam(param.fdValue);
|
|
345
|
+
let res = [];
|
|
346
|
+
let values = value.split("##");
|
|
347
|
+
for (let i = 0; i < values.length; i++) {
|
|
348
|
+
|
|
349
|
+
let item = {};
|
|
350
|
+
let objs = values[i].split(",,");
|
|
351
|
+
for (let j = 0; j < objs.length; j++) {
|
|
352
|
+
if (objs[j].indexOf("::") > 0) {
|
|
353
|
+
res.push(objs[j]);
|
|
354
|
+
} else {
|
|
355
|
+
let obj = objs[j].split("::");
|
|
356
|
+
item[obj[0]] = item[obj[1]];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
res.push(item);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return res;
|
|
363
|
+
},
|
|
364
|
+
// 判定是否显示参数
|
|
365
|
+
checkShowCondition(param) {
|
|
366
|
+
let showCondition = param.fdShowCondition;
|
|
367
|
+
if (showCondition == null || showCondition == "") {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
let condition = this.replaceTemplateParam(showCondition);
|
|
371
|
+
return eval(condition);
|
|
372
|
+
},
|
|
373
|
+
// 判定是否添加参数到代码
|
|
374
|
+
checkAddCondition(addCondition) {
|
|
375
|
+
if (addCondition == null || addCondition == "") {
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
let condition = this.replaceTemplateParam(addCondition);
|
|
379
|
+
return eval(condition);
|
|
380
|
+
},
|
|
381
|
+
// 判定是否使用默认参数
|
|
382
|
+
checkDefaultCondition(defaultCondition) {
|
|
383
|
+
if (defaultCondition == null || defaultCondition == "") {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
let condition = this.replaceTemplateParam(defaultCondition);
|
|
387
|
+
return eval(condition);
|
|
388
|
+
},
|
|
389
|
+
// 模板赋值 -> type:1参数模板 2组件模板
|
|
390
|
+
handleTemplate(template, type) {
|
|
391
|
+
let res = "";
|
|
392
|
+
|
|
393
|
+
// 判断是否添加模板
|
|
394
|
+
if (!this.checkAddCondition(template.fdAddCondition)) {
|
|
395
|
+
return "";
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// 判断是否使用默认模板
|
|
399
|
+
if (this.checkDefaultCondition(template.fdDefaultCondition)) {
|
|
400
|
+
res = template.fdDefault;
|
|
401
|
+
} else {
|
|
402
|
+
res = template.fdTemplate;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// 参数模板
|
|
406
|
+
if (type == 1) {
|
|
407
|
+
return this.replaceTemplateParam(res);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// 组件模板
|
|
411
|
+
if (type == 2) {
|
|
412
|
+
return this.replaceTemplateCpt(res);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
},
|
|
416
|
+
changeEvent(param) {
|
|
417
|
+
this.renderTemplate();
|
|
418
|
+
},
|
|
419
|
+
// 渲染代码
|
|
420
|
+
renderTemplate() {
|
|
421
|
+
// 设定参数对象
|
|
422
|
+
this.initParamObj();
|
|
423
|
+
|
|
424
|
+
// 设定参数模板
|
|
425
|
+
this.initParamTemplate()
|
|
426
|
+
|
|
427
|
+
// 设定组件模板
|
|
428
|
+
this.initCptTemplate();
|
|
429
|
+
|
|
430
|
+
// 设定组件基础模板
|
|
431
|
+
this.initBaseTemplate();
|
|
432
|
+
|
|
433
|
+
},
|
|
434
|
+
// 设定参数对象
|
|
435
|
+
initParamObj() {
|
|
436
|
+
let paramList = this.paramList;
|
|
437
|
+
|
|
438
|
+
// 设定参数对象
|
|
439
|
+
let param = {};
|
|
440
|
+
for (let i = 0; i < paramList.length; i++) {
|
|
441
|
+
param[paramList[i].fdCode] = {
|
|
442
|
+
value: paramList[i].value,
|
|
443
|
+
defaultCondition: paramList[i].fdDefaultCondition,
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
this.paramObj = param;
|
|
447
|
+
console.log("paramObj: 参数对象");
|
|
448
|
+
console.log(param);
|
|
449
|
+
},
|
|
450
|
+
// 替换模板中的参数
|
|
451
|
+
replaceTemplateParam(template) {
|
|
452
|
+
if (template == null) {
|
|
453
|
+
return "";
|
|
454
|
+
}
|
|
455
|
+
// 正则参数:例:${InputChangeEvent.value}
|
|
456
|
+
let reg = new RegExp(/\${\w*\.\w*}/g);
|
|
457
|
+
let paramArr = template.match(reg);
|
|
458
|
+
if (paramArr == null) {
|
|
459
|
+
return template;
|
|
460
|
+
}
|
|
461
|
+
for (let j = 0; j < paramArr.length; j++) {
|
|
462
|
+
let pTemp = paramArr[j].substring(2, paramArr[j].length - 1).split(".");
|
|
463
|
+
// 参数实际值
|
|
464
|
+
let paramValue = this.paramObj[pTemp[0]];
|
|
465
|
+
let replaceStr = "";
|
|
466
|
+
if (paramValue == null) {
|
|
467
|
+
replaceStr = `###error: 获取参数对象为空 ${paramArr[j]}###`;
|
|
468
|
+
} else {
|
|
469
|
+
let value = paramValue[pTemp[1]];
|
|
470
|
+
if (value == null || value == "") {
|
|
471
|
+
replaceStr = "";
|
|
472
|
+
} else {
|
|
473
|
+
replaceStr = value;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
template = template.replaceAll(paramArr[j], replaceStr);
|
|
477
|
+
}
|
|
478
|
+
return template;
|
|
479
|
+
},
|
|
480
|
+
// 替换组件模板的参数
|
|
481
|
+
replaceTemplateCpt(template) {
|
|
482
|
+
if (template == null) {
|
|
483
|
+
return "";
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// 正则参数:例:${attrs}
|
|
487
|
+
let reg = new RegExp(/\${\w*}/g);
|
|
488
|
+
// 正则参数:例:${attrs#,}
|
|
489
|
+
let regCustom = new RegExp(/\${\w*#[^$]*}/g);
|
|
490
|
+
|
|
491
|
+
// 参数赋值:数组默认拼接
|
|
492
|
+
let paramArr = template.match(reg);
|
|
493
|
+
if (paramArr != null) {
|
|
494
|
+
for (let j = 0; j < paramArr.length; j++) {
|
|
495
|
+
// 参数实际值
|
|
496
|
+
let attrName = paramArr[j].substring(2, paramArr[j].length - 1);
|
|
497
|
+
let valueObj = this.paramTemplateObj[attrName];
|
|
498
|
+
if (valueObj == null) {
|
|
499
|
+
// 不存在参数数组,替换为空
|
|
500
|
+
template = template.replaceAll(paramArr[j], "");
|
|
501
|
+
} else {
|
|
502
|
+
template = template.replaceAll(paramArr[j], valueObj.join(" "));
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// 参数赋值:数组自定义拼接
|
|
509
|
+
let paramArr2 = template.match(regCustom);
|
|
510
|
+
if (paramArr2 != null) {
|
|
511
|
+
for (let j = 0; j < paramArr2.length; j++) {
|
|
512
|
+
// 参数实际值
|
|
513
|
+
let attrName = paramArr2[j].substring(2, paramArr2[j].length - 1).split("#");
|
|
514
|
+
let valueObj = this.paramTemplateObj[attrName[0]];
|
|
515
|
+
if (valueObj == null) {
|
|
516
|
+
// 不存在参数数组,替换为空
|
|
517
|
+
template = template.replaceAll(paramArr2[j], "");
|
|
518
|
+
} else {
|
|
519
|
+
template = template.replaceAll(paramArr2[j], valueObj.join(attrName[1]));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return template;
|
|
525
|
+
},
|
|
526
|
+
// 设定参数模板
|
|
527
|
+
initParamTemplate() {
|
|
528
|
+
let templates = this.paramTemplateList;
|
|
529
|
+
|
|
530
|
+
for (let i = 0; i < templates.length; i++) {
|
|
531
|
+
templates[i].template = this.handleTemplate(templates[i], 1);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// 参数模板对象
|
|
535
|
+
let templateObj = {};
|
|
536
|
+
for (let i = 0; i < templates.length; i++) {
|
|
537
|
+
let paramName = templates[i].fdParamName;
|
|
538
|
+
if (templateObj[paramName] == null) {
|
|
539
|
+
templateObj[paramName] = [];
|
|
540
|
+
}
|
|
541
|
+
templateObj[paramName].push(templates[i].template);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
this.paramTemplateObj = templateObj;
|
|
545
|
+
// console.log("paramTemplateObj: 参数模板对象");
|
|
546
|
+
// console.log(templateObj);
|
|
547
|
+
},
|
|
548
|
+
// 设定组件模板
|
|
549
|
+
initCptTemplate() {
|
|
550
|
+
let templates = this.cptTemplateList;
|
|
551
|
+
for (let i = 0; i < templates.length; i++) {
|
|
552
|
+
templates[i].template = this.handleTemplate(templates[i], 2);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// 组件模板对象
|
|
556
|
+
let templateObj = {};
|
|
557
|
+
for (let i = 0; i < templates.length; i++) {
|
|
558
|
+
let paramName = templates[i].fdParamName;
|
|
559
|
+
if (templateObj[paramName] == null) {
|
|
560
|
+
templateObj[paramName] = [];
|
|
561
|
+
}
|
|
562
|
+
templateObj[paramName].push(templates[i].template);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
this.cptTemplateObj = templateObj;
|
|
566
|
+
// console.log("cptTemplateObj: 组件模板");
|
|
567
|
+
// console.log(this.cptTemplateObj);
|
|
568
|
+
},
|
|
569
|
+
// 设定组件基础模板
|
|
570
|
+
initBaseTemplate() {
|
|
571
|
+
let baseInfo = this.baseInfo;
|
|
572
|
+
let cptTemplateObj = this.cptTemplateObj;
|
|
573
|
+
// 正则参数:例:${attrs}
|
|
574
|
+
let reg = new RegExp(/\${\w*}/g);
|
|
575
|
+
// 正则参数:例:${attrs#,}
|
|
576
|
+
let regCustom = new RegExp(/\${\w*#[^}]*}/g);
|
|
577
|
+
let template = this.baseInfo.fdTemplate;
|
|
578
|
+
if (template == null) {
|
|
579
|
+
template = "组件的基础模板不存在";
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
// 参数赋值:数组默认拼接
|
|
583
|
+
let paramArr = template.match(reg);
|
|
584
|
+
if (paramArr != null) {
|
|
585
|
+
for (let j = 0; j < paramArr.length; j++) {
|
|
586
|
+
// 参数实际值
|
|
587
|
+
let attrName = paramArr[j].substring(2, paramArr[j].length - 1);
|
|
588
|
+
let valueObj = cptTemplateObj[attrName];
|
|
589
|
+
if (valueObj == null) {
|
|
590
|
+
// 不存在参数数组,替换为空
|
|
591
|
+
template = template.replaceAll(paramArr[j], "");
|
|
592
|
+
} else {
|
|
593
|
+
template = template.replaceAll(paramArr[j], valueObj.join(" "));
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// 参数赋值:数组自定义拼接
|
|
600
|
+
let paramArr2 = template.match(regCustom);
|
|
601
|
+
if (paramArr2 != null) {
|
|
602
|
+
for (let j = 0; j < paramArr2.length; j++) {
|
|
603
|
+
// 参数实际值
|
|
604
|
+
let attrName = paramArr2[j].substring(2, paramArr2[j].length - 1).split("#");
|
|
605
|
+
let valueObj = cptTemplateObj[attrName[0]];
|
|
606
|
+
if (valueObj == null) {
|
|
607
|
+
// 不存在参数数组,替换为空
|
|
608
|
+
template = template.replaceAll(paramArr2[j], "");
|
|
609
|
+
} else {
|
|
610
|
+
template = template.replaceAll(paramArr2[j], valueObj.join(attrName[1]));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
this.template = template;
|
|
615
|
+
|
|
616
|
+
// console.log("cptTemplateObj: 组件模板对象");
|
|
617
|
+
// console.log(this.cptTemplateObj);
|
|
618
|
+
this.vueCode = this.template;
|
|
619
|
+
},
|
|
620
|
+
renderCode() {
|
|
621
|
+
this.vueCode = this.template;
|
|
622
|
+
},
|
|
623
|
+
copyCode(event) {
|
|
624
|
+
clipboard(this.vueCode, event)
|
|
625
|
+
},
|
|
626
|
+
openDialog(param) {
|
|
627
|
+
this.dialogTitle = param.fdName;
|
|
628
|
+
this.dialogVisible = true;
|
|
629
|
+
this.currentArrayParam = param;
|
|
630
|
+
},
|
|
631
|
+
openEditDialog(param) {
|
|
632
|
+
this.dialogTitle = param.fdName;
|
|
633
|
+
this.dialogVisible = true;
|
|
634
|
+
this.currentArrayParam = param;
|
|
635
|
+
// 参数赋值
|
|
636
|
+
console.log(this.currentArrayParamObj);
|
|
637
|
+
},
|
|
638
|
+
// 删除数组参数
|
|
639
|
+
delArrayParam() {
|
|
640
|
+
|
|
641
|
+
},
|
|
642
|
+
// 返回当前数组参数的子参数
|
|
643
|
+
getCurrentArrayParam() {
|
|
644
|
+
let id = this.currentArrayParam.fdId;
|
|
645
|
+
let arrParam = [];
|
|
646
|
+
let paramList = this.paramList;
|
|
647
|
+
for (let i = 0; i < paramList.length; i++) {
|
|
648
|
+
if (paramList[i].fdParentId == id) {
|
|
649
|
+
arrParam.push(paramList[i]);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return arrParam;
|
|
654
|
+
},
|
|
655
|
+
handleStr() {
|
|
656
|
+
|
|
657
|
+
},
|
|
658
|
+
getCurrentArrayParamObj() {
|
|
659
|
+
let arrParam = this.getCurrentArrayParam();
|
|
660
|
+
let obj = {};
|
|
661
|
+
for (let i = 0; i < arrParam.length; i++) {
|
|
662
|
+
obj[arrParam[i].fdCode] = arrParam[i].value;
|
|
663
|
+
}
|
|
664
|
+
this.currentArrayParamObj = obj;
|
|
665
|
+
},
|
|
666
|
+
// 返回当前数组参数的子参数模板
|
|
667
|
+
getCurrentArrayParamTemplate() {
|
|
668
|
+
this.currentArrayParamObj = {};
|
|
669
|
+
let arrParam = this.getCurrentArrayParam();
|
|
670
|
+
let pValue = this.currentArrayParam.arrValue;
|
|
671
|
+
if (arrParam == null || arrParam.length < 1) {
|
|
672
|
+
return pValue;
|
|
673
|
+
}
|
|
674
|
+
let itemInfo = [];
|
|
675
|
+
let templates = this.paramTemplateList;
|
|
676
|
+
for (let i = 0; i < arrParam.length; i++) {
|
|
677
|
+
for (let j = 0; j < templates.length; j++) {
|
|
678
|
+
if (templates[j].fdParamId == arrParam[i].fdId) {
|
|
679
|
+
let tmp = this.handleTemplate(templates[j], 1);
|
|
680
|
+
if (tmp != null && tmp != "") {
|
|
681
|
+
itemInfo.push(tmp);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (itemInfo.length < 1) {
|
|
687
|
+
return pValue;
|
|
688
|
+
}
|
|
689
|
+
console.log(111);
|
|
690
|
+
let item = "";
|
|
691
|
+
if (itemInfo.length == 1) {
|
|
692
|
+
if (itemInfo[0].indexOf(": ") > -1) {
|
|
693
|
+
// 对象参数
|
|
694
|
+
item = `{ ${itemInfo.join(",")} } `;
|
|
695
|
+
} else {
|
|
696
|
+
// 非对象类型
|
|
697
|
+
item = itemInfo[0];
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (itemInfo.length > 1) {
|
|
701
|
+
item = `{ ${itemInfo.join(",")} } `;
|
|
702
|
+
}
|
|
703
|
+
pValue.push(item);
|
|
704
|
+
this.currentArrayParam.value = `[ ${pValue.join(", ")} ]`;
|
|
705
|
+
},
|
|
706
|
+
// 保存数组参数
|
|
707
|
+
saveArrayParam() {
|
|
708
|
+
this.getCurrentArrayParamTemplate();
|
|
709
|
+
this.renderTemplate();
|
|
710
|
+
this.getCurrentArrayParamObj();
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
}
|
|
716
|
+
</script>
|
|
717
|
+
|
|
718
|
+
<style scoped>
|
|
719
|
+
.dev-container {
|
|
720
|
+
height: 100%;
|
|
721
|
+
background-color: white;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.dev-left-panel {
|
|
725
|
+
width: 270px;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.dev-right-panel {
|
|
729
|
+
width: 450px;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.dev-right-panel /deep/ .el-form-item {
|
|
733
|
+
margin-bottom: 12px;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.dev-left-panel /deep/ .el-tabs__header {
|
|
737
|
+
margin: 0px;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
.dev-main-panel {
|
|
741
|
+
height: 100%;
|
|
742
|
+
width: 100%;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.dev-collapse-title {
|
|
746
|
+
font-weight: bold;
|
|
747
|
+
font-size: 13px;
|
|
748
|
+
padding: 0px 8px;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.dev-comp-item {
|
|
752
|
+
padding: 5px 8px;
|
|
753
|
+
background: #f6f7ff;
|
|
754
|
+
font-size: 12px;
|
|
755
|
+
cursor: pointer;
|
|
756
|
+
border: 1px solid #f6f7ff;
|
|
757
|
+
border-radius: 3px;
|
|
758
|
+
width: 44%;
|
|
759
|
+
margin-left: 4%;
|
|
760
|
+
float: left;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.dev-comp-item:hover {
|
|
764
|
+
border: 1px solid #787be8;
|
|
765
|
+
color: #787be8;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.dev-code {
|
|
769
|
+
color: #c7254e;
|
|
770
|
+
border-radius: 4px;
|
|
771
|
+
padding: 5px;
|
|
772
|
+
white-space: pre;
|
|
773
|
+
width: fit-content;
|
|
774
|
+
}
|
|
775
|
+
</style>
|