dengzedong
5 天以前 3357b5f0f0919f7a52cd32a6d6de0acb14e0daaf
提交 | 用户 | 时间
3e359e 1 <template>
H 2   <el-drawer
3     :append-to-body="true"
4     v-model="settingVisible"
5     :show-close="false"
6     :size="550"
7     :before-close="saveConfig"
8   >
9     <template #header>
10       <div class="config-header">
11         <input
12           v-if="showInput"
13           type="text"
14           class="config-editable-input"
15           @blur="blurEvent()"
16           v-mountedFocus
17           v-model="nodeName"
18           :placeholder="nodeName"
19         />
20         <div v-else class="node-name">
21           {{ nodeName }} <Icon class="ml-1" icon="ep:edit-pen" :size="16" @click="clickIcon()" />
22         </div>
23         <div class="divide-line"></div>
24       </div>
25     </template>
26     <el-tabs type="border-card" v-model="activeTabName">
27       <el-tab-pane label="权限" name="user">
28         <div> 待实现 </div>
29       </el-tab-pane>
30       <el-tab-pane label="表单字段权限" name="fields" v-if="formType === 10">
31         <div class="field-setting-pane">
32           <div class="field-setting-desc">字段权限</div>
33           <div class="field-permit-title">
34             <div class="setting-title-label first-title"> 字段名称 </div>
35             <div class="other-titles">
36               <span class="setting-title-label">只读</span>
37               <span class="setting-title-label">可编辑</span>
38               <span class="setting-title-label">隐藏</span>
39             </div>
40           </div>
41           <div
42             class="field-setting-item"
43             v-for="(item, index) in fieldsPermissionConfig"
44             :key="index"
45           >
46             <div class="field-setting-item-label"> {{ item.title }} </div>
47             <el-radio-group class="field-setting-item-group" v-model="item.permission">
48               <div class="item-radio-wrap">
49                 <el-radio
50                   :value="FieldPermissionType.READ"
51                   size="large"
52                   :label="FieldPermissionType.READ"
53                   ><span></span
54                 ></el-radio>
55               </div>
56               <div class="item-radio-wrap">
57                 <el-radio
58                   :value="FieldPermissionType.WRITE"
59                   size="large"
60                   :label="FieldPermissionType.WRITE"
61                   ><span></span
62                 ></el-radio>
63               </div>
64               <div class="item-radio-wrap">
65                 <el-radio
66                   :value="FieldPermissionType.NONE"
67                   size="large"
68                   :label="FieldPermissionType.NONE"
69                   ><span></span
70                 ></el-radio>
71               </div>
72             </el-radio-group>
73           </div>
74         </div>
75       </el-tab-pane>
76     </el-tabs>
77     <template #footer>
78       <el-divider />
79       <div>
80         <el-button type="primary" @click="saveConfig">确 定</el-button>
81         <el-button @click="closeDrawer">取 消</el-button>
82       </div>
83     </template>
84   </el-drawer>
85 </template>
86 <script setup lang="ts">
87 import { SimpleFlowNode, NodeType, FieldPermissionType, START_USER_BUTTON_SETTING } from '../consts'
88 import { useWatchNode, useDrawer, useNodeName, useFormFieldsPermission } from '../node'
89
90 defineOptions({
91   name: 'StartUserNodeConfig'
92 })
93 const props = defineProps({
94   flowNode: {
95     type: Object as () => SimpleFlowNode,
96     required: true
97   }
98 })
99 // 抽屉配置
100 const { settingVisible, closeDrawer, openDrawer } = useDrawer()
101 // 当前节点
102 const currentNode = useWatchNode(props)
103 // 节点名称
104 const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(NodeType.COPY_TASK_NODE)
105 // 激活的 Tab 标签页
106 const activeTabName = ref('user')
107 // 表单字段权限配置
108 const { formType, fieldsPermissionConfig, getNodeConfigFormFields } = useFormFieldsPermission(
109   FieldPermissionType.WRITE
110 )
111
112 // 保存配置
113 const saveConfig = async () => {
114   activeTabName.value = 'user'
115   currentNode.value.name = nodeName.value!
116   // TODO 暂时写死。后续可以显示谁有权限可以发起
117   currentNode.value.showText = '已设置'
118   // 设置表单权限
119   currentNode.value.fieldsPermission = fieldsPermissionConfig.value
120   // 设置发起人的按钮权限
121   currentNode.value.buttonsSetting = START_USER_BUTTON_SETTING
122   settingVisible.value = false
123   return true
124 }
125 // 显示发起人节点配置, 由父组件传过来
126 const showStartUserNodeConfig = (node: SimpleFlowNode) => {
127   nodeName.value = node.name
128   // 表单字段权限
129   getNodeConfigFormFields(node.fieldsPermission)
130 }
131
132 defineExpose({ openDrawer, showStartUserNodeConfig }) // 暴露方法给父组件
133 </script>
134
135 <style lang="scss" scoped></style>