| | |
| | | style="width: 100%;"> |
| | | <el-table-column label="序号" width="80" align="center" type="index"></el-table-column> |
| | | <el-table-column label="申请时间" prop="createTime" align="center" :show-overflow-tooltip="true" width="180"/> |
| | | <el-table-column label="项目名称" prop="projectName" align="center" :show-overflow-tooltip="true" width="180"/> |
| | | <el-table-column label="出差事由" prop="projectName" align="center" :show-overflow-tooltip="true" width="180"/> |
| | | <el-table-column label="部门" prop="deptName" align="center"/> |
| | | <el-table-column label="专家组组长" prop="expertName" align="center" width="150"/> |
| | | <el-table-column label="专家组人数" prop="expertNum" align="center" width="150"/> |
| | |
| | | const title = [["自治区应急管理厅外聘专家劳务费发放表"]] |
| | | // 固定一行:填报处室和单位 |
| | | const fixedHeader = [ |
| | | ["填报处室:" + row.deptName, "", "", "", "", "单位:元", "", "", "", ""] |
| | | ["填报处室:" + row.deptName, "", "", "", "", "单位:元", "", "", "", "","","",""] |
| | | ] |
| | | if(res.data && res.data[0] && Array.isArray(res.data[0].projectExpertExportResps) && res.data[0].projectExpertExportResps.length>0){ |
| | | let mainData = res.data[0].projectExpertExportResps |
| | | const data = mainData.map((item,index)=>{ |
| | | return [index+1,item.name,item.companyName,item.title,item.idCard,item.freightBasis,item.billingDuration,item.afterTaxAmount,item.openBank,item.bankCard] |
| | | return [index+1,item.name,item.companyName,item.title,item.idCard,item.freightBasis,item.billingDuration,item.afterTaxAmount,item.openBank,item.bankCard,item.taxExpertFee,item.taxableIncome,item.incomeTaxPayable] |
| | | }) |
| | | |
| | | // 定义表头 |
| | | const headers = [ |
| | | ["序号", "姓名", "工作单位", "职称", "身份证号", "计费标准", "计费时长", "税后金额", "开户银行", "卡号"] |
| | | ["序号", "姓名", "工作单位", "职称", "身份证号", "计费标准", "计费时长", "税后金额", "开户银行", "卡号","专家费","应纳税所得额","应缴个税"] |
| | | ] |
| | | // 固定一行:经办人和负责人 |
| | | const footer = [ |
| | | ["经办人:", "", "", "", "", "处室负责人:", "", "", "", ""] |
| | | ["经办人:", "", "", "", "", "处室负责人:", "", "", "", "","","",""] |
| | | ] |
| | | // 创建工作表 |
| | | const ws = XLSX.utils.aoa_to_sheet([ |
| | |
| | | const dataRowCount = data.length; |
| | | // 合并单元格的范围 |
| | | ws['!merges'] = [ |
| | | { s: { r: 0, c: 0 }, e: { r: 0, c: 9 } }, // 合并标题:第1行 0列到9列 |
| | | { s: { r: 0, c: 0 }, e: { r: 0, c: 12 } }, // 合并标题:第1行 0列到12列 |
| | | { s: { r: 1, c: 0 }, e: { r: 1, c: 4 } }, // 合并填报处室:第2行 第0列到4列 |
| | | { s: { r: 1, c: 5 }, e: { r: 1, c: 9 } }, // 合并单位:第2行 第5列到9列 |
| | | { s: { r: 1, c: 5 }, e: { r: 1, c: 12 } }, // 合并单位:第2行 第5列到12列 |
| | | { s: { r: 3 + dataRowCount, c: 0 }, e: { r: 3 + dataRowCount, c: 4 } }, // 合并经办人:最后一行的第0列到4列 |
| | | { s: { r: 3 + dataRowCount, c: 5 }, e: { r: 3 + dataRowCount, c: 9 } }, // 合并负责人:最后一行的第5列到9列 |
| | | { s: { r: 3 + dataRowCount, c: 5 }, e: { r: 3 + dataRowCount, c: 12 } }, // 合并负责人:最后一行的第5列到12列 |
| | | ] |
| | | // 设置标题 |
| | | if (!ws['A1']) ws['A1'] = {}; // 确保 A1 单元格存在 |
| | |
| | | // 设置数据区(包括填报处室、单位、数据行和最后一行)为左对齐 |
| | | const totalRows = 3 + dataRowCount + 1; // 标题、固定行和数据行的总数 |
| | | for (let r = 3; r <= totalRows; r++) { // 遍历每一行 |
| | | for (let c = 0; c < 10; c++) { // 遍历每一列 |
| | | for (let c = 0; c < 13; c++) { // 遍历每一列 |
| | | const cellRef = `${String.fromCharCode(65 + c)}${r}`; |
| | | if (!ws[cellRef]) ws[cellRef] = {}; // 确保单元格存在 |
| | | ws[cellRef].s = { |
| | |
| | | } |
| | | // 设置最后一行(经办人、负责人)左对齐 |
| | | const lastRowStart = 3 + dataRowCount; |
| | | for (let c = 0; c < 10; c++) { |
| | | for (let c = 0; c < 13; c++) { |
| | | const cellRef = `${String.fromCharCode(65 + c)}${lastRowStart + 1}`; |
| | | if (!ws[cellRef]) ws[cellRef] = {}; // 确保单元格存在 |
| | | ws[cellRef].s = { |
| | |
| | | // 设置列宽,计算每列的最大宽度 |
| | | const MIN_COL_WIDTH = 60; |
| | | const colWidths = []; |
| | | for (let c = 0; c < 10; c++) { |
| | | for (let c = 0; c < 13; c++) { |
| | | let maxLength = 0; |
| | | // 计算每列最大单元格内容长度 |
| | | for (let r = 0; r < totalRows; r++) { |
| | | const cellRef = `${String.fromCharCode(65 + c)}${r + 1}`; // 获取每个单元格的引用 |
| | | const cell = ws[cellRef]; |
| | | if (cell && cell.v) { |
| | | if(cell.v == '序号'){ |
| | | maxLength = 1 |
| | | }else { |
| | | maxLength = Math.max(maxLength, cell.v.toString().length); |
| | | } |
| | | |
| | | } |
| | | } |
| | | // 根据最大长度设置列宽,添加额外的空间 |
| | | colWidths[c] = { wpx: Math.max(maxLength * 10, MIN_COL_WIDTH) }; // 你可以根据需要调整乘数 |
| | | colWidths[c] = { wpx: Math.max(maxLength * 15, MIN_COL_WIDTH) }; // 你可以根据需要调整乘数 |
| | | } |
| | | |
| | | // 设置工作表的列宽 |