|
@@ -0,0 +1,212 @@
|
|
|
|
+import { saveAs } from 'file-saver';
|
|
|
|
+import ExcelJS from 'exceljs';
|
|
|
|
+import dayjs from "dayjs";
|
|
|
|
+
|
|
|
|
+export const backCustomFile = async (backInfo) => {
|
|
|
|
+ // 创建工作簿和工作表
|
|
|
|
+ const workbook = new ExcelJS.Workbook();
|
|
|
|
+ const worksheet = workbook.addWorksheet("Sheet1", {
|
|
|
|
+ pageSetup: {
|
|
|
|
+ paperSize: 9,
|
|
|
|
+ orientation: "landscape",
|
|
|
|
+ printArea: "A1:G9"
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ worksheet.columns = [
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ // 批量调整行高
|
|
|
|
+ const rowsToAdjust = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // 要调整的行号
|
|
|
|
+ rowsToAdjust.forEach((rowNumber, index) => {
|
|
|
|
+ const row = worksheet.getRow(rowNumber);
|
|
|
|
+ row.height = 25; // 每行高度递增
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 设置首个单元格内容
|
|
|
|
+ worksheet.getCell("A1").value = "《集采中心代理项目投标人汇总及投标保证金审收/退审批表》";
|
|
|
|
+ worksheet.getCell("A1").font = {
|
|
|
|
+ name: "宋体",
|
|
|
|
+ size: 11,
|
|
|
|
+ bold: true,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ worksheet.mergeCells(`A1:G1`);
|
|
|
|
+ worksheet.getCell("F2").value = "填表日期:";
|
|
|
|
+ worksheet.getCell("G2").value = dayjs().format('YYYY-MM-DD');;
|
|
|
|
+
|
|
|
|
+ worksheet.mergeCells(`A3:B3`);
|
|
|
|
+ worksheet.mergeCells(`C3:G3`);
|
|
|
|
+ worksheet.mergeCells(`A4:B4`);
|
|
|
|
+ worksheet.mergeCells(`C4:G4`);
|
|
|
|
+ worksheet.mergeCells(`B5:E5`);
|
|
|
|
+ worksheet.mergeCells(`F5:G5`);
|
|
|
|
+ worksheet.mergeCells(`B6:E6`);
|
|
|
|
+ worksheet.mergeCells(`F6:G6`);
|
|
|
|
+ worksheet.mergeCells(`B7:E7`);
|
|
|
|
+ worksheet.mergeCells(`F7:G7`);
|
|
|
|
+ worksheet.mergeCells(`B8:E8`);
|
|
|
|
+ worksheet.mergeCells(`F8:G8`);
|
|
|
|
+
|
|
|
|
+ worksheet.getCell("A3").value = "工程名称"
|
|
|
|
+ worksheet.getCell("C3").value = backInfo.cggg
|
|
|
|
+ // 将单元格设置为自动换行
|
|
|
|
+ worksheet.getCell("C3").alignment = { wrapText: true };
|
|
|
|
+
|
|
|
|
+ worksheet.getCell("A4").value = "投标保证金金额"
|
|
|
|
+ worksheet.getCell("C4").value = backInfo.rtnRfndamt + "元"
|
|
|
|
+ worksheet.getCell("A5").value = "报名"
|
|
|
|
+ worksheet.getCell("B5").value = "投标申请人名称"
|
|
|
|
+ worksheet.getCell("F5").value = "退款原因"
|
|
|
|
+ worksheet.getCell("A6").value = "1"
|
|
|
|
+ worksheet.getCell("B6").value = backInfo.rtnTdracctnm
|
|
|
|
+ worksheet.getCell("F6").value = "批量退款失败"
|
|
|
|
+ worksheet.getCell("A9").value = "主管副总:"
|
|
|
|
+ worksheet.getCell("D9").value = "财务负责人:"
|
|
|
|
+ worksheet.getCell("F9").value = "制表人:"
|
|
|
|
+
|
|
|
|
+ // 添加边框到 A3:G9 的每个单元格
|
|
|
|
+ for (let row = 3; row <= 8; row++) {
|
|
|
|
+ for (let col = 1; col <= 7; col++) {
|
|
|
|
+ const cell = worksheet.getCell(row, col);
|
|
|
|
+ cell.border = {
|
|
|
|
+ top: { style: 'thin' }, // 上边框
|
|
|
|
+ left: { style: 'thin' }, // 左边框
|
|
|
|
+ bottom: { style: 'thin' }, // 下边框
|
|
|
|
+ right: { style: 'thin' }, // 右边框
|
|
|
|
+ };
|
|
|
|
+ cell.alignment = {
|
|
|
|
+ horizontal: 'center', // 水平居中
|
|
|
|
+ vertical: 'middle', // 垂直居中
|
|
|
|
+ };
|
|
|
|
+ cell.height = 22
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const centerCell = ['A1', 'A2', 'F2', 'G2', 'A9', 'D9', 'F9']
|
|
|
|
+ // 批量设置居中对齐
|
|
|
|
+ centerCell.forEach((cellAddress) => {
|
|
|
|
+ const cell = worksheet.getCell(cellAddress);
|
|
|
|
+ cell.alignment = {
|
|
|
|
+ horizontal: 'center', // 水平居中
|
|
|
|
+ vertical: 'middle', // 垂直居中
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 将工作簿写入 Blob
|
|
|
|
+ const buffer = await workbook.xlsx.writeBuffer();
|
|
|
|
+
|
|
|
|
+ // 使用 FileSaver 触发下载
|
|
|
|
+ const blob = new Blob([buffer], {
|
|
|
|
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
+ });
|
|
|
|
+ saveAs(blob, `${backInfo.rtnTdracctnm}手动退款.xlsx`);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export const backBankFile = async (backInfo) => {
|
|
|
|
+ // 创建工作簿和工作表
|
|
|
|
+ const workbook = new ExcelJS.Workbook();
|
|
|
|
+ const worksheet = workbook.addWorksheet("Sheet1", {
|
|
|
|
+ pageSetup: {
|
|
|
|
+ paperSize: 9,
|
|
|
|
+ orientation: "landscape",
|
|
|
|
+ printArea: "A1:G8"
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ worksheet.columns = [
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 },
|
|
|
|
+ { width: 18 }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ // 批量调整行高
|
|
|
|
+ const rowsToAdjust = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // 要调整的行号
|
|
|
|
+ rowsToAdjust.forEach((rowNumber, index) => {
|
|
|
|
+ const row = worksheet.getRow(rowNumber);
|
|
|
|
+ row.height = 25; // 每行高度递增
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 设置首个单元格内容
|
|
|
|
+ worksheet.getCell("A1").value = "《集采中心代理项目投标人汇总及投标保证金审收/退审批表》";
|
|
|
|
+ worksheet.getCell("A1").font = {
|
|
|
|
+ name: "宋体",
|
|
|
|
+ size: 11,
|
|
|
|
+ bold: true,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ worksheet.mergeCells(`A1:G1`);
|
|
|
|
+ worksheet.getCell("F2").value = "填表日期:";
|
|
|
|
+ worksheet.getCell("G2").value = dayjs().format('YYYY-MM-DD');
|
|
|
|
+
|
|
|
|
+ worksheet.mergeCells(`A3:B3`);
|
|
|
|
+ worksheet.mergeCells(`C3:G3`);
|
|
|
|
+ worksheet.mergeCells(`B4:D4`);
|
|
|
|
+ worksheet.mergeCells(`E4:G4`);
|
|
|
|
+ worksheet.mergeCells(`B5:D5`);
|
|
|
|
+ worksheet.mergeCells(`E5:G5`);
|
|
|
|
+ worksheet.mergeCells(`B6:D6`);
|
|
|
|
+ worksheet.mergeCells(`E6:G6`);
|
|
|
|
+ worksheet.mergeCells(`B7:D7`);
|
|
|
|
+ worksheet.mergeCells(`E7:G7`);
|
|
|
|
+
|
|
|
|
+ worksheet.getCell("A3").value = "投标保证金金额"
|
|
|
|
+ worksheet.getCell("C3").value = backInfo.rtnSelfbal + "元"
|
|
|
|
+ worksheet.getCell("A4").value = "报名"
|
|
|
|
+ worksheet.getCell("B4").value = "投标申请人名称"
|
|
|
|
+ worksheet.getCell("E4").value = "不明原因"
|
|
|
|
+ worksheet.getCell("A5").value = "1"
|
|
|
|
+ worksheet.getCell("B5").value = backInfo.rtnOppassetname
|
|
|
|
+ worksheet.getCell("E5").value = backInfo.rtnAdjustreason
|
|
|
|
+ worksheet.getCell("A8").value = "主管副总:"
|
|
|
|
+ worksheet.getCell("D8").value = "财务负责人:"
|
|
|
|
+ worksheet.getCell("F8").value = "制表人:"
|
|
|
|
+
|
|
|
|
+ // 添加边框到 A3:G9 的每个单元格
|
|
|
|
+ for (let row = 3; row <= 7; row++) {
|
|
|
|
+ for (let col = 1; col <= 7; col++) {
|
|
|
|
+ const cell = worksheet.getCell(row, col);
|
|
|
|
+ cell.border = {
|
|
|
|
+ top: { style: 'thin' }, // 上边框
|
|
|
|
+ left: { style: 'thin' }, // 左边框
|
|
|
|
+ bottom: { style: 'thin' }, // 下边框
|
|
|
|
+ right: { style: 'thin' }, // 右边框
|
|
|
|
+ };
|
|
|
|
+ cell.alignment = {
|
|
|
|
+ horizontal: 'center', // 水平居中
|
|
|
|
+ vertical: 'middle', // 垂直居中
|
|
|
|
+ };
|
|
|
|
+ cell.height = 22
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const centerCell = ['A1', 'A2', 'F2', 'G2', 'A8', 'D8', 'F8']
|
|
|
|
+ // 批量设置居中对齐
|
|
|
|
+ centerCell.forEach((cellAddress) => {
|
|
|
|
+ const cell = worksheet.getCell(cellAddress);
|
|
|
|
+ cell.alignment = {
|
|
|
|
+ horizontal: 'center', // 水平居中
|
|
|
|
+ vertical: 'middle', // 垂直居中
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 将工作簿写入 Blob
|
|
|
|
+ const buffer = await workbook.xlsx.writeBuffer();
|
|
|
|
+
|
|
|
|
+ // 使用 FileSaver 触发下载
|
|
|
|
+ const blob = new Blob([buffer], {
|
|
|
|
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
|
|
+ });
|
|
|
|
+ saveAs(blob, `${backInfo.rtnOppassetname}手动退款.xlsx`);
|
|
|
|
+}
|