|
@@ -39,6 +39,12 @@ class ExportExcel {
|
|
|
// 叶子节点的父项ID
|
|
|
leafParentIDs = [];
|
|
|
|
|
|
+ // 字体
|
|
|
+ font = 'normal normal 9pt 宋体';
|
|
|
+ blockTitleFont = 'bold normal 9pt 宋体';
|
|
|
+ bigSectionFont = 'bold normal 12pt 黑体';
|
|
|
+ leafSectionFont = 'bold normal 11pt 黑体';
|
|
|
+
|
|
|
constructor(workBook, billTree, libID) {
|
|
|
this.workBook = workBook;
|
|
|
this.sheet = this.workBook.getSheet(0);
|
|
@@ -95,7 +101,7 @@ class ExportExcel {
|
|
|
this.curMaxCol = 0;
|
|
|
if (billNode.children.length) {
|
|
|
// 清单分部章节,合并的列数依赖主体表格,所以先存数据画空行,后续再画具体内容
|
|
|
- this.sections.push({ ID: billNode.data.ID, isNotLeaf: true, row: this.curRow, col: 0, text: `${billNode.data.code} ${billNode.data.name}`, rowCount: 1, colCount: 1 });
|
|
|
+ this.sections.push({ ID: billNode.data.ID, isNotLeaf: true, row: this.curRow, col: 0, text: `${billNode.data.code} ${billNode.data.name}`, rowCount: 1, colCount: 1, font: this.bigSectionFont });
|
|
|
this.curRow++;
|
|
|
} else {
|
|
|
if (!this.leafParentIDs.includes(billNode.data.ParentID)) {
|
|
@@ -106,7 +112,7 @@ class ExportExcel {
|
|
|
}
|
|
|
// 叶子清单,合并的列数依赖主体表格,所以先存数据画空行,后续再画具体内容
|
|
|
const billText = `编码:${billNode.data.code} 名称:${billNode.data.name} 单位:${billNode.data.unit}`;
|
|
|
- this.sections.push({ ID: billNode.data.ID, row: this.curRow, col: 0, text: billText, rowCount: 1, colCount: 1 });
|
|
|
+ this.sections.push({ ID: billNode.data.ID, row: this.curRow, col: 0, text: billText, rowCount: 1, colCount: 1, font: this.leafSectionFont });
|
|
|
this.curRow++;
|
|
|
// 画清单精灵表格
|
|
|
const elfTree = await this.getElfTree(billNode.data.ID);
|
|
@@ -163,11 +169,12 @@ class ExportExcel {
|
|
|
const row = addCurRow ? item.row + this.curRow : item.row;
|
|
|
this.sheet.addSpan(row, item.col, item.rowCount, item.colCount);
|
|
|
this.sheet.setFormatter(row, item.col, '@');
|
|
|
+ const font = item.font || this.font;
|
|
|
+ this.sheet.getCell(row, item.col).font(font);
|
|
|
if (item.isTitle) {
|
|
|
// 标题水平居中,字体加粗
|
|
|
const range = this.sheet.getRange(row, item.col, 1, 1);
|
|
|
range.hAlign(GC.Spread.Sheets.VerticalAlign.center);
|
|
|
- this.sheet.getCell(row, item.col).font('bold normal 15px normal');
|
|
|
} else if (item.isNotLeaf) {
|
|
|
const range = this.sheet.getRange(row, item.col, 1, 1);
|
|
|
range.hAlign(GC.Spread.Sheets.VerticalAlign.center);
|
|
@@ -275,6 +282,7 @@ class ExportExcel {
|
|
|
text,
|
|
|
isRation: node.data.type === itemType.ration,
|
|
|
colCount: 1,
|
|
|
+ font: this.font,
|
|
|
}
|
|
|
});
|
|
|
this.moveRationTextToLastCol(block);
|
|
@@ -284,9 +292,9 @@ class ExportExcel {
|
|
|
// 获取表格标题单元格数据,计算标题合并列依赖正文表格
|
|
|
getBlockTitle() {
|
|
|
return [
|
|
|
- { row: 0, col: 0, rowCount: 1, colCount: 1, text: '工序', isTitle: true },
|
|
|
- { row: 0, col: 1, rowCount: 1, colCount: this.curMaxCol === 0 ? 1 : this.curMaxCol - 1, text: '选项', isTitle: true },
|
|
|
- { row: 0, col: this.curMaxCol === 0 ? 2 : this.curMaxCol, rowCount: 1, colCount: 1, text: '定额', isTitle: true },
|
|
|
+ { row: 0, col: 0, rowCount: 1, colCount: 1, text: '工序', isTitle: true, font: this.blockTitleFont },
|
|
|
+ { row: 0, col: 1, rowCount: 1, colCount: this.curMaxCol === 0 ? 1 : this.curMaxCol - 1, text: '选项', isTitle: true, font: this.blockTitleFont },
|
|
|
+ { row: 0, col: this.curMaxCol === 0 ? 2 : this.curMaxCol, rowCount: 1, colCount: 1, text: '定额', isTitle: true, font: this.blockTitleFont },
|
|
|
];
|
|
|
}
|
|
|
|