| | |
| | | |
| | | import { ref, watch } from 'vue'; |
| | | |
| | | import { useVbenModal } from '../../../../../packages/effects/common-ui/src'; |
| | | import { DICT_TYPE } from '../../../../../packages/constants/src'; |
| | | import { getDictOptions } from '../../../../../packages/effects/hooks/src'; |
| | | import { IconifyIcon } from '../../../../../packages/icons/src'; |
| | | import { useVbenModal } from '@vben/common-ui'; |
| | | import { DICT_TYPE } from '@vben/constants'; |
| | | import { getDictOptions } from '@vben/hooks'; |
| | | import { IconifyIcon } from '@vben/icons'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | |
| | | import { |
| | | Avatar, |
| | |
| | | |
| | | const formRef = ref(); // 表单引用 |
| | | const modelData = defineModel<any>(); // 创建本地数据副本 |
| | | const userStore = useUserStore(); // 当前登录用户(写入流程管理员,避免换账号后无法再修改模型) |
| | | |
| | | const selectedStartUsers = ref<SystemUserApi.User[]>([]); // 选中的发起人 |
| | | const selectedStartDepts = ref<SystemDeptApi.Dept[]>([]); // 选中的发起部门 |
| | |
| | | newVal.managerUserIds.includes(user.id), |
| | | ) as SystemUserApi.User[]) |
| | | : []; |
| | | // 流程管理员固定为超级管理员:进入页面即强制回写,修改场景同样生效。 |
| | | // 注意:同时把「当前操作人」一并写入。因为后端 updateModel 是「先校验管理员、后写入」, |
| | | // 一旦模型被保存成只包含超管,用其他账号再次修改就会报 |
| | | // 「操作流程失败,原因:你不是该流程(xxx)的管理员」,且无法自愈。 |
| | | const admin = props.userList.find( |
| | | (user: SystemUserApi.User) => user.username === 'admin', |
| | | ); |
| | | const currentUserId = userStore.userInfo?.id; |
| | | const managerIds: number[] = []; |
| | | if (admin) { |
| | | managerIds.push(admin.id); |
| | | } |
| | | if (currentUserId && !managerIds.includes(currentUserId)) { |
| | | managerIds.push(currentUserId); |
| | | } |
| | | if (managerIds.length > 0) { |
| | | newVal.managerUserIds = managerIds; |
| | | // 界面上仍然只展示「超级管理员」 |
| | | const displayUser = |
| | | admin ?? props.userList.find((user) => user.id === managerIds[0]); |
| | | selectedManagerUsers.value = displayUser ? [displayUser] : []; |
| | | } |
| | | }, |
| | | { |
| | | immediate: true, |
| | |
| | | </div> |
| | | </Form.Item> |
| | | <Form.Item label="流程管理员" name="managerUserIds"> |
| | | <div class="flex flex-wrap gap-1"> |
| | | <div |
| | | v-for="user in selectedManagerUsers" |
| | | :key="user.id" |
| | | class="relative flex h-9 items-center rounded-full bg-gray-100 pr-2 hover:bg-gray-200 dark:border dark:border-gray-500 dark:bg-gray-700 dark:hover:bg-gray-600" |
| | | > |
| | | <Avatar class="m-1 size-7" v-if="user.avatar" :src="user.avatar" /> |
| | | <Avatar class="m-1 size-7" v-else> |
| | | {{ user.nickname?.substring(0, 1) }} |
| | | </Avatar> |
| | | <span class="text-gray-700 dark:text-gray-200"> |
| | | {{ user.nickname }} |
| | | </span> |
| | | <IconifyIcon |
| | | icon="lucide:x" |
| | | class="ml-2 size-4 cursor-pointer text-gray-400 hover:text-red-500" |
| | | @click="handleRemoveManagerUser(user)" |
| | | /> |
| | | </div> |
| | | <Button |
| | | type="link" |
| | | @click="openManagerUserSelect" |
| | | class="flex items-center" |
| | | > |
| | | <template #icon> |
| | | <IconifyIcon icon="lucide:user-plus" class="size-4" /> |
| | | </template> |
| | | 选择人员 |
| | | </Button> |
| | | </div> |
| | | <!-- 流程管理员固定为超级管理员,不允许选择 --> |
| | | <span class="text-gray-700 dark:text-gray-200"> |
| | | {{ selectedManagerUsers[0]?.nickname || '超级管理员' }} |
| | | </span> |
| | | </Form.Item> |
| | | </Form> |
| | | |