feat(purchase): 政府采购意向表添加模版下载功能
- 添加政府采购意向表模版下载按钮(类型编码: gov_pur_int) - 模版名称从后台动态获取,支持后台维护后前端自动更新 - 页面加载时并行获取模版列表 - downloadTemplate 函数优化:优先使用后台模版名称,后备使用本地硬编码
This commit is contained in:
@@ -669,6 +669,15 @@
|
||||
upload-file-url="/purchase/purchasingfiles/upload"
|
||||
:disabled="flowFieldDisabled('governmentPurchaseIntent')"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
icon="Download"
|
||||
size="small"
|
||||
@click="downloadTemplate('gov_pur_int')"
|
||||
style="margin-top: 8px; display: inline-block"
|
||||
>下载《{{ getTemplateName('gov_pur_int') }}》模版
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" class="mb12">
|
||||
@@ -865,6 +874,7 @@ import { fetchList as getPurchasingManagerList } from '/@/api/purchase/purchasin
|
||||
import { fetchList as getBusinessLeaderList } from '/@/api/purchase/purchasingBusinessLeader';
|
||||
import { Session } from '/@/utils/storage';
|
||||
import * as orderVue from '/@/api/order/order-key-vue';
|
||||
import { listTemplates } from '/@/api/purchase/purchasingtemplate';
|
||||
|
||||
/** 采购中心角色编码:审批时仅该角色可编辑采购方式/采购形式 */
|
||||
const PURCHASE_CENTER_ROLE_CODE = 'PURCHASE_CENTER';
|
||||
@@ -1031,6 +1041,8 @@ const purchasingManagerList = ref<any[]>([]);
|
||||
const businessLeaderList = ref<any[]>([]);
|
||||
/** 人员类型字典(采购代表/评委) */
|
||||
const representorTypeList = ref<any[]>([]);
|
||||
/** 模版列表(从后台获取,用于显示模版名称) */
|
||||
const templateList = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const helpDialogVisible = ref(false);
|
||||
/** 数据是否已加载完成(用于控制自动设置采购方式的逻辑) */
|
||||
@@ -1590,33 +1602,78 @@ watch(
|
||||
|
||||
// 下载模版:统一走后端接口,按原始文件下载(避免前端静态资源被当成 HTML 返回)
|
||||
const downloadTemplate = async (type: string) => {
|
||||
const templateMap: Record<string, { displayName: string }> = {
|
||||
business_negotiation: { displayName: '商务洽谈表.doc' },
|
||||
market_purchase_minutes: { displayName: '部门自行采购市场采购纪要.doc' },
|
||||
inquiry: { displayName: '部门采购询价模版.doc' },
|
||||
direct_select: { displayName: '服务商城项目需求模板(直选).doc' },
|
||||
public_select: { displayName: '服务商城项目需求模板(公开比选).doc' },
|
||||
invite_select: { displayName: '服务商城项目需求模板(邀请比选).doc' },
|
||||
purchase_requirement: { displayName: '采购需求填报模板.doc' },
|
||||
import_application: { displayName: '进口产品申请及专家论证意见表.doc' },
|
||||
single_source: { displayName: '单一来源论专家证附件.docx' },
|
||||
feasibility_report: { displayName: '项目可行性论证报告模板.doc' },
|
||||
};
|
||||
// 优先从后台模版列表获取模版名称
|
||||
const backendTemplate = templateList.value.find((t: any) => t.type === type);
|
||||
let displayName = '';
|
||||
|
||||
const template = templateMap[type];
|
||||
if (!template) {
|
||||
if (backendTemplate?.templateTitle) {
|
||||
displayName = backendTemplate.templateTitle;
|
||||
} else {
|
||||
// 后备:使用本地硬编码的名称
|
||||
const templateMap: Record<string, string> = {
|
||||
business_negotiation: '商务洽谈表.doc',
|
||||
market_purchase_minutes: '部门自行采购市场采购纪要.doc',
|
||||
inquiry: '部门采购询价模版.doc',
|
||||
direct_select: '服务商城项目需求模板(直选).doc',
|
||||
public_select: '服务商城项目需求模板(公开比选).doc',
|
||||
invite_select: '服务商城项目需求模板(邀请比选).doc',
|
||||
purchase_requirement: '采购需求填报模板.doc',
|
||||
import_application: '进口产品申请及专家论证意见表.doc',
|
||||
single_source: '单一来源论专家证附件.docx',
|
||||
feasibility_report: '项目可行性论证报告模板.doc',
|
||||
gov_pur_int: '政府采购意向申请表.doc',
|
||||
};
|
||||
displayName = templateMap[type] || '';
|
||||
}
|
||||
|
||||
if (!displayName) {
|
||||
useMessage().error('模版不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await other.downBlobFile(`/purchase/purchasingtemplate/download?type=${encodeURIComponent(type)}`, {}, template.displayName);
|
||||
await other.downBlobFile(`/purchase/purchasingtemplate/download?type=${encodeURIComponent(type)}`, {}, displayName);
|
||||
useMessage().success('模版下载成功');
|
||||
} catch (err) {
|
||||
useMessage().error('模版下载失败,请联系管理员维护模版文件');
|
||||
}
|
||||
};
|
||||
|
||||
// 获取模版名称(用于按钮显示,优先从后台获取)
|
||||
const getTemplateName = (type: string): string => {
|
||||
const backendTemplate = templateList.value.find((t: any) => t.type === type);
|
||||
if (backendTemplate?.templateTitle) {
|
||||
return backendTemplate.templateTitle.replace(/\.(doc|docx)$/i, '');
|
||||
}
|
||||
// 后备名称
|
||||
const fallbackNames: Record<string, string> = {
|
||||
business_negotiation: '商务洽谈表',
|
||||
market_purchase_minutes: '部门自行采购市场采购纪要',
|
||||
inquiry: '部门采购询价模版',
|
||||
direct_select: '服务商城项目需求模板(直选)',
|
||||
public_select: '服务商城项目需求模板(公开比选)',
|
||||
invite_select: '服务商城项目需求模板(邀请比选)',
|
||||
purchase_requirement: '采购需求填报模板',
|
||||
import_application: '进口产品申请及专家论证意见表',
|
||||
single_source: '单一来源论专家证附件',
|
||||
feasibility_report: '项目可行性论证报告模板',
|
||||
gov_pur_int: '政府采购意向申请表',
|
||||
};
|
||||
return fallbackNames[type] || '模版';
|
||||
};
|
||||
|
||||
// 获取模版列表
|
||||
const getTemplateList = async () => {
|
||||
try {
|
||||
const res = await listTemplates();
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
templateList.value = res.data;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取模版列表失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
const dataRules = reactive({
|
||||
projectName: [{ required: true, message: '采购项目名称不能为空', trigger: 'blur' }],
|
||||
applyDate: [{ required: true, message: '填报日期不能为空', trigger: 'change' }],
|
||||
@@ -2666,6 +2723,7 @@ onMounted(async () => {
|
||||
getSchoolLeaderListData(),
|
||||
getPurchasingManagerListData(),
|
||||
getBusinessLeaderListData(),
|
||||
getTemplateList(),
|
||||
]);
|
||||
|
||||
// 编辑/查看:从 URL 或流程 currJob.orderId 加载详情
|
||||
|
||||
Reference in New Issue
Block a user