cloud-web-corejs 1.0.54-dev.138 → 1.0.54-dev.140

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.
@@ -1,753 +1,767 @@
1
- <template>
2
- <div>
3
- <!-- <el-button type="primary" @click="test">Submit</el-button> -->
4
- <div class="designer-box" id="containt" style="margin-bottom: 0;">
5
- <v-form-designer
6
- ref="designer"
7
- :reportTemplate.sync="reportTemplate"
8
- :designer-config="designerConfig"
9
- :field-list-data="fieldListData"
10
- @field-widget-used="handleFWU"
11
- @field-widget-removed="handleFWR"
12
- @form-json-updated="handleFJU"
13
- @reflushTemplateList="reflushTemplateList"
14
- v-if="showDesinger"
15
- :readonly="readonly"
16
- />
17
- </div><!--
18
- <el-tabs v-model="activeName" class="tab-boxCard tabCard-sty1" v-if="showDesinger">
19
- <el-tab-pane label="设计器" name="first">
20
-
21
- </el-tab-pane>
22
- </el-tabs> -->
23
- </div>
24
- </template>
25
-
26
- <script>
27
- import {loadExtension} from '@base/components/xform/extension/extension-loader'
28
-
29
- loadExtension()
30
- import VFormDesigner from '@base/components/xform/form-designer/index.vue'
31
- import {deepClone, overwriteObj} from "@base/components/xform/utils/util";
32
- import {formFieldMapping} from "../../../../views/user/form/vform/formFieldMapping";
33
-
34
- export default {
35
- name: 'vform-designer:edit',
36
- props: {
37
- formCode: String,
38
- readonly: Boolean
39
- },
40
- components: {
41
- VFormDesigner
42
- },
43
- data() {
44
- return {
45
- formJson: {},
46
- formData: {},
47
- optionData: {},
48
- reportTemplate: {},
49
- showDesinger: false,
50
- activeName: 'first',
51
- showRequestaccessList: false,
52
- showFunctionScriptList: false,
53
- designerConfig: {
54
- componentLib: false,
55
- formTemplates: false,
56
- eventCollapse: true,
57
- metadataLib: true,
58
- logoHeader: false,
59
- exportCodeButton: false,
60
- generateSFCButton: false,
61
- toolbarMaxWidth: 300,
62
- },
63
- fieldListData: {},
64
- layoutId: null,
65
- formOptionData: {},
66
-
67
- meteFieldsResult: null,
68
- usedFieldNames: {},
69
- entity: null,
70
- entityLabel: null
71
- };
72
- },
73
- computed: {},
74
- watch: {
75
- activeName(val) {
76
- if (this.showRequestaccessList === false && val == "second") {
77
- this.showRequestaccessList = true;
78
- }
79
- }
80
- },
81
- mounted() {
82
- this.getTemplate();
83
- },
84
- methods: {
85
- test() {
86
- let that = this;
87
- let designer = this.$refs.designer;
88
- let json = designer.getFormJson();
89
- designer.setFormJson(this.formJson);
90
- },
91
- getTemplate() {
92
- /* this.showDesinger = true;
93
- return */
94
- this.$http({
95
- aes: true,
96
- url: USER_PREFIX + `/formTemplate/getByFormCode`,
97
- method: `post`,
98
- data: {
99
- stringOne: this.formCode
100
- },
101
- isLoading: true,
102
- modalStrictly: true,
103
- success: res => {
104
- let reportTemplate = res.objx || {};
105
- this.reportTemplate = reportTemplate;
106
- this.showDesinger = true;
107
- this.$nextTick(() => {
108
- this.$refs.designer.setFormJson(reportTemplate.formViewContent);
109
-
110
- // this.loadFieldListData();
111
-
112
- })
113
- }
114
- });
115
- },
116
- loadFieldListData(res) {
117
- this.entity = "User";
118
- this.entityLabel = "用户";
119
- /*res = {
120
- "code": 200, "error": null, "message": "success", "data": {
121
- "subFormList": [],
122
- "storageSetting": [{"cloudStorage": "false"}],
123
- "fieldList": [
124
- /!*{
125
- "name": "userId",
126
- "label": "用户Id主键",
127
- "type": "PrimaryKey",
128
- "required": "1"
129
- }, {"name": "createdOn", "label": "创建时间", "type": "DateTime", "required": "1"}, {
130
- "searchDialogWidth": "520px",
131
- "name": "createdBy",
132
- "label": "创建用户",
133
- "type": "Reference",
134
- "required": "1"
135
- },*!/ {
136
- "name": "modifiedOn",
137
- "label": "最近修改时间",
138
- "type": "DateTime",
139
- "required": "0"
140
- }, /!*{
141
- "searchDialogWidth": "520px",
142
- "name": "modifiedBy",
143
- "label": "修改用户",
144
- "type": "Reference",
145
- "required": "0"
146
- }, {
147
- "searchDialogWidth": "520px",
148
- "name": "ownerUser",
149
- "label": "所属用户",
150
- "type": "Reference",
151
- "required": "1"
152
- }, {
153
- "searchDialogWidth": "520px",
154
- "name": "ownerDepartment",
155
- "label": "所属部门",
156
- "type": "Reference",
157
- "required": "1"
158
- }, {
159
- "searchDialogWidth": "510px",
160
- "name": "departmentId",
161
- "label": "部门",
162
- "type": "Reference",
163
- "required": "1"
164
- },*!/ {"name": "userName", "label": "用户名称", "type": "Text", "required": "1"}, {
165
- "name": "loginPwd",
166
- "label": "登录密码",
167
- "type": "Password",
168
- "required": "1"
169
- }, {"name": "loginName", "label": "登录账号名", "type": "Text", "required": "1"}, {
170
- "name": "jobTitle",
171
- "label": "职务",
172
- "type": "Option",
173
- "required": "1"
174
- }, {"name": "roles", "label": "权限角色", "type": "ReferenceList", "required": "0"}, {
175
- "name": "disabled",
176
- "label": "是否禁用",
177
- "type": "Boolean",
178
- "required": "1"
179
- }, {"name": "mobilePhone", "label": "手机号", "type": "Text", "required": "0"}, {
180
- "name": "email",
181
- "label": "邮箱",
182
- "type": "Text",
183
- "required": "0"
184
- },/!* {"name": "ownerTeam", "label": "所属团队", "type": "ReferenceList", "required": "0"}, {
185
- "name": "avatar",
186
- "label": "头像",
187
- "type": "Picture",
188
- "required": "0"
189
- },*!/ {"name": "dingTalkUserId", "label": "钉钉用户ID", "type": "Text", "required": "0"}]
190
- }
191
- };*/
192
- res = {
193
- "code": 200, "error": null, "message": "success", "data": {
194
- "subFormList": [{"name": "Jinjilianxiren", "label": "员工-紧急联系人"}],
195
- "storageSetting": [{"cloudStorage": "false"}],
196
- "fieldList": [
197
- /*{
198
- "name": "yuangongdanganId",
199
- "label": "id主键",
200
- "type": "PrimaryKey",
201
- "required": "1"
202
- },*/ {"name": "createdOn", "label": "创建时间", "type": "DateTime", "required": "1"}, /*{
203
- "searchDialogWidth": "520px",
204
- "name": "createdBy",
205
- "label": "创建用户",
206
- "type": "Reference",
207
- "required": "1"
208
- },*/ {
209
- "name": "modifiedOn",
210
- "label": "最近修改时间",
211
- "type": "DateTime",
212
- "required": "0"
213
- }, /*{
214
- "searchDialogWidth": "520px",
215
- "name": "modifiedBy",
216
- "label": "修改用户",
217
- "type": "Reference",
218
- "required": "0"
219
- }, {
220
- "searchDialogWidth": "520px",
221
- "name": "ownerUser",
222
- "label": "所属用户",
223
- "type": "Reference",
224
- "required": "1"
225
- }, {
226
- "searchDialogWidth": "520px",
227
- "name": "ownerDepartment",
228
- "label": "所属部门",
229
- "type": "Reference",
230
- "required": "1"
231
- },*/ {
232
- "name": "gonghao",
233
- "label": "工号",
234
- "type": "Text",
235
- "required": "0",
236
- "maxLength": "200"
237
- }, {
238
- "name": "xingming",
239
- "label": "姓名",
240
- "type": "Text",
241
- "required": "1",
242
- "maxLength": "200"
243
- }, /*{
244
- "searchDialogWidth": "520px",
245
- "name": "bumen",
246
- "label": "部门",
247
- "type": "Reference",
248
- "required": "1"
249
- },*/ {
250
- "name": "gangwei",
251
- "label": "岗位",
252
- "type": "Text",
253
- "required": "1",
254
- "maxLength": "200"
255
- }, /*{
256
- "searchDialogWidth": "520px",
257
- "name": "yuangongchengyuan",
258
- "label": "员工成员",
259
- "type": "Reference",
260
- "required": "0"
261
- },*/ {
262
- "name": "shenfenzhenghao",
263
- "label": "身份证号",
264
- "type": "Text",
265
- "required": "0",
266
- "maxLength": "200"
267
- }, {"name": "xingbie", "label": "性别", "type": "Option", "required": "1"}, {
268
- "name": "chushengriqi",
269
- "label": "出生日期",
270
- "type": "Date",
271
- "required": "0"
272
- }, /*{
273
- "name": "jiguan",
274
- "label": "籍贯",
275
- "type": "AreaSelect",
276
- "areaDataType": "2",
277
- "required": "0"
278
- },*/ {
279
- "name": "hujisuozaidi",
280
- "label": "户籍所在地",
281
- "type": "Text",
282
- "required": "0",
283
- "maxLength": "200"
284
- }, {"name": "hujileixing", "label": "户籍类型", "type": "Option", "required": "0"}, {
285
- "name": "minzu",
286
- "label": "民族",
287
- "type": "Text",
288
- "required": "0",
289
- "maxLength": "200"
290
- }, {
291
- "name": "hunyinzhuangtai",
292
- "label": "婚姻状态",
293
- "type": "Option",
294
- "required": "0"
295
- }, {
296
- "name": "zhengzhimianmao",
297
- "label": "政治面貌",
298
- "type": "Option",
299
- "required": "0"
300
- }, /*{
301
- "name": "yuangongzhaopian",
302
- "label": "员工照片",
303
- "type": "Picture",
304
- "required": "0"
305
- },*/ {
306
- "name": "pinyongxingshi",
307
- "label": "聘用形式",
308
- "type": "Option",
309
- "required": "0"
310
- }, {
311
- "name": "yuangongzhuangtai",
312
- "label": "员工状态",
313
- "type": "Option",
314
- "required": "1"
315
- }, {"name": "canjiagongzuoriqi", "label": "参加工作日期", "type": "Date", "required": "0"}, {
316
- "name": "ruzhiriqi",
317
- "label": "入职日期",
318
- "type": "Date",
319
- "required": "1"
320
- }, {
321
- "name": "shiyongqitianshu",
322
- "label": "试用期天数(天)",
323
- "type": "Integer",
324
- "required": "1"
325
- }, {"name": "zhuanzhengriqi", "label": "转正日期", "type": "Date", "required": "0"}, {
326
- "min": "-999999999",
327
- "max": "999999999",
328
- "precision": "2",
329
- "name": "shiyongqixinzi",
330
- "label": "试用期薪资",
331
- "type": "Money",
332
- "required": "0"
333
- }, {
334
- "min": "-999999999",
335
- "max": "999999999",
336
- "precision": "2",
337
- "name": "zhengshixinzi",
338
- "label": "正式薪资",
339
- "type": "Money",
340
- "required": "0"
341
- }, /*{
342
- "searchDialogWidth": "520px",
343
- "name": "zhijieshangji",
344
- "label": "直接上级",
345
- "type": "Reference",
346
- "required": "0"
347
- }, {
348
- "searchDialogWidth": "520px",
349
- "name": "fuzeHR",
350
- "label": "负责HR",
351
- "type": "Reference",
352
- "required": "0"
353
- },*/ {
354
- "name": "shebaozhanghao",
355
- "label": "社保账号",
356
- "type": "Text",
357
- "required": "0",
358
- "maxLength": "200"
359
- }, {
360
- "name": "gongjijinzhanghao",
361
- "label": "公积金账号",
362
- "type": "Text",
363
- "required": "0",
364
- "maxLength": "200"
365
- }, {
366
- "name": "yinhangkahao",
367
- "label": "银行卡号",
368
- "type": "Text",
369
- "required": "0",
370
- "maxLength": "200"
371
- }, {
372
- "name": "kaihuxing",
373
- "label": "开户行",
374
- "type": "Text",
375
- "required": "0",
376
- "maxLength": "200"
377
- }, {
378
- "name": "shoujihao",
379
- "label": "手机号",
380
- "type": "Text",
381
- "required": "0",
382
- "maxLength": "200"
383
- }, /*{
384
- "name": "changzhudizhi",
385
- "label": "常住地址",
386
- "type": "AreaSelect",
387
- "areaDataType": "2",
388
- "required": "0"
389
- },*/ {
390
- "name": "jutidizhi",
391
- "label": "具体地址",
392
- "type": "Text",
393
- "required": "0",
394
- "maxLength": "200"
395
- }, {"name": "zuigaoxueli", "label": "最高学历", "type": "Option", "required": "0"}, {
396
- "name": "biyeshijian",
397
- "label": "毕业时间",
398
- "type": "Date",
399
- "required": "0"
400
- }, {"name": "aa", "label": "aa", "type": "Integer", "required": "1"}, /*{
401
- "detailEntity": "Jinjilianxiren",
402
- "name": "jinjilianxirenId",
403
- "label": "员工-紧急联系人.id主键",
404
- "type": "PrimaryKey",
405
- "required": "1"
406
- },*/ {
407
- "detailEntity": "Jinjilianxiren",
408
- "name": "createdOn",
409
- "label": "员工-紧急联系人.创建时间",
410
- "type": "DateTime",
411
- "required": "1"
412
- }, /*{
413
- "searchDialogWidth": "520px",
414
- "detailEntity": "Jinjilianxiren",
415
- "name": "createdBy",
416
- "label": "员工-紧急联系人.创建用户",
417
- "type": "Reference",
418
- "required": "1"
419
- },*/ {
420
- "detailEntity": "Jinjilianxiren",
421
- "name": "modifiedOn",
422
- "label": "员工-紧急联系人.最近修改时间",
423
- "type": "DateTime",
424
- "required": "0"
425
- }, /*{
426
- "searchDialogWidth": "520px",
427
- "detailEntity": "Jinjilianxiren",
428
- "name": "modifiedBy",
429
- "label": "员工-紧急联系人.修改用户",
430
- "type": "Reference",
431
- "required": "0"
432
- }, {
433
- "searchDialogWidth": "520px",
434
- "detailEntity": "Jinjilianxiren",
435
- "name": "mdYuangongdanganId",
436
- "label": "员工-紧急联系人.主从关联Id",
437
- "type": "Reference",
438
- "required": "1"
439
- },*/ {
440
- "detailEntity": "Jinjilianxiren",
441
- "name": "shouji",
442
- "label": "员工-紧急联系人.手机",
443
- "type": "Text",
444
- "required": "0",
445
- "maxLength": "200"
446
- }, {
447
- "detailEntity": "Jinjilianxiren",
448
- "name": "jinjilianxirenxingming",
449
- "label": "员工-紧急联系人.紧急联系人姓名",
450
- "type": "Text",
451
- "required": "0",
452
- "maxLength": "200"
453
- }]
454
- }
455
- };
456
- if (res.data.fieldList) {
457
- this.fieldListData.fieldList = res.data.fieldList;
458
- if (res.data.subFormList) {
459
- this.fieldListData.subFormList =
460
- res.data.subFormList;
461
- }
462
- this.meteFieldsResult = res;
463
- const metaFields = this.buildMetaFields(
464
- this.meteFieldsResult
465
- );
466
- this.$refs.designer.setFieldListData(
467
- this.fieldListData
468
- );
469
- this.$refs.designer.setMetaFields(metaFields);
470
- }
471
-
472
- },
473
-
474
- buildMetaFields(mdResult) {
475
- const result = {
476
- main: {
477
- entityName: this.entity,
478
- entityLabel: this.entityLabel,
479
- fieldList: [],
480
- },
481
- detail: [],
482
- };
483
-
484
- if (mdResult && mdResult.data?.fieldList) {
485
- mdResult.data.fieldList.forEach((fld) => {
486
- if (!fld.detailEntity && fld.type !== "PrimaryKey") {
487
- //跳过id主键
488
- if (fld.name === "loginPwd") {
489
- return;
490
- }
491
-
492
- if (
493
- fld.type === "AnyReference" ||
494
- fld.type === "ReferenceList"
495
- ) {
496
- return;
497
- }
498
-
499
- if (this.usedFieldNames.hasOwnProperty(fld.name)) {
500
- return; //跳过本次循环
501
- }
502
-
503
- const fieldNewProps = deepClone(
504
- formFieldMapping[fld.type]
505
- );
506
- const fieldSchema = deepClone(
507
- this.$refs.designer.designer.getFieldWidgetByType(
508
- fieldNewProps.type
509
- )
510
- );
511
- overwriteObj(
512
- fieldSchema.options,
513
- fieldNewProps.options
514
- );
515
-
516
- fieldSchema.displayName = fld.label;
517
- fieldSchema.nameReadonly = true;
518
- fieldSchema.options.name = fld.name;
519
- fieldSchema.options.label = fld.label;
520
- this.adjustFieldSchema(fieldSchema, fld, mdResult);
521
- result.main.fieldList.push(fieldSchema);
522
- }
523
- });
524
- }
525
-
526
- if (mdResult && mdResult.data?.subFormList) {
527
- mdResult.data.subFormList.forEach((sf) => {
528
- const deName = sf.name;
529
- const deLabel = sf.label;
530
- const detailDataItem = {
531
- entityName: deName,
532
- entityLabel: deLabel,
533
- fieldList: [],
534
- };
535
-
536
- mdResult.data.fieldList.forEach((fld) => {
537
- if (
538
- fld.detailEntity &&
539
- fld.detailEntity === deName &&
540
- fld.type !== "PrimaryKey"
541
- ) {
542
- //跳过id主键
543
- if (
544
- fld.type === "AnyReference" ||
545
- fld.type === "ReferenceList"
546
- ) {
547
- return;
548
- }
549
-
550
- if (this.usedFieldNames.hasOwnProperty(fld.name)) {
551
- return; //跳过本次循环
552
- }
553
-
554
- const fieldNewProps = deepClone(
555
- formFieldMapping[fld.type]
556
- );
557
- const fieldSchema = deepClone(
558
- this.$refs.designer.designer.getFieldWidgetByType(
559
- fieldNewProps.type
560
- )
561
- );
562
- overwriteObj(
563
- fieldSchema.options,
564
- fieldNewProps.options
565
- );
566
-
567
- fieldSchema.displayName = fld.label;
568
- fieldSchema.nameReadonly = true;
569
- fieldSchema.options.name = fld.name;
570
- fieldSchema.options.label = fld.label;
571
- this.adjustFieldSchema(fieldSchema, fld, mdResult);
572
- detailDataItem.fieldList.push(fieldSchema);
573
- }
574
- });
575
-
576
- result.detail.push(detailDataItem);
577
- });
578
- }
579
-
580
- return result;
581
- },
582
-
583
- adjustFieldSchema(fieldSchema, fldObj, mdResult) {
584
- // 处理图片、文件上传字段!!
585
- let cloudStorageFlag = false;
586
- let cloudStorageType = "";
587
- if (mdResult.data.storageSetting) {
588
- cloudStorageFlag =
589
- mdResult.data.storageSetting[0].cloudStorage === "true";
590
- if (cloudStorageFlag) {
591
- cloudStorageType =
592
- mdResult.data.storageSetting[0].cloudStorageType;
593
- }
594
- }
595
-
596
- if (fldObj.type === "Picture" || fldObj.type === "File") {
597
- if (cloudStorageFlag) {
598
- //设置withCredentials
599
- fieldSchema.options.withCredentials = false;
600
-
601
- //设置onBeforeUpload事件代码(还需要生成uuid新文件名)
602
- fieldSchema.options.onBeforeUpload =
603
- "const gDSV = this.getGlobalDsv();\nconst wType = this.field.type;\nif (wType === 'picture-upload') {\n this.field.options.uploadURL = gDSV.picUploadURL;\n} else if (wType === 'file-upload') {\n this.field.options.uploadURL = gDSV.fileUploadURL;\n}\n\nconst cloudStorage = gDSV.cloudStorage;\nif (cloudStorage === \"true\") {\n this.field.options.withCredentials = false\n const token = gDSV.cloudUploadToken;\n this.setUploadData('token', token);\n \n const randomNum = Math.floor(Math.random() * 100);\n const newFileName = new Date().getTime() + randomNum+ '_' + file.name;\n this.setUploadData('key', newFileName);\n} else {\n //this.field.options.withCredentials = true\n}\n";
604
-
605
- //设置onUploadSuccess事件代码(上传返回结果需要设置QiNiu=前缀)
606
- fieldSchema.options.onUploadSuccess =
607
- "const gDSV = this.getGlobalDsv();\nconst cloudStorage = gDSV.cloudStorage;\nif (cloudStorage === \"true\") {\n const wType = this.field.type;\n let downloadPrefix = \"\"\n if (wType === 'picture-upload') {\n downloadPrefix = gDSV.picDownloadPrefix;\n } else if (wType === 'file-upload') {\n downloadPrefix = gDSV.fileDownloadPrefix;\n }\n \n let downUrl = downloadPrefix + result.key;\n const paramName = (downUrl.indexOf(\"?\") === -1) ? '?fileName=' : '&fileName=';\n return {\n name: file.name,\n url: downUrl + paramName + file.name\n }\n} else {\n const paramName = (result.url.indexOf(\"?\") === -1) ? '?fileName=' : '&fileName=';\n return {\n name: file.name,\n url: result.url + paramName + file.name\n }\n}\n";
608
- }
609
- }
610
- // 处理图片、文件上传字段 -- 结束
611
-
612
- /* 处理文本、长文本字段 */
613
- if (fldObj.type === "Text" || fldObj.type === "TextArea") {
614
- fieldSchema.options.maxLength = !fldObj.maxLength
615
- ? fieldSchema.options.maxLength
616
- : fldObj.maxLength * 1;
617
- }
618
-
619
- /* 处理精度小数字段 */
620
- if (
621
- fldObj.type === "Integer" ||
622
- fldObj.type === "Percent" ||
623
- fldObj.type === "Money" ||
624
- fldObj.type === "Decimal"
625
- ) {
626
- fieldSchema.options.precision = !fldObj.precision
627
- ? fieldSchema.options.precision
628
- : fldObj.precision * 1;
629
- fieldSchema.options.min = !fldObj.min
630
- ? fieldSchema.options.min
631
- : fldObj.min * 1;
632
- fieldSchema.options.max = !fldObj.max
633
- ? fieldSchema.options.max
634
- : fldObj.max * 1;
635
- }
636
-
637
- /* 处理地区选择字段 */
638
- if (fldObj.type === "AreaSelect") {
639
- fieldSchema.optionItemsReadonly = true;
640
- fieldSchema.options.areaDataType = !fldObj.areaDataType
641
- ? fieldSchema.options.areaDataType
642
- : fldObj.areaDataType * 1;
643
- }
644
-
645
- /* 处理一对一字段 */
646
- if (fldObj.type === "Reference") {
647
- fieldSchema.options.searchDialogWidth =
648
- !fldObj.searchDialogWidth
649
- ? fieldSchema.options.searchDialogWidth
650
- : fldObj.searchDialogWidth;
651
- }
652
-
653
- /* 处理单选项字段 */
654
- if (fieldSchema.options.hasOwnProperty("optionItems")) {
655
- if (
656
- this.formOptionData.hasOwnProperty(fieldSchema.options.name)
657
- ) {
658
- fieldSchema.options.optionItems = deepClone(
659
- this.formOptionData[fieldSchema.options.name]
660
- );
661
- }
662
-
663
- if (fldObj.type === "Boolean") {
664
- fieldSchema.options.optionItems = [
665
- {value: true, label: "是"},
666
- {value: false, label: "否"},
667
- ];
668
- }
669
-
670
- fieldSchema.optionItemsReadonly = true;
671
- }
672
-
673
- /* 设置字段必填校验 */
674
- if (fldObj.hasOwnProperty("required")) {
675
- fieldSchema.options.required = fldObj["required"] === "1";
676
- }
677
-
678
- /* 取消系统字段的必填校验 */
679
- if (fieldSchema.options.name === "createdOn" || fieldSchema.options.name === "createdBy"
680
- || fieldSchema.options.name === "modifiedOn" || fieldSchema.options.name === "modifiedBy"
681
- || fieldSchema.options.name === "ownerUser" || fieldSchema.options.name === "ownerDepartment"
682
- || fieldSchema.options.name === "approvalConfigId" || fieldSchema.options.name === "approvalStatus"
683
- || fieldSchema.options.name === "lastApprovedBy" || fieldSchema.options.name === "lastApprovedOn") {
684
- fieldSchema.options.required = false;
685
- }
686
-
687
- //
688
- },
689
-
690
- handleFWU(fwName) {
691
- this.usedFieldNames[fwName] = 1;
692
-
693
- /* 必须延时处理,否则draggable会报错 */
694
- setTimeout(() => {
695
- const metaFields = this.buildMetaFields(this.meteFieldsResult);
696
- this.$refs.designer.setMetaFields(metaFields);
697
- }, 800);
698
- },
699
-
700
- handleFWR(fwName) {
701
- delete this.usedFieldNames[fwName];
702
-
703
- /* 必须延时处理,否则draggable会报错 */
704
- setTimeout(() => {
705
- const metaFields = this.buildMetaFields(this.meteFieldsResult);
706
- this.$refs.designer.setMetaFields(metaFields);
707
- }, 800);
708
- },
709
-
710
- handleFJU() {
711
- this.handleUsedFields();
712
- setTimeout(() => {
713
- const metaFields = this.buildMetaFields(this.meteFieldsResult);
714
- this.$refs.designer.setMetaFields(metaFields);
715
- }, 300);
716
- },
717
-
718
- /**
719
- * 过滤已使用字段组件
720
- */
721
- handleUsedFields() {
722
- this.usedFieldNames = {};
723
- const allFieldWidgets = this.$refs.designer.getFieldWidgets();
724
- allFieldWidgets.forEach((fwItem) => {
725
- this.usedFieldNames[fwItem.name] = 1;
726
- });
727
- },
728
- initField() {
729
- this.$http({
730
- aes: true,
731
- url: USER_PREFIX + "/szTaMb/listPage",
732
- data: {},
733
- success: res => {
734
-
735
- }
736
- });
737
- },
738
- reflushTemplateList() {
739
- this.$emit("reflushTemplateList");
740
- }
741
- }
742
- };
743
- </script>
744
-
745
- <style lang="scss" scoped>
746
- body {
747
- margin: 0; /* 如果页面出现垂直滚动条,则加入此行CSS以消除之 */
748
- }
749
-
750
- #app .main-container {
751
- margin-left: 0px;
752
- }
753
- </style>
1
+ <template>
2
+ <div>
3
+ <!-- <el-button type="primary" @click="test">Submit</el-button> -->
4
+ <div class="designer-box" id="containt" style="margin-bottom: 0;">
5
+ <v-form-designer
6
+ ref="designer"
7
+ :reportTemplate.sync="reportTemplate"
8
+ :designer-config="designerConfig"
9
+ :field-list-data="fieldListData"
10
+ @field-widget-used="handleFWU"
11
+ @field-widget-removed="handleFWR"
12
+ @form-json-updated="handleFJU"
13
+ @reflushTemplateList="reflushTemplateList"
14
+ v-if="showDesinger"
15
+ :readonly="readonly"
16
+ :columnFlag="columnFlag"
17
+ />
18
+ </div><!--
19
+ <el-tabs v-model="activeName" class="tab-boxCard tabCard-sty1" v-if="showDesinger">
20
+ <el-tab-pane label="设计器" name="first">
21
+
22
+ </el-tab-pane>
23
+ </el-tabs> -->
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ import {loadExtension} from '@base/components/xform/extension/extension-loader'
29
+
30
+ loadExtension()
31
+ import VFormDesigner from '@base/components/xform/form-designer/index.vue'
32
+ import {deepClone, overwriteObj} from "@base/components/xform/utils/util";
33
+ import {formFieldMapping} from "./formFieldMapping";
34
+
35
+ export default {
36
+ name: 'vform-designer:edit',
37
+ props: {
38
+ formCode: String,
39
+ readonly: Boolean,
40
+ formTemplate:Object,
41
+ widgetList: Array,
42
+ columnFlag: Boolean,
43
+ },
44
+ components: {
45
+ VFormDesigner
46
+ },
47
+ data() {
48
+ return {
49
+ formJson: {},
50
+ formData: {},
51
+ optionData: {},
52
+ reportTemplate: {},
53
+ showDesinger: false,
54
+ activeName: 'first',
55
+ showRequestaccessList: false,
56
+ showFunctionScriptList: false,
57
+ designerConfig: {
58
+ componentLib: false,
59
+ formTemplates: false,
60
+ eventCollapse: true,
61
+ metadataLib: true,
62
+ logoHeader: false,
63
+ exportCodeButton: false,
64
+ generateSFCButton: false,
65
+ toolbarMaxWidth: 300,
66
+ },
67
+ fieldListData: {},
68
+ layoutId: null,
69
+ formOptionData: {},
70
+
71
+ meteFieldsResult: null,
72
+ usedFieldNames: {},
73
+ entity: null,
74
+ entityLabel: null
75
+ };
76
+ },
77
+ computed: {},
78
+ watch: {
79
+ activeName(val) {
80
+ if (this.showRequestaccessList === false && val == "second") {
81
+ this.showRequestaccessList = true;
82
+ }
83
+ }
84
+ },
85
+ mounted() {
86
+ this.getTemplate();
87
+ },
88
+ methods: {
89
+ test() {
90
+ let that = this;
91
+ let designer = this.$refs.designer;
92
+ let json = designer.getFormJson();
93
+ designer.setFormJson(this.formJson);
94
+ },
95
+ getTemplate() {
96
+ /* this.showDesinger = true;
97
+ return */
98
+ if(this.columnFlag){
99
+ this.reportTemplate = this.formTemplate;
100
+ this.showDesinger = true;
101
+ this.$nextTick(() => {
102
+ let formJson = this.$baseLodash.cloneDeep({
103
+ widgetList:this.widgetList
104
+ });
105
+ this.$refs.designer.setFormJson(formJson);
106
+ })
107
+ }
108
+ this.$http({
109
+ aes: true,
110
+ url: USER_PREFIX + `/formTemplate/getByFormCode`,
111
+ method: `post`,
112
+ data: {
113
+ stringOne: this.formCode
114
+ },
115
+ isLoading: true,
116
+ modalStrictly: true,
117
+ success: res => {
118
+ let reportTemplate = res.objx || {};
119
+ this.reportTemplate = reportTemplate;
120
+ this.showDesinger = true;
121
+ this.$nextTick(() => {
122
+ this.$refs.designer.setFormJson(reportTemplate.formViewContent);
123
+
124
+ // this.loadFieldListData();
125
+
126
+ })
127
+ }
128
+ });
129
+ },
130
+ loadFieldListData(res) {
131
+ this.entity = "User";
132
+ this.entityLabel = "用户";
133
+ /*res = {
134
+ "code": 200, "error": null, "message": "success", "data": {
135
+ "subFormList": [],
136
+ "storageSetting": [{"cloudStorage": "false"}],
137
+ "fieldList": [
138
+ /!*{
139
+ "name": "userId",
140
+ "label": "用户Id主键",
141
+ "type": "PrimaryKey",
142
+ "required": "1"
143
+ }, {"name": "createdOn", "label": "创建时间", "type": "DateTime", "required": "1"}, {
144
+ "searchDialogWidth": "520px",
145
+ "name": "createdBy",
146
+ "label": "创建用户",
147
+ "type": "Reference",
148
+ "required": "1"
149
+ },*!/ {
150
+ "name": "modifiedOn",
151
+ "label": "最近修改时间",
152
+ "type": "DateTime",
153
+ "required": "0"
154
+ }, /!*{
155
+ "searchDialogWidth": "520px",
156
+ "name": "modifiedBy",
157
+ "label": "修改用户",
158
+ "type": "Reference",
159
+ "required": "0"
160
+ }, {
161
+ "searchDialogWidth": "520px",
162
+ "name": "ownerUser",
163
+ "label": "所属用户",
164
+ "type": "Reference",
165
+ "required": "1"
166
+ }, {
167
+ "searchDialogWidth": "520px",
168
+ "name": "ownerDepartment",
169
+ "label": "所属部门",
170
+ "type": "Reference",
171
+ "required": "1"
172
+ }, {
173
+ "searchDialogWidth": "510px",
174
+ "name": "departmentId",
175
+ "label": "部门",
176
+ "type": "Reference",
177
+ "required": "1"
178
+ },*!/ {"name": "userName", "label": "用户名称", "type": "Text", "required": "1"}, {
179
+ "name": "loginPwd",
180
+ "label": "登录密码",
181
+ "type": "Password",
182
+ "required": "1"
183
+ }, {"name": "loginName", "label": "登录账号名", "type": "Text", "required": "1"}, {
184
+ "name": "jobTitle",
185
+ "label": "职务",
186
+ "type": "Option",
187
+ "required": "1"
188
+ }, {"name": "roles", "label": "权限角色", "type": "ReferenceList", "required": "0"}, {
189
+ "name": "disabled",
190
+ "label": "是否禁用",
191
+ "type": "Boolean",
192
+ "required": "1"
193
+ }, {"name": "mobilePhone", "label": "手机号", "type": "Text", "required": "0"}, {
194
+ "name": "email",
195
+ "label": "邮箱",
196
+ "type": "Text",
197
+ "required": "0"
198
+ },/!* {"name": "ownerTeam", "label": "所属团队", "type": "ReferenceList", "required": "0"}, {
199
+ "name": "avatar",
200
+ "label": "头像",
201
+ "type": "Picture",
202
+ "required": "0"
203
+ },*!/ {"name": "dingTalkUserId", "label": "钉钉用户ID", "type": "Text", "required": "0"}]
204
+ }
205
+ };*/
206
+ res = {
207
+ "code": 200, "error": null, "message": "success", "data": {
208
+ "subFormList": [{"name": "Jinjilianxiren", "label": "员工-紧急联系人"}],
209
+ "storageSetting": [{"cloudStorage": "false"}],
210
+ "fieldList": [
211
+ /*{
212
+ "name": "yuangongdanganId",
213
+ "label": "id主键",
214
+ "type": "PrimaryKey",
215
+ "required": "1"
216
+ },*/ {"name": "createdOn", "label": "创建时间", "type": "DateTime", "required": "1"}, /*{
217
+ "searchDialogWidth": "520px",
218
+ "name": "createdBy",
219
+ "label": "创建用户",
220
+ "type": "Reference",
221
+ "required": "1"
222
+ },*/ {
223
+ "name": "modifiedOn",
224
+ "label": "最近修改时间",
225
+ "type": "DateTime",
226
+ "required": "0"
227
+ }, /*{
228
+ "searchDialogWidth": "520px",
229
+ "name": "modifiedBy",
230
+ "label": "修改用户",
231
+ "type": "Reference",
232
+ "required": "0"
233
+ }, {
234
+ "searchDialogWidth": "520px",
235
+ "name": "ownerUser",
236
+ "label": "所属用户",
237
+ "type": "Reference",
238
+ "required": "1"
239
+ }, {
240
+ "searchDialogWidth": "520px",
241
+ "name": "ownerDepartment",
242
+ "label": "所属部门",
243
+ "type": "Reference",
244
+ "required": "1"
245
+ },*/ {
246
+ "name": "gonghao",
247
+ "label": "工号",
248
+ "type": "Text",
249
+ "required": "0",
250
+ "maxLength": "200"
251
+ }, {
252
+ "name": "xingming",
253
+ "label": "姓名",
254
+ "type": "Text",
255
+ "required": "1",
256
+ "maxLength": "200"
257
+ }, /*{
258
+ "searchDialogWidth": "520px",
259
+ "name": "bumen",
260
+ "label": "部门",
261
+ "type": "Reference",
262
+ "required": "1"
263
+ },*/ {
264
+ "name": "gangwei",
265
+ "label": "岗位",
266
+ "type": "Text",
267
+ "required": "1",
268
+ "maxLength": "200"
269
+ }, /*{
270
+ "searchDialogWidth": "520px",
271
+ "name": "yuangongchengyuan",
272
+ "label": "员工成员",
273
+ "type": "Reference",
274
+ "required": "0"
275
+ },*/ {
276
+ "name": "shenfenzhenghao",
277
+ "label": "身份证号",
278
+ "type": "Text",
279
+ "required": "0",
280
+ "maxLength": "200"
281
+ }, {"name": "xingbie", "label": "性别", "type": "Option", "required": "1"}, {
282
+ "name": "chushengriqi",
283
+ "label": "出生日期",
284
+ "type": "Date",
285
+ "required": "0"
286
+ }, /*{
287
+ "name": "jiguan",
288
+ "label": "籍贯",
289
+ "type": "AreaSelect",
290
+ "areaDataType": "2",
291
+ "required": "0"
292
+ },*/ {
293
+ "name": "hujisuozaidi",
294
+ "label": "户籍所在地",
295
+ "type": "Text",
296
+ "required": "0",
297
+ "maxLength": "200"
298
+ }, {"name": "hujileixing", "label": "户籍类型", "type": "Option", "required": "0"}, {
299
+ "name": "minzu",
300
+ "label": "民族",
301
+ "type": "Text",
302
+ "required": "0",
303
+ "maxLength": "200"
304
+ }, {
305
+ "name": "hunyinzhuangtai",
306
+ "label": "婚姻状态",
307
+ "type": "Option",
308
+ "required": "0"
309
+ }, {
310
+ "name": "zhengzhimianmao",
311
+ "label": "政治面貌",
312
+ "type": "Option",
313
+ "required": "0"
314
+ }, /*{
315
+ "name": "yuangongzhaopian",
316
+ "label": "员工照片",
317
+ "type": "Picture",
318
+ "required": "0"
319
+ },*/ {
320
+ "name": "pinyongxingshi",
321
+ "label": "聘用形式",
322
+ "type": "Option",
323
+ "required": "0"
324
+ }, {
325
+ "name": "yuangongzhuangtai",
326
+ "label": "员工状态",
327
+ "type": "Option",
328
+ "required": "1"
329
+ }, {"name": "canjiagongzuoriqi", "label": "参加工作日期", "type": "Date", "required": "0"}, {
330
+ "name": "ruzhiriqi",
331
+ "label": "入职日期",
332
+ "type": "Date",
333
+ "required": "1"
334
+ }, {
335
+ "name": "shiyongqitianshu",
336
+ "label": "试用期天数(天)",
337
+ "type": "Integer",
338
+ "required": "1"
339
+ }, {"name": "zhuanzhengriqi", "label": "转正日期", "type": "Date", "required": "0"}, {
340
+ "min": "-999999999",
341
+ "max": "999999999",
342
+ "precision": "2",
343
+ "name": "shiyongqixinzi",
344
+ "label": "试用期薪资",
345
+ "type": "Money",
346
+ "required": "0"
347
+ }, {
348
+ "min": "-999999999",
349
+ "max": "999999999",
350
+ "precision": "2",
351
+ "name": "zhengshixinzi",
352
+ "label": "正式薪资",
353
+ "type": "Money",
354
+ "required": "0"
355
+ }, /*{
356
+ "searchDialogWidth": "520px",
357
+ "name": "zhijieshangji",
358
+ "label": "直接上级",
359
+ "type": "Reference",
360
+ "required": "0"
361
+ }, {
362
+ "searchDialogWidth": "520px",
363
+ "name": "fuzeHR",
364
+ "label": "负责HR",
365
+ "type": "Reference",
366
+ "required": "0"
367
+ },*/ {
368
+ "name": "shebaozhanghao",
369
+ "label": "社保账号",
370
+ "type": "Text",
371
+ "required": "0",
372
+ "maxLength": "200"
373
+ }, {
374
+ "name": "gongjijinzhanghao",
375
+ "label": "公积金账号",
376
+ "type": "Text",
377
+ "required": "0",
378
+ "maxLength": "200"
379
+ }, {
380
+ "name": "yinhangkahao",
381
+ "label": "银行卡号",
382
+ "type": "Text",
383
+ "required": "0",
384
+ "maxLength": "200"
385
+ }, {
386
+ "name": "kaihuxing",
387
+ "label": "开户行",
388
+ "type": "Text",
389
+ "required": "0",
390
+ "maxLength": "200"
391
+ }, {
392
+ "name": "shoujihao",
393
+ "label": "手机号",
394
+ "type": "Text",
395
+ "required": "0",
396
+ "maxLength": "200"
397
+ }, /*{
398
+ "name": "changzhudizhi",
399
+ "label": "常住地址",
400
+ "type": "AreaSelect",
401
+ "areaDataType": "2",
402
+ "required": "0"
403
+ },*/ {
404
+ "name": "jutidizhi",
405
+ "label": "具体地址",
406
+ "type": "Text",
407
+ "required": "0",
408
+ "maxLength": "200"
409
+ }, {"name": "zuigaoxueli", "label": "最高学历", "type": "Option", "required": "0"}, {
410
+ "name": "biyeshijian",
411
+ "label": "毕业时间",
412
+ "type": "Date",
413
+ "required": "0"
414
+ }, {"name": "aa", "label": "aa", "type": "Integer", "required": "1"}, /*{
415
+ "detailEntity": "Jinjilianxiren",
416
+ "name": "jinjilianxirenId",
417
+ "label": "员工-紧急联系人.id主键",
418
+ "type": "PrimaryKey",
419
+ "required": "1"
420
+ },*/ {
421
+ "detailEntity": "Jinjilianxiren",
422
+ "name": "createdOn",
423
+ "label": "员工-紧急联系人.创建时间",
424
+ "type": "DateTime",
425
+ "required": "1"
426
+ }, /*{
427
+ "searchDialogWidth": "520px",
428
+ "detailEntity": "Jinjilianxiren",
429
+ "name": "createdBy",
430
+ "label": "员工-紧急联系人.创建用户",
431
+ "type": "Reference",
432
+ "required": "1"
433
+ },*/ {
434
+ "detailEntity": "Jinjilianxiren",
435
+ "name": "modifiedOn",
436
+ "label": "员工-紧急联系人.最近修改时间",
437
+ "type": "DateTime",
438
+ "required": "0"
439
+ }, /*{
440
+ "searchDialogWidth": "520px",
441
+ "detailEntity": "Jinjilianxiren",
442
+ "name": "modifiedBy",
443
+ "label": "员工-紧急联系人.修改用户",
444
+ "type": "Reference",
445
+ "required": "0"
446
+ }, {
447
+ "searchDialogWidth": "520px",
448
+ "detailEntity": "Jinjilianxiren",
449
+ "name": "mdYuangongdanganId",
450
+ "label": "员工-紧急联系人.主从关联Id",
451
+ "type": "Reference",
452
+ "required": "1"
453
+ },*/ {
454
+ "detailEntity": "Jinjilianxiren",
455
+ "name": "shouji",
456
+ "label": "员工-紧急联系人.手机",
457
+ "type": "Text",
458
+ "required": "0",
459
+ "maxLength": "200"
460
+ }, {
461
+ "detailEntity": "Jinjilianxiren",
462
+ "name": "jinjilianxirenxingming",
463
+ "label": "员工-紧急联系人.紧急联系人姓名",
464
+ "type": "Text",
465
+ "required": "0",
466
+ "maxLength": "200"
467
+ }]
468
+ }
469
+ };
470
+ if (res.data.fieldList) {
471
+ this.fieldListData.fieldList = res.data.fieldList;
472
+ if (res.data.subFormList) {
473
+ this.fieldListData.subFormList =
474
+ res.data.subFormList;
475
+ }
476
+ this.meteFieldsResult = res;
477
+ const metaFields = this.buildMetaFields(
478
+ this.meteFieldsResult
479
+ );
480
+ this.$refs.designer.setFieldListData(
481
+ this.fieldListData
482
+ );
483
+ this.$refs.designer.setMetaFields(metaFields);
484
+ }
485
+
486
+ },
487
+
488
+ buildMetaFields(mdResult) {
489
+ const result = {
490
+ main: {
491
+ entityName: this.entity,
492
+ entityLabel: this.entityLabel,
493
+ fieldList: [],
494
+ },
495
+ detail: [],
496
+ };
497
+
498
+ if (mdResult && mdResult.data?.fieldList) {
499
+ mdResult.data.fieldList.forEach((fld) => {
500
+ if (!fld.detailEntity && fld.type !== "PrimaryKey") {
501
+ //跳过id主键
502
+ if (fld.name === "loginPwd") {
503
+ return;
504
+ }
505
+
506
+ if (
507
+ fld.type === "AnyReference" ||
508
+ fld.type === "ReferenceList"
509
+ ) {
510
+ return;
511
+ }
512
+
513
+ if (this.usedFieldNames.hasOwnProperty(fld.name)) {
514
+ return; //跳过本次循环
515
+ }
516
+
517
+ const fieldNewProps = deepClone(
518
+ formFieldMapping[fld.type]
519
+ );
520
+ const fieldSchema = deepClone(
521
+ this.$refs.designer.designer.getFieldWidgetByType(
522
+ fieldNewProps.type
523
+ )
524
+ );
525
+ overwriteObj(
526
+ fieldSchema.options,
527
+ fieldNewProps.options
528
+ );
529
+
530
+ fieldSchema.displayName = fld.label;
531
+ fieldSchema.nameReadonly = true;
532
+ fieldSchema.options.name = fld.name;
533
+ fieldSchema.options.label = fld.label;
534
+ this.adjustFieldSchema(fieldSchema, fld, mdResult);
535
+ result.main.fieldList.push(fieldSchema);
536
+ }
537
+ });
538
+ }
539
+
540
+ if (mdResult && mdResult.data?.subFormList) {
541
+ mdResult.data.subFormList.forEach((sf) => {
542
+ const deName = sf.name;
543
+ const deLabel = sf.label;
544
+ const detailDataItem = {
545
+ entityName: deName,
546
+ entityLabel: deLabel,
547
+ fieldList: [],
548
+ };
549
+
550
+ mdResult.data.fieldList.forEach((fld) => {
551
+ if (
552
+ fld.detailEntity &&
553
+ fld.detailEntity === deName &&
554
+ fld.type !== "PrimaryKey"
555
+ ) {
556
+ //跳过id主键
557
+ if (
558
+ fld.type === "AnyReference" ||
559
+ fld.type === "ReferenceList"
560
+ ) {
561
+ return;
562
+ }
563
+
564
+ if (this.usedFieldNames.hasOwnProperty(fld.name)) {
565
+ return; //跳过本次循环
566
+ }
567
+
568
+ const fieldNewProps = deepClone(
569
+ formFieldMapping[fld.type]
570
+ );
571
+ const fieldSchema = deepClone(
572
+ this.$refs.designer.designer.getFieldWidgetByType(
573
+ fieldNewProps.type
574
+ )
575
+ );
576
+ overwriteObj(
577
+ fieldSchema.options,
578
+ fieldNewProps.options
579
+ );
580
+
581
+ fieldSchema.displayName = fld.label;
582
+ fieldSchema.nameReadonly = true;
583
+ fieldSchema.options.name = fld.name;
584
+ fieldSchema.options.label = fld.label;
585
+ this.adjustFieldSchema(fieldSchema, fld, mdResult);
586
+ detailDataItem.fieldList.push(fieldSchema);
587
+ }
588
+ });
589
+
590
+ result.detail.push(detailDataItem);
591
+ });
592
+ }
593
+
594
+ return result;
595
+ },
596
+
597
+ adjustFieldSchema(fieldSchema, fldObj, mdResult) {
598
+ // 处理图片、文件上传字段!!
599
+ let cloudStorageFlag = false;
600
+ let cloudStorageType = "";
601
+ if (mdResult.data.storageSetting) {
602
+ cloudStorageFlag =
603
+ mdResult.data.storageSetting[0].cloudStorage === "true";
604
+ if (cloudStorageFlag) {
605
+ cloudStorageType =
606
+ mdResult.data.storageSetting[0].cloudStorageType;
607
+ }
608
+ }
609
+
610
+ if (fldObj.type === "Picture" || fldObj.type === "File") {
611
+ if (cloudStorageFlag) {
612
+ //设置withCredentials
613
+ fieldSchema.options.withCredentials = false;
614
+
615
+ //设置onBeforeUpload事件代码(还需要生成uuid新文件名)
616
+ fieldSchema.options.onBeforeUpload =
617
+ "const gDSV = this.getGlobalDsv();\nconst wType = this.field.type;\nif (wType === 'picture-upload') {\n this.field.options.uploadURL = gDSV.picUploadURL;\n} else if (wType === 'file-upload') {\n this.field.options.uploadURL = gDSV.fileUploadURL;\n}\n\nconst cloudStorage = gDSV.cloudStorage;\nif (cloudStorage === \"true\") {\n this.field.options.withCredentials = false\n const token = gDSV.cloudUploadToken;\n this.setUploadData('token', token);\n \n const randomNum = Math.floor(Math.random() * 100);\n const newFileName = new Date().getTime() + randomNum+ '_' + file.name;\n this.setUploadData('key', newFileName);\n} else {\n //this.field.options.withCredentials = true\n}\n";
618
+
619
+ //设置onUploadSuccess事件代码(上传返回结果需要设置QiNiu=前缀)
620
+ fieldSchema.options.onUploadSuccess =
621
+ "const gDSV = this.getGlobalDsv();\nconst cloudStorage = gDSV.cloudStorage;\nif (cloudStorage === \"true\") {\n const wType = this.field.type;\n let downloadPrefix = \"\"\n if (wType === 'picture-upload') {\n downloadPrefix = gDSV.picDownloadPrefix;\n } else if (wType === 'file-upload') {\n downloadPrefix = gDSV.fileDownloadPrefix;\n }\n \n let downUrl = downloadPrefix + result.key;\n const paramName = (downUrl.indexOf(\"?\") === -1) ? '?fileName=' : '&fileName=';\n return {\n name: file.name,\n url: downUrl + paramName + file.name\n }\n} else {\n const paramName = (result.url.indexOf(\"?\") === -1) ? '?fileName=' : '&fileName=';\n return {\n name: file.name,\n url: result.url + paramName + file.name\n }\n}\n";
622
+ }
623
+ }
624
+ // 处理图片、文件上传字段 -- 结束
625
+
626
+ /* 处理文本、长文本字段 */
627
+ if (fldObj.type === "Text" || fldObj.type === "TextArea") {
628
+ fieldSchema.options.maxLength = !fldObj.maxLength
629
+ ? fieldSchema.options.maxLength
630
+ : fldObj.maxLength * 1;
631
+ }
632
+
633
+ /* 处理精度小数字段 */
634
+ if (
635
+ fldObj.type === "Integer" ||
636
+ fldObj.type === "Percent" ||
637
+ fldObj.type === "Money" ||
638
+ fldObj.type === "Decimal"
639
+ ) {
640
+ fieldSchema.options.precision = !fldObj.precision
641
+ ? fieldSchema.options.precision
642
+ : fldObj.precision * 1;
643
+ fieldSchema.options.min = !fldObj.min
644
+ ? fieldSchema.options.min
645
+ : fldObj.min * 1;
646
+ fieldSchema.options.max = !fldObj.max
647
+ ? fieldSchema.options.max
648
+ : fldObj.max * 1;
649
+ }
650
+
651
+ /* 处理地区选择字段 */
652
+ if (fldObj.type === "AreaSelect") {
653
+ fieldSchema.optionItemsReadonly = true;
654
+ fieldSchema.options.areaDataType = !fldObj.areaDataType
655
+ ? fieldSchema.options.areaDataType
656
+ : fldObj.areaDataType * 1;
657
+ }
658
+
659
+ /* 处理一对一字段 */
660
+ if (fldObj.type === "Reference") {
661
+ fieldSchema.options.searchDialogWidth =
662
+ !fldObj.searchDialogWidth
663
+ ? fieldSchema.options.searchDialogWidth
664
+ : fldObj.searchDialogWidth;
665
+ }
666
+
667
+ /* 处理单选项字段 */
668
+ if (fieldSchema.options.hasOwnProperty("optionItems")) {
669
+ if (
670
+ this.formOptionData.hasOwnProperty(fieldSchema.options.name)
671
+ ) {
672
+ fieldSchema.options.optionItems = deepClone(
673
+ this.formOptionData[fieldSchema.options.name]
674
+ );
675
+ }
676
+
677
+ if (fldObj.type === "Boolean") {
678
+ fieldSchema.options.optionItems = [
679
+ {value: true, label: ""},
680
+ {value: false, label: ""},
681
+ ];
682
+ }
683
+
684
+ fieldSchema.optionItemsReadonly = true;
685
+ }
686
+
687
+ /* 设置字段必填校验 */
688
+ if (fldObj.hasOwnProperty("required")) {
689
+ fieldSchema.options.required = fldObj["required"] === "1";
690
+ }
691
+
692
+ /* 取消系统字段的必填校验 */
693
+ if (fieldSchema.options.name === "createdOn" || fieldSchema.options.name === "createdBy"
694
+ || fieldSchema.options.name === "modifiedOn" || fieldSchema.options.name === "modifiedBy"
695
+ || fieldSchema.options.name === "ownerUser" || fieldSchema.options.name === "ownerDepartment"
696
+ || fieldSchema.options.name === "approvalConfigId" || fieldSchema.options.name === "approvalStatus"
697
+ || fieldSchema.options.name === "lastApprovedBy" || fieldSchema.options.name === "lastApprovedOn") {
698
+ fieldSchema.options.required = false;
699
+ }
700
+
701
+ //
702
+ },
703
+
704
+ handleFWU(fwName) {
705
+ this.usedFieldNames[fwName] = 1;
706
+
707
+ /* 必须延时处理,否则draggable会报错 */
708
+ setTimeout(() => {
709
+ const metaFields = this.buildMetaFields(this.meteFieldsResult);
710
+ this.$refs.designer.setMetaFields(metaFields);
711
+ }, 800);
712
+ },
713
+
714
+ handleFWR(fwName) {
715
+ delete this.usedFieldNames[fwName];
716
+
717
+ /* 必须延时处理,否则draggable会报错 */
718
+ setTimeout(() => {
719
+ const metaFields = this.buildMetaFields(this.meteFieldsResult);
720
+ this.$refs.designer.setMetaFields(metaFields);
721
+ }, 800);
722
+ },
723
+
724
+ handleFJU() {
725
+ this.handleUsedFields();
726
+ setTimeout(() => {
727
+ const metaFields = this.buildMetaFields(this.meteFieldsResult);
728
+ this.$refs.designer.setMetaFields(metaFields);
729
+ }, 300);
730
+ },
731
+
732
+ /**
733
+ * 过滤已使用字段组件
734
+ */
735
+ handleUsedFields() {
736
+ this.usedFieldNames = {};
737
+ const allFieldWidgets = this.$refs.designer.getFieldWidgets();
738
+ allFieldWidgets.forEach((fwItem) => {
739
+ this.usedFieldNames[fwItem.name] = 1;
740
+ });
741
+ },
742
+ initField() {
743
+ this.$http({
744
+ aes: true,
745
+ url: USER_PREFIX + "/szTaMb/listPage",
746
+ data: {},
747
+ success: res => {
748
+
749
+ }
750
+ });
751
+ },
752
+ reflushTemplateList() {
753
+ this.$emit("reflushTemplateList");
754
+ }
755
+ }
756
+ };
757
+ </script>
758
+
759
+ <style lang="scss" scoped>
760
+ body {
761
+ margin: 0; /* 如果页面出现垂直滚动条,则加入此行CSS以消除之 */
762
+ }
763
+
764
+ #app .main-container {
765
+ margin-left: 0px;
766
+ }
767
+ </style>