feat(bpm): 抽取 useSubApproveUserResolver 统一 username→realname 解析,修复 isEnd 切换时审批意见不响应
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -246,7 +246,7 @@
|
||||
</a-col>
|
||||
<a-col v-if="showSubApproveUserSelector" :span="12">
|
||||
<a-form-item label="部门经办人" :labelCol="wideLabelCol" :wrapperCol="wideWrapperCol">
|
||||
<sz-dept-user-modal v-model:value="subApproveUser" :disabled="savingSubApproveUser" />
|
||||
<sz-dept-user-modal v-model:value="subApproveUser" :disabled="savingSubApproveUser" @confirm="setDisplayNames" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
@@ -278,7 +278,7 @@
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import Icon from '/@/components/Icon/index';
|
||||
import { bgXiSpeakFeedbackList, bgXiSpeakFeedbackDelete, saveBpmForm, saveSubApprove, getProcessVariable } from '../BgXiSpeak.api';
|
||||
import { getUserList } from '/@/api/common/api';
|
||||
import { useSubApproveUserResolver } from '/@/composables/useSubApproveUserResolver';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
|
||||
import BgXiSpeakBPMFeedbackModal from './BgXiSpeakBPMFeedbackModal.vue';
|
||||
@@ -328,9 +328,7 @@ import {
|
||||
const showBaseInfoDetail = ref(false);
|
||||
const showFeedbackDetail = ref(true);
|
||||
const feedbackList = ref<any[]>([]);
|
||||
const subApproveUser = ref('');
|
||||
const subApproveUserNameText = ref('');
|
||||
const userResolveVersion = ref(0);
|
||||
const { usernames: subApproveUser, displayNames: subApproveUserNameText, setDisplayNames, initFromData } = useSubApproveUserResolver();
|
||||
const isEnd = ref(0);
|
||||
|
||||
const mainForm = reactive<Record<string, any>>({
|
||||
@@ -469,9 +467,10 @@ import {
|
||||
Task_0jrgrzs: buildDeptHandlerFeedbackReason,
|
||||
Task_12vdqzv: buildDeptHandlerFeedbackReason,
|
||||
// 部门负责人接受任务并分配
|
||||
Task_1v9ce78: () => buildDeptLeaderAssignReason(
|
||||
normalizeDeptNames(subApproveUserNameText.value || subApproveUser.value),
|
||||
),
|
||||
Task_1v9ce78: () => {
|
||||
if (isEnd.value === 1) return '';
|
||||
return buildDeptLeaderAssignReason(normalizeDeptNames(subApproveUserNameText.value));
|
||||
},
|
||||
// 部门负责人直接反馈
|
||||
Task_0sialna: buildDeptLeaderDirectFeedbackReason,
|
||||
// 督办部门经办人确认全部反馈事项
|
||||
@@ -525,14 +524,13 @@ import {
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
subApproveUser,
|
||||
(value) => {
|
||||
resolveSubApproveUserName(value);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
watch(isEnd, (val) => {
|
||||
const vars = props.formData?.vars;
|
||||
if (vars) {
|
||||
vars.is_end = String(val);
|
||||
vars.isEnd = String(val);
|
||||
}
|
||||
});
|
||||
|
||||
async function initFormData() {
|
||||
const dataId = props.formData?.dataId;
|
||||
@@ -560,7 +558,7 @@ import {
|
||||
if (approveInfo && deptId && approveInfo[deptId]) {
|
||||
const detail = approveInfo[deptId];
|
||||
isEnd.value = detail.isEnd ?? 0;
|
||||
subApproveUser.value = detail.implWorker ?? '';
|
||||
initFromData(detail.implWorker ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,42 +769,6 @@ import {
|
||||
.join(',');
|
||||
}
|
||||
|
||||
async function resolveSubApproveUserName(value: any) {
|
||||
const resolveVersion = ++userResolveVersion.value;
|
||||
const usernames = normalizeUsernameList(value);
|
||||
if (!usernames) {
|
||||
subApproveUserNameText.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
subApproveUserNameText.value = normalizeDeptNames(usernames);
|
||||
try {
|
||||
const res = await getUserList({ username: usernames, isMultiTranslate: 'true', pageNo: 1, pageSize: 999 });
|
||||
if (resolveVersion !== userResolveVersion.value) {
|
||||
return;
|
||||
}
|
||||
const records = res?.records || res?.result?.records || res || [];
|
||||
const userNameMap = Array.isArray(records)
|
||||
? records.reduce((cache: Record<string, string>, item: any) => {
|
||||
const username = String(item?.username || '').trim();
|
||||
const realname = String(item?.realname || item?.name || '').trim();
|
||||
if (username && realname) {
|
||||
cache[username] = realname;
|
||||
}
|
||||
return cache;
|
||||
}, {})
|
||||
: {};
|
||||
const names = usernames
|
||||
.split(',')
|
||||
.map((username) => userNameMap[username] || username)
|
||||
.filter(Boolean);
|
||||
subApproveUserNameText.value = normalizeDeptNames(names.join(','));
|
||||
} catch {
|
||||
if (resolveVersion === userResolveVersion.value) {
|
||||
subApproveUserNameText.value = normalizeDeptNames(usernames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleProcessSuccess() {
|
||||
emit('success');
|
||||
|
||||
Reference in New Issue
Block a user