| | |
| | | <el-button type="primary" @click="openForm('add')">新增台账</el-button> |
| | | <el-button type="primary" plain @click="handleImport">导入</el-button> |
| | | <el-button @click="handleOut">导出</el-button> |
| | | <el-button type="success" plain @click="handleExportDocx">导出采购订单</el-button> |
| | | <el-button type="danger" plain @click="handleDelete">删除 |
| | | </el-button> |
| | | </div> |
| | |
| | | getOptions, |
| | | getPurchaseTemplateList, |
| | | delPurchaseTemplate, |
| | | exportPurchaseOrderDocx, |
| | | } from "@/api/procurementManagement/procurementLedger.js"; |
| | | import useFormData from "@/hooks/useFormData.js"; |
| | | const FileList = defineAsyncComponent(() => |
| | |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | // 导出采购订单(Word模板) |
| | | const handleExportDocx = () => { |
| | | if (selectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning("请先选择一条数据"); |
| | | return; |
| | | } |
| | | if (selectedRows.value.length > 1) { |
| | | proxy.$modal.msgWarning("请选择一条数据导出"); |
| | | return; |
| | | } |
| | | const row = selectedRows.value[0]; |
| | | ElMessageBox.confirm(`确定导出采购订单(${row.purchaseContractNumber})?`, "导出采购订单", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "info", |
| | | }) |
| | | .then(async () => { |
| | | try { |
| | | const res = await exportPurchaseOrderDocx(row.id); |
| | | const blob = new Blob([res], { type: "application/msword" }); |
| | | const url = window.URL.createObjectURL(blob); |
| | | const link = document.createElement("a"); |
| | | link.href = url; |
| | | link.download = `采购订单_${row.purchaseContractNumber || row.id}.docx`; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(url); |
| | | proxy.$modal.msgSuccess("导出成功"); |
| | | } catch (error) { |
| | | console.error("导出采购订单失败:", error); |
| | | proxy.$modal.msgError("导出失败,请稍后重试"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | // 删除 |
| | | const handleDelete = () => { |
| | | let ids = []; |