@@ -218,7 +210,6 @@ defineExpose({
:deep(.el-form-item__content) {
margin-left: 0 !important;
}
- margin-right: 16px;
margin-bottom: 18px;
}
@@ -280,40 +271,21 @@ defineExpose({
}
:deep(.el-form-item:not(:has(.el-button))) {
- margin-right: 16px;
+ margin-right: 15px;
}
- /* grid 0fr→1fr 高度过渡,ease-out 收尾不弹跳 */
- .collapse-grid {
- display: grid;
- grid-template-rows: 0fr;
- transition: grid-template-rows 0.26s cubic-bezier(0.33, 1, 0.68, 1);
- contain: layout;
- &.is-expanded {
- grid-template-rows: 1fr;
- }
- }
- .collapse-grid-inner {
- overflow: hidden;
- min-height: 0;
- backface-visibility: hidden;
- }
- .collapse-grid-cell {
- overflow: hidden;
- min-height: 0;
- opacity: 0;
- /* 收起时立即隐藏,不出现输入框慢慢消失 */
- transition: opacity 0s;
- }
- .collapse-grid.is-expanded .collapse-grid-cell {
- opacity: 1;
- /* 仅展开时淡入 */
- transition: opacity 0.12s ease-out;
- }
- .actions-outside,
- .actions-inside {
+ /* 折叠区收起时隐藏,展开时 display:contents 不破坏表单行内流 */
+ .collapse-visibility {
display: contents;
}
+
+ /* 查询/重置按钮区:表单项 margin-right 为 0 */
+ .search-form__actions {
+ display: contents;
+ :deep(.el-form-item) {
+ margin-right: 0 !important;
+ }
+ }
}
diff --git a/src/components/SearchForm/index2.vue b/src/components/SearchForm/index2.vue
new file mode 100644
index 0000000..fb2f580
--- /dev/null
+++ b/src/components/SearchForm/index2.vue
@@ -0,0 +1,321 @@
+
+
+
+
+
+
+
+
diff --git a/src/components/Upload/index.vue b/src/components/Upload/index.vue
index d5817ff..4540b95 100644
--- a/src/components/Upload/index.vue
+++ b/src/components/Upload/index.vue
@@ -161,6 +161,7 @@ interface FileItem {
name?: string;
url?: string;
uid?: number;
+ id?: string; // 文件ID
}
interface UploadFileItem {
@@ -170,6 +171,7 @@ interface UploadFileItem {
fileSize: number;
fileName: string;
fileType: string;
+ id?: string; // 文件ID
}
const props = defineProps({
@@ -270,14 +272,74 @@ const handleBeforeUpload = (file: File) => {
// 上传成功回调
function handleUploadSuccess(res: any, file: any) {
if (res.code === 0) {
+ // 调试:打印完整的响应数据
+ console.log('上传成功响应数据:', res);
+ console.log('res.data:', res.data);
+
+ // 获取文件ID - 尝试多种可能的字段名
+ let fileId = res.data?.id || res.data?.fileId || res.data?.file_id || null;
+ let fileUrl = res.data?.url || res.data?.fileUrl || '';
+
+ // 如果fileId不存在,尝试从fileName中提取(fileName可能是ID)
+ if (!fileId && res.data?.fileName) {
+ const fileName = res.data.fileName;
+ // 检查fileName是否是32位十六进制字符串(文件ID格式)
+ if (/^[a-f0-9]{32}$/i.test(fileName)) {
+ fileId = fileName;
+ }
+ }
+
+ // 如果fileId仍然不存在,尝试从URL中提取
+ if (!fileId && fileUrl) {
+ try {
+ const urlObj = new URL(fileUrl, window.location.origin);
+ fileId = urlObj.searchParams.get('id');
+ // 如果URL参数中没有id,检查路径中是否有32位十六进制字符串
+ if (!fileId) {
+ const pathParts = urlObj.pathname.split('/').filter(p => p);
+ const lastPart = pathParts[pathParts.length - 1];
+ if (lastPart && /^[a-f0-9]{32}$/i.test(lastPart)) {
+ fileId = lastPart;
+ }
+ }
+ } catch (e) {
+ // URL解析失败,忽略
+ }
+ }
+
+ // 如果仍然没有fileId,尝试从整个res.data中查找可能的ID字段
+ if (!fileId && res.data) {
+ // 遍历res.data的所有属性,查找32位十六进制字符串
+ for (const key in res.data) {
+ const value = res.data[key];
+ if (typeof value === 'string' && /^[a-f0-9]{32}$/i.test(value)) {
+ fileId = value;
+ break;
+ }
+ }
+ }
+
+ console.log('提取的文件ID:', fileId);
+
+ // 构建URL,如果存在id则添加到URL参数中(用于兼容性)
+ if (fileId && fileUrl) {
+ // 如果URL中已经有参数,使用&,否则使用?
+ fileUrl = fileUrl.includes('?') ? `${fileUrl}&id=${fileId}` : `${fileUrl}?id=${fileId}`;
+ }
+ fileUrl = `${fileUrl}&originalFileName=${file.name}`;
+
uploadList.value.push({
name: file.name,
- url: `${res.data?.url}&originalFileName=${file.name}`,
+ url: fileUrl,
fileUrl: res.data?.fileName,
fileSize: file.size,
fileName: file.name,
fileType: file.raw.type,
+ id: fileId, // 保存文件ID(优先使用)
});
+
+ console.log('保存的文件对象:', uploadList.value[uploadList.value.length - 1]);
+
uploadedSuccessfully();
} else {
number.value--;
@@ -298,10 +360,12 @@ const uploadedSuccessfully = () => {
}
};
-const handleRemove = (file: { name: string }) => {
- fileList.value = fileList.value.filter((f) => f.name !== file.name);
- emit('update:modelValue', listToString(fileList.value));
- emit('change', listToString(fileList.value), fileList.value);
+const handleRemove = (file: { name?: string }) => {
+ if (file.name) {
+ fileList.value = fileList.value.filter((f) => f.name !== file.name);
+ emit('update:modelValue', listToString(fileList.value));
+ emit('change', listToString(fileList.value), fileList.value);
+ }
};
const handlePreview = (file: any) => {
@@ -319,12 +383,21 @@ const handleExceed = () => {
* @param separator 分隔符,默认为逗号。
* @returns {string} 返回转换后的字符串。
*/
+/**
+ * 将对象数组转为字符串,以逗号分隔。
+ * 如果文件有id,优先使用id,否则使用url。
+ * @param list 待转换的对象数组。
+ * @param separator 分隔符,默认为逗号。
+ * @returns {string} 返回转换后的字符串(ID或URL,用逗号分隔)。
+ */
const listToString = (list: FileItem[], separator = ','): string => {
let strs = '';
separator = separator || ',';
for (let i in list) {
- if (list[i].url) {
- strs += list[i].url + separator;
+ // 优先使用id,如果没有id则使用url
+ const value = list[i].id || list[i].url;
+ if (value) {
+ strs += value + separator;
}
}
return strs !== '' ? strs.substr(0, strs.length - 1) : '';
@@ -347,7 +420,28 @@ watch(
// 然后将数组转为对象数组
fileList.value = list.map((item: any) => {
if (typeof item === 'string') {
- item = { name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'), url: item };
+ // 检查是否是32位十六进制字符串(文件ID格式)
+ const isId = /^[a-f0-9]{32}$/i.test(item.trim());
+ if (isId) {
+ // 如果是ID格式,直接使用
+ item = { id: item.trim(), name: '', url: '' };
+ } else {
+ // 如果是URL,尝试从URL中提取id
+ try {
+ const urlObj = new URL(item, window.location.origin);
+ const id = urlObj.searchParams.get('id');
+ item = {
+ name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'),
+ url: item,
+ id: id || undefined
+ };
+ } catch {
+ item = {
+ name: other.getQueryString(item, 'originalFileName') || other.getQueryString(item, 'fileName'),
+ url: item
+ };
+ }
+ }
}
item.uid = item.uid || new Date().getTime() + temp++;
return item as FileItem;
diff --git a/src/views/finance/purchasingrequisition/add.vue b/src/views/finance/purchasingrequisition/add.vue
index 02651f1..c11e65c 100644
--- a/src/views/finance/purchasingrequisition/add.vue
+++ b/src/views/finance/purchasingrequisition/add.vue
@@ -211,10 +211,33 @@
upload-file-url="/purchase/purchasingfiles/upload" />
+
+
+
+ 下载《部门采购询价模版》模版
+
+
+
+
-
+
+
服务类网上商城
其他方式
@@ -224,12 +247,12 @@
- 有
- 无
+ 有
+ 无
-
+
= {
businessNegotiationTable: '10', // 商务洽谈纪要
marketPurchaseMinutes: '20', // 市场采购纪要
+ inquiryTemplate: '20', // 询价模板(归类到市场采购纪要)
onlineMallMaterials: '30', // 网上商城采购相关材料
feasibilityReport: '40', // 可行性论证报告
meetingMinutes: '50', // 会议记录
@@ -845,16 +870,16 @@ const FILE_TYPE_MAP: Record = {
singleSourceProof: '70', // 单一来源专家论证表
importApplication: '80', // 进口产品申请表
governmentPurchaseIntent: '100', // 政府采购意向表
- // 需求文件相关(暂时使用默认值,可根据实际需求调整)
- serviceDirectSelect: '30', // 服务商城项目需求模板(直选)- 归类到网上商城采购相关材料
- serviceInviteSelect: '30', // 服务商城项目需求模板(邀请比选)
- servicePublicSelect: '30', // 服务商城项目需求模板(公开比选)
- servicePublicSelectAuto: '30', // 服务商城项目需求模板(公开比选-自动)
- purchaseRequirementTemplate: '30', // 采购需求填报模板
- purchaseRequirement: '30', // 采购需求填报模板
- serviceInviteSelectSchool: '30', // 服务商城项目需求模板(邀请比选-学校)
- servicePublicSelectSchoolAuto: '30', // 服务商城项目需求模板(公开比选-学校-自动)
- servicePublicSelectSchool: '30', // 服务商城项目需求模板(公开比选-学校)
+ // 需求文件相关 - 所有需求模板都应该是120(采购需求表)
+ serviceDirectSelect: '120', // 服务商城项目需求模板(直选)- 采购需求表
+ serviceInviteSelect: '120', // 服务商城项目需求模板(邀请比选)- 采购需求表
+ servicePublicSelect: '120', // 服务商城项目需求模板(公开比选)- 采购需求表
+ servicePublicSelectAuto: '120', // 服务商城项目需求模板(公开比选-自动)- 采购需求表
+ purchaseRequirementTemplate: '120', // 采购需求填报模板 - 采购需求表
+ purchaseRequirement: '120', // 采购需求填报模板 - 采购需求表
+ serviceInviteSelectSchool: '120', // 服务商城项目需求模板(邀请比选-学校)- 采购需求表
+ servicePublicSelectSchoolAuto: '120', // 服务商城项目需求模板(公开比选-学校-自动)- 采购需求表
+ servicePublicSelectSchool: '120', // 服务商城项目需求模板(公开比选-学校)- 采购需求表
};
// 辅助函数:判断当前采购方式是否为指定类型(通过 id 或 value 匹配)
@@ -871,6 +896,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;
@@ -998,6 +1034,53 @@ const isSpecialServiceCategory = computed(() => {
return Number(category.isMallService) === 1 || Number(category.isProjectService) === 1;
});
+// 委托采购中心方式自动判断:
+// - 服务类:若末级节点 isMallService=0 且 isMallProject=0,则选“其他方式”,否则选“服务类网上商城”
+// - 非服务类:默认选“其他方式”
+const calcEntrustCenterType = (): 'service_online' | 'other' | '' => {
+ if (!isPurchaseType(PURCHASE_TYPE_IDS.ENTRUST_CENTER)) return '';
+ if (!dataForm.categoryCode) return '';
+
+ const category = getCategoryInfo();
+ if (!category) return '';
+
+ // 兼容字段:接口可能为 isMallProject,也可能历史字段为 isProjectService
+ const mallService = Number(category.isMallService ?? 0);
+ const mallProject = Number(category.isMallProject ?? category.isProjectService ?? 0);
+
+ if (isServiceCategory.value) {
+ return mallService === 0 && mallProject === 0 ? 'other' : 'service_online';
+ }
+ return 'other';
+};
+
+// 监听品目/采购方式变化,自动设置委托采购中心方式,并清理无关字段
+watch(
+ [() => dataForm.purchaseType, () => dataForm.categoryCode, () => categoryTreeData.value],
+ () => {
+ const nextType = calcEntrustCenterType();
+ if (!nextType) return;
+
+ const prevType = dataForm.entrustCenterType as any;
+ if (prevType === nextType) return;
+
+ dataForm.entrustCenterType = nextType;
+
+ // 切换时清理不相关字段,避免脏数据
+ if (nextType === 'other') {
+ dataForm.hasSupplier = '';
+ dataForm.suppliers = '';
+ dataForm.serviceDirectSelect = '';
+ dataForm.serviceInviteSelect = '';
+ dataForm.servicePublicSelect = '';
+ dataForm.servicePublicSelectAuto = '';
+ } else if (nextType === 'service_online') {
+ dataForm.purchaseRequirementTemplate = '';
+ }
+ },
+ { immediate: true }
+);
+
// 判断是否自动选择网上商城采购方式(5万<=金额<40万,服务类目,特殊服务类目)
const isAutoSelectPurchaseType = computed(() => {
if (!dataForm.budget) return false;
@@ -1085,6 +1168,7 @@ const downloadTemplate = async (type: string) => {
const templateMap: Record = {
'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 +1521,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);
}
}
});
@@ -1504,9 +1590,9 @@ const handleSubmit = async () => {
...dataForm,
};
- // 处理所有文件字段
+ // 处理所有文件字段 - 收集所有文件ID到fileIds数组中
const fileFields = [
- 'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials',
+ 'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials', 'inquiryTemplate',
'serviceDirectSelect', 'servicePublicSelect', 'purchaseRequirementTemplate',
'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement',
'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent',
@@ -1515,11 +1601,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);
+ // 收集到总数组中
+ allFileIds.push(...ids);
+ // 清空原字段,不再单独传递
+ delete submitData[field];
}
});
+
+ // 将所有文件ID统一放到fileIds字段中
+ if (allFileIds.length > 0) {
+ submitData.fileIds = allFileIds;
+ console.log('所有文件ID (fileIds):', allFileIds);
+ }
+
+ console.log('提交数据:', submitData);
await addObj(submitData);
useMessage().success('提交成功');
@@ -1555,8 +1657,9 @@ const handleTempStore = async () => {
...dataForm,
};
+ // 处理所有文件字段 - 收集所有文件ID到fileIds数组中
const fileFields = [
- 'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials',
+ 'businessNegotiationTable', 'marketPurchaseMinutes', 'onlineMallMaterials', 'inquiryTemplate',
'serviceDirectSelect', 'servicePublicSelect', 'purchaseRequirementTemplate',
'serviceInviteSelect', 'servicePublicSelectAuto', 'purchaseRequirement',
'meetingMinutes', 'feasibilityReport', 'meetingMinutesUrgent',
@@ -1565,11 +1668,23 @@ const handleTempStore = async () => {
'servicePublicSelectSchoolAuto', 'otherMaterials'
];
+ // 收集所有文件ID到一个数组中
+ const allFileIds: string[] = [];
+
fileFields.forEach(field => {
if (submitData[field]) {
- submitData[field] = getFileIdsArray(submitData[field]);
+ const ids = getFileIdsArray(submitData[field]);
+ // 收集到总数组中
+ allFileIds.push(...ids);
+ // 清空原字段,不再单独传递
+ delete submitData[field];
}
});
+
+ // 将所有文件ID统一放到fileIds字段中
+ if (allFileIds.length > 0) {
+ submitData.fileIds = allFileIds;
+ }
await tempStore(submitData);
useMessage().success('暂存成功');