@@ -175,10 +175,11 @@ import {
175
175
DEFAULT_BUTTON_SETTING ,
176
176
FieldPermissionType ,
177
177
APPROVE_TYPE ,
178
- ApproveType
178
+ ApproveType ,
179
+ ButtonSetting
179
180
} from ' @/components/SimpleProcessDesignerV2/src/consts'
180
181
import * as UserApi from ' @/api/system/user'
181
- import { cloneDeep } from ' lodash-es '
182
+ import { useFormFieldsPermission } from ' @/components/SimpleProcessDesignerV2/src/node '
182
183
183
184
defineOptions ({ name: ' ElementCustomConfig4UserTask' })
184
185
const props = defineProps ({
@@ -206,8 +207,7 @@ const assignEmptyUserIds = ref()
206
207
207
208
// 操作按钮
208
209
const buttonsSettingEl = ref ()
209
- const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
210
- useButtonsSetting ()
210
+ const { btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } = useButtonsSetting ()
211
211
212
212
// 字段权限
213
213
const fieldsPermissionEl = ref ([])
@@ -300,6 +300,8 @@ const resetCustomConfigList = () => {
300
300
)
301
301
fieldsPermissionEl .value = []
302
302
getNodeConfigFormFields ()
303
+ // 由于默认添加了发起人元素,这里需要删掉
304
+ fieldsPermissionConfig .value = fieldsPermissionConfig .value .slice (1 )
303
305
fieldsPermissionConfig .value .forEach ((element ) => {
304
306
element .permission =
305
307
fieldsPermissionList ?.find ((obj ) => obj .field === element .field )?.permission ?? ' 1'
@@ -454,69 +456,6 @@ function useButtonsSetting() {
454
456
}
455
457
}
456
458
457
- // 表单字段权限设置
458
- function useFormFieldsPermission(defaultPermission ) {
459
- // 字段权限配置. 需要有 field, title, permissioin 属性
460
- const fieldsPermissionConfig = ref <Array <Record <string , string >>>([])
461
-
462
- const formType = inject <Ref <number >>(' formType' ) // 表单类型
463
-
464
- const formFields = inject <Ref <string []>>(' formFields' ) // 流程表单字段
465
-
466
- const getNodeConfigFormFields = (nodeFormFields ? : Array <Record <string , string >>) => {
467
- nodeFormFields = toRaw (nodeFormFields )
468
- fieldsPermissionConfig .value =
469
- cloneDeep (nodeFormFields ) || getDefaultFieldsPermission (unref (formFields ))
470
- }
471
- // 默认的表单权限: 获取表单的所有字段,设置字段默认权限为只读
472
- const getDefaultFieldsPermission = (formFields ? : string []) => {
473
- const defaultFieldsPermission: Array <Record <string , string >> = []
474
- if (formFields ) {
475
- formFields .forEach ((fieldStr : string ) => {
476
- parseFieldsSetDefaultPermission (JSON .parse (fieldStr ), defaultFieldsPermission )
477
- })
478
- }
479
- return defaultFieldsPermission
480
- }
481
- // 解析字段。赋给默认权限
482
- const parseFieldsSetDefaultPermission = (
483
- rule : Record <string , any >,
484
- fieldsPermission : Array <Record <string , string >>,
485
- parentTitle : string = ' '
486
- ) => {
487
- const { /** type,*/ field, title : tempTitle, children } = rule
488
- if (field && tempTitle ) {
489
- let title = tempTitle
490
- if (parentTitle ) {
491
- title = ` ${parentTitle }.${tempTitle } `
492
- }
493
- fieldsPermission .push ({
494
- field ,
495
- title ,
496
- permission: defaultPermission
497
- })
498
- // TODO 子表单 需要处理子表单字段
499
- // if (type === 'group' && rule.props?.rule && Array.isArray(rule.props.rule)) {
500
- // // 解析子表单的字段
501
- // rule.props.rule.forEach((item) => {
502
- // parseFieldsSetDefaultPermission(item, fieldsPermission, title)
503
- // })
504
- // }
505
- }
506
- if (children && Array .isArray (children )) {
507
- children .forEach ((rule ) => {
508
- parseFieldsSetDefaultPermission (rule , fieldsPermission )
509
- })
510
- }
511
- }
512
-
513
- return {
514
- formType ,
515
- fieldsPermissionConfig ,
516
- getNodeConfigFormFields
517
- }
518
- }
519
-
520
459
const userOptions = ref <UserApi .UserVO []>([]) // 用户列表
521
460
onMounted (async () => {
522
461
// 获得用户列表
0 commit comments