diff --git a/src/views/finance/purchasingrequisition/add.vue b/src/views/finance/purchasingrequisition/add.vue index c28293d..7816f8f 100644 --- a/src/views/finance/purchasingrequisition/add.vue +++ b/src/views/finance/purchasingrequisition/add.vue @@ -145,11 +145,11 @@ clearable :disabled="isAutoSelectPurchaseType" style="width: 100%"> - + @@ -170,6 +170,7 @@ @@ -190,6 +191,7 @@ @@ -202,11 +204,8 @@ -
- 请上传zip格式的压缩包 -
@@ -258,6 +257,7 @@ @@ -277,6 +277,7 @@ @@ -298,6 +299,7 @@ @@ -339,6 +341,7 @@ @@ -359,9 +362,20 @@ + + + + +
支持上传zip格式的压缩包文件
+
@@ -395,6 +409,40 @@ + + + + + + + + + + + + + + @@ -428,6 +478,7 @@ @@ -449,12 +500,14 @@ @@ -476,32 +529,18 @@ - - - - 下载《采购需求填报模板》模版 - - - - - - - - - 下载《服务商城项目需求模板(公开比选)》模版 - - + + + + @@ -594,8 +657,19 @@ + + + + +
支持上传zip格式的压缩包文件
+
@@ -651,6 +725,8 @@ import { useMessage } from '/@/hooks/message'; import UploadFile from '/@/components/Upload/index.vue'; import other from '/@/utils/other'; import { Document, Download } from '@element-plus/icons-vue'; +import { fetchList as getBusinessDeptList } from '/@/api/purchase/purchasingBusinessDept'; +import { getPage as getSchoolLeaderPage } from '/@/api/finance/purchasingschoolleader'; // 路由 const router = useRouter(); @@ -704,6 +780,13 @@ const dataForm = reactive({ recommendedSuppliersSchool: '', serviceInviteSelectSchool: '', servicePublicSelectSchoolAuto: '', + // 业务分管处室和分管校领导 + deptClassifyId: '', + deptClassifyName: '', + schoolLeaderUserId: '', + schoolLeaderName: '', + // 其他材料(zip压缩包) + otherMaterials: '', }); const categoryTreeData = ref([]); const categoryCodePath = ref([]); // 级联选择器的路径数组 @@ -713,6 +796,8 @@ const isSpecialList = ref([]); const purchaseTypeDeptList = ref([]); const purchaseModeSchoolList = ref([]); const purchaseTypeUnionList = ref([]); +const businessDeptList = ref([]); +const schoolLeaderList = ref([]); const loading = ref(false); // 采购方式ID常量 @@ -727,12 +812,16 @@ const PURCHASE_TYPE_IDS = { // 条件:特殊情况=否 且 集采=否 且 预算金额<5万 → 部门自行采购 // 其他情况 → 学校统一采购 const isDeptPurchase = computed(() => { - // 检查是否特殊情况是否为"否"(id: "1799c07f3a3b8a484f60c495ab9227b6") - const isSpecialNo = isSpecialList.value.find(item => item.id === '1799c07f3a3b8a484f60c495ab9227b6'); + // 检查是否特殊情况是否为"否"(通过 id 或 value 查找,value 为 '0') + const isSpecialNo = isSpecialList.value.find(item => + item.id === '1799c07f3a3b8a484f60c495ab9227b6' || item.value === '0' + ); const isSpecialNoValue = isSpecialNo ? isSpecialNo.value : null; - // 检查是否集采是否为"否"(id: "8e60f8860c1ea2459a41a8ae64fe5518") - const isCentralizedNo = isCentralizedList.value.find(item => item.id === '8e60f8860c1ea2459a41a8ae64fe5518'); + // 检查是否集采是否为"否"(通过 id 或 value 查找,value 为 '0') + const isCentralizedNo = isCentralizedList.value.find(item => + item.id === '8e60f8860c1ea2459a41a8ae64fe5518' || item.value === '0' + ); const isCentralizedNoValue = isCentralizedNo ? isCentralizedNo.value : null; // 三个条件必须同时满足:特殊情况=否 且 集采=否 且 预算金额<5万 @@ -746,9 +835,12 @@ const isDeptPurchase = computed(() => { return false; }); -// 判断是否为紧急情况(ID: 6509b59e24c1c6568f4277e544f3e55e) +// 判断是否为紧急情况(通过 id 或 value 查找,value 为 '1') const isUrgentSpecial = computed(() => { - const urgentItem = isSpecialList.value.find(item => item.id === '6509b59e24c1c6568f4277e544f3e55e'); + const urgentItem = isSpecialList.value.find(item => + item.id === '6509b59e24c1c6568f4277e544f3e55e' || + (item.value === '1' && (item.label?.includes('紧急') || item.dictLabel?.includes('紧急'))) + ); if (!urgentItem) return false; return dataForm.isSpecial === urgentItem.value; }); @@ -860,6 +952,20 @@ const showAutoPublicSelect = computed(() => { return budget >= 400000 && budget < 1000000 && isSpecialServiceCategory.value; }); +// 获取需求文件的 prop 名称(用于表单验证) +const getRequirementFileProp = () => { + if (showAutoInviteSelectSchool.value) { + if (dataForm.hasRecommendedSupplierSchool === 'yes') { + return 'serviceInviteSelectSchool'; + } else if (dataForm.hasRecommendedSupplierSchool === 'no') { + return 'servicePublicSelectSchoolAuto'; + } + } else if (showAutoPublicSelect.value) { + return 'servicePublicSelectSchool'; + } + return 'purchaseRequirement'; +}; + // 判断学校统一采购是否需要自动设置采购方式(5万<=金额<40万,服务类目,特殊服务类目) const isAutoSelectPurchaseTypeUnion = computed(() => { if (isDeptPurchase.value) return false; @@ -872,11 +978,13 @@ const isAutoSelectPurchaseTypeUnion = computed(() => { watch([() => dataForm.categoryCode, () => dataForm.budget], () => { // 部门自行采购:自动设置网上商城 if (isAutoSelectPurchaseType.value && isDeptPurchase.value) { - // 查找网上商城选项(通过id或value匹配) - const onlineMallOption = purchaseTypeDeptList.value.find(item => - item.id === PURCHASE_TYPE_IDS.ONLINE_MALL || - item.value === PURCHASE_TYPE_IDS.ONLINE_MALL - ); + // 查找网上商城选项(通过 id 或 label 匹配) + const onlineMallOption = purchaseTypeDeptList.value.find(item => { + const label = item.label || item.dictLabel || item.name || ''; + return item.id === PURCHASE_TYPE_IDS.ONLINE_MALL || + item.value === PURCHASE_TYPE_IDS.ONLINE_MALL || + label.includes('网上商城') || label.includes('商城'); + }); if (onlineMallOption && dataForm.purchaseType !== onlineMallOption.value) { dataForm.purchaseType = onlineMallOption.value; } @@ -1036,6 +1144,7 @@ const getFundSourceDict = async () => { fundSourceList.value = []; if (res.data && Array.isArray(res.data)) { fundSourceList.value = res.data.map((item: any) => ({ + id: item.id, label: item.label || item.dictLabel || item.name, value: item.value || item.dictValue || item.code })); @@ -1134,7 +1243,7 @@ const getPurchaseTypeDeptDict = async () => { purchaseTypeDeptList.value = res.data.map((item: any) => ({ id: item.id, label: item.label || item.dictLabel || item.name, - value: item.id || item.dictValue || item.code + value: item.value || item.dictValue || item.code })); } } catch (err) { @@ -1149,6 +1258,7 @@ const getPurchaseModeSchoolDict = async () => { purchaseModeSchoolList.value = []; if (res.data && Array.isArray(res.data)) { purchaseModeSchoolList.value = res.data.map((item: any) => ({ + id: item.id, label: item.label || item.dictLabel || item.name, value: item.value || item.dictValue || item.code })); @@ -1173,6 +1283,7 @@ const getPurchaseTypeUnionDict = async () => { purchaseTypeUnionList.value = []; if (res.data && Array.isArray(res.data)) { purchaseTypeUnionList.value = res.data.map((item: any) => ({ + id: item.id, label: item.label || item.dictLabel || item.name, value: item.value || item.dictValue || item.code })); @@ -1182,6 +1293,72 @@ const getPurchaseTypeUnionDict = async () => { } }; +// 获取业务分管处室列表 +const getBusinessDeptListData = async () => { + try { + const res = await getBusinessDeptList({ records: 1000 }); // 获取所有数据 + if (res.data && res.data.records) { + businessDeptList.value = res.data.records.map((item: any) => ({ + id: item.id, + deptId: item.deptId, + deptName: item.deptName, + userId: item.userId, + name: item.name, + username: item.username + })); + } + } catch (err) { + console.error('获取业务分管处室列表失败:', err); + businessDeptList.value = []; + } +}; + +// 获取分管校领导列表 +const getSchoolLeaderListData = async () => { + try { + const res = await getSchoolLeaderPage({ records: 1000 }); // 获取所有数据 + if (res.data && res.data.records) { + schoolLeaderList.value = res.data.records.map((item: any) => ({ + id: item.id, + userId: item.userId, + name: item.name, + username: item.username + })); + } + } catch (err) { + console.error('获取分管校领导列表失败:', err); + schoolLeaderList.value = []; + } +}; + +// 处理业务分管处室选择变化 +const handleBusinessDeptChange = (value: string) => { + if (value) { + const selected = businessDeptList.value.find(item => item.id === value); + if (selected) { + dataForm.deptClassifyId = selected.id; + dataForm.deptClassifyName = selected.deptName || ''; + } + } else { + dataForm.deptClassifyId = ''; + dataForm.deptClassifyName = ''; + } +}; + +// 处理分管校领导选择变化 +const handleSchoolLeaderChange = (value: string) => { + if (value) { + const selected = schoolLeaderList.value.find(item => item.userId === value); + if (selected) { + dataForm.schoolLeaderUserId = selected.userId; + dataForm.schoolLeaderName = selected.name || ''; + } + } else { + dataForm.schoolLeaderUserId = ''; + dataForm.schoolLeaderName = ''; + } +}; + // 处理文件ID字符串转数组 const getFileIdsArray = (fileIds: string | string[]): string[] => { if (!fileIds) return []; @@ -1234,7 +1411,7 @@ const handleSubmit = async () => { 'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement', 'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent', 'meetingMinutesSingle', 'meetingMinutesImport', 'singleSourceProof', 'importApplication', - 'governmentPurchaseIntent', 'servicePublicSelectSchool' + 'governmentPurchaseIntent', 'servicePublicSelectSchool', 'otherMaterials' ]; fileFields.forEach(field => { @@ -1283,7 +1460,7 @@ const handleTempStore = async () => { 'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement', 'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent', 'meetingMinutesSingle', 'meetingMinutesImport', 'singleSourceProof', 'importApplication', - 'governmentPurchaseIntent', 'servicePublicSelectSchool' + 'governmentPurchaseIntent', 'servicePublicSelectSchool', 'otherMaterials' ]; fileFields.forEach(field => { @@ -1366,7 +1543,26 @@ onMounted(async () => { getPurchaseTypeDeptDict(), getPurchaseModeSchoolDict(), getPurchaseTypeUnionDict(), + getBusinessDeptListData(), + getSchoolLeaderListData(), ]); + + // 新增模式下设置默认值(只有在没有 id 的情况下才设置) + if (!dataForm.id) { + // 填报日期默认为当天 + const today = new Date(); + const year = today.getFullYear(); + const month = String(today.getMonth() + 1).padStart(2, '0'); + const day = String(today.getDate()).padStart(2, '0'); + dataForm.applyDate = `${year}-${month}-${day}`; + + // 是否集采默认为"否"(value: '0') + dataForm.isCentralized = '0'; + + // 是否特殊情况默认为"否"(value: '0') + dataForm.isSpecial = '0'; + } + // 如果有 categoryCode,设置回显路径 if (dataForm.categoryCode) { setCategoryCodePath();