yuan
21 小时以前 3c875736f8c12f27af835da110dcc3653a8676d6
src/views/procurementManagement/procurementLedger/index.vue
@@ -43,6 +43,7 @@
        <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>
@@ -405,6 +406,7 @@
  getOptions,
  getPurchaseTemplateList,
  delPurchaseTemplate,
  exportPurchaseOrderDocx,
} from "@/api/procurementManagement/procurementLedger.js";
import useFormData from "@/hooks/useFormData.js";
const FileList = defineAsyncComponent(() =>
@@ -1400,6 +1402,44 @@
      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 = [];