fix(fixcontact): 反馈列表按当前子流程部门范围过滤,新增所领导审批流程变量
- 反馈保存时 feedback_dept 存当前子流程部门(无子流程节点时回退登录人部门) - 子流程部门读取改为优先读多实例局部变量 dept_id(原 impl_dept_id 从未写入导致过滤落空) - filterByDept=1 时反馈列表仅展示当前子流程内的反馈,同子流程内其他部门反馈可见 - 刷新 watch 增加 taskId,切换同实例不同子流程任务时正确重刷 - 新增是否需要所领导审批开关与审批人(is_need_leader_approve / leader_approve_user 全局变量) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
const formRef = ref();
|
||||
const uploadFileRef = ref<InstanceType<typeof SUploadFile> | null>(null);
|
||||
const uploadKey = ref(0);
|
||||
const subProcessDeptId = ref('');
|
||||
const labelCol = { xs: { span: 24 }, sm: { span: 7 } };
|
||||
const wrapperCol = { xs: { span: 24 }, sm: { span: 17 } };
|
||||
const wideLabelCol = { xs: { span: 24 }, sm: { span: 5 } };
|
||||
@@ -114,18 +115,19 @@
|
||||
planFinishStatus: [{ required: true, message: '请输入计划完成情况' }],
|
||||
};
|
||||
|
||||
function resetForm(mainId = '', bpmProcessId = '') {
|
||||
function resetForm(mainId = '', bpmProcessId = '', deptId = '') {
|
||||
Object.keys(formData).forEach((key) => {
|
||||
formData[key] = '';
|
||||
});
|
||||
formData.fixedContact20260730Id = mainId;
|
||||
formData.bpmProcessId = bpmProcessId;
|
||||
subProcessDeptId.value = deptId;
|
||||
uploadKey.value += 1;
|
||||
nextTick(() => formRef.value?.clearValidate?.());
|
||||
}
|
||||
|
||||
function open(mainId: string, bpmProcessId = '', record?: Record<string, any>) {
|
||||
resetForm(mainId, bpmProcessId);
|
||||
function open(mainId: string, bpmProcessId = '', deptId = '', record?: Record<string, any>) {
|
||||
resetForm(mainId, bpmProcessId, deptId);
|
||||
if (record?.id) {
|
||||
isEdit.value = true;
|
||||
modalTitle.value = '编辑反馈';
|
||||
@@ -158,9 +160,8 @@
|
||||
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
|
||||
formData.feedbackUser = userInfo.id || userInfo.userId || '';
|
||||
const loginDepart = getCurrentLoginDepart();
|
||||
if (loginDepart) {
|
||||
formData.feedbackDept = loginDepart.id || '';
|
||||
}
|
||||
// 反馈部门存当前子流程范围(impl_dept_id),供子流程内按范围过滤;非子流程节点回退到登录人部门
|
||||
formData.feedbackDept = subProcessDeptId.value || loginDepart?.id || '';
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
|
||||
@@ -195,6 +195,23 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
</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
|
||||
:form-data="formData"
|
||||
:claim="claim"
|
||||
@@ -222,7 +239,7 @@
|
||||
import SUploadFile from '/@/components/semri/fileComponent/SUploadFile.vue';
|
||||
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.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 { PARTY_COMMITTEE_DEPT_ID, CHARGE_LEADER_ROLE_ID } from '/@/constant/supervision';
|
||||
|
||||
@@ -257,6 +274,9 @@
|
||||
const feedbackAttachmentRefreshKey = ref(0);
|
||||
const { usernames: subApproveUser, setDisplayNames, initFromData } = useSubApproveUserResolver();
|
||||
const isEnd = ref(0);
|
||||
const isNeedLeaderApprove = ref(0);
|
||||
const leaderApproveUser = ref('');
|
||||
const savingIsNeedLeaderApprove = ref(false);
|
||||
|
||||
const mainForm = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
@@ -320,6 +340,7 @@
|
||||
const showAddFeedback = computed(
|
||||
() => String(props.formData?.extendUrlParams?.showAddFeedback ?? props.formData?.extendUrlParams?.addfeedback ?? '') === '1'
|
||||
);
|
||||
const filterByDept = computed(() => String(props.formData?.extendUrlParams?.filterByDept ?? '') === '1');
|
||||
|
||||
const processInfo = computed(() => ({
|
||||
taskId: props.formData?.taskId,
|
||||
@@ -347,12 +368,19 @@
|
||||
() => String(props.formData?.extendUrlParams?.showSubApproveUser ?? props.formData?.extendUrlParams?.selectuser ?? '') === '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(() => {
|
||||
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(
|
||||
() => props.formData?.vars?.isEnd,
|
||||
@@ -368,6 +396,20 @@
|
||||
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() {
|
||||
const dataId = props.formData?.dataId;
|
||||
@@ -395,6 +437,9 @@
|
||||
Object.keys(mainForm).forEach((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 和部门经办人
|
||||
const approveInfo = record.approveInfo;
|
||||
const deptId = await getCurrentProcessDeptId();
|
||||
@@ -412,17 +457,20 @@
|
||||
async function getCurrentProcessDeptId() {
|
||||
const taskId = props.formData?.taskId;
|
||||
if (taskId) {
|
||||
try {
|
||||
const res = await getProcessVariable({ taskId, key: 'impl_dept_id', isLocal: true });
|
||||
const value = res?.result?.value ?? res?.value;
|
||||
if (value) {
|
||||
const deptId = String(value).replace('[', '').replace(']', '').trim();
|
||||
if (deptId) {
|
||||
return deptId;
|
||||
// 子流程当前部门ID实际存于多实例元素变量 dept_id(impl_dept_id 从未写入),优先读取
|
||||
for (const key of ['dept_id', 'impl_dept_id']) {
|
||||
try {
|
||||
const res = await getProcessVariable({ taskId, key, isLocal: true });
|
||||
const value = res?.result?.value ?? res?.value;
|
||||
if (value) {
|
||||
const deptId = String(value).replace('[', '').replace(']', '').trim();
|
||||
if (deptId) {
|
||||
return deptId;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 局部变量读取失败,尝试下一个候选键
|
||||
}
|
||||
} catch (e) {
|
||||
// 局部变量读取失败,回退到当前用户部门
|
||||
}
|
||||
}
|
||||
return getCurrentUserDeptId();
|
||||
@@ -444,6 +492,11 @@
|
||||
return userInfo.username || '';
|
||||
}
|
||||
|
||||
async function getProcessVarDeptIds(): Promise<string[]> {
|
||||
const deptId = await getCurrentProcessDeptId();
|
||||
return deptId ? [deptId] : [];
|
||||
}
|
||||
|
||||
async function loadFeedbackList() {
|
||||
const bpmProcessId = processInfo.value.processInstanceId;
|
||||
if (!mainForm.id || !bpmProcessId) {
|
||||
@@ -452,7 +505,21 @@
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -501,7 +568,16 @@
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -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 存储目标保持一致
|
||||
function saveProcessVariableLocal(varField: string, varVal: any) {
|
||||
return setBpmVariableLocal({
|
||||
@@ -592,7 +718,7 @@
|
||||
.join(',');
|
||||
}
|
||||
|
||||
function openFeedbackModal() {
|
||||
async function openFeedbackModal() {
|
||||
if (!mainForm.id) {
|
||||
createMessage.warning('主表数据不存在,无法新增反馈');
|
||||
return;
|
||||
@@ -602,7 +728,8 @@
|
||||
createMessage.warning('流程实例ID不能为空,无法新增反馈');
|
||||
return;
|
||||
}
|
||||
feedbackModalRef.value?.open(mainForm.id, processInstanceId);
|
||||
const deptId = await getCurrentProcessDeptId();
|
||||
feedbackModalRef.value?.open(mainForm.id, processInstanceId, deptId);
|
||||
}
|
||||
|
||||
function openFeedbackEditModal(record: Recordable) {
|
||||
@@ -614,7 +741,7 @@
|
||||
createMessage.warning('反馈记录不存在,无法编辑');
|
||||
return;
|
||||
}
|
||||
feedbackModalRef.value?.open(mainForm.id, processInfo.value.processInstanceId, record);
|
||||
feedbackModalRef.value?.open(mainForm.id, processInfo.value.processInstanceId, '', record);
|
||||
}
|
||||
|
||||
async function handleFeedbackDelete(record: Recordable) {
|
||||
|
||||
Reference in New Issue
Block a user