cloud-web-corejs 1.0.111 → 1.0.113

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,632 +1,632 @@
1
- <!--
2
- /**
3
- * author: vformAdmin
4
- * email: vdpadmin@163.com
5
- * website: https://www.vform666.com
6
- * date: 2021.08.18
7
- * remark: 如果要分发VForm源码,需在本文件顶部保留此文件头信息!!
8
- */
9
- -->
10
-
11
- <template>
12
- <div class="field-wrapper" :class="{'design-time-bottom-margin': !!this.designer}"
13
- v-show="!field.options.hidden || (designState === true)">
14
- <div>
15
- <template v-if="formItemProp=='false'">
16
- <template v-if="!field.options.hidden">
17
- <template v-if="isShowWidget()">
18
- <slot></slot>
19
- </template>
20
- <template v-else-if="field.options.widgetTextFlag===3 && field.options.widgetTextLinkConfig">
21
- <div class="ellipsis">
22
- <a class="a-link" :class="getWidgetClass()" @click.native="handleClick">
23
- <span>
24
- <i :class="field.options.widgetTextLinkConfig.options.prefixIcon"
25
- v-if="!!field.options.widgetTextLinkConfig.options.prefixIcon"></i>
26
- <span>{{ getWidgetValue() }}</span>
27
- <i :class="field.options.widgetTextLinkConfig.options.suffixIcon"
28
- v-if="!!field.options.widgetTextLinkConfig.options.suffixIcon"></i>
29
- </span>
30
- </a>
31
- </div>
32
- </template>
33
- <template v-else>
34
- <span>{{ getShowValue() }}</span>
35
- </template>
36
- </template>
37
- </template>
38
- <template v-else>
39
- <el-form-item v-if="!!field.formItemFlag && (!field.options.hidden || (designState === true))"
40
- :label="label" :label-width="labelWidth + 'px'"
41
- :title="field.options.labelTooltip"
42
- :rules="rules" :prop="getPropName()"
43
- :class="[selected ? 'selected' : '', labelAlign, customClass, field.options.required ? 'required' : '']"
44
- @click.native.stop="selectField(field)">
45
-
46
- <span v-if="!!field.options.labelIconClass" slot="label" class="custom-label"
47
- :style="{'color':field.options.labelColor}">
48
- <template v-if="field.options.labelIconPosition === 'front'">
49
- <template v-if="!!field.options.labelTooltip">
50
- <el-tooltip :content="field.options.labelTooltip" effect="light">
51
- <i :class="field.options.labelIconClass"></i></el-tooltip>{{ label }}</template>
52
- <template v-else>
53
- <i :class="field.options.labelIconClass"></i>{{ label }}</template>
54
- </template>
55
- <template v-else-if="field.options.labelIconPosition === 'rear'">
56
- <template v-if="!!field.options.labelTooltip">
57
- {{ label }}<el-tooltip :content="field.options.labelTooltip" effect="light">
58
- <i :class="field.options.labelIconClass"></i></el-tooltip></template>
59
- <template v-else>
60
- {{ label }}<i :class="field.options.labelIconClass"></i></template>
61
- </template>
62
- </span>
63
- <span v-if="!!field.options.labelColor" slot="label" :style="{'color':field.options.labelColor}">
64
- {{ label }}
65
- </span>
66
- <template v-if="isShowWidget()">
67
- <slot></slot>
68
- </template>
69
- <template v-else-if="field.options.widgetTextFlag===3 && field.options.widgetTextLinkConfig">
70
- <div class="ellipsis">
71
- <a class="a-link" :class="getWidgetClass()" @click="handleClick">
72
- <span>
73
- <i :class="field.options.widgetTextLinkConfig.options.prefixIcon"
74
- v-if="!!field.options.widgetTextLinkConfig.options.prefixIcon"></i>
75
- <span>{{ getWidgetValue() }}</span>
76
- <i :class="field.options.widgetTextLinkConfig.options.suffixIcon"
77
- v-if="!!field.options.widgetTextLinkConfig.options.suffixIcon"></i>
78
- </span>
79
- </a>
80
- </div>
81
- </template>
82
- <template v-else>
83
- <span>{{ getShowValue() }}</span>
84
- </template>
85
- </el-form-item>
86
- </template>
87
- </div>
88
- <template v-if="!!this.designer">
89
- <div class="field-action" v-if="designer.selectedId === field.id">
90
- <i class="el-icon-back" :title="i18nt('designer.hint.selectParentWidget')"
91
- @click.stop="selectParentWidget(field)"></i>
92
- <i class="el-icon-top" v-if="!!parentList && (parentList.length > 1)"
93
- :title="i18nt('designer.hint.moveUpWidget')"
94
- @click.stop="moveUpWidget(field)"></i>
95
- <i class="el-icon-bottom" v-if="!!parentList && (parentList.length > 1)"
96
- :title="i18nt('designer.hint.moveDownWidget')"
97
- @click.stop="moveDownWidget(field)"></i>
98
- <i class="el-icon-delete" :title="i18nt('designer.hint.remove')" @click.stop="removeFieldWidget"></i>
99
- </div>
100
-
101
- <div class="drag-handler background-opacity" v-if="designer.selectedId === field.id">
102
- <i class="el-icon-rank" :title="i18nt('designer.hint.dragHandler')"></i>
103
- <i>{{ i18n2t(`designer.widgetLabel.${field.type}`, `extension.widgetLabel.${field.type}`) }}</i>
104
- <i v-if="field.options.hidden === true" class="iconfont icon-hide"></i>
105
- </div>
106
- </template>
107
- </div>
108
- </template>
109
-
110
- <script>
111
- import i18n from "../../../../../components/xform/utils/i18n";
112
- import {getSubFormNameByFieldId} from "../../../../../components/xform/utils/util";
113
-
114
-
115
- export default {
116
- name: "form-item-wrapper",
117
- mixins: [i18n],
118
- props: {
119
- field: Object,
120
- designer: Object,
121
- parentWidget: Object,
122
- parentList: Array,
123
- indexOfParentList: Number,
124
-
125
- designState: {
126
- type: Boolean,
127
- default: false
128
- },
129
- subFormRowIndex: { /* 子表单组件行索引,从0开始计数 */
130
- type: Number,
131
- default: -1
132
- },
133
- subFormColIndex: { /* 子表单组件列索引,从0开始计数 */
134
- type: Number,
135
- default: -1
136
- },
137
- subFormRowId: { /* 子表单组件行Id,唯一id且不可变 */
138
- type: String,
139
- default: ''
140
- },
141
-
142
- rules: Array,
143
- },
144
- inject: ["getFormConfig", "getSubFormFieldFlag", "getSubFormName", "tableParam", "formItemProp", "getObjectFieldFlag", "getObjectName"],
145
- data(){
146
- return {
147
- encryptFormula:null
148
- }
149
- },
150
- computed: {
151
- formConfig: function () {
152
- return this.getFormConfig()
153
- },
154
- selected() {
155
- return !!this.designer && this.field.id === this.designer.selectedId
156
- },
157
-
158
- label() {
159
- if (!!this.field.options.labelHidden) {
160
- return ''
161
- }
162
- return this.getI18nLabel(this.field.options.label)
163
- // let label = this.field.options.label
164
- // return label ? this.$t2(label) : label;
165
- },
166
-
167
- labelWidth() {
168
- if (!!this.field.options.labelHidden) {
169
- return !!this.designState ? 5 : 0 //设计期间标签最小宽度5像素,以便于鼠标点击可选中组件!!
170
- }
171
-
172
- if (!!this.field.options.labelWidth) {
173
- return this.field.options.labelWidth
174
- }
175
-
176
- if (!!this.designer) {
177
- return this.designer.formConfig.labelWidth
178
- } else {
179
- return this.formConfig.labelWidth
180
- }
181
- },
182
-
183
- labelAlign() {
184
- if (!this?.field?.options?.labelAlign) {
185
- return ""
186
- }
187
- if (!!this.field.options.labelAlign) {
188
- return this.field.options.labelAlign
189
- }
190
-
191
- if (!!this.designer) {
192
- return this.designer.formConfig.labelAlign || 'label-left-align'
193
- } else {
194
- return this.formConfig.labelAlign || 'label-left-align'
195
- }
196
- },
197
-
198
- customClass() {
199
- return !!this.field.options.customClass ? this.field.options.customClass.join(' ') : ''
200
- },
201
-
202
- subFormName() {
203
- return !!this.parentWidget ? this.parentWidget.options.name : ''
204
- },
205
-
206
- subFormItemFlag() {
207
- return this.isSubFormItem() || (!!this.parentWidget ? this.parentWidget.type === 'sub-form' : false)
208
- },
209
-
210
- },
211
- created() {
212
- //
213
- this.initShowType();
214
- },
215
- methods: {
216
- isSubFormItem() {
217
- return !!this.tableParam;
218
- },
219
- selectField(field) {
220
- if (!!this.designer) {
221
- this.designer.setSelected(field)
222
- this.designer.emitEvent('field-selected', this.parentWidget) //发送选中组件的父组件对象
223
- }
224
- },
225
-
226
- selectParentWidget() {
227
- if (this.parentWidget) {
228
- this.designer.setSelected(this.parentWidget)
229
- } else {
230
- this.designer.clearSelected()
231
- }
232
- },
233
-
234
- moveUpWidget() {
235
- this.designer.moveUpWidget(this.parentList, this.indexOfParentList)
236
- this.designer.emitHistoryChange()
237
- },
238
-
239
- moveDownWidget() {
240
- this.designer.moveDownWidget(this.parentList, this.indexOfParentList)
241
- this.designer.emitHistoryChange()
242
- },
243
-
244
- removeFieldWidget() {
245
- if (!!this.parentList) {
246
- const selectedWidgetName = this.designer.selectedWidgetName;
247
- let selectedId = this.designer.selectedId;
248
- let nextSelected = null
249
- if (this.parentList.length === 1) {
250
- if (!!this.parentWidget) {
251
- nextSelected = this.parentWidget
252
- }
253
- } else if (this.parentList.length === (1 + this.indexOfParentList)) {
254
- nextSelected = this.parentList[this.indexOfParentList - 1]
255
- } else {
256
- nextSelected = this.parentList[this.indexOfParentList + 1]
257
- }
258
-
259
- this.$nextTick(() => {
260
- const l = getSubFormNameByFieldId(
261
- this.designer.widgetList,
262
- selectedId
263
- );
264
- this.parentList.splice(this.indexOfParentList, 1)
265
- //if (!!nextSelected) {
266
- this.designer.setSelected(nextSelected)
267
- //}
268
- this.designer.formWidget.deleteWidgetRef(
269
- selectedWidgetName,
270
- l
271
- );
272
- this.designer.emitHistoryChange()
273
- this.designer.emitEvent(
274
- "canvas-remove-field",
275
- selectedWidgetName
276
- );
277
- })
278
- }
279
- },
280
-
281
- getPropName() {
282
- if (this.formItemProp) {
283
- return this.formItemProp;
284
- }
285
- let o = this.field.options.name;
286
- return (
287
- (o
288
- = (this.field.options.keyNameEnabled
289
- && this.field.options.keyName)
290
- || o),
291
- this.subFormItemFlag && !this.designState
292
- ? this.subFormName
293
- + "."
294
- + this.subFormRowIndex
295
- + "."
296
- + o
297
- : this.getObjectFieldFlag() && !this.designState
298
- ? this.getObjectName() + "." + o
299
- : o
300
- );
301
- },
302
- getI18nLabel(label, path, param) {
303
- return !this.designState && label ? this.$t2(label, path, param) : label;
304
- },
305
- getProcessText(text,pattern) {
306
-
307
- if (pattern == '' || pattern === null || pattern === undefined) {
308
- return text;
309
- }
310
-
311
- let result = '';
312
-
313
- // 处理固定模式
314
- if (pattern === '-') {
315
- result = '-';
316
- }
317
- else if (pattern === '*') {
318
- result = '*****';
319
- }
320
- // 处理自定义模式
321
- else if (pattern.includes('*')) {
322
- text = text ?? ""
323
- const parts = pattern.split('*');
324
-
325
- // 处理 A*B 模式
326
- if (parts.length === 2 && parts[0] && parts[1]) {
327
- const a = parseInt(parts[0]);
328
- const b = parseInt(parts[1]);
329
-
330
- if (!isNaN(a) && !isNaN(b) && a >= 0 && b >= 0) {
331
- if (text.length >= a + b) {
332
- const prefix = text.substring(0, a);
333
- const suffix = text.substring(text.length - b);
334
- const stars = '*'.repeat(text.length - a - b);
335
- result = prefix + stars + suffix;
336
- } else {
337
- result = '*****';
338
- }
339
- } else {
340
- // result = '无效模式:A和B必须是数字';
341
- result = text;
342
- }
343
- }
344
- // 处理 A* 模式
345
- else if (parts.length === 2 && parts[0] && !parts[1]) {
346
- const a = parseInt(parts[0]);
347
-
348
- if (!isNaN(a) && a >= 0) {
349
- if (text.length >= a) {
350
- const prefix = text.substring(0, a);
351
- const stars = '*'.repeat(text.length - a);
352
- result = prefix + stars;
353
- } else {
354
- result = '*****';
355
- }
356
- } else {
357
- // result = '无效模式:A必须是数字';
358
- result = text;
359
- }
360
- }
361
- // 处理 *B 模式
362
- else if (parts.length === 2 && !parts[0] && parts[1]) {
363
- const b = parseInt(parts[1]);
364
-
365
- if (!isNaN(b) && b >= 0) {
366
- if (text.length >= b) {
367
- const suffix = text.substring(text.length - b);
368
- const stars = '*'.repeat(text.length - b);
369
- result = stars + suffix;
370
- } else {
371
- result = '*****';
372
- }
373
- } else {
374
- // result = '无效模式:B必须是数字';
375
- result = text;
376
- }
377
- }
378
- // 处理无效模式
379
- else {
380
- result = '*****';
381
- }
382
- }
383
- // 处理其他无效模式
384
- else {
385
- result = '*****';
386
- }
387
-
388
- return result;
389
- },
390
- initShowType() {
391
- if (!!this.designer) return
392
- let that = this.$parent
393
- let formRef = that.getFormRef ? that.getFormRef() : that;
394
-
395
- if(!formRef)return
396
- //详情页,新增页面不加密
397
- let fJson = formRef.formJson;
398
- let formConfig = fJson.formConfig;
399
- if (formConfig.isLoadEntity && !formRef.dataId) return
400
-
401
- let bdService = formRef.bdService;
402
- let companyCode = this.$store.getters.companyCode;
403
- let loginAccount = this.$store.getters.loginAccount;
404
-
405
- let userSaleOrgDTOs = formRef.userSaleOrgDTOs;
406
- let userRoleDTOs = formRef.userRoleDTOs;
407
-
408
- let saleOrgCodeList = userSaleOrgDTOs.map(item => item.sn);
409
- let roleCodeList = userRoleDTOs.map(item => item.roleCode);
410
-
411
- let optionModel = this.field.options;
412
-
413
- let flag = 0;//0 原本组件,1明文文本,2密文文本
414
- /*if (optionModel.showTextEnabled) {
415
- flag = 1;
416
- } else if (optionModel.showEncryptTextEnabled) {
417
- flag = 2;
418
- } else if (optionModel.showLinkTextEnabled) {
419
- flag = 3;
420
- }*/
421
- if (optionModel.userTextRuleEnabled) {
422
- let userTextRuleConfig = optionModel.userTextRuleConfig || [];
423
- userTextRuleConfig.forEach(item => {
424
- let type = item.type ?? null;
425
- if (type !== null && type !== "") {
426
- let companyCodeStr = item.companyCodes;
427
- let companyCodes = companyCodeStr ? companyCodeStr.split(",").filter(item => !!item) : [];
428
- /*
429
-
430
- let loginAccountStr = item.loginAccounts;
431
- let loginAccounts = loginAccountStr ? loginAccountStr.split(",").filter(item => !!item) : [];
432
-
433
- let saleOrgCodeStr = item.saleOrgCodes;
434
- let saleOrgCodes = saleOrgCodeStr ? saleOrgCodeStr.split(",").filter(item => !!item) : [];
435
- */
436
-
437
- let roleCodeStr = item.roleCodes;
438
- let roleCodes = roleCodeStr ? roleCodeStr.split(",").filter(item => !!item) : [];
439
-
440
- let flag1 = !item.serveName || item.serveName == bdService;
441
- let flag2 = !companyCodes.length || companyCodes.includes(companyCode)
442
- // let flag3 = !loginAccounts.length || loginAccounts.includes(loginAccount)
443
- // let flag4 = this.compareToList(saleOrgCodes, saleOrgCodeList)
444
- if(flag1 && flag2){
445
- this.encryptFormula = item.encryptFormula
446
- let flag5 = this.compareToList(roleCodes, roleCodeList)
447
- if(flag5){
448
- //匹配角色
449
- if(type == 2)flag = 2//type=2时加密
450
- }else {
451
- //角色不匹配
452
- if(type == 1)flag = 2
453
- }
454
- }
455
- }
456
- })
457
- }
458
- this.field.options.widgetTextFlag = flag
459
- // this.showType = flag;
460
- },
461
- compareToList(list1, list2) {
462
- if (!list1.length) {
463
- return true;
464
- }
465
- if (!list2.length) {
466
- return false;
467
- }
468
- return list1.some(item => {
469
- return list2.some(item2 => item == item2)
470
- });
471
- },
472
- isShowWidget() {
473
- let widgetTextFlag = this.field.options.widgetTextFlag;
474
- return widgetTextFlag === undefined || widgetTextFlag === null || widgetTextFlag === 0
475
- },
476
- getShowValue() {
477
- let widgetTextFlag = this.field.options.widgetTextFlag;
478
- let fieldModel = this.$parent.fieldModel;
479
- if (this.$parent.fieldModelLabel) fieldModel = this.$parent.fieldModelLabel();
480
- let showValue = fieldModel
481
- if (widgetTextFlag == 2) {
482
- showValue = this.getProcessText(showValue,this.encryptFormula)
483
- }
484
-
485
- return showValue;
486
- },
487
- getWidgetClass() {
488
- let list = [];
489
- let optionModel = this.field.options.widgetTextLinkConfig?.options || {};
490
- if (optionModel.colorClass) list.push(optionModel.colorClass);
491
- if (optionModel.underline) list.push('underLine');
492
- if (this.field.options.disabled) list.push('is-disabled');
493
- return list
494
- },
495
- handleClick(event) {
496
- if(this.field.options.disabled) return;
497
- this.$parent.handleButtonWidgetClick(event, true)
498
- if (!this.designState && this.field.options.widgetTextLinkConfig?.options.href) {
499
- window.open(this.field.options.widgetTextLinkConfig?.options.href);
500
- }
501
- },
502
- getWidgetValue() {
503
- let fieldModel = this.$parent.fieldModel;
504
- if (this.$parent.fieldModelLabel) fieldModel = this.$parent.fieldModelLabel();
505
- return fieldModel;
506
- }
507
- }
508
- }
509
- </script>
510
-
511
- <style lang="scss" scoped>
512
- @import "~@/styles/global.scss";
513
-
514
- .design-time-bottom-margin {
515
- margin-bottom: 5px;
516
- }
517
-
518
- .field-wrapper {
519
- position: relative;
520
-
521
- .field-action {
522
- position: absolute;
523
- //bottom: -24px;
524
- bottom: 0;
525
- right: -1px;
526
- height: 22px;
527
- line-height: 22px;
528
- background: $--color-primary;
529
- z-index: 9;
530
-
531
- i {
532
- font-size: 14px;
533
- color: #fff;
534
- margin: 0 5px;
535
- cursor: pointer;
536
- }
537
- }
538
-
539
- .drag-handler {
540
- position: absolute;
541
- top: 0;
542
- //bottom: -22px; /* 拖拽手柄位于组件下方,有时无法正常拖动,原因未明?? */
543
- left: -1px;
544
- height: 20px;
545
- line-height: 18px;
546
- //background: $--color-primary;
547
- z-index: 9;
548
-
549
- i {
550
- font-size: 12px;
551
- font-style: normal;
552
- color: #fff;
553
- margin: 4px;
554
- cursor: move;
555
- }
556
-
557
- &:hover {
558
- //opacity: 1;
559
- background: $--color-primary;
560
- }
561
- }
562
- }
563
-
564
- .el-form-item {
565
- //margin-bottom: 0 !important;
566
- //margin-bottom: 6px;
567
-
568
- //margin-top: 2px;
569
- position: relative;
570
-
571
- ::v-deep .el-form-item__label {
572
- white-space: nowrap;
573
- text-overflow: ellipsis;
574
- }
575
-
576
- ::v-deep .el-form-item__content {
577
- //position: unset; /* TODO: 忘了这个样式设置是为了解决什么问题?? */
578
- }
579
-
580
- span.custom-label i {
581
- margin: 0 3px;
582
- }
583
-
584
- /* 隐藏Chrome浏览器中el-input数字输入框右侧的上下调整小箭头 */
585
- ::v-deep .hide-spin-button input::-webkit-outer-spin-button,
586
- ::v-deep .hide-spin-button input::-webkit-inner-spin-button {
587
- -webkit-appearance: none !important;
588
- }
589
-
590
- /* 隐藏Firefox浏览器中el-input数字输入框右侧的上下调整小箭头 */
591
- ::v-deep .hide-spin-button input[type="number"] {
592
- -moz-appearance: textfield;
593
- }
594
- }
595
-
596
- .required ::v-deep .el-form-item__label::before {
597
- content: '*';
598
- color: #F56C6C;
599
- margin-right: 4px;
600
- }
601
-
602
- .static-content-item {
603
- min-height: 20px;
604
- display: flex; /* 垂直居中 */
605
- align-items: center; /* 垂直居中 */
606
-
607
- ::v-deep .el-divider--horizontal {
608
- margin: 0;
609
- }
610
- }
611
-
612
- .el-form-item.selected, .static-content-item.selected {
613
- outline: 2px solid $--color-primary;
614
- }
615
-
616
- ::v-deep .label-left-align .el-form-item__label {
617
- text-align: left;
618
- }
619
-
620
- ::v-deep .label-center-align .el-form-item__label {
621
- text-align: center;
622
- }
623
-
624
- ::v-deep .label-right-align .el-form-item__label {
625
- text-align: right;
626
- }
627
-
628
- .a-link.is-disabled {
629
- cursor: no-drop;
630
- }
631
-
632
- </style>
1
+ <!--
2
+ /**
3
+ * author: vformAdmin
4
+ * email: vdpadmin@163.com
5
+ * website: https://www.vform666.com
6
+ * date: 2021.08.18
7
+ * remark: 如果要分发VForm源码,需在本文件顶部保留此文件头信息!!
8
+ */
9
+ -->
10
+
11
+ <template>
12
+ <div class="field-wrapper" :class="{'design-time-bottom-margin': !!this.designer}"
13
+ v-show="!field.options.hidden || (designState === true)">
14
+ <div>
15
+ <template v-if="formItemProp=='false'">
16
+ <template v-if="!field.options.hidden">
17
+ <template v-if="isShowWidget()">
18
+ <slot></slot>
19
+ </template>
20
+ <template v-else-if="field.options.widgetTextFlag===3 && field.options.widgetTextLinkConfig">
21
+ <div class="ellipsis">
22
+ <a class="a-link" :class="getWidgetClass()" @click.native="handleClick">
23
+ <span>
24
+ <i :class="field.options.widgetTextLinkConfig.options.prefixIcon"
25
+ v-if="!!field.options.widgetTextLinkConfig.options.prefixIcon"></i>
26
+ <span>{{ getWidgetValue() }}</span>
27
+ <i :class="field.options.widgetTextLinkConfig.options.suffixIcon"
28
+ v-if="!!field.options.widgetTextLinkConfig.options.suffixIcon"></i>
29
+ </span>
30
+ </a>
31
+ </div>
32
+ </template>
33
+ <template v-else>
34
+ <span>{{ getShowValue() }}</span>
35
+ </template>
36
+ </template>
37
+ </template>
38
+ <template v-else>
39
+ <el-form-item v-if="!!field.formItemFlag && (!field.options.hidden || (designState === true))"
40
+ :label="label" :label-width="labelWidth"
41
+ :title="field.options.labelTooltip"
42
+ :rules="rules" :prop="getPropName()"
43
+ :class="[selected ? 'selected' : '', labelAlign, customClass, field.options.required ? 'required' : '']"
44
+ @click.native.stop="selectField(field)">
45
+
46
+ <span v-if="!!field.options.labelIconClass" slot="label" class="custom-label"
47
+ :style="{'color':field.options.labelColor}">
48
+ <template v-if="field.options.labelIconPosition === 'front'">
49
+ <template v-if="!!field.options.labelTooltip">
50
+ <el-tooltip :content="field.options.labelTooltip" effect="light">
51
+ <i :class="field.options.labelIconClass"></i></el-tooltip>{{ label }}</template>
52
+ <template v-else>
53
+ <i :class="field.options.labelIconClass"></i>{{ label }}</template>
54
+ </template>
55
+ <template v-else-if="field.options.labelIconPosition === 'rear'">
56
+ <template v-if="!!field.options.labelTooltip">
57
+ {{ label }}<el-tooltip :content="field.options.labelTooltip" effect="light">
58
+ <i :class="field.options.labelIconClass"></i></el-tooltip></template>
59
+ <template v-else>
60
+ {{ label }}<i :class="field.options.labelIconClass"></i></template>
61
+ </template>
62
+ </span>
63
+ <span v-if="!!field.options.labelColor" slot="label" :style="{'color':field.options.labelColor}">
64
+ {{ label }}
65
+ </span>
66
+ <template v-if="isShowWidget()">
67
+ <slot></slot>
68
+ </template>
69
+ <template v-else-if="field.options.widgetTextFlag===3 && field.options.widgetTextLinkConfig">
70
+ <div class="ellipsis">
71
+ <a class="a-link" :class="getWidgetClass()" @click="handleClick">
72
+ <span>
73
+ <i :class="field.options.widgetTextLinkConfig.options.prefixIcon"
74
+ v-if="!!field.options.widgetTextLinkConfig.options.prefixIcon"></i>
75
+ <span>{{ getWidgetValue() }}</span>
76
+ <i :class="field.options.widgetTextLinkConfig.options.suffixIcon"
77
+ v-if="!!field.options.widgetTextLinkConfig.options.suffixIcon"></i>
78
+ </span>
79
+ </a>
80
+ </div>
81
+ </template>
82
+ <template v-else>
83
+ <span>{{ getShowValue() }}</span>
84
+ </template>
85
+ </el-form-item>
86
+ </template>
87
+ </div>
88
+ <template v-if="!!this.designer">
89
+ <div class="field-action" v-if="designer.selectedId === field.id">
90
+ <i class="el-icon-back" :title="i18nt('designer.hint.selectParentWidget')"
91
+ @click.stop="selectParentWidget(field)"></i>
92
+ <i class="el-icon-top" v-if="!!parentList && (parentList.length > 1)"
93
+ :title="i18nt('designer.hint.moveUpWidget')"
94
+ @click.stop="moveUpWidget(field)"></i>
95
+ <i class="el-icon-bottom" v-if="!!parentList && (parentList.length > 1)"
96
+ :title="i18nt('designer.hint.moveDownWidget')"
97
+ @click.stop="moveDownWidget(field)"></i>
98
+ <i class="el-icon-delete" :title="i18nt('designer.hint.remove')" @click.stop="removeFieldWidget"></i>
99
+ </div>
100
+
101
+ <div class="drag-handler background-opacity" v-if="designer.selectedId === field.id">
102
+ <i class="el-icon-rank" :title="i18nt('designer.hint.dragHandler')"></i>
103
+ <i>{{ i18n2t(`designer.widgetLabel.${field.type}`, `extension.widgetLabel.${field.type}`) }}</i>
104
+ <i v-if="field.options.hidden === true" class="iconfont icon-hide"></i>
105
+ </div>
106
+ </template>
107
+ </div>
108
+ </template>
109
+
110
+ <script>
111
+ import i18n from "../../../../../components/xform/utils/i18n";
112
+ import {getSubFormNameByFieldId} from "../../../../../components/xform/utils/util";
113
+
114
+
115
+ export default {
116
+ name: "form-item-wrapper",
117
+ mixins: [i18n],
118
+ props: {
119
+ field: Object,
120
+ designer: Object,
121
+ parentWidget: Object,
122
+ parentList: Array,
123
+ indexOfParentList: Number,
124
+
125
+ designState: {
126
+ type: Boolean,
127
+ default: false
128
+ },
129
+ subFormRowIndex: { /* 子表单组件行索引,从0开始计数 */
130
+ type: Number,
131
+ default: -1
132
+ },
133
+ subFormColIndex: { /* 子表单组件列索引,从0开始计数 */
134
+ type: Number,
135
+ default: -1
136
+ },
137
+ subFormRowId: { /* 子表单组件行Id,唯一id且不可变 */
138
+ type: String,
139
+ default: ''
140
+ },
141
+
142
+ rules: Array,
143
+ },
144
+ inject: ["getFormConfig", "getSubFormFieldFlag", "getSubFormName", "tableParam", "formItemProp", "getObjectFieldFlag", "getObjectName"],
145
+ data(){
146
+ return {
147
+ encryptFormula:null
148
+ }
149
+ },
150
+ computed: {
151
+ formConfig: function () {
152
+ return this.getFormConfig()
153
+ },
154
+ selected() {
155
+ return !!this.designer && this.field.id === this.designer.selectedId
156
+ },
157
+
158
+ label() {
159
+ if (!!this.field.options.labelHidden) {
160
+ return ''
161
+ }
162
+ return this.getI18nLabel(this.field.options.label)
163
+ // let label = this.field.options.label
164
+ // return label ? this.$t2(label) : label;
165
+ },
166
+
167
+ labelWidth() {
168
+ if (!!this.field.options.labelHidden) {
169
+ return !!this.designState ? 5 : 0 //设计期间标签最小宽度5像素,以便于鼠标点击可选中组件!!
170
+ }
171
+
172
+ if (!!this.field.options.labelWidth) {
173
+ return this.field.options.labelWidth + "px !important"
174
+ }
175
+
176
+ if (!!this.designer) {
177
+ return this.designer.formConfig.labelWidth + "px"
178
+ } else {
179
+ return this.formConfig.labelWidth + "px"
180
+ }
181
+ },
182
+
183
+ labelAlign() {
184
+ if (!this?.field?.options?.labelAlign) {
185
+ return ""
186
+ }
187
+ if (!!this.field.options.labelAlign) {
188
+ return this.field.options.labelAlign
189
+ }
190
+
191
+ if (!!this.designer) {
192
+ return this.designer.formConfig.labelAlign || 'label-left-align'
193
+ } else {
194
+ return this.formConfig.labelAlign || 'label-left-align'
195
+ }
196
+ },
197
+
198
+ customClass() {
199
+ return !!this.field.options.customClass ? this.field.options.customClass.join(' ') : ''
200
+ },
201
+
202
+ subFormName() {
203
+ return !!this.parentWidget ? this.parentWidget.options.name : ''
204
+ },
205
+
206
+ subFormItemFlag() {
207
+ return this.isSubFormItem() || (!!this.parentWidget ? this.parentWidget.type === 'sub-form' : false)
208
+ },
209
+
210
+ },
211
+ created() {
212
+ //
213
+ this.initShowType();
214
+ },
215
+ methods: {
216
+ isSubFormItem() {
217
+ return !!this.tableParam;
218
+ },
219
+ selectField(field) {
220
+ if (!!this.designer) {
221
+ this.designer.setSelected(field)
222
+ this.designer.emitEvent('field-selected', this.parentWidget) //发送选中组件的父组件对象
223
+ }
224
+ },
225
+
226
+ selectParentWidget() {
227
+ if (this.parentWidget) {
228
+ this.designer.setSelected(this.parentWidget)
229
+ } else {
230
+ this.designer.clearSelected()
231
+ }
232
+ },
233
+
234
+ moveUpWidget() {
235
+ this.designer.moveUpWidget(this.parentList, this.indexOfParentList)
236
+ this.designer.emitHistoryChange()
237
+ },
238
+
239
+ moveDownWidget() {
240
+ this.designer.moveDownWidget(this.parentList, this.indexOfParentList)
241
+ this.designer.emitHistoryChange()
242
+ },
243
+
244
+ removeFieldWidget() {
245
+ if (!!this.parentList) {
246
+ const selectedWidgetName = this.designer.selectedWidgetName;
247
+ let selectedId = this.designer.selectedId;
248
+ let nextSelected = null
249
+ if (this.parentList.length === 1) {
250
+ if (!!this.parentWidget) {
251
+ nextSelected = this.parentWidget
252
+ }
253
+ } else if (this.parentList.length === (1 + this.indexOfParentList)) {
254
+ nextSelected = this.parentList[this.indexOfParentList - 1]
255
+ } else {
256
+ nextSelected = this.parentList[this.indexOfParentList + 1]
257
+ }
258
+
259
+ this.$nextTick(() => {
260
+ const l = getSubFormNameByFieldId(
261
+ this.designer.widgetList,
262
+ selectedId
263
+ );
264
+ this.parentList.splice(this.indexOfParentList, 1)
265
+ //if (!!nextSelected) {
266
+ this.designer.setSelected(nextSelected)
267
+ //}
268
+ this.designer.formWidget.deleteWidgetRef(
269
+ selectedWidgetName,
270
+ l
271
+ );
272
+ this.designer.emitHistoryChange()
273
+ this.designer.emitEvent(
274
+ "canvas-remove-field",
275
+ selectedWidgetName
276
+ );
277
+ })
278
+ }
279
+ },
280
+
281
+ getPropName() {
282
+ if (this.formItemProp) {
283
+ return this.formItemProp;
284
+ }
285
+ let o = this.field.options.name;
286
+ return (
287
+ (o
288
+ = (this.field.options.keyNameEnabled
289
+ && this.field.options.keyName)
290
+ || o),
291
+ this.subFormItemFlag && !this.designState
292
+ ? this.subFormName
293
+ + "."
294
+ + this.subFormRowIndex
295
+ + "."
296
+ + o
297
+ : this.getObjectFieldFlag() && !this.designState
298
+ ? this.getObjectName() + "." + o
299
+ : o
300
+ );
301
+ },
302
+ getI18nLabel(label, path, param) {
303
+ return !this.designState && label ? this.$t2(label, path, param) : label;
304
+ },
305
+ getProcessText(text,pattern) {
306
+
307
+ if (pattern == '' || pattern === null || pattern === undefined) {
308
+ return text;
309
+ }
310
+
311
+ let result = '';
312
+
313
+ // 处理固定模式
314
+ if (pattern === '-') {
315
+ result = '-';
316
+ }
317
+ else if (pattern === '*') {
318
+ result = '*****';
319
+ }
320
+ // 处理自定义模式
321
+ else if (pattern.includes('*')) {
322
+ text = text ?? ""
323
+ const parts = pattern.split('*');
324
+
325
+ // 处理 A*B 模式
326
+ if (parts.length === 2 && parts[0] && parts[1]) {
327
+ const a = parseInt(parts[0]);
328
+ const b = parseInt(parts[1]);
329
+
330
+ if (!isNaN(a) && !isNaN(b) && a >= 0 && b >= 0) {
331
+ if (text.length >= a + b) {
332
+ const prefix = text.substring(0, a);
333
+ const suffix = text.substring(text.length - b);
334
+ const stars = '*'.repeat(text.length - a - b);
335
+ result = prefix + stars + suffix;
336
+ } else {
337
+ result = '*****';
338
+ }
339
+ } else {
340
+ // result = '无效模式:A和B必须是数字';
341
+ result = text;
342
+ }
343
+ }
344
+ // 处理 A* 模式
345
+ else if (parts.length === 2 && parts[0] && !parts[1]) {
346
+ const a = parseInt(parts[0]);
347
+
348
+ if (!isNaN(a) && a >= 0) {
349
+ if (text.length >= a) {
350
+ const prefix = text.substring(0, a);
351
+ const stars = '*'.repeat(text.length - a);
352
+ result = prefix + stars;
353
+ } else {
354
+ result = '*****';
355
+ }
356
+ } else {
357
+ // result = '无效模式:A必须是数字';
358
+ result = text;
359
+ }
360
+ }
361
+ // 处理 *B 模式
362
+ else if (parts.length === 2 && !parts[0] && parts[1]) {
363
+ const b = parseInt(parts[1]);
364
+
365
+ if (!isNaN(b) && b >= 0) {
366
+ if (text.length >= b) {
367
+ const suffix = text.substring(text.length - b);
368
+ const stars = '*'.repeat(text.length - b);
369
+ result = stars + suffix;
370
+ } else {
371
+ result = '*****';
372
+ }
373
+ } else {
374
+ // result = '无效模式:B必须是数字';
375
+ result = text;
376
+ }
377
+ }
378
+ // 处理无效模式
379
+ else {
380
+ result = '*****';
381
+ }
382
+ }
383
+ // 处理其他无效模式
384
+ else {
385
+ result = '*****';
386
+ }
387
+
388
+ return result;
389
+ },
390
+ initShowType() {
391
+ if (!!this.designer) return
392
+ let that = this.$parent
393
+ let formRef = that.getFormRef ? that.getFormRef() : that;
394
+
395
+ if(!formRef)return
396
+ //详情页,新增页面不加密
397
+ let fJson = formRef.formJson;
398
+ let formConfig = fJson.formConfig;
399
+ if (formConfig.isLoadEntity && !formRef.dataId) return
400
+
401
+ let bdService = formRef.bdService;
402
+ let companyCode = this.$store.getters.companyCode;
403
+ let loginAccount = this.$store.getters.loginAccount;
404
+
405
+ let userSaleOrgDTOs = formRef.userSaleOrgDTOs;
406
+ let userRoleDTOs = formRef.userRoleDTOs;
407
+
408
+ let saleOrgCodeList = userSaleOrgDTOs.map(item => item.sn);
409
+ let roleCodeList = userRoleDTOs.map(item => item.roleCode);
410
+
411
+ let optionModel = this.field.options;
412
+
413
+ let flag = 0;//0 原本组件,1明文文本,2密文文本
414
+ /*if (optionModel.showTextEnabled) {
415
+ flag = 1;
416
+ } else if (optionModel.showEncryptTextEnabled) {
417
+ flag = 2;
418
+ } else if (optionModel.showLinkTextEnabled) {
419
+ flag = 3;
420
+ }*/
421
+ if (optionModel.userTextRuleEnabled) {
422
+ let userTextRuleConfig = optionModel.userTextRuleConfig || [];
423
+ userTextRuleConfig.forEach(item => {
424
+ let type = item.type ?? null;
425
+ if (type !== null && type !== "") {
426
+ let companyCodeStr = item.companyCodes;
427
+ let companyCodes = companyCodeStr ? companyCodeStr.split(",").filter(item => !!item) : [];
428
+ /*
429
+
430
+ let loginAccountStr = item.loginAccounts;
431
+ let loginAccounts = loginAccountStr ? loginAccountStr.split(",").filter(item => !!item) : [];
432
+
433
+ let saleOrgCodeStr = item.saleOrgCodes;
434
+ let saleOrgCodes = saleOrgCodeStr ? saleOrgCodeStr.split(",").filter(item => !!item) : [];
435
+ */
436
+
437
+ let roleCodeStr = item.roleCodes;
438
+ let roleCodes = roleCodeStr ? roleCodeStr.split(",").filter(item => !!item) : [];
439
+
440
+ let flag1 = !item.serveName || item.serveName == bdService;
441
+ let flag2 = !companyCodes.length || companyCodes.includes(companyCode)
442
+ // let flag3 = !loginAccounts.length || loginAccounts.includes(loginAccount)
443
+ // let flag4 = this.compareToList(saleOrgCodes, saleOrgCodeList)
444
+ if(flag1 && flag2){
445
+ this.encryptFormula = item.encryptFormula
446
+ let flag5 = this.compareToList(roleCodes, roleCodeList)
447
+ if(flag5){
448
+ //匹配角色
449
+ if(type == 2)flag = 2//type=2时加密
450
+ }else {
451
+ //角色不匹配
452
+ if(type == 1)flag = 2
453
+ }
454
+ }
455
+ }
456
+ })
457
+ }
458
+ this.field.options.widgetTextFlag = flag
459
+ // this.showType = flag;
460
+ },
461
+ compareToList(list1, list2) {
462
+ if (!list1.length) {
463
+ return true;
464
+ }
465
+ if (!list2.length) {
466
+ return false;
467
+ }
468
+ return list1.some(item => {
469
+ return list2.some(item2 => item == item2)
470
+ });
471
+ },
472
+ isShowWidget() {
473
+ let widgetTextFlag = this.field.options.widgetTextFlag;
474
+ return widgetTextFlag === undefined || widgetTextFlag === null || widgetTextFlag === 0
475
+ },
476
+ getShowValue() {
477
+ let widgetTextFlag = this.field.options.widgetTextFlag;
478
+ let fieldModel = this.$parent.fieldModel;
479
+ if (this.$parent.fieldModelLabel) fieldModel = this.$parent.fieldModelLabel();
480
+ let showValue = fieldModel
481
+ if (widgetTextFlag == 2) {
482
+ showValue = this.getProcessText(showValue,this.encryptFormula)
483
+ }
484
+
485
+ return showValue;
486
+ },
487
+ getWidgetClass() {
488
+ let list = [];
489
+ let optionModel = this.field.options.widgetTextLinkConfig?.options || {};
490
+ if (optionModel.colorClass) list.push(optionModel.colorClass);
491
+ if (optionModel.underline) list.push('underLine');
492
+ if (this.field.options.disabled) list.push('is-disabled');
493
+ return list
494
+ },
495
+ handleClick(event) {
496
+ if(this.field.options.disabled) return;
497
+ this.$parent.handleButtonWidgetClick(event, true)
498
+ if (!this.designState && this.field.options.widgetTextLinkConfig?.options.href) {
499
+ window.open(this.field.options.widgetTextLinkConfig?.options.href);
500
+ }
501
+ },
502
+ getWidgetValue() {
503
+ let fieldModel = this.$parent.fieldModel;
504
+ if (this.$parent.fieldModelLabel) fieldModel = this.$parent.fieldModelLabel();
505
+ return fieldModel;
506
+ }
507
+ }
508
+ }
509
+ </script>
510
+
511
+ <style lang="scss" scoped>
512
+ @import "~@/styles/global.scss";
513
+
514
+ .design-time-bottom-margin {
515
+ margin-bottom: 5px;
516
+ }
517
+
518
+ .field-wrapper {
519
+ position: relative;
520
+
521
+ .field-action {
522
+ position: absolute;
523
+ //bottom: -24px;
524
+ bottom: 0;
525
+ right: -1px;
526
+ height: 22px;
527
+ line-height: 22px;
528
+ background: $--color-primary;
529
+ z-index: 9;
530
+
531
+ i {
532
+ font-size: 14px;
533
+ color: #fff;
534
+ margin: 0 5px;
535
+ cursor: pointer;
536
+ }
537
+ }
538
+
539
+ .drag-handler {
540
+ position: absolute;
541
+ top: 0;
542
+ //bottom: -22px; /* 拖拽手柄位于组件下方,有时无法正常拖动,原因未明?? */
543
+ left: -1px;
544
+ height: 20px;
545
+ line-height: 18px;
546
+ //background: $--color-primary;
547
+ z-index: 9;
548
+
549
+ i {
550
+ font-size: 12px;
551
+ font-style: normal;
552
+ color: #fff;
553
+ margin: 4px;
554
+ cursor: move;
555
+ }
556
+
557
+ &:hover {
558
+ //opacity: 1;
559
+ background: $--color-primary;
560
+ }
561
+ }
562
+ }
563
+
564
+ .el-form-item {
565
+ //margin-bottom: 0 !important;
566
+ //margin-bottom: 6px;
567
+
568
+ //margin-top: 2px;
569
+ position: relative;
570
+
571
+ ::v-deep .el-form-item__label {
572
+ white-space: nowrap;
573
+ text-overflow: ellipsis;
574
+ }
575
+
576
+ ::v-deep .el-form-item__content {
577
+ //position: unset; /* TODO: 忘了这个样式设置是为了解决什么问题?? */
578
+ }
579
+
580
+ span.custom-label i {
581
+ margin: 0 3px;
582
+ }
583
+
584
+ /* 隐藏Chrome浏览器中el-input数字输入框右侧的上下调整小箭头 */
585
+ ::v-deep .hide-spin-button input::-webkit-outer-spin-button,
586
+ ::v-deep .hide-spin-button input::-webkit-inner-spin-button {
587
+ -webkit-appearance: none !important;
588
+ }
589
+
590
+ /* 隐藏Firefox浏览器中el-input数字输入框右侧的上下调整小箭头 */
591
+ ::v-deep .hide-spin-button input[type="number"] {
592
+ -moz-appearance: textfield;
593
+ }
594
+ }
595
+
596
+ .required ::v-deep .el-form-item__label::before {
597
+ content: '*';
598
+ color: #F56C6C;
599
+ margin-right: 4px;
600
+ }
601
+
602
+ .static-content-item {
603
+ min-height: 20px;
604
+ display: flex; /* 垂直居中 */
605
+ align-items: center; /* 垂直居中 */
606
+
607
+ ::v-deep .el-divider--horizontal {
608
+ margin: 0;
609
+ }
610
+ }
611
+
612
+ .el-form-item.selected, .static-content-item.selected {
613
+ outline: 2px solid $--color-primary;
614
+ }
615
+
616
+ ::v-deep .label-left-align .el-form-item__label {
617
+ text-align: left;
618
+ }
619
+
620
+ ::v-deep .label-center-align .el-form-item__label {
621
+ text-align: center;
622
+ }
623
+
624
+ ::v-deep .label-right-align .el-form-item__label {
625
+ text-align: right;
626
+ }
627
+
628
+ .a-link.is-disabled {
629
+ cursor: no-drop;
630
+ }
631
+
632
+ </style>