更新采购导出
This commit is contained in:
@@ -182,3 +182,11 @@ export function getArchiveDownloadUrl(purchaseId: string | number) {
|
|||||||
return `/purchase/purchasingfiles/archive?purchaseId=${encodeURIComponent(String(purchaseId))}`;
|
return `/purchase/purchasingfiles/archive?purchaseId=${encodeURIComponent(String(purchaseId))}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载审批表:导出采购审批表 Word 文档(apply.docx 模板,仅占位符替换)
|
||||||
|
* @param id 采购申请ID
|
||||||
|
*/
|
||||||
|
export function getApplyTemplateDownloadUrl(id: string | number) {
|
||||||
|
return `/purchase/purchasingapply/export-apply-template?id=${encodeURIComponent(String(id))}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,18 @@ export function getAcceptanceItems(acceptanceType: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载履约验收模板
|
||||||
|
*/
|
||||||
|
export function downloadPerformanceAcceptanceTemplate(purchaseId: string, batch?: number) {
|
||||||
|
return request({
|
||||||
|
url: '/purchase/purchasingAccept/export-performance-acceptance-template',
|
||||||
|
method: 'get',
|
||||||
|
params: { purchaseId, batch },
|
||||||
|
responseType: 'blob' // 重要:用于文件下载
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 工具函数 ==========
|
// ========== 工具函数 ==========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -82,6 +82,20 @@
|
|||||||
<template #footer>
|
<template #footer>
|
||||||
<span>
|
<span>
|
||||||
<el-button @click="handleClose">关 闭</el-button>
|
<el-button @click="handleClose">关 闭</el-button>
|
||||||
|
<!-- 下载履约验收模板按钮 -->
|
||||||
|
<el-dropdown split-button type="primary" @click="handleDownloadTemplate" @command="handleDownloadTemplateCommand">
|
||||||
|
下载履约模板
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item command="current" :disabled="!activeBatchId">
|
||||||
|
下载当前期({{ activeTab }}期)
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="all" :disabled="batches.length === 0">
|
||||||
|
下载全部期数
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="mainTab === 'common' || batches.length === 0"
|
v-if="mainTab === 'common' || batches.length === 0"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -106,6 +120,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, computed, watch, nextTick } from 'vue'
|
import { ref, reactive, computed, watch, nextTick } from 'vue'
|
||||||
import { useMessage } from '/@/hooks/message'
|
import { useMessage } from '/@/hooks/message'
|
||||||
|
import { handleBlobFile } from '/@/utils/other'
|
||||||
import {
|
import {
|
||||||
saveCommonConfig as apiSaveCommonConfig,
|
saveCommonConfig as apiSaveCommonConfig,
|
||||||
getCommonConfigWithBatches,
|
getCommonConfigWithBatches,
|
||||||
@@ -113,6 +128,7 @@ import {
|
|||||||
canFillForm as apiCanFillForm,
|
canFillForm as apiCanFillForm,
|
||||||
getAcceptanceItems,
|
getAcceptanceItems,
|
||||||
getDetail,
|
getDetail,
|
||||||
|
downloadPerformanceAcceptanceTemplate,
|
||||||
} from '/@/api/purchase/purchasingAccept'
|
} from '/@/api/purchase/purchasingAccept'
|
||||||
import AcceptCommonForm from './AcceptCommonForm.vue'
|
import AcceptCommonForm from './AcceptCommonForm.vue'
|
||||||
import AcceptBatchForm from './AcceptBatchForm.vue'
|
import AcceptBatchForm from './AcceptBatchForm.vue'
|
||||||
@@ -382,6 +398,51 @@ const handleClose = () => {
|
|||||||
emit('refresh')
|
emit('refresh')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 下载履约验收模板
|
||||||
|
const handleDownloadTemplate = async () => {
|
||||||
|
if (!purchaseId.value) {
|
||||||
|
useMessage().error('请先选择采购项目')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认下载当前期
|
||||||
|
await downloadTemplateForBatch(Number(activeTab.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理下拉菜单命令
|
||||||
|
const handleDownloadTemplateCommand = async (command: string) => {
|
||||||
|
if (!purchaseId.value) {
|
||||||
|
useMessage().error('请先选择采购项目')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command === 'current') {
|
||||||
|
await downloadTemplateForBatch(Number(activeTab.value))
|
||||||
|
} else if (command === 'all') {
|
||||||
|
// 下载全部期数的模板
|
||||||
|
for (const batch of batches.value) {
|
||||||
|
await downloadTemplateForBatch(batch.batch)
|
||||||
|
}
|
||||||
|
useMessage().success(`已触发${batches.value.length}期模板下载`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为指定批次下载模板
|
||||||
|
const downloadTemplateForBatch = async (batchNum: number) => {
|
||||||
|
try {
|
||||||
|
const response = await downloadPerformanceAcceptanceTemplate(String(purchaseId.value), batchNum)
|
||||||
|
|
||||||
|
// 使用项目中现有的工具函数处理文件下载
|
||||||
|
const fileName = `履约验收表-${purchaseId.value}-第${batchNum}期-${new Date().getTime()}.docx`;
|
||||||
|
handleBlobFile(response, fileName)
|
||||||
|
|
||||||
|
useMessage().success(`第${batchNum}期履约模板下载成功`)
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('下载模板失败:', error)
|
||||||
|
useMessage().error(error?.msg || '下载履约模板失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const DEFAULT_COMMON_FORM = {
|
const DEFAULT_COMMON_FORM = {
|
||||||
hasContract: '0',
|
hasContract: '0',
|
||||||
contractId: '',
|
contractId: '',
|
||||||
|
|||||||
@@ -335,11 +335,11 @@
|
|||||||
import { ref, reactive, defineAsyncComponent, onMounted } from 'vue'
|
import { ref, reactive, defineAsyncComponent, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||||
import { getPage, delObj, submitObj, getArchiveDownloadUrl } from "/@/api/finance/purchasingrequisition";
|
import { getPage, delObj, submitObj, getArchiveDownloadUrl, getApplyTemplateDownloadUrl } from "/@/api/finance/purchasingrequisition";
|
||||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||||
import { getDicts } from '/@/api/admin/dict';
|
import { getDicts } from '/@/api/admin/dict';
|
||||||
import { getTree } from '/@/api/finance/purchasingcategory';
|
import { getTree } from '/@/api/finance/purchasingcategory';
|
||||||
import { List, Document, DocumentCopy, Search, Collection, Money, CircleCheck, InfoFilled, Calendar, OfficeBuilding, Warning, DocumentChecked, Edit, Delete, Upload, FolderOpened } from '@element-plus/icons-vue'
|
import { List, Document, DocumentCopy, Search, Collection, Money, CircleCheck, InfoFilled, Calendar, OfficeBuilding, Warning, DocumentChecked, Edit, Delete, Upload, FolderOpened, Download } from '@element-plus/icons-vue'
|
||||||
import other from '/@/utils/other'
|
import other from '/@/utils/other'
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
@@ -541,6 +541,12 @@ const getActionMenuItems = (row: any) => {
|
|||||||
icon: FolderOpened,
|
icon: FolderOpened,
|
||||||
visible: () => true,
|
visible: () => true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
command: 'downloadApply',
|
||||||
|
label: '下载审批表',
|
||||||
|
icon: Download,
|
||||||
|
visible: () => true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -565,9 +571,24 @@ const handleMoreCommand = (command: string, row: any) => {
|
|||||||
case 'archive':
|
case 'archive':
|
||||||
handleArchive(row);
|
handleArchive(row);
|
||||||
break;
|
break;
|
||||||
|
case 'downloadApply':
|
||||||
|
handleDownloadApply(row);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 下载审批表 */
|
||||||
|
const handleDownloadApply = (row: any) => {
|
||||||
|
const id = row?.id ?? row?.purchaseId;
|
||||||
|
if (id == null || id === '') {
|
||||||
|
useMessage().warning('无法获取申请单ID');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const url = getApplyTemplateDownloadUrl(id);
|
||||||
|
const fileName = `审批表_${row?.purchaseNo || id}.docx`;
|
||||||
|
other.downBlobFile(url, {}, fileName);
|
||||||
|
};
|
||||||
|
|
||||||
/** 文件归档:按文件类型打包下载该申请单下所有附件 */
|
/** 文件归档:按文件类型打包下载该申请单下所有附件 */
|
||||||
const handleArchive = (row: any) => {
|
const handleArchive = (row: any) => {
|
||||||
const id = row?.id ?? row?.purchaseId;
|
const id = row?.id ?? row?.purchaseId;
|
||||||
|
|||||||
Reference in New Issue
Block a user