fix
This commit is contained in:
@@ -591,8 +591,8 @@
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="form-footer">
|
||||
<!-- 操作按钮(非流程嵌入模式显示) -->
|
||||
<div class="form-footer" v-if="!isFlowEmbed">
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="warning" @click="handleTempStore" :disabled="loading"> 暂存 </el-button>
|
||||
</div>
|
||||
@@ -619,6 +619,11 @@ import { fetchList as getBusinessDeptList } from '/@/api/purchase/purchasingBusi
|
||||
import { getPage as getSchoolLeaderPage } from '/@/api/purchase/purchasingschoolleader';
|
||||
import { fetchList as getPurchasingManagerList } from '/@/api/purchase/purchasingPurchaseManager';
|
||||
import { fetchList as getBusinessLeaderList } from '/@/api/purchase/purchasingBusinessLeader';
|
||||
import * as orderVue from '/@/api/order/order-key-vue';
|
||||
import { handleCustomFormPerm } from '/@/flow/utils/form-perm';
|
||||
|
||||
// 流程嵌入时触发保存事件
|
||||
const emits = defineEmits(['handleJob']);
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -635,6 +640,9 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
// 是否为流程嵌入模式
|
||||
const isFlowEmbed = computed(() => !!props.currJob);
|
||||
|
||||
// 当前使用的申请单 ID(优先从流程 currJob.orderId 获取,否则从 URL query 获取)
|
||||
const effectiveQueryId = computed(() => {
|
||||
// 流程嵌入模式:优先使用 currJob.orderId
|
||||
@@ -2006,6 +2014,78 @@ const handleTempStore = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 流程嵌入时保存表单并通知流程
|
||||
const handleFlowSave = async () => {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const submitData: any = {
|
||||
...dataForm,
|
||||
};
|
||||
|
||||
// 学校统一采购申请阶段:采购方式由审批环节补充,暂存时不写入
|
||||
if (!isDeptPurchase.value) {
|
||||
submitData.purchaseType = '';
|
||||
}
|
||||
|
||||
// 处理所有文件字段 - 收集所有文件ID到fileIds数组中
|
||||
const fileFields = [
|
||||
'businessNegotiationTable',
|
||||
'marketPurchaseMinutes',
|
||||
'onlineMallMaterials',
|
||||
'inquiryTemplate',
|
||||
'purchaseRequirementTemplate',
|
||||
'deptSelfMeetingMinutes',
|
||||
'purchaseRequirement',
|
||||
'meetingMinutes',
|
||||
'feasibilityReport',
|
||||
'singleSourceProof',
|
||||
'importApplication',
|
||||
'governmentPurchaseIntent',
|
||||
'otherMaterials',
|
||||
];
|
||||
|
||||
const allFileIds: string[] = [];
|
||||
|
||||
fileFields.forEach((field) => {
|
||||
if (submitData[field]) {
|
||||
const ids = getFileIdsArray(submitData[field]);
|
||||
allFileIds.push(...ids);
|
||||
delete submitData[field];
|
||||
}
|
||||
});
|
||||
|
||||
if (allFileIds.length > 0) {
|
||||
submitData.fileIds = allFileIds;
|
||||
}
|
||||
|
||||
await tempStore(submitData);
|
||||
// 通知流程保存成功
|
||||
orderVue.currElTabIsSave(props.currJob, props.currElTab.id, true, emits);
|
||||
useMessage().success('保存成功');
|
||||
} catch (err: any) {
|
||||
if (!err?.msg) {
|
||||
useMessage().error('保存失败');
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 监听 currJob 变化,流程嵌入时加载数据
|
||||
watch(
|
||||
() => props.currJob?.id,
|
||||
() => {
|
||||
if (isFlowEmbed.value) {
|
||||
const queryId = effectiveQueryId.value;
|
||||
if (queryId) {
|
||||
loadDetail(queryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 设置品目编码回显路径
|
||||
const setCategoryCodePath = () => {
|
||||
if (dataForm.categoryCode && categoryTreeData.value.length > 0) {
|
||||
@@ -2099,6 +2179,16 @@ onMounted(async () => {
|
||||
if (dataForm.categoryCode) {
|
||||
setCategoryCodePath();
|
||||
}
|
||||
|
||||
// 流程嵌入模式:注册保存函数
|
||||
if (isFlowEmbed.value) {
|
||||
const elTab = props.currElTab;
|
||||
await handleCustomFormPerm(props, {}, {}, elTab);
|
||||
// 注册保存函数到流程
|
||||
if (props.currJob?.resolveSaves) {
|
||||
props.currJob.resolveSaves.push(handleFlowSave);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user