| | |
| | | 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) { |
| | | newVal.managerUserIds = [admin.id]; |
| | | selectedManagerUsers.value = [admin as SystemUserApi.User]; |
| | | 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] : []; |
| | | } |
| | | }, |
| | | { |