采购暂存逻辑修改
This commit is contained in:
@@ -846,12 +846,7 @@
|
||||
<template v-else>
|
||||
<el-button v-if="!isFlowEmbed" @click="handleCancel">取消</el-button>
|
||||
<el-button v-if="!isFlowEmbed && !flowSubmitDisabled" type="warning" @click="handleTempStore" :disabled="loading"> 暂存 </el-button>
|
||||
<!-- <el-button -->
|
||||
<!-- type="primary" -->
|
||||
<!-- @click="handleSubmit" -->
|
||||
<!-- :disabled="loading">-->
|
||||
<!-- {{ isEditMode ? '保存' : '提交' }}-->
|
||||
<!-- </el-button>-->
|
||||
<el-button v-if="!isFlowEmbed" type="primary" @click="handleSubmitFlow" :disabled="loading"> 提交 </el-button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -863,10 +858,10 @@
|
||||
<script setup lang="ts" name="PurchasingRequisitionAdd">
|
||||
import { reactive, ref, onMounted, computed, watch, nextTick } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { addObj, tempStore, getObj, editObj, getApplyFiles } from '/@/api/purchase/purchasingrequisition';
|
||||
import { addObj, tempStore, getObj, editObj, getApplyFiles, submitObj } from '/@/api/purchase/purchasingrequisition';
|
||||
import { getTree } from '/@/api/purchase/purchasingcategory';
|
||||
import { getDicts } from '/@/api/admin/dict';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useUserInfo } from '/@/stores/userInfo';
|
||||
import { usePurchaseRulesSingleton } from '/@/hooks/usePurchaseRules';
|
||||
import UploadFile from '/@/components/Upload/index.vue';
|
||||
@@ -2634,6 +2629,101 @@ const handleTempStore = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 提交(暂存后启动流程)
|
||||
const handleSubmitFlow = async () => {
|
||||
if (loading.value) return;
|
||||
|
||||
try {
|
||||
await useMessageBox().confirm('确定要提交该采购申请并启动流程吗?');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const valid = await formRef.value?.validate().catch(() => {});
|
||||
if (!valid) {
|
||||
loading.value = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
const submitData: any = {
|
||||
...dataForm,
|
||||
};
|
||||
|
||||
// 学校统一采购申请阶段:采购方式由审批环节补充,提交时不写入
|
||||
if (!isFlowEmbed.value && !isDeptPurchase.value) {
|
||||
submitData.purchaseType = '';
|
||||
}
|
||||
|
||||
// 处理所有文件字段
|
||||
const fileFields = [
|
||||
'businessNegotiationTable',
|
||||
'marketPurchaseMinutes',
|
||||
'onlineMallMaterials',
|
||||
'inquiryTemplate',
|
||||
'serviceDirectSelect',
|
||||
'servicePublicSelect',
|
||||
'purchaseRequirementTemplate',
|
||||
'serviceInviteSelect',
|
||||
'servicePublicSelectAuto',
|
||||
'deptSelfMeetingMinutes',
|
||||
'purchaseRequirement',
|
||||
'meetingMinutes',
|
||||
'feasibilityReport',
|
||||
'meetingMinutesUrgent',
|
||||
'meetingMinutesSingle',
|
||||
'meetingMinutesImport',
|
||||
'singleSourceProof',
|
||||
'importApplication',
|
||||
'governmentPurchaseIntent',
|
||||
'servicePublicSelectSchool',
|
||||
'serviceInviteSelectSchool',
|
||||
'servicePublicSelectSchoolAuto',
|
||||
'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;
|
||||
}
|
||||
|
||||
// 先暂存
|
||||
const tempResult = await tempStore(submitData);
|
||||
const applyId = tempResult?.data?.id || submitData.id || dataForm.id;
|
||||
|
||||
// 再提交
|
||||
await submitObj({ id: applyId });
|
||||
useMessage().success('提交成功');
|
||||
|
||||
if (window.parent !== window) {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: 'purchasingrequisition:submitSuccess',
|
||||
},
|
||||
'*'
|
||||
);
|
||||
} else {
|
||||
router.push('/purchase/purchasingrequisition');
|
||||
}
|
||||
} catch (err: any) {
|
||||
if (!err?.msg) {
|
||||
useMessage().error('提交失败');
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 设置品目编码回显路径
|
||||
const setCategoryCodePath = () => {
|
||||
if (dataForm.categoryCode && categoryTreeData.value.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user