feat(dq, xispeak): 统一反馈表单部门自动填充,从登录信息取当前部门

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-07-14 10:55:59 +08:00
co-authored by Claude Opus 4.7
parent b1af9cd575
commit 44e74d75f6
2 changed files with 47 additions and 29 deletions
@@ -8,7 +8,7 @@
<a-row class="form-content-row" :gutter="[12, 4]">
<a-col :xs="24" :md="12">
<a-form-item label="反馈部门" name="responDeptid">
<j-select-dept v-model:value="formData.responDeptid" :multiple="true" checkStrictly allow-clear @change="handleDeptChange" />
<j-select-dept v-model:value="formData.responDeptid" :multiple="true" disabled checkStrictly @change="handleDeptChange" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="12">
@@ -177,6 +177,7 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { useUserStore } from '/@/store/modules/user';
import { bgXiSpeakFeedbackSaveOrUpdate } from '../BgXiSpeak.api';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
@@ -213,6 +214,7 @@
startTime: '',
});
const { createMessage } = useMessage();
const userStore = useUserStore();
const confirmLoading = ref<boolean>(false);
const validatorRules = reactive({
completionStatus: [{ required: true, message: '请选择完成状态' }],
@@ -225,6 +227,27 @@
const labelCol = { xs: { span: 24 }, sm: { span: 7 } };
const wrapperCol = { xs: { span: 24 }, sm: { span: 17 } };
function fillDeptFromLogin() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
let deptId = userInfo.departIds || userInfo.orgCode || '';
let deptName = userInfo.departIds_dictText || userInfo.orgCodeTxt || '';
// 如果 orgCodeTxt 仍为空(极少情况),从 loginInfo.departs 按 orgCode 补齐名称
if (!deptName && deptId) {
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>;
const departs = Array.isArray(loginInfo.departs) ? loginInfo.departs : [];
console.log('【所务会-反馈】兜底查找, orgCode:', deptId, ', departs orgCodes:', departs.map((d: any) => d.orgCode), ', departs names:', departs.map((d: any) => d.departName));
const matched = departs.find((d: any) => d.orgCode === deptId);
if (matched) {
deptId = matched.id || deptId;
deptName = matched.departName || '';
console.log('【所务会-反馈】兜底匹配成功, matched:', matched);
}
}
formData.responDeptid = deptId;
formData.responDeptname = deptName;
console.log('【所务会-反馈】填充当前部门, deptId:', deptId, ', deptName:', deptName);
}
/**
* 部门选择变化
*/
@@ -268,6 +291,7 @@
}
});
Object.assign(formData, tmpData);
fillDeptFromLogin();
});
}
@@ -13,7 +13,7 @@
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="反馈部门" name="feedbackDeptId">
<j-select-dept v-model:value="formData.feedbackDeptId" :disabled="nonJiJianFieldsReadonly" checkStrictly allow-clear @change="handleDeptChange" />
<j-select-dept v-model:value="formData.feedbackDeptId" disabled checkStrictly @change="handleDeptChange" />
</a-form-item>
</a-col>
<a-col :span="12">
@@ -135,9 +135,9 @@
resetForm(mainId, bpmProcessId);
isEdit.value = false;
if (defaultDeptId) {
void applyCurrentUserFeedbackInfo(defaultDeptId, defaultDeptName);
applyCurrentUserFeedbackInfo(defaultDeptId, defaultDeptName);
} else {
void applyCurrentUserFeedbackInfo();
applyCurrentUserFeedbackInfo();
}
visible.value = true;
}
@@ -153,32 +153,28 @@
visible.value = true;
}
function getCurrentLoginDepart() {
function fillCurrentDept() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>;
const departs = Array.isArray(loginInfo.departs) ? loginInfo.departs : [];
if (userInfo.orgCode) {
return departs.find((item) => item.orgCode === userInfo.orgCode);
let deptId = userInfo.departIds || userInfo.orgCode || '';
let deptName = userInfo.departIds_dictText || userInfo.orgCodeTxt || '';
// 如果 orgCodeTxt 仍为空(极少情况),从 loginInfo.departs 按 orgCode 补齐名称
if (!deptName && deptId) {
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>;
const departs = Array.isArray(loginInfo.departs) ? loginInfo.departs : [];
console.log('【巡视整改-反馈】兜底查找, orgCode:', deptId, ', departs orgCodes:', departs.map((d: any) => d.orgCode), ', departs names:', departs.map((d: any) => d.departName));
const matched = departs.find((d: any) => d.orgCode === deptId);
if (matched) {
deptId = matched.id || deptId;
deptName = matched.departName || '';
console.log('【巡视整改-反馈】兜底匹配成功, matched:', matched);
}
}
return departs.length === 1 ? departs[0] : undefined;
formData.feedbackDeptId = deptId;
formData.feedbackDeptName = deptName;
console.log('【巡视整改-反馈】填充当前部门, deptId:', deptId, ', deptName:', deptName);
}
async function getCurrentDepartInfo() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
const loginDepart = getCurrentLoginDepart();
if (loginDepart) {
return {
id: loginDepart.id || '',
departName: loginDepart.departName || '',
};
}
return {
id: userInfo.departIds || '',
departName: userInfo.departIds_dictText || userInfo.orgCodeTxt || '',
};
}
async function applyCurrentUserFeedbackInfo(defaultDeptId = '', defaultDeptName = '') {
function applyCurrentUserFeedbackInfo(defaultDeptId = '', defaultDeptName = '') {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
formData.feedbackPersonId = userInfo.id || userInfo.userId || '';
formData.feedbackPersonName = userInfo.realname || '';
@@ -186,9 +182,7 @@
formData.feedbackDeptId = defaultDeptId;
formData.feedbackDeptName = defaultDeptName || '';
} else {
const departInfo = await getCurrentDepartInfo();
formData.feedbackDeptId = departInfo.id;
formData.feedbackDeptName = departInfo.departName;
fillCurrentDept();
}
}