sub and total has done
This commit is contained in:
parent
e2d7f832ad
commit
6f9fdf39f4
@ -20,7 +20,7 @@ const data = {
|
|||||||
length: 944,
|
length: 944,
|
||||||
width: 59,
|
width: 59,
|
||||||
thickness: 18,
|
thickness: 18,
|
||||||
quantity: 1,
|
quantity: 10,
|
||||||
area: 0.568,
|
area: 0.568,
|
||||||
mutation: '',
|
mutation: '',
|
||||||
shape: '',
|
shape: '',
|
||||||
|
@ -62,8 +62,5 @@ const Tool = {
|
|||||||
}
|
}
|
||||||
that.selectedCell = 9000;
|
that.selectedCell = 9000;
|
||||||
},
|
},
|
||||||
copySingleRow: (Id: number) => {
|
|
||||||
Id += 1;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
export { Tool };
|
export { Tool };
|
||||||
|
@ -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: 10, rowTitle: '10', cells: [] },
|
||||||
{ rowId: 11, rowTitle: '11', cells: [] },
|
{ rowId: 11, rowTitle: '11', cells: [] },
|
||||||
|
@ -47,10 +47,10 @@
|
|||||||
<p style="color: blue">以下功能用于测试使用</p>
|
<p style="color: blue">以下功能用于测试使用</p>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span>选择板材头模板:</span><br>
|
<span>选择重用板材模板:</span><br>
|
||||||
<span>开始:</span><input type="number" v-model="banCaiHeadStartLine"><br>
|
<span>开始:</span><input type="number" v-model="banCaiHeadStartLineIndex"><br>
|
||||||
<span>结束:</span><input type="number" v-model="banCaiHeadEndLine">
|
<span>结束:</span><input type="number" v-model="banCaiHeadEndLineIndex">
|
||||||
<button @click="copyBanCaiHeadTemplate">确定板材头</button>
|
<button @click="copyBanCaiTemplate">确定板材头</button>
|
||||||
</div>
|
</div>
|
||||||
<button @click="importTemplate">导入设计样式</button>
|
<button @click="importTemplate">导入设计样式</button>
|
||||||
<button @click="importData">导入数据</button><br>
|
<button @click="importData">导入数据</button><br>
|
||||||
@ -78,6 +78,20 @@ import { Tool } from '@/assets/methodTool';
|
|||||||
let rowId = 30; // this figure is for testing use
|
let rowId = 30; // this figure is for testing use
|
||||||
let cellId = 9050; // this figure is for testing use
|
let cellId = 9050; // this figure is for testing use
|
||||||
let copiedRowHolder: any;
|
let copiedRowHolder: any;
|
||||||
|
const subKeyWords = [
|
||||||
|
'sublength',
|
||||||
|
'subwidth',
|
||||||
|
'subthickness',
|
||||||
|
'subquantity',
|
||||||
|
'subarea',
|
||||||
|
];
|
||||||
|
const totalKeyWords = [
|
||||||
|
'totallength',
|
||||||
|
'totalwidth',
|
||||||
|
'totalthickness',
|
||||||
|
'totalquantity',
|
||||||
|
'totalarea',
|
||||||
|
];
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
components: { reportCell, test },
|
components: { reportCell, test },
|
||||||
@ -116,8 +130,8 @@ export default Vue.extend({
|
|||||||
fontSize: number;
|
fontSize: number;
|
||||||
fontStyle: string;
|
fontStyle: string;
|
||||||
};
|
};
|
||||||
banCaiHeadStartLine: string;
|
banCaiHeadStartLineIndex: string;
|
||||||
banCaiHeadEndLine: string;
|
banCaiHeadEndLineIndex: string;
|
||||||
} {
|
} {
|
||||||
return {
|
return {
|
||||||
infos: startUpRowColumn,
|
infos: startUpRowColumn,
|
||||||
@ -141,8 +155,9 @@ export default Vue.extend({
|
|||||||
fontSize: 0,
|
fontSize: 0,
|
||||||
fontStyle: '',
|
fontStyle: '',
|
||||||
},
|
},
|
||||||
banCaiHeadStartLine: '5',
|
banCaiHeadStartLineIndex: '5',
|
||||||
banCaiHeadEndLine: '8',
|
banCaiHeadEndLineIndex: '8',
|
||||||
|
afterBanCaiIdHolder: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -231,18 +246,90 @@ export default Vue.extend({
|
|||||||
rowClickHandler(row: any): void {
|
rowClickHandler(row: any): void {
|
||||||
this.selectedRow = row.rowId;
|
this.selectedRow = row.rowId;
|
||||||
},
|
},
|
||||||
copyBanCaiHeadTemplate() {
|
addTotalAmount(query) {
|
||||||
let temStartLine = Number(this.banCaiHeadStartLine);
|
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 = [];
|
const banCaiHeadTemplateHolder = [];
|
||||||
|
|
||||||
while (temStartLine <= Number(this.banCaiHeadEndLine)) {
|
while (temStartLineIndex <= Number(this.banCaiHeadEndLineIndex)) {
|
||||||
banCaiHeadTemplateHolder.push(
|
banCaiHeadTemplateHolder.push(
|
||||||
this.copySingleRow(this.infos[temStartLine].rowId),
|
this.copySingleRow(this.infos[temStartLineIndex].rowId),
|
||||||
);
|
);
|
||||||
temStartLine += 1;
|
temStartLineIndex += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return banCaiHeadTemplateHolder;
|
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) {
|
pasteBanCaiHeadTemplate(copyBanCaiTemplate: any) {
|
||||||
const temCopyBanCaiTemplate = copyBanCaiTemplate;
|
const temCopyBanCaiTemplate = copyBanCaiTemplate;
|
||||||
for (const banCaiRow of temCopyBanCaiTemplate) {
|
for (const banCaiRow of temCopyBanCaiTemplate) {
|
||||||
@ -266,7 +353,7 @@ export default Vue.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pasteBanCaiBodyTemplate(boardIndex: number) {
|
pasteBanCaiBody(boardIndex: number) {
|
||||||
const boardInfosTemplateHolder = [];
|
const boardInfosTemplateHolder = [];
|
||||||
const copyBanCaiBodyTemplateIndex: any = this.copyBanCaiBodyTemplate();
|
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 row of this.infos) {
|
||||||
for (const cell of row.cells) {
|
for (const cell of row.cells) {
|
||||||
if (cell.title === query) {
|
if (subKeyWords.indexOf(cell.title) !== -1) {
|
||||||
cell.title = '单个板材数量';
|
cell.title = this.addSubAmount(cell.title, board);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,18 +438,20 @@ export default Vue.extend({
|
|||||||
// 复制完整板材的模板
|
// 复制完整板材的模板
|
||||||
const copyBanCaiTemplate = [];
|
const copyBanCaiTemplate = [];
|
||||||
for (const board of data.boards) {
|
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++) {
|
for (let i = 0; i < data.boards.length; i++) {
|
||||||
addBanCaiHeader(i);
|
addBanCaiHeader(i); // 添加板材的头部信息
|
||||||
this.pasteBanCaiBodyTemplate(i);
|
this.pasteBanCaiBody(i); // 添加板材的身部信息
|
||||||
subQuantityMatch('subquantity');
|
addsubQuantity(data.boards[i]); // 添加小计信息
|
||||||
if (i < data.boards.length - 1) {
|
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
|
// for testing use -----import data from other file
|
||||||
|
Loading…
Reference in New Issue
Block a user