Merge branch 'material-ui' of http://192.168.30.2:3000/bonus/bonus-ui into material-ui

This commit is contained in:
hongchao 2025-10-20 11:31:45 +08:00
commit 9e9196c8c5
3 changed files with 337 additions and 148 deletions

View File

@ -43,6 +43,7 @@
"crypto-js": "^4.2.0",
"echarts": "5.4.0",
"element-ui": "2.15.14",
"exceljs": "^4.4.0",
"file-saver": "2.0.5",
"fuse.js": "6.4.3",
"highlight.js": "9.18.5",

View File

@ -212,7 +212,7 @@ import {
import { getLeaseCostRangeReportList, getLeaseCostDetails } from '@/api/cost/cost'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import * as XLSX from 'xlsx';
import ExcelJS from 'exceljs';
export default {
name: 'LeaseCostRangeReportHome',
@ -398,87 +398,103 @@ export default {
},
// Excel
exportExcel() {
async exportExcel() {
if (!this.tableList || this.tableList.length === 0) {
this.$modal.msgWarning('没有可导出的数据');
return;
}
try {
// Excel
// 簿
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('租赁费用区间报表');
//
const columns = [
{ key: 'index', title: '序号' },
{ key: 'agreementCode', title: '协议号' },
{ key: 'unitName', title: '结算单位' },
{ key: 'projectName', title: '结算工程' },
{ key: 'isSettled', title: '结算状态' },
{ key: 'equipmentTypeCount', title: '设备类型数' },
{ key: 'totalEquipmentCount', title: '设备总数量' },
{ key: 'totalLeaseDays', title: '总租赁天数' },
{ key: 'totalLeaseCost', title: '总租赁费用(元)' },
{ key: 'avgDailyRent', title: '日均租金(元)' },
{ key: 'queryStartDate', title: '查询开始日期' },
{ key: 'queryEndDate', title: '查询结束日期' },
{ key: 'earliestLeaseTime', title: '最早租赁时间' },
{ key: 'latestReturnTime', title: '最晚归还时间' },
{ key: 'settlementTime', title: '结算时间' },
{ key: 'remark', title: '备注' }
{ header: '序号', key: 'index', width: 8 },
{ header: '协议号', key: 'agreementCode', width: 18 },
{ header: '结算单位', key: 'unitName', width: 20 },
{ header: '结算工程', key: 'projectName', width: 25 },
{ header: '结算状态', key: 'isSettled', width: 10 },
{ header: '设备类型数', key: 'equipmentTypeCount', width: 12 },
{ header: '设备总数量', key: 'totalEquipmentCount', width: 12 },
{ header: '总租赁天数', key: 'totalLeaseDays', width: 12 },
{ header: '总租赁费用(元)', key: 'totalLeaseCost', width: 15 },
{ header: '日均租金(元)', key: 'avgDailyRent', width: 15 },
{ header: '查询开始日期', key: 'queryStartDate', width: 15 },
{ header: '查询结束日期', key: 'queryEndDate', width: 15 },
{ header: '最早租赁时间', key: 'earliestLeaseTime', width: 15 },
{ header: '最晚归还时间', key: 'latestReturnTime', width: 15 },
{ header: '结算时间', key: 'settlementTime', width: 12 },
{ header: '备注', key: 'remark', width: 20 }
];
// Excel
const excelData = [];
worksheet.columns = columns;
//
const headerRow = columns.map(col => col.title);
excelData.push(headerRow);
//
const headerStyle = {
font: { bold: true, color: { argb: 'FFFFFFFF' }, size: 11 },
fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF4472C4' } },
alignment: { horizontal: 'center', vertical: 'center', wrapText: true },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
const dataStyle = {
alignment: { horizontal: 'center', vertical: 'center' },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
worksheet.getRow(1).eachCell((cell) => {
cell.style = headerStyle;
});
//
this.tableList.forEach((row, index) => {
const dataRow = columns.map(col => {
if (col.key === 'index') {
return index + 1;
} else if (col.key === 'isSettled') {
return row.isSettled === '1' ? '已结算' : '未结算';
} else if (col.key === 'totalEquipmentCount') {
return row.totalEquipmentCount ? parseFloat(row.totalEquipmentCount).toFixed(3) : '0.000';
} else if (col.key === 'totalLeaseCost' || col.key === 'avgDailyRent') {
return row[col.key] ? parseFloat(row[col.key]).toFixed(2) : '0.00';
} else {
return row[col.key] || '';
}
});
excelData.push(dataRow);
const dataRow = {
index: index + 1,
agreementCode: row.agreementCode || '',
unitName: row.unitName || '',
projectName: row.projectName || '',
isSettled: row.isSettled === '1' ? '已结算' : '未结算',
equipmentTypeCount: row.equipmentTypeCount || '',
totalEquipmentCount: row.totalEquipmentCount ? parseFloat(row.totalEquipmentCount) : 0,
totalLeaseDays: row.totalLeaseDays || '',
totalLeaseCost: row.totalLeaseCost ? parseFloat(row.totalLeaseCost) : 0,
avgDailyRent: row.avgDailyRent ? parseFloat(row.avgDailyRent) : 0,
queryStartDate: row.queryStartDate || '',
queryEndDate: row.queryEndDate || '',
earliestLeaseTime: row.earliestLeaseTime || '',
latestReturnTime: row.latestReturnTime || '',
settlementTime: row.settlementTime || '',
remark: row.remark || ''
};
const newRow = worksheet.addRow(dataRow);
//
newRow.eachCell((cell) => {
cell.style = dataStyle;
});
// 簿
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
//
newRow.getCell(7).numFmt = '0.000'; //
newRow.getCell(9).numFmt = '0.00'; //
newRow.getCell(10).numFmt = '0.00'; //
});
//
const columnWidths = [
{ wch: 8 }, //
{ wch: 18 }, //
{ wch: 20 }, //
{ wch: 25 }, //
{ wch: 10 }, //
{ wch: 12 }, //
{ wch: 12 }, //
{ wch: 12 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '租赁费用区间报表');
//
//
let fileName = '租赁费用区间报表';
if (this.queryParams.startDate && this.queryParams.endDate) {
fileName += `_${this.queryParams.startDate}_至_${this.queryParams.endDate}`;
@ -486,8 +502,8 @@ export default {
fileName += `_${new Date().toISOString().slice(0, 10)}.xlsx`;
// Excel
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const buffer = await workbook.xlsx.writeBuffer();
const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
//
const link = document.createElement('a');
@ -535,87 +551,103 @@ export default {
},
/** 导出详情Excel */
exportDetailExcel() {
async exportDetailExcel() {
if (!this.detailTableList || this.detailTableList.length === 0) {
this.$modal.msgWarning('没有可导出的详情数据');
return;
}
try {
// Excel
// 簿
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('租赁费用明细');
//
const columns = [
{ key: 'index', title: '序号' },
{ key: 'agreementCode', title: '协议号' },
{ key: 'typeName', title: '机具名称' },
{ key: 'modelName', title: '机具规格' },
{ key: 'maCode', title: '物资编码' },
{ key: 'num', title: '租赁数量' },
{ key: 'mtUnitName', title: '单位' },
{ key: 'leasePrice', title: '租赁单价(元)' },
{ key: 'calcStartTime', title: '计算开始时间' },
{ key: 'calcEndTime', title: '计算结束时间' },
{ key: 'leaseDays', title: '租赁天数' },
{ key: 'leaseCost', title: '租赁费用(元)' },
{ key: 'isSettled', title: '结算状态' },
{ key: 'settlementTime', title: '结算时间' },
{ key: 'startTime', title: '出场时间' },
{ key: 'endTime', title: '退场时间' },
{ key: 'remark', title: '备注' }
{ header: '序号', key: 'index', width: 8 },
{ header: '协议号', key: 'agreementCode', width: 18 },
{ header: '机具名称', key: 'typeName', width: 20 },
{ header: '机具规格', key: 'modelName', width: 15 },
{ header: '物资编码', key: 'maCode', width: 15 },
{ header: '租赁数量', key: 'num', width: 12 },
{ header: '单位', key: 'mtUnitName', width: 8 },
{ header: '租赁单价(元)', key: 'leasePrice', width: 18 },
{ header: '计算开始时间', key: 'calcStartTime', width: 15 },
{ header: '计算结束时间', key: 'calcEndTime', width: 15 },
{ header: '租赁天数', key: 'leaseDays', width: 10 },
{ header: '租赁费用(元)', key: 'leaseCost', width: 18 },
{ header: '结算状态', key: 'isSettled', width: 10 },
{ header: '结算时间', key: 'settlementTime', width: 15 },
{ header: '出场时间', key: 'startTime', width: 15 },
{ header: '退场时间', key: 'endTime', width: 15 },
{ header: '备注', key: 'remark', width: 20 }
];
// Excel
const excelData = [];
worksheet.columns = columns;
//
const headerRow = columns.map(col => col.title);
excelData.push(headerRow);
//
const headerStyle = {
font: { bold: true, color: { argb: 'FFFFFFFF' }, size: 11 },
fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF4472C4' } },
alignment: { horizontal: 'center', vertical: 'center', wrapText: true },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
const dataStyle = {
alignment: { horizontal: 'center', vertical: 'center' },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
worksheet.getRow(1).eachCell((cell) => {
cell.style = headerStyle;
});
//
this.detailTableList.forEach((row, index) => {
const dataRow = columns.map(col => {
if (col.key === 'index') {
return index + 1;
} else if (col.key === 'isSettled') {
return row.isSettled === '1' ? '已结算' : '未结算';
} else if (col.key === 'num') {
return row.num ? parseFloat(row.num).toFixed(3) : '0.000';
} else if (col.key === 'leasePrice' || col.key === 'leaseCost') {
return row[col.key] ? parseFloat(row[col.key]).toFixed(2) : '0.00';
} else {
return row[col.key] || '';
}
});
excelData.push(dataRow);
const dataRow = {
index: index + 1,
agreementCode: row.agreementCode || '',
typeName: row.typeName || '',
modelName: row.modelName || '',
maCode: row.maCode || '',
num: row.num ? parseFloat(row.num) : 0,
mtUnitName: row.mtUnitName || '',
leasePrice: row.leasePrice ? parseFloat(row.leasePrice) : 0,
calcStartTime: row.calcStartTime || '',
calcEndTime: row.calcEndTime || '',
leaseDays: row.leaseDays || '',
leaseCost: row.leaseCost ? parseFloat(row.leaseCost) : 0,
isSettled: row.isSettled === '1' ? '已结算' : '未结算',
settlementTime: row.settlementTime || '',
startTime: row.startTime || '',
endTime: row.endTime || '',
remark: row.remark || ''
};
const newRow = worksheet.addRow(dataRow);
//
newRow.eachCell((cell) => {
cell.style = dataStyle;
});
// 簿
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
//
const columnWidths = [
{ wch: 8 }, //
{ wch: 18 }, //
{ wch: 20 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 8 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, // 退
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '租赁费用明细');
//
newRow.getCell(6).numFmt = '0.000'; //
newRow.getCell(8).numFmt = '0.00'; //
newRow.getCell(12).numFmt = '0.00'; //
});
//
let fileName = `租赁费用明细_${this.selectedRowData.agreementCode}`;
@ -625,8 +657,8 @@ export default {
fileName += `_${new Date().toISOString().slice(0, 10)}.xlsx`;
// Excel
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const buffer = await workbook.xlsx.writeBuffer();
const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
//
const link = document.createElement('a');

View File

@ -440,6 +440,7 @@ import {
import {getPushReviewList,getLeaseListApi,getRepairList,getLoseList,getScrapList,submitPushCosts } from "@/api/costPush/costPush";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import ExcelJS from 'exceljs';
export default {
name: "PushReview",
data() {
@ -934,14 +935,169 @@ export default {
// )
},
/** 外层导出 */
handleExport() {
this.download(
'material/iws_cost_push/exportCostPushExamList',
{
...this.queryParams,
},
`费用推送审核记录_${new Date().getTime()}.xlsx`,
)
async handleExport() {
if (!this.pushReviewList || this.pushReviewList.length === 0) {
this.$modal.msgWarning('没有可导出的数据');
return;
}
try {
// 簿
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('费用推送审核记录');
//
const columns = [
{ header: '序号', key: 'index', width: 8 },
{ header: '协议号', key: 'agreementCode', width: 18 },
{ header: '单位名称', key: 'unitName', width: 20 },
{ header: '工程名称', key: 'projectName', width: 20 },
{ header: '推送月份', key: 'month', width: 12 },
{ header: '费用所属', key: 'settlementType', width: 12 },
{ header: '租赁费用(元)', key: 'leaseMoney', width: 18 },
{ header: '维修费用(元)', key: 'repairMoney', width: 18 },
{ header: '报废费用(元)', key: 'scrapMoney', width: 18 },
{ header: '丢失费用(元)', key: 'lostMoney', width: 18 },
{ header: '合计费用(元)', key: 'money', width: 18 },
{ header: '是否结算', key: 'isSettlement', width: 12 },
{ header: '是否审核', key: 'checkStatus', width: 12 }
];
worksheet.columns = columns;
//
const headerStyle = {
font: { bold: true, color: { argb: 'FFFFFFFF' }, size: 11 },
fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF4472C4' } },
alignment: { horizontal: 'center', vertical: 'center', wrapText: true },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
const dataStyle = {
alignment: { horizontal: 'center', vertical: 'center' },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
const totalStyle = {
font: { bold: true, size: 11 },
fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF8F8F9' } },
alignment: { horizontal: 'center', vertical: 'center' },
border: {
top: { style: 'thin', color: { argb: 'FF000000' } },
bottom: { style: 'thin', color: { argb: 'FF000000' } },
left: { style: 'thin', color: { argb: 'FF000000' } },
right: { style: 'thin', color: { argb: 'FF000000' } }
}
};
//
worksheet.getRow(1).eachCell((cell) => {
cell.style = headerStyle;
});
//
const dataRows = this.pushReviewList.slice(0, -1);
dataRows.forEach((row, index) => {
const dataRow = {
index: index + 1,
agreementCode: row.agreementCode || '',
unitName: row.unitName || '',
projectName: row.projectName || '',
month: this.originalMonthTrue || row.month || '',
settlementType: row.settlementType === 1 ? '工器具' : (row.settlementType === 2 ? '安全用品' : ''),
leaseMoney: row.leaseMoney ? parseFloat(row.leaseMoney) : 0,
repairMoney: row.repairMoney ? parseFloat(row.repairMoney) : 0,
scrapMoney: row.scrapMoney ? parseFloat(row.scrapMoney) : 0,
lostMoney: row.lostMoney ? parseFloat(row.lostMoney) : 0,
money: row.money ? parseFloat(row.money) : 0,
isSettlement: row.isSettlement === 1 || row.isSettlement === 2 ? '已结算' : '未结算',
checkStatus: row.checkStatus === 1 ? '已审核' : '未审核'
};
const newRow = worksheet.addRow(dataRow);
//
newRow.eachCell((cell) => {
cell.style = dataStyle;
});
// 2
newRow.getCell(7).numFmt = '0.00'; //
newRow.getCell(8).numFmt = '0.00'; //
newRow.getCell(9).numFmt = '0.00'; //
newRow.getCell(10).numFmt = '0.00'; //
newRow.getCell(11).numFmt = '0.00'; //
});
//
const totalRow = this.pushReviewList[this.pushReviewList.length - 1];
const totalDataRow = {
index: '合计',
agreementCode: '',
unitName: '',
projectName: '',
month: '',
settlementType: '',
leaseMoney: totalRow.leaseMoney ? parseFloat(totalRow.leaseMoney) : 0,
repairMoney: totalRow.repairMoney ? parseFloat(totalRow.repairMoney) : 0,
scrapMoney: totalRow.scrapMoney ? parseFloat(totalRow.scrapMoney) : 0,
lostMoney: totalRow.lostMoney ? parseFloat(totalRow.lostMoney) : 0,
money: totalRow.money ? parseFloat(totalRow.money) : 0,
isSettlement: '',
checkStatus: ''
};
const newTotalRow = worksheet.addRow(totalDataRow);
//
newTotalRow.eachCell((cell) => {
cell.style = totalStyle;
});
//
newTotalRow.getCell(7).numFmt = '0.00'; //
newTotalRow.getCell(8).numFmt = '0.00'; //
newTotalRow.getCell(9).numFmt = '0.00'; //
newTotalRow.getCell(10).numFmt = '0.00'; //
newTotalRow.getCell(11).numFmt = '0.00'; //
//
const fileName = `费用推送审核记录_${new Date().toISOString().slice(0, 10)}.xlsx`;
// Excel
const buffer = await workbook.xlsx.writeBuffer();
const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
//
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', fileName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// URL
URL.revokeObjectURL(url);
this.$modal.msgSuccess('Excel导出成功');
} catch (error) {
console.error('导出Excel失败:', error);
this.$modal.msgError('导出Excel失败请稍后重试');
}
},
/** 提交 */