!133 fix(fixcontact): 反馈列表按当前子流程部门范围过滤,新增所领导审批流程变量

Merge pull request !133 from wsm/feature/fix_contact_select_ld
This commit is contained in:
wsm
2026-08-04 02:30:38 +00:00
committed by Gitee
2 changed files with 150 additions and 22 deletions
@@ -87,6 +87,7 @@
const formRef = ref(); const formRef = ref();
const uploadFileRef = ref<InstanceType<typeof SUploadFile> | null>(null); const uploadFileRef = ref<InstanceType<typeof SUploadFile> | null>(null);
const uploadKey = ref(0); const uploadKey = ref(0);
const subProcessDeptId = ref('');
const labelCol = { xs: { span: 24 }, sm: { span: 7 } }; const labelCol = { xs: { span: 24 }, sm: { span: 7 } };
const wrapperCol = { xs: { span: 24 }, sm: { span: 17 } }; const wrapperCol = { xs: { span: 24 }, sm: { span: 17 } };
const wideLabelCol = { xs: { span: 24 }, sm: { span: 5 } }; const wideLabelCol = { xs: { span: 24 }, sm: { span: 5 } };
@@ -114,18 +115,19 @@
planFinishStatus: [{ required: true, message: '请输入计划完成情况' }], planFinishStatus: [{ required: true, message: '请输入计划完成情况' }],
}; };
function resetForm(mainId = '', bpmProcessId = '') { function resetForm(mainId = '', bpmProcessId = '', deptId = '') {
Object.keys(formData).forEach((key) => { Object.keys(formData).forEach((key) => {
formData[key] = ''; formData[key] = '';
}); });
formData.fixedContact20260730Id = mainId; formData.fixedContact20260730Id = mainId;
formData.bpmProcessId = bpmProcessId; formData.bpmProcessId = bpmProcessId;
subProcessDeptId.value = deptId;
uploadKey.value += 1; uploadKey.value += 1;
nextTick(() => formRef.value?.clearValidate?.()); nextTick(() => formRef.value?.clearValidate?.());
} }
function open(mainId: string, bpmProcessId = '', record?: Record<string, any>) { function open(mainId: string, bpmProcessId = '', deptId = '', record?: Record<string, any>) {
resetForm(mainId, bpmProcessId); resetForm(mainId, bpmProcessId, deptId);
if (record?.id) { if (record?.id) {
isEdit.value = true; isEdit.value = true;
modalTitle.value = '编辑反馈'; modalTitle.value = '编辑反馈';
@@ -158,9 +160,8 @@
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>; const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
formData.feedbackUser = userInfo.id || userInfo.userId || ''; formData.feedbackUser = userInfo.id || userInfo.userId || '';
const loginDepart = getCurrentLoginDepart(); const loginDepart = getCurrentLoginDepart();
if (loginDepart) { // 反馈部门存当前子流程范围(impl_dept_id),供子流程内按范围过滤;非子流程节点回退到登录人部门
formData.feedbackDept = loginDepart.id || ''; formData.feedbackDept = subProcessDeptId.value || loginDepart?.id || '';
}
} }
function handleCancel() { function handleCancel() {
@@ -195,6 +195,23 @@
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
<a-form v-if="showIsNeedLeaderApprove" class="process-variable-form" labelAlign="left" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="是否需要所领导审批" :labelCol="wideLabelCol" :wrapperCol="wideWrapperCol">
<a-radio-group v-model:value="isNeedLeaderApprove" :disabled="savingIsNeedLeaderApprove">
<a-radio :value="0">不需要</a-radio>
<a-radio :value="1">需要所领导审批</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col v-if="showIsNeedLeaderApproveSelector" :span="12">
<a-form-item label="所领导审批人" :labelCol="wideLabelCol" :wrapperCol="wideWrapperCol">
<sz-dept-user-modal v-model:value="leaderApproveUser" :disabled="savingIsNeedLeaderApprove" />
</a-form-item>
</a-col>
</a-row>
</a-form>
<TaskHandleInnerContent <TaskHandleInnerContent
:form-data="formData" :form-data="formData"
:claim="claim" :claim="claim"
@@ -222,7 +239,7 @@
import SUploadFile from '/@/components/semri/fileComponent/SUploadFile.vue'; import SUploadFile from '/@/components/semri/fileComponent/SUploadFile.vue';
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue'; import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
import FixedContact20260730BPMFeedbackModal from './FixedContact20260730BPMFeedbackModal.vue'; import FixedContact20260730BPMFeedbackModal from './FixedContact20260730BPMFeedbackModal.vue';
import { fixedContactFeedbackList, getProcessVariable, saveBpmForm, setBpmVariableLocal, saveSubApprove } from '../FixedContact20260730.api'; import { fixedContactFeedbackList, getProcessVariable, saveBpmForm, setBpmVariableLocal, saveSubApprove, setProcessVariable } from '../FixedContact20260730.api';
import { useSubApproveUserResolver } from '/@/composables/useSubApproveUserResolver'; import { useSubApproveUserResolver } from '/@/composables/useSubApproveUserResolver';
import { PARTY_COMMITTEE_DEPT_ID, CHARGE_LEADER_ROLE_ID } from '/@/constant/supervision'; import { PARTY_COMMITTEE_DEPT_ID, CHARGE_LEADER_ROLE_ID } from '/@/constant/supervision';
@@ -257,6 +274,9 @@
const feedbackAttachmentRefreshKey = ref(0); const feedbackAttachmentRefreshKey = ref(0);
const { usernames: subApproveUser, setDisplayNames, initFromData } = useSubApproveUserResolver(); const { usernames: subApproveUser, setDisplayNames, initFromData } = useSubApproveUserResolver();
const isEnd = ref(0); const isEnd = ref(0);
const isNeedLeaderApprove = ref(0);
const leaderApproveUser = ref('');
const savingIsNeedLeaderApprove = ref(false);
const mainForm = reactive<Record<string, any>>({ const mainForm = reactive<Record<string, any>>({
id: '', id: '',
@@ -320,6 +340,7 @@
const showAddFeedback = computed( const showAddFeedback = computed(
() => String(props.formData?.extendUrlParams?.showAddFeedback ?? props.formData?.extendUrlParams?.addfeedback ?? '') === '1' () => String(props.formData?.extendUrlParams?.showAddFeedback ?? props.formData?.extendUrlParams?.addfeedback ?? '') === '1'
); );
const filterByDept = computed(() => String(props.formData?.extendUrlParams?.filterByDept ?? '') === '1');
const processInfo = computed(() => ({ const processInfo = computed(() => ({
taskId: props.formData?.taskId, taskId: props.formData?.taskId,
@@ -347,12 +368,19 @@
() => String(props.formData?.extendUrlParams?.showSubApproveUser ?? props.formData?.extendUrlParams?.selectuser ?? '') === '1' () => String(props.formData?.extendUrlParams?.showSubApproveUser ?? props.formData?.extendUrlParams?.selectuser ?? '') === '1'
); );
const showSubApproveUserSelector = computed(() => showSubApproveUser.value && String(isEnd.value) !== '1'); const showSubApproveUserSelector = computed(() => showSubApproveUser.value && String(isEnd.value) !== '1');
const showIsNeedLeaderApprove = computed(() => String(props.formData?.extendUrlParams?.showIsNeedLeaderApprove ?? '') === '1');
const showIsNeedLeaderApproveSelector = computed(() => showIsNeedLeaderApprove.value && String(isNeedLeaderApprove.value) === '1');
onMounted(() => { onMounted(() => {
initFormData(); initFormData();
}); });
watch([() => props.formData?.dataId, () => processInfo.value.processInstanceId], () => initFormData()); // taskId 参与刷新:同实例多个子流程(督办经办人确认等)的 taskId 不同但 processInstanceId/dataId 相同,
// 切换子流程任务时若不刷新会沿用上一个子流程的部门过滤结果
watch(
[() => props.formData?.dataId, () => processInfo.value.processInstanceId, () => props.formData?.taskId],
() => initFormData()
);
watch( watch(
() => props.formData?.vars?.isEnd, () => props.formData?.vars?.isEnd,
@@ -368,6 +396,20 @@
vars.isEnd = String(val); vars.isEnd = String(val);
} }
}); });
watch(
() => props.formData?.vars?.isNeedLeaderApprove,
(value) => {
isNeedLeaderApprove.value = String(value ?? '0') === '1' ? 1 : 0;
},
{ immediate: true }
);
watch(isNeedLeaderApprove, (val) => {
const vars = props.formData?.vars;
if (vars) {
vars.is_need_leader_approve = String(val);
vars.isNeedLeaderApprove = String(val);
}
});
async function initFormData() { async function initFormData() {
const dataId = props.formData?.dataId; const dataId = props.formData?.dataId;
@@ -395,6 +437,9 @@
Object.keys(mainForm).forEach((key) => { Object.keys(mainForm).forEach((key) => {
mainForm[key] = record[key] ?? ''; mainForm[key] = record[key] ?? '';
}); });
// 所领导审批人默认取定点联系所领导 + 相关分管所领导,若流程变量已保存则沿用
const savedLeaderApproveUser = props.formData?.vars?.leader_approve_user ?? props.formData?.vars?.leaderApproveUser;
leaderApproveUser.value = String(savedLeaderApproveUser ?? '') || [mainForm.contactLeader, mainForm.relatedLeader].filter(Boolean).join(',');
// 从 approveInfo JSON 初始化当前子流程部门的 isEnd 和部门经办人 // 从 approveInfo JSON 初始化当前子流程部门的 isEnd 和部门经办人
const approveInfo = record.approveInfo; const approveInfo = record.approveInfo;
const deptId = await getCurrentProcessDeptId(); const deptId = await getCurrentProcessDeptId();
@@ -412,17 +457,20 @@
async function getCurrentProcessDeptId() { async function getCurrentProcessDeptId() {
const taskId = props.formData?.taskId; const taskId = props.formData?.taskId;
if (taskId) { if (taskId) {
try { // 子流程当前部门ID实际存于多实例元素变量 dept_idimpl_dept_id 从未写入),优先读取
const res = await getProcessVariable({ taskId, key: 'impl_dept_id', isLocal: true }); for (const key of ['dept_id', 'impl_dept_id']) {
const value = res?.result?.value ?? res?.value; try {
if (value) { const res = await getProcessVariable({ taskId, key, isLocal: true });
const deptId = String(value).replace('[', '').replace(']', '').trim(); const value = res?.result?.value ?? res?.value;
if (deptId) { if (value) {
return deptId; const deptId = String(value).replace('[', '').replace(']', '').trim();
if (deptId) {
return deptId;
}
} }
} catch (e) {
// 局部变量读取失败,尝试下一个候选键
} }
} catch (e) {
// 局部变量读取失败,回退到当前用户部门
} }
} }
return getCurrentUserDeptId(); return getCurrentUserDeptId();
@@ -444,6 +492,11 @@
return userInfo.username || ''; return userInfo.username || '';
} }
async function getProcessVarDeptIds(): Promise<string[]> {
const deptId = await getCurrentProcessDeptId();
return deptId ? [deptId] : [];
}
async function loadFeedbackList() { async function loadFeedbackList() {
const bpmProcessId = processInfo.value.processInstanceId; const bpmProcessId = processInfo.value.processInstanceId;
if (!mainForm.id || !bpmProcessId) { if (!mainForm.id || !bpmProcessId) {
@@ -452,7 +505,21 @@
return; return;
} }
const res = await fixedContactFeedbackList({ id: mainForm.id, bpmProcessId }); const res = await fixedContactFeedbackList({ id: mainForm.id, bpmProcessId });
feedbackList.value = Array.isArray(res) ? res : res?.records || []; let list = Array.isArray(res) ? res : res?.records || [];
// 子流程过滤:filterByDept=1 时仅展示当前子流程内的反馈(反馈部门即保存时写入的子流程范围)
if (list.length && filterByDept.value) {
const deptIds = await getProcessVarDeptIds();
if (deptIds.length) {
list = list.filter((item) => {
const itemDeptIds = String(item.feedbackDept || '')
.split(',')
.map((s: string) => s.trim())
.filter(Boolean);
return itemDeptIds.some((id) => deptIds.includes(id));
});
}
}
feedbackList.value = list;
feedbackAttachmentRefreshKey.value += 1; feedbackAttachmentRefreshKey.value += 1;
} }
@@ -501,7 +568,16 @@
} }
} }
if (showSubApproveUser.value) { if (showSubApproveUser.value) {
return saveSubApproveUserVariable({ showSuccessMessage: false }); const subSaved = await saveSubApproveUserVariable({ showSuccessMessage: false });
if (!subSaved) {
return false;
}
}
if (showIsNeedLeaderApprove.value) {
const leaderSaved = await saveIsNeedLeaderApproveVariable({ showSuccessMessage: false });
if (!leaderSaved) {
return false;
}
} }
return true; return true;
} }
@@ -573,6 +649,56 @@
} }
} }
async function saveIsNeedLeaderApproveVariable(options: { showSuccessMessage?: boolean } = {}) {
const { showSuccessMessage = true } = options;
const processInstanceId = processInfo.value.processInstanceId;
const isNeedLeaderApproveValue = String(isNeedLeaderApprove.value);
const leaderUsernameValue = normalizeUsernameList(leaderApproveUser.value);
if (!processInstanceId) {
createMessage.warning('流程实例ID不能为空');
return false;
}
if (isNeedLeaderApproveValue === '1' && !leaderUsernameValue) {
createMessage.warning('请选择所领导审批人');
return false;
}
savingIsNeedLeaderApprove.value = true;
try {
const result = await saveGlobalProcessVariable('is_need_leader_approve', isNeedLeaderApproveValue);
if (!result?.success) {
createMessage.warning(result.message || '保存失败');
return false;
}
if (isNeedLeaderApproveValue === '1') {
const leaderResult = await saveGlobalProcessVariable('leader_approve_user', leaderUsernameValue);
if (!leaderResult?.success) {
createMessage.warning(leaderResult.message || '保存失败');
return false;
}
}
if (showSuccessMessage) {
createMessage.success('保存成功');
}
return true;
} catch (error) {
createMessage.warning('保存失败');
return false;
} finally {
savingIsNeedLeaderApprove.value = false;
}
}
// 所领导审批为顶层流程决策,写入全局流程变量供流程网关判断
function saveGlobalProcessVariable(varField: string, varVal: any) {
return setProcessVariable({
processInstanceId: processInfo.value.processInstanceId,
local: false,
varField,
varVal,
});
}
// 局部变量写入(默认向上追溯 2 层父级执行实例),与 FixContactDeptLeaderApproveListener 存储目标保持一致 // 局部变量写入(默认向上追溯 2 层父级执行实例),与 FixContactDeptLeaderApproveListener 存储目标保持一致
function saveProcessVariableLocal(varField: string, varVal: any) { function saveProcessVariableLocal(varField: string, varVal: any) {
return setBpmVariableLocal({ return setBpmVariableLocal({
@@ -592,7 +718,7 @@
.join(','); .join(',');
} }
function openFeedbackModal() { async function openFeedbackModal() {
if (!mainForm.id) { if (!mainForm.id) {
createMessage.warning('主表数据不存在,无法新增反馈'); createMessage.warning('主表数据不存在,无法新增反馈');
return; return;
@@ -602,7 +728,8 @@
createMessage.warning('流程实例ID不能为空,无法新增反馈'); createMessage.warning('流程实例ID不能为空,无法新增反馈');
return; return;
} }
feedbackModalRef.value?.open(mainForm.id, processInstanceId); const deptId = await getCurrentProcessDeptId();
feedbackModalRef.value?.open(mainForm.id, processInstanceId, deptId);
} }
function openFeedbackEditModal(record: Recordable) { function openFeedbackEditModal(record: Recordable) {
@@ -614,7 +741,7 @@
createMessage.warning('反馈记录不存在,无法编辑'); createMessage.warning('反馈记录不存在,无法编辑');
return; return;
} }
feedbackModalRef.value?.open(mainForm.id, processInfo.value.processInstanceId, record); feedbackModalRef.value?.open(mainForm.id, processInfo.value.processInstanceId, '', record);
} }
async function handleFeedbackDelete(record: Recordable) { async function handleFeedbackDelete(record: Recordable) {