fix:修改结算单导出Excel名称 (#697) fix #696

<!-- Note -->
<!-- This is a template for submitting a new feature.
Use the bug fix template if you're submitting a bug fix pull request by adding `template=bug_fix.md` to your pull request URL. -->

# Description
<!-- Describe the new feature or modification to an existing feature clearly and consciously. -->

# Motivation
<!-- Explain the reason for adding or modifying this feature. -->

# Key changes
<!-- Provide a technically detailed description of the key changes made. -->
- Frontend
- Backend

# Test plan
## Suggestions
<!-- Provide any suggestions or recommendations for improvements in the testing plan. -->

## Underlying risk
<!-- Identify any potential risks or issues that may arise from the new feature or modification. -->

# Showcase
<!-- Including any screenshots of the new feature or modification. -->

Reviewed-on: daoyoucloud/tachycode#697
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-04-12 17:49:57 +08:00 committed by sealday
parent da8b4d0b45
commit 122d5ab9ac
2 changed files with 9 additions and 8 deletions

View File

@ -284,7 +284,7 @@ export const excelDataHandle = (excelData) => {
if (!value.is_excluded) { if (!value.is_excluded) {
table3.rows.push([ table3.rows.push([
converDate(value.date, 'YYYY-MM-DD'), converDate(value.date, 'YYYY-MM-DD'),
value.movement == -1 ? '出库' : value.movement == 1 ? '入库' : '出入库', value.movement === -1 ? '出库' : value.movement === 1 ? '入库' : '出入库',
value.name, value.name,
'', '',
category, category,
@ -544,13 +544,13 @@ export const ExportToExcel = async (data) => {
const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
const CellBorder = (row) => { const CellBorder = (row) => {
cols.forEach((value) => { cols.forEach((value) => {
if (value == 'A' && row == `${notesRow}`) { if (value === 'A' && row === `${notesRow}`) {
ws.getCell(`${value}${row}`).border = { ws.getCell(`${value}${row}`).border = {
top: { style: 'thin' }, top: { style: 'thin' },
left: { style: 'thin' }, left: { style: 'thin' },
bottom: { style: 'thin' }, bottom: { style: 'thin' },
}; };
} else if ((value == 'B' || value == 'C' || value == 'D' || value == 'E') && row == `${notesRow}`) { } else if ((value === 'B' || value === 'C' || value === 'D' || value === 'E') && row === `${notesRow}`) {
ws.getCell(`${value}${row}`).border = { ws.getCell(`${value}${row}`).border = {
top: { style: 'thin' }, top: { style: 'thin' },
bottom: { style: 'thin' }, bottom: { style: 'thin' },
@ -613,7 +613,7 @@ export const ExportToExcel = async (data) => {
ws.mergeCells(`A${value['_number']}:B${value['_number']}`); ws.mergeCells(`A${value['_number']}:B${value['_number']}`);
ws.mergeCells(`F${value['_number']}:G${value['_number']}`); ws.mergeCells(`F${value['_number']}:G${value['_number']}`);
ws.mergeCells(`I${value['_number']}:J${value['_number']}`); ws.mergeCells(`I${value['_number']}:J${value['_number']}`);
if (value['_number'] != table2Row) { if (value['_number'] !== table2Row) {
const row25 = ws.getRow(value['_number']); const row25 = ws.getRow(value['_number']);
row25.alignment = { horizontal: 'right' }; row25.alignment = { horizontal: 'right' };
} }
@ -628,7 +628,7 @@ export const ExportToExcel = async (data) => {
const rows37 = ws.getRows(table3Row, calc.list ? calc.list?.length + 1 : 1); const rows37 = ws.getRows(table3Row, calc.list ? calc.list?.length + 1 : 1);
rows37.forEach((value) => { rows37.forEach((value) => {
ws.mergeCells(`C${value['_number']}:D${value['_number']}`); ws.mergeCells(`C${value['_number']}:D${value['_number']}`);
if (value['_number'] != table3Row) { if (value['_number'] !== table3Row) {
const row38 = ws.getRow(value['_number']); const row38 = ws.getRow(value['_number']);
row38.alignment = { horizontal: 'right' }; row38.alignment = { horizontal: 'right' };
} }
@ -643,7 +643,7 @@ export const ExportToExcel = async (data) => {
ws.mergeCells(`C${value['_number']}:D${value['_number']}`); ws.mergeCells(`C${value['_number']}:D${value['_number']}`);
ws.mergeCells(`F${value['_number']}:G${value['_number']}`); ws.mergeCells(`F${value['_number']}:G${value['_number']}`);
ws.mergeCells(`H${value['_number']}:J${value['_number']}`); ws.mergeCells(`H${value['_number']}:J${value['_number']}`);
if (value['_number'] != table4row) { if (value['_number'] !== table4row) {
const row38 = ws.getRow(value['_number']); const row38 = ws.getRow(value['_number']);
row38.alignment = { horizontal: 'right' }; row38.alignment = { horizontal: 'right' };
} }
@ -666,7 +666,7 @@ export const ExportToExcel = async (data) => {
ws.mergeCells(`D${value['_number']}:E${value['_number']}`); ws.mergeCells(`D${value['_number']}:E${value['_number']}`);
ws.mergeCells(`F${value['_number']}:G${value['_number']}`); ws.mergeCells(`F${value['_number']}:G${value['_number']}`);
ws.mergeCells(`I${value['_number']}:J${value['_number']}`); ws.mergeCells(`I${value['_number']}:J${value['_number']}`);
if (value['_number'] != table5Row) { if (value['_number'] !== table5Row) {
const row38 = ws.getRow(value['_number']); const row38 = ws.getRow(value['_number']);
row38.alignment = { horizontal: 'right' }; row38.alignment = { horizontal: 'right' };
} }
@ -715,6 +715,6 @@ export const ExportToExcel = async (data) => {
const blob = new Blob([buffer], { const blob = new Blob([buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
}); });
await saveAs(blob, '对账单.xlsx'); await saveAs(blob, `${contracts.project?.name}-${calc.name}.xlsx`);
await message.success('导出成功'); await message.success('导出成功');
}; };

View File

@ -759,6 +759,7 @@ export class SettlementService {
addItems: settlementAbout.settlement_add_items, //人工增补项 addItems: settlementAbout.settlement_add_items, //人工增补项
summary: settlementAbout.settlement_summary_items, //汇总项 summary: settlementAbout.settlement_summary_items, //汇总项
utcOffset: utcOffset, utcOffset: utcOffset,
name: settlementAbout.name,
}; };
calc.list = calc.list?.filter(Boolean); calc.list = calc.list?.filter(Boolean);
const product = await this.db.getRepository('product').find(); const product = await this.db.getRepository('product').find();