@@ -47,10 +47,10 @@
< p style = "color: blue" > 以下功能用于测试使用 < / p >
< div >
< span > 选择板材头 模板 : < / span > < br >
< span > 开始 : < / span > < input type = "number" v-model = "banCaiHeadStartLine" > < br >
< span > 结束 : < / span > < input type = "number" v-model = "banCaiHeadEndLine" >
< button @click ="copyBanCaiHead Template" > 确定板材头 < / button >
< span > 选择重用 板材模板 : < / span > < br >
< span > 开始 : < / span > < input type = "number" v-model = "banCaiHeadStartLineIndex " > < br >
< span > 结束 : < / span > < input type = "number" v-model = "banCaiHeadEndLineIndex " >
< button @click ="copyBanCaiTemplate" > 确定板材头 < / button >
< / div >
< button @click ="importTemplate" > 导入设计样式 < / button >
< button @click ="importData" > 导入数据 < / button > < br >
@@ -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 add subQuantity = ( 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 . copyBanCaiHead Template ( ) ) ;
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 ) ; // 添加板材的身部信息
add subQuantity( 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