tijiao
This commit is contained in:
@@ -211,6 +211,28 @@
|
||||
upload-file-url="/purchase/purchasingfiles/upload" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 询价 -->
|
||||
<el-form-item
|
||||
v-if="isInquiryPurchaseType"
|
||||
label="询价模板"
|
||||
prop="inquiryTemplate"
|
||||
class="mb20">
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
icon="Download"
|
||||
@click="downloadTemplate('inquiry')"
|
||||
class="mb10">
|
||||
下载《部门采购询价模版》模版
|
||||
</el-button>
|
||||
<upload-file
|
||||
v-model="dataForm.inquiryTemplate"
|
||||
:limit="5"
|
||||
:file-type="['doc', 'docx', 'pdf']"
|
||||
:data="{ fileType: FILE_TYPE_MAP.inquiryTemplate }"
|
||||
upload-file-url="/purchase/purchasingfiles/upload" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 委托采购中心 -->
|
||||
<template v-if="isPurchaseType(PURCHASE_TYPE_IDS.ENTRUST_CENTER)">
|
||||
<el-form-item label="委托采购中心方式" prop="entrustCenterType" class="mb20">
|
||||
@@ -776,6 +798,7 @@ const dataForm = reactive({
|
||||
businessNegotiationTable: '',
|
||||
marketPurchaseMinutes: '',
|
||||
onlineMallMaterials: '',
|
||||
inquiryTemplate: '', // 询价模板
|
||||
entrustCenterType: '',
|
||||
hasSupplier: '',
|
||||
suppliers: '', // 供应商名称(逗号或分号分隔)
|
||||
@@ -835,6 +858,7 @@ const PURCHASE_TYPE_IDS = {
|
||||
const FILE_TYPE_MAP: Record<string, string> = {
|
||||
businessNegotiationTable: '10', // 商务洽谈纪要
|
||||
marketPurchaseMinutes: '20', // 市场采购纪要
|
||||
inquiryTemplate: '20', // 询价模板(归类到市场采购纪要)
|
||||
onlineMallMaterials: '30', // 网上商城采购相关材料
|
||||
feasibilityReport: '40', // 可行性论证报告
|
||||
meetingMinutes: '50', // 会议记录
|
||||
@@ -871,6 +895,17 @@ const isPurchaseType = (purchaseTypeId: string) => {
|
||||
return dataForm.purchaseType === purchaseTypeId;
|
||||
};
|
||||
|
||||
// 辅助函数:判断当前采购方式是否为"询价"(通过 label 匹配)
|
||||
const isInquiryPurchaseType = computed(() => {
|
||||
if (!dataForm.purchaseType) return false;
|
||||
const item = purchaseTypeDeptList.value.find(item => item.value === dataForm.purchaseType);
|
||||
if (item) {
|
||||
const label = item.label || item.dictLabel || item.name || '';
|
||||
return label.includes('询价');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 辅助函数:判断特殊情况是否为指定类型(通过 id 或 value 匹配)
|
||||
const isSpecialType = (specialIdOrValue: string) => {
|
||||
if (!dataForm.isSpecial) return false;
|
||||
@@ -1085,6 +1120,7 @@ const downloadTemplate = async (type: string) => {
|
||||
const templateMap: Record<string, { fileName: string, displayName: string }> = {
|
||||
'business_negotiation': { fileName: '商务洽谈表.xlsx', displayName: '商务洽谈表.xlsx' },
|
||||
'market_purchase_minutes': { fileName: '市场采购纪要.xlsx', displayName: '市场采购纪要.xlsx' },
|
||||
'inquiry': { fileName: '部门采购询价模版.docx', displayName: '部门采购询价模版.docx' },
|
||||
'direct_select': { fileName: '服务商城项目需求模板(直选).doc', displayName: '服务商城项目需求模板(直选).doc' },
|
||||
'public_select': { fileName: '服务商城项目需求模板(公开比选).doc', displayName: '服务商城项目需求模板(公开比选).doc' },
|
||||
'invite_select': { fileName: '服务商城项目需求模板(邀请比选).doc', displayName: '服务商城项目需求模板(邀请比选).doc' },
|
||||
@@ -1437,50 +1473,52 @@ const handleSchoolLeaderChange = (value: string) => {
|
||||
};
|
||||
|
||||
// 处理文件ID字符串转数组
|
||||
// 从上传返回的URL中提取文件ID,拼成数组格式:["id1", "id2"]
|
||||
// 从上传返回的URL或ID中提取文件ID,拼成数组格式:["id1", "id2"]
|
||||
// 上传接口返回的id会保存在URL的id参数中,或者直接是32位十六进制字符串
|
||||
const getFileIdsArray = (fileIds: string | string[]): string[] => {
|
||||
if (!fileIds) return [];
|
||||
if (Array.isArray(fileIds)) return fileIds;
|
||||
|
||||
const urls = fileIds.split(',').filter(url => url.trim());
|
||||
const items = fileIds.split(',').filter(item => item.trim());
|
||||
const ids: string[] = [];
|
||||
|
||||
urls.forEach(url => {
|
||||
items.forEach(item => {
|
||||
const trimmed = item.trim();
|
||||
// 首先检查是否是直接的ID格式(32位十六进制字符串)
|
||||
if (/^[a-f0-9]{32}$/i.test(trimmed)) {
|
||||
ids.push(trimmed);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果不是ID格式,尝试从URL中提取id参数
|
||||
try {
|
||||
// 尝试解析为URL
|
||||
const urlObj = new URL(url, window.location.origin);
|
||||
const urlObj = new URL(trimmed, window.location.origin);
|
||||
// 优先从URL参数中获取id
|
||||
let id = urlObj.searchParams.get('id');
|
||||
|
||||
// 如果没有id参数,尝试从路径中提取(可能是直接的文件ID)
|
||||
if (!id) {
|
||||
const pathParts = urlObj.pathname.split('/').filter(p => p);
|
||||
// 检查最后一个路径段是否是32位十六进制字符串(文件ID格式)
|
||||
const lastPart = pathParts[pathParts.length - 1];
|
||||
if (lastPart && /^[a-f0-9]{32}$/i.test(lastPart)) {
|
||||
id = lastPart;
|
||||
} else if (lastPart) {
|
||||
id = lastPart;
|
||||
}
|
||||
}
|
||||
|
||||
if (id) {
|
||||
ids.push(id);
|
||||
} else {
|
||||
// 如果URL解析失败,检查原始字符串是否是ID格式
|
||||
if (/^[a-f0-9]{32}$/i.test(url.trim())) {
|
||||
ids.push(url.trim());
|
||||
} else {
|
||||
ids.push(url);
|
||||
}
|
||||
// 如果无法提取ID,使用原始字符串(可能是URL)
|
||||
// 但这种情况不应该发生,因为上传接口应该返回id
|
||||
console.warn('无法从URL中提取文件ID:', trimmed);
|
||||
ids.push(trimmed);
|
||||
}
|
||||
} catch {
|
||||
// URL解析失败,检查是否是直接的ID格式(32位十六进制)
|
||||
if (/^[a-f0-9]{32}$/i.test(url.trim())) {
|
||||
ids.push(url.trim());
|
||||
// URL解析失败,如果原始字符串是ID格式则使用,否则忽略
|
||||
if (/^[a-f0-9]{32}$/i.test(trimmed)) {
|
||||
ids.push(trimmed);
|
||||
} else {
|
||||
// 否则直接使用原始字符串
|
||||
ids.push(url);
|
||||
console.warn('无法解析文件标识:', trimmed);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1506,7 +1544,7 @@ const handleSubmit = async () => {
|
||||
|
||||
// 处理所有文件字段
|
||||
const fileFields = [
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials',
|
||||
'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials', 'inquiryTemplate',
|
||||
'serviceDirectSelect', 'servicePublicSelect', 'purchaseRequirementTemplate',
|
||||
'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement',
|
||||
'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent',
|
||||
@@ -1515,11 +1553,27 @@ const handleSubmit = async () => {
|
||||
'servicePublicSelectSchoolAuto', 'otherMaterials'
|
||||
];
|
||||
|
||||
// 收集所有文件ID到一个数组中
|
||||
const allFileIds: string[] = [];
|
||||
|
||||
fileFields.forEach(field => {
|
||||
if (submitData[field]) {
|
||||
submitData[field] = getFileIdsArray(submitData[field]);
|
||||
const ids = getFileIdsArray(submitData[field]);
|
||||
console.log(`字段 ${field} 的文件ID:`, ids);
|
||||
// 将文件字段转换为ID数组
|
||||
submitData[field] = ids;
|
||||
// 同时收集到总数组中
|
||||
allFileIds.push(...ids);
|
||||
}
|
||||
});
|
||||
|
||||
// 添加fileIds字段,包含所有文件ID
|
||||
if (allFileIds.length > 0) {
|
||||
submitData.fileIds = allFileIds;
|
||||
console.log('所有文件ID:', allFileIds);
|
||||
}
|
||||
|
||||
console.log('提交数据:', submitData);
|
||||
|
||||
await addObj(submitData);
|
||||
useMessage().success('提交成功');
|
||||
|
||||
Reference in New Issue
Block a user