将数据存入业务表单json字段,并适配后端修改
This commit is contained in:
@@ -244,7 +244,7 @@
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col v-if="showSubApproveUser" :span="12">
|
||||
<a-col v-if="showSubApproveUserSelector" :span="12">
|
||||
<a-form-item label="部门经办人" :labelCol="wideLabelCol" :wrapperCol="wideWrapperCol">
|
||||
<j-select-user v-model:value="subApproveUser" :disabled="savingSubApproveUser" allow-clear />
|
||||
</a-form-item>
|
||||
@@ -278,8 +278,7 @@
|
||||
bgXiSpeakFeedbackListWithDept,
|
||||
bgXiSpeakFeedbackDelete,
|
||||
saveBpmForm,
|
||||
setProcessVariable,
|
||||
updateDeptHandlerName,
|
||||
saveSubApprove,
|
||||
} from '../BgXiSpeak.api';
|
||||
import { usePermission } from '/@/hooks/web/usePermission';
|
||||
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
|
||||
@@ -469,6 +468,14 @@
|
||||
Object.keys(mainForm).forEach((key) => {
|
||||
mainForm[key] = record[key] ?? '';
|
||||
});
|
||||
// 从 approveInfo JSON 初始化当前部门的 isEnd 和 subApproveUser
|
||||
const approveInfo = record.approveInfo;
|
||||
const deptId = getCurrentUserDeptId();
|
||||
if (approveInfo && deptId && approveInfo[deptId]) {
|
||||
const detail = approveInfo[deptId];
|
||||
isEnd.value = detail.isEnd ?? 0;
|
||||
subApproveUser.value = detail.implWorker ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentUserDeptId() {
|
||||
@@ -482,6 +489,11 @@
|
||||
return departs.length === 1 ? departs[0]?.id || '' : '';
|
||||
}
|
||||
|
||||
function getCurrentAssignee() {
|
||||
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>;
|
||||
return userInfo.username || '';
|
||||
}
|
||||
|
||||
async function loadFeedbackList() {
|
||||
const bpmProcessId = processInfo.value.processInstanceId;
|
||||
if (!mainForm.id || !bpmProcessId) {
|
||||
@@ -577,11 +589,15 @@
|
||||
|
||||
async function saveSubApproveUserVariable(options: { showSuccessMessage?: boolean } = {}) {
|
||||
const { showSuccessMessage = true } = options;
|
||||
const processInstanceId = processInfo.value.processInstanceId;
|
||||
const isEndValue = String(isEnd.value);
|
||||
const usernameValue = normalizeUsernameList(subApproveUser.value);
|
||||
if (!processInstanceId) {
|
||||
createMessage.warning('流程实例ID不能为空');
|
||||
const deptId = getCurrentUserDeptId();
|
||||
if (!mainForm.id) {
|
||||
createMessage.warning('主表ID不能为空');
|
||||
return false;
|
||||
}
|
||||
if (!deptId) {
|
||||
createMessage.warning('无法获取当前用户部门');
|
||||
return false;
|
||||
}
|
||||
if (isEndValue !== '1' && !usernameValue) {
|
||||
@@ -591,20 +607,20 @@
|
||||
|
||||
savingSubApproveUser.value = true;
|
||||
try {
|
||||
const isEndResult = await saveProcessVariable('isEnd', isEndValue);
|
||||
if (!isEndResult?.success) {
|
||||
createMessage.warning(isEndResult.message || '保存失败');
|
||||
return false;
|
||||
const params: Record<string, any> = {
|
||||
mainId: mainForm.id,
|
||||
deptId,
|
||||
isEnd: Number(isEndValue),
|
||||
};
|
||||
if (isEndValue === '1') {
|
||||
params.implWorker = getCurrentAssignee();
|
||||
} else {
|
||||
params.implUserNameList = usernameValue.split(',').filter(Boolean);
|
||||
}
|
||||
|
||||
if (isEndValue !== '1') {
|
||||
const subApproveUserResult = await saveProcessVariable('subApproveUser', usernameValue);
|
||||
if (!subApproveUserResult?.success) {
|
||||
createMessage.warning(subApproveUserResult.message || '保存失败');
|
||||
return false;
|
||||
}
|
||||
// 同步更新 task_task 表的 deptHandlerName,供 XiSpeakFeedbackFlow.getImplDeptWorker 使用
|
||||
updateDeptHandlerName({ processInstanceId, deptHandlerName: usernameValue }).catch(() => {});
|
||||
const res = await saveSubApprove(params);
|
||||
if (!res?.success) {
|
||||
createMessage.warning(res?.message || '保存失败');
|
||||
return false;
|
||||
}
|
||||
if (showSuccessMessage) {
|
||||
createMessage.success('保存成功');
|
||||
@@ -618,16 +634,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function saveProcessVariable(varField: string, varVal: any) {
|
||||
return setProcessVariable({
|
||||
processInstanceId: processInfo.value.processInstanceId,
|
||||
taskId: processInfo.value.taskId,
|
||||
local: true,
|
||||
varField,
|
||||
varVal,
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeUsernameList(value: string) {
|
||||
return String(value || '')
|
||||
.split(',')
|
||||
|
||||
Reference in New Issue
Block a user