!65 fix(xispeak): 通过taskId精准获取当前分支局部变量impl_dept_id实现部门过滤
Merge pull request !65 from wsm/feature/20260629
This commit is contained in:
@@ -134,6 +134,14 @@ export const bgXiSpeakFeedbackDelete = (params, handleSuccess) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取流程变量(支持局部变量查询),从task执行实例向上精准查找
|
||||||
|
* @param params { taskId, key, isLocal }
|
||||||
|
*/
|
||||||
|
export const getProcessVariable = (params: { taskId: string; key: string; isLocal?: boolean }) => {
|
||||||
|
return defHttp.get({ url: '/act/process/extActProcessNode/getVariable', params });
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子表批量删除
|
* 子表批量删除
|
||||||
* @param params
|
* @param params
|
||||||
|
|||||||
@@ -277,7 +277,7 @@
|
|||||||
import JTreeSelect from '/@/components/Form/src/jeecg/components/JTreeSelect.vue';
|
import JTreeSelect from '/@/components/Form/src/jeecg/components/JTreeSelect.vue';
|
||||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||||
import Icon from '/@/components/Icon/index';
|
import Icon from '/@/components/Icon/index';
|
||||||
import { bgXiSpeakFeedbackList, bgXiSpeakFeedbackListWithDept, bgXiSpeakFeedbackDelete, saveBpmForm, saveSubApprove } from '../BgXiSpeak.api';
|
import { bgXiSpeakFeedbackList, bgXiSpeakFeedbackDelete, saveBpmForm, saveSubApprove, getProcessVariable } from '../BgXiSpeak.api';
|
||||||
import { getUserList } from '/@/api/common/api';
|
import { getUserList } from '/@/api/common/api';
|
||||||
import { usePermission } from '/@/hooks/web/usePermission';
|
import { usePermission } from '/@/hooks/web/usePermission';
|
||||||
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
|
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
|
||||||
@@ -577,15 +577,41 @@ import { PARTY_COMMITTEE_DEPT_ID, SDW_LEADER_ROLE_ID } from '/@/constant/supervi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProcessVarDeptIds(): string[] {
|
async function getProcessVarDeptIds(): Promise<string[]> {
|
||||||
|
const taskId = props.formData?.taskId;
|
||||||
|
console.log('【部门过滤】taskId:', taskId, 'processInstanceId:', processInfo.value.processInstanceId);
|
||||||
|
if (taskId) {
|
||||||
|
try {
|
||||||
|
const res = await getProcessVariable({ taskId, key: 'impl_dept_id', isLocal: true });
|
||||||
|
const value = res?.result?.value ?? res?.value;
|
||||||
|
if (value) {
|
||||||
|
const result = String(value).split(',').map((s: string) => s.trim()).filter(Boolean);
|
||||||
|
console.log('【部门过滤】从流程局部变量 impl_dept_id 获取到:', result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('【部门过滤】获取局部变量 impl_dept_id 失败:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 局部变量未找到,尝试从流程级变量获取
|
||||||
const vars = (props.formData?.vars ?? {}) as Record<string, any>;
|
const vars = (props.formData?.vars ?? {}) as Record<string, any>;
|
||||||
const value = vars.implDept ?? vars.impl_dept_id ?? vars.pending_depts_id ?? vars.dept_id ?? vars.deptid;
|
console.log('【部门过滤】vars所有key:', Object.keys(vars), 'implDept:', vars.implDept, 'pending_depts_id:', vars.pending_depts_id);
|
||||||
if (!value) return [];
|
const value = vars.implDept ?? vars.pending_depts_id ?? vars.dept_id ?? vars.deptid;
|
||||||
if (Array.isArray(value)) return value.map((v: any) => String(v).trim()).filter(Boolean);
|
if (value) {
|
||||||
return String(value)
|
const result = Array.isArray(value)
|
||||||
.split(',')
|
? value.map((v: any) => String(v).trim()).filter(Boolean)
|
||||||
.map((s: string) => s.trim())
|
: String(value).split(',').map((s: string) => s.trim()).filter(Boolean);
|
||||||
.filter(Boolean);
|
console.log('【部门过滤】从流程级变量获取到部门ID:', result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 最终 fallback 到主表已保存的牵头部门
|
||||||
|
if (mainForm.implDept) {
|
||||||
|
const result = String(mainForm.implDept).split(',').map((s: string) => s.trim()).filter(Boolean);
|
||||||
|
console.log('【部门过滤】fallback mainForm.implDept:', result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
console.log('【部门过滤】未获取到任何部门ID');
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentUserDeptId() {
|
function getCurrentUserDeptId() {
|
||||||
@@ -610,18 +636,22 @@ import { PARTY_COMMITTEE_DEPT_ID, SDW_LEADER_ROLE_ID } from '/@/constant/supervi
|
|||||||
feedbackList.value = [];
|
feedbackList.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const apiFn = showDeptFeedback.value ? bgXiSpeakFeedbackListWithDept : bgXiSpeakFeedbackList;
|
const apiFn = bgXiSpeakFeedbackList;
|
||||||
const res = await apiFn({ mainId: mainForm.id, bpmProcessId, pageNo: 1, pageSize: 999 });
|
const res = await apiFn({ mainId: mainForm.id, bpmProcessId, pageNo: 1, pageSize: 999 });
|
||||||
let list = res?.records || res?.result?.records || [];
|
let list = res?.records || res?.result?.records || [];
|
||||||
|
console.log('【部门过滤】showDeptFeedback:', showDeptFeedback.value, '反馈总数:', list.length);
|
||||||
if (list.length && showDeptFeedback.value) {
|
if (list.length && showDeptFeedback.value) {
|
||||||
const deptIds = getProcessVarDeptIds();
|
const deptIds = await getProcessVarDeptIds();
|
||||||
|
console.log('【部门过滤】用于过滤的部门ID列表:', deptIds);
|
||||||
if (deptIds.length) {
|
if (deptIds.length) {
|
||||||
|
console.log('【部门过滤】过滤前各反馈的 responDeptid:', list.map((item: any) => ({ id: item.id, responDeptid: item.responDeptid, responDeptname: item.responDeptname })));
|
||||||
list = list.filter((item: any) => {
|
list = list.filter((item: any) => {
|
||||||
const responDeptIds = String(item.responDeptid || '')
|
const responDeptIds = String(item.responDeptid || '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((s: string) => s.trim());
|
.map((s: string) => s.trim());
|
||||||
return deptIds.some((id) => responDeptIds.includes(id));
|
return deptIds.some((id) => responDeptIds.includes(id));
|
||||||
});
|
});
|
||||||
|
console.log('【部门过滤】过滤后剩余:', list.map((item: any) => ({ id: item.id, responDeptid: item.responDeptid, responDeptname: item.responDeptname })));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
feedbackList.value = list;
|
feedbackList.value = list;
|
||||||
|
|||||||
Reference in New Issue
Block a user