diff --git a/src/assets/data.ts b/src/assets/data.ts
index b6e84d4..f7e07b3 100644
--- a/src/assets/data.ts
+++ b/src/assets/data.ts
@@ -20,7 +20,7 @@ const data = {
length: 944,
width: 59,
thickness: 18,
- quantity: 1,
+ quantity: 10,
area: 0.568,
mutation: '',
shape: '',
diff --git a/src/assets/methodTool.ts b/src/assets/methodTool.ts
index 5067b30..b96d4e4 100644
--- a/src/assets/methodTool.ts
+++ b/src/assets/methodTool.ts
@@ -62,8 +62,5 @@ const Tool = {
}
that.selectedCell = 9000;
},
- copySingleRow: (Id: number) => {
- Id += 1;
- },
};
export { Tool };
diff --git a/src/assets/templateInitialData.ts b/src/assets/templateInitialData.ts
index 80c9519..08e307b 100644
--- a/src/assets/templateInitialData.ts
+++ b/src/assets/templateInitialData.ts
@@ -728,6 +728,30 @@ const initialTemplateData = [
},
],
},
+ {
+ rowId: 9,
+ rowTitle: '9',
+ cells: [
+ {
+ cellId: 9049,
+ title: '总计:',
+ colspan: 10,
+ height: 30,
+ textAlign: 'right',
+ fontSize: 16,
+ fontStyle: 'bold',
+ },
+ {
+ cellId: 9050,
+ title: 'totalquantity',
+ colspan: 14,
+ height: 30,
+ textAlign: 'left',
+ fontSize: 16,
+ fontStyle: 'normal',
+ },
+ ],
+ },
{ rowId: 10, rowTitle: '10', cells: [] },
{ rowId: 11, rowTitle: '11', cells: [] },
diff --git a/src/components/reportTemplate/ReportTemplate.vue b/src/components/reportTemplate/ReportTemplate.vue
index 3477d1e..01e8662 100644
--- a/src/components/reportTemplate/ReportTemplate.vue
+++ b/src/components/reportTemplate/ReportTemplate.vue
@@ -47,10 +47,10 @@
以下功能用于测试使用
- 选择板材头模板:
- 开始:
- 结束:
-
+ 选择重用板材模板:
+ 开始:
+ 结束:
+
@@ -78,6 +78,20 @@ import { Tool } from '@/assets/methodTool';
let rowId = 30; // this figure is for testing use
let cellId = 9050; // this figure is for testing use
let copiedRowHolder: any;
+const subKeyWords = [
+ 'sublength',
+ 'subwidth',
+ 'subthickness',
+ 'subquantity',
+ 'subarea',
+];
+const totalKeyWords = [
+ 'totallength',
+ 'totalwidth',
+ 'totalthickness',
+ 'totalquantity',
+ 'totalarea',
+];
export default Vue.extend({
components: { reportCell, test },
@@ -116,8 +130,8 @@ export default Vue.extend({
fontSize: number;
fontStyle: string;
};
- banCaiHeadStartLine: string;
- banCaiHeadEndLine: string;
+ banCaiHeadStartLineIndex: string;
+ banCaiHeadEndLineIndex: string;
} {
return {
infos: startUpRowColumn,
@@ -141,8 +155,9 @@ export default Vue.extend({
fontSize: 0,
fontStyle: '',
},
- banCaiHeadStartLine: '5',
- banCaiHeadEndLine: '8',
+ banCaiHeadStartLineIndex: '5',
+ banCaiHeadEndLineIndex: '8',
+ afterBanCaiIdHolder: [],
};
},
computed: {
@@ -231,18 +246,90 @@ export default Vue.extend({
rowClickHandler(row: any): void {
this.selectedRow = row.rowId;
},
- copyBanCaiHeadTemplate() {
- let temStartLine = Number(this.banCaiHeadStartLine);
+ addTotalAmount(query) {
+ let total = 0;
+ const query1 = query.slice(5);
+ for (const board of data.boards) {
+ for (const eachBoardInfo of board.boardInfos) {
+ if (Object.keys(eachBoardInfo).indexOf(query1) !== -1) {
+ total += eachBoardInfo[query1];
+ }
+ }
+ }
+ if (Number.isInteger(total)) {
+ return total;
+ } else {
+ return total.toFixed(3);
+ }
+ },
+ addSubAmount(query, board) {
+ let sub = 0;
+ const query1 = query.slice(3);
+
+ for (const eachBoardInfo of board.boardInfos) {
+ if (Object.keys(eachBoardInfo).indexOf(query1) !== -1) {
+ sub += eachBoardInfo[query1];
+ }
+ }
+ if (Number.isInteger(sub)) {
+ return sub;
+ } else {
+ return sub.toFixed(3);
+ }
+ },
+
+ copyBanCaiTemplate() {
+ let temStartLineIndex = Number(this.banCaiHeadStartLineIndex);
+
const banCaiHeadTemplateHolder = [];
- while (temStartLine <= Number(this.banCaiHeadEndLine)) {
+ while (temStartLineIndex <= Number(this.banCaiHeadEndLineIndex)) {
banCaiHeadTemplateHolder.push(
- this.copySingleRow(this.infos[temStartLine].rowId),
+ this.copySingleRow(this.infos[temStartLineIndex].rowId),
);
- temStartLine += 1;
+ temStartLineIndex += 1;
}
+
return banCaiHeadTemplateHolder;
},
+ copyRemainingForm() {
+ let remainingIndex = Number(this.banCaiHeadEndLineIndex) + 1;
+ const remainingFormHolder = [];
+ for (
+ remainingIndex;
+ remainingIndex < this.infos.length;
+ remainingIndex++
+ ) {
+ if (this.infos[remainingIndex].cells.length !== 0) {
+ remainingFormHolder.push(this.infos[remainingIndex]);
+ }
+ }
+ for (const eachRemainingRow of remainingFormHolder) {
+ for (const row of this.infos) {
+ if (eachRemainingRow === row) {
+ this.infos.splice(this.infos.indexOf(row), 1);
+ }
+ }
+ }
+ return remainingFormHolder;
+ },
+ pasteRemainingForm(remainingFormHolder) {
+ for (const eachRemainingRow of remainingFormHolder) {
+ for (const row of this.infos) {
+ if (row.cells.length === 0) {
+ this.infos.splice(this.infos.indexOf(row), 1, eachRemainingRow);
+ break;
+ }
+ }
+ for (const row of this.infos) {
+ for (const cell of row.cells) {
+ if (totalKeyWords.indexOf(cell.title) !== -1) {
+ cell.title = this.addTotalAmount(cell.title);
+ }
+ }
+ }
+ }
+ },
pasteBanCaiHeadTemplate(copyBanCaiTemplate: any) {
const temCopyBanCaiTemplate = copyBanCaiTemplate;
for (const banCaiRow of temCopyBanCaiTemplate) {
@@ -266,7 +353,7 @@ export default Vue.extend({
}
}
},
- pasteBanCaiBodyTemplate(boardIndex: number) {
+ pasteBanCaiBody(boardIndex: number) {
const boardInfosTemplateHolder = [];
const copyBanCaiBodyTemplateIndex: any = this.copyBanCaiBodyTemplate();
@@ -338,11 +425,11 @@ export default Vue.extend({
}
};
- const subQuantityMatch = (query: string) => {
+ const addsubQuantity = (board: any) => {
for (const row of this.infos) {
for (const cell of row.cells) {
- if (cell.title === query) {
- cell.title = '单个板材数量';
+ if (subKeyWords.indexOf(cell.title) !== -1) {
+ cell.title = this.addSubAmount(cell.title, board);
}
}
}
@@ -351,18 +438,20 @@ export default Vue.extend({
// 复制完整板材的模板
const copyBanCaiTemplate = [];
for (const board of data.boards) {
- copyBanCaiTemplate.push(this.copyBanCaiHeadTemplate());
+ copyBanCaiTemplate.push(this.copyBanCaiTemplate());
}
+ const copiedRemaingForm = this.copyRemainingForm(); // 复制板材之外的剩余表格
- addOrderDetails();
+ addOrderDetails(); // 添加表单头部信息
for (let i = 0; i < data.boards.length; i++) {
- addBanCaiHeader(i);
- this.pasteBanCaiBodyTemplate(i);
- subQuantityMatch('subquantity');
+ addBanCaiHeader(i); // 添加板材的头部信息
+ this.pasteBanCaiBody(i); // 添加板材的身部信息
+ addsubQuantity(data.boards[i]); // 添加小计信息
if (i < data.boards.length - 1) {
- this.pasteBanCaiHeadTemplate(copyBanCaiTemplate[i]);
+ this.pasteBanCaiHeadTemplate(copyBanCaiTemplate[i]); // 添加板材样板
}
}
+ this.pasteRemainingForm(copiedRemaingForm); // 粘贴剩余的表格
},
// for testing use -----import data from other file