3
3
2. 审批人拒绝时
4
4
3. 审批人为空时
5
5
4. 操作按钮
6
+ 5. 字段权限
6
7
-->
7
8
<template >
8
9
<div class =" panel-tab__content" >
104
105
</div >
105
106
</div >
106
107
</div >
108
+
109
+ <el-divider content-position =" left" >字段权限</el-divider >
110
+ <div class =" field-setting-pane" v-if =" formType === 10" >
111
+ <div class =" field-permit-title" >
112
+ <div class =" setting-title-label first-title" > 字段名称 </div >
113
+ <div class =" other-titles" >
114
+ <span class =" setting-title-label" >只读</span >
115
+ <span class =" setting-title-label" >可编辑</span >
116
+ <span class =" setting-title-label" >隐藏</span >
117
+ </div >
118
+ </div >
119
+ <div class =" field-setting-item" v-for =" (item, index) in fieldsPermissionEl" :key =" index" >
120
+ <div class =" field-setting-item-label" > {{ item.title }} </div >
121
+ <el-radio-group class =" field-setting-item-group" v-model =" item.permission" >
122
+ <div class =" item-radio-wrap" >
123
+ <el-radio
124
+ :value =" FieldPermissionType.READ"
125
+ size =" large"
126
+ :label =" FieldPermissionType.READ"
127
+ ><span ></span
128
+ ></el-radio >
129
+ </div >
130
+ <div class =" item-radio-wrap" >
131
+ <el-radio
132
+ :value =" FieldPermissionType.WRITE"
133
+ size =" large"
134
+ :label =" FieldPermissionType.WRITE"
135
+ ><span ></span
136
+ ></el-radio >
137
+ </div >
138
+ <div class =" item-radio-wrap" >
139
+ <el-radio
140
+ :value =" FieldPermissionType.NONE"
141
+ size =" large"
142
+ :label =" FieldPermissionType.NONE"
143
+ ><span ></span
144
+ ></el-radio >
145
+ </div >
146
+ </el-radio-group >
147
+ </div >
148
+ </div >
107
149
</div >
108
150
</template >
109
151
@@ -115,9 +157,11 @@ import {
115
157
ASSIGN_EMPTY_HANDLER_TYPES ,
116
158
AssignEmptyHandlerType ,
117
159
OPERATION_BUTTON_NAME ,
118
- DEFAULT_BUTTON_SETTING
160
+ DEFAULT_BUTTON_SETTING ,
161
+ FieldPermissionType
119
162
} from ' @/components/SimpleProcessDesignerV2/src/consts'
120
163
import * as UserApi from ' @/api/system/user'
164
+ import { cloneDeep } from ' lodash-es'
121
165
122
166
defineOptions ({ name: ' ElementCustomConfig' })
123
167
const props = defineProps ({
@@ -148,6 +192,12 @@ const buttonsSettingEl = ref()
148
192
const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
149
193
useButtonsSetting ()
150
194
195
+ // 字段权限
196
+ const fieldsPermissionEl = ref ()
197
+ const { formType, fieldsPermissionConfig, getNodeConfigFormFields } = useFormFieldsPermission (
198
+ FieldPermissionType .READ
199
+ )
200
+
151
201
const elExtensionElements = ref ()
152
202
const otherExtensions = ref ()
153
203
const bpmnElement = ref ()
@@ -218,6 +268,21 @@ const resetCustomConfigList = () => {
218
268
})
219
269
}
220
270
271
+ // 字段权限
272
+ if (formType .value === 10 ) {
273
+ fieldsPermissionEl .value = elExtensionElements .value .values ?.filter (
274
+ (ex ) => ex .$type === ` ${prefix }:FieldsPermission `
275
+ )
276
+ if (fieldsPermissionEl .value .length === 0 ) {
277
+ getNodeConfigFormFields ()
278
+ fieldsPermissionConfig .value .forEach ((el ) => {
279
+ fieldsPermissionEl .value .push (
280
+ bpmnInstances ().moddle .create (` ${prefix }:FieldsPermission ` , el )
281
+ )
282
+ })
283
+ }
284
+ }
285
+
221
286
// 保留剩余扩展元素,便于后面更新该元素对应属性
222
287
otherExtensions .value =
223
288
elExtensionElements .value .values ?.filter (
@@ -227,7 +292,8 @@ const resetCustomConfigList = () => {
227
292
ex .$type !== ` ${prefix }:RejectReturnTaskId ` &&
228
293
ex .$type !== ` ${prefix }:AssignEmptyHandlerType ` &&
229
294
ex .$type !== ` ${prefix }:AssignEmptyUserIds ` &&
230
- ex .$type !== ` ${prefix }:ButtonsSetting `
295
+ ex .$type !== ` ${prefix }:ButtonsSetting ` &&
296
+ ex .$type !== ` ${prefix }:FieldsPermission `
231
297
) ?? []
232
298
233
299
// 更新元素扩展属性,避免后续报错
@@ -276,7 +342,8 @@ const updateElementExtensions = () => {
276
342
returnNodeIdEl .value ,
277
343
assignEmptyHandlerTypeEl .value ,
278
344
assignEmptyUserIdsEl .value ,
279
- ... buttonsSettingEl .value
345
+ ... buttonsSettingEl .value ,
346
+ ... fieldsPermissionEl .value
280
347
]
281
348
})
282
349
bpmnInstances ().modeling .updateProperties (toRaw (bpmnElement .value ), {
@@ -359,6 +426,69 @@ function useButtonsSetting() {
359
426
}
360
427
}
361
428
429
+ // 表单字段权限设置
430
+ function useFormFieldsPermission(defaultPermission ) {
431
+ // 字段权限配置. 需要有 field, title, permissioin 属性
432
+ const fieldsPermissionConfig = ref <Array <Record <string , string >>>([])
433
+
434
+ const formType = inject <Ref <number >>(' formType' ) // 表单类型
435
+
436
+ const formFields = inject <Ref <string []>>(' formFields' ) // 流程表单字段
437
+
438
+ const getNodeConfigFormFields = (nodeFormFields ? : Array <Record <string , string >>) => {
439
+ nodeFormFields = toRaw (nodeFormFields )
440
+ fieldsPermissionConfig .value =
441
+ cloneDeep (nodeFormFields ) || getDefaultFieldsPermission (unref (formFields ))
442
+ }
443
+ // 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读
444
+ const getDefaultFieldsPermission = (formFields ? : string []) => {
445
+ const defaultFieldsPermission: Array <Record <string , string >> = []
446
+ if (formFields ) {
447
+ formFields .forEach ((fieldStr : string ) => {
448
+ parseFieldsSetDefaultPermission (JSON .parse (fieldStr ), defaultFieldsPermission )
449
+ })
450
+ }
451
+ return defaultFieldsPermission
452
+ }
453
+ // 解析字段。赋给默认权限
454
+ const parseFieldsSetDefaultPermission = (
455
+ rule : Record <string , any >,
456
+ fieldsPermission : Array <Record <string , string >>,
457
+ parentTitle : string = ' '
458
+ ) => {
459
+ const { /** type,*/ field, title : tempTitle, children } = rule
460
+ if (field && tempTitle ) {
461
+ let title = tempTitle
462
+ if (parentTitle ) {
463
+ title = ` ${parentTitle }.${tempTitle } `
464
+ }
465
+ fieldsPermission .push ({
466
+ field ,
467
+ title ,
468
+ permission: defaultPermission
469
+ })
470
+ // TODO 子表单 需要处理子表单字段
471
+ // if (type === 'group' && rule.props?.rule && Array.isArray(rule.props.rule)) {
472
+ // // 解析子表单的字段
473
+ // rule.props.rule.forEach((item) => {
474
+ // parseFieldsSetDefaultPermission(item, fieldsPermission, title)
475
+ // })
476
+ // }
477
+ }
478
+ if (children && Array .isArray (children )) {
479
+ children .forEach ((rule ) => {
480
+ parseFieldsSetDefaultPermission (rule , fieldsPermission )
481
+ })
482
+ }
483
+ }
484
+
485
+ return {
486
+ formType ,
487
+ fieldsPermissionConfig ,
488
+ getNodeConfigFormFields
489
+ }
490
+ }
491
+
362
492
const userOptions = ref <UserApi .UserVO []>([]) // 用户列表
363
493
onMounted (async () => {
364
494
// 获得用户列表
@@ -449,4 +579,78 @@ onMounted(async () => {
449
579
}
450
580
}
451
581
}
582
+
583
+ .field-setting-pane {
584
+ display : flex ;
585
+ flex-direction : column ;
586
+ font-size : 14px ;
587
+
588
+ .field-setting-desc {
589
+ padding-right : 8px ;
590
+ margin-bottom : 16px ;
591
+ font-size : 16px ;
592
+ font-weight : 700 ;
593
+ }
594
+
595
+ .field-permit-title {
596
+ display : flex ;
597
+ justify-content : space-between ;
598
+ align-items : center ;
599
+ height : 45px ;
600
+ padding-left : 12px ;
601
+ line-height : 45px ;
602
+ background-color : #f8fafc0a ;
603
+ border : 1px solid #1f38581a ;
604
+
605
+ .first-title {
606
+ text-align : left !important ;
607
+ }
608
+
609
+ .other-titles {
610
+ display : flex ;
611
+ justify-content : space-between ;
612
+ }
613
+
614
+ .setting-title-label {
615
+ display : inline-block ;
616
+ width : 100px ;
617
+ padding : 5px 0 ;
618
+ font-size : 13px ;
619
+ font-weight : 700 ;
620
+ color : #000 ;
621
+ text-align : center ;
622
+ }
623
+ }
624
+
625
+ .field-setting-item {
626
+ align-items : center ;
627
+ display : flex ;
628
+ justify-content : space-between ;
629
+ height : 38px ;
630
+ padding-left : 12px ;
631
+ border : 1px solid #1f38581a ;
632
+ border-top : 0 ;
633
+
634
+ .field-setting-item-label {
635
+ display : inline-block ;
636
+ width : 100px ;
637
+ min-height : 16px ;
638
+ overflow : hidden ;
639
+ text-overflow : ellipsis ;
640
+ white-space : nowrap ;
641
+ cursor : text ;
642
+ }
643
+
644
+ .field-setting-item-group {
645
+ display : flex ;
646
+ justify-content : space-between ;
647
+
648
+ .item-radio-wrap {
649
+ display : inline-block ;
650
+ width : 100px ;
651
+ text-align : center ;
652
+ }
653
+ }
654
+ }
655
+ }
452
656
</style >
0 commit comments