diff --git a/src/components/reportTemplate/ReportTemplate.vue b/src/components/reportTemplate/ReportTemplate.vue index fca0b65..c355557 100644 --- a/src/components/reportTemplate/ReportTemplate.vue +++ b/src/components/reportTemplate/ReportTemplate.vue @@ -45,11 +45,23 @@
-

标签:

- +

订单标签:

+

板材头部标签:

+ +

板材身体标签:

+ +

其他标签:

+ +
@@ -89,6 +101,7 @@ import reportCell from './reportCell.vue'; import { Tool } from '@/components/reportTemplate/rescource/methodTool'; import { hightlight } from '@/components/reportTemplate/rescource/hightlight'; +import * as TypeDefinition from '@/components/reportTemplate/rescource/tyscriptDefinition'; let rowId = 30; // this figure is for testing use let cellId = 9060; // this figure is for testing use @@ -123,46 +136,7 @@ const banCaiBodyTags = [ export default Vue.extend({ components: { reportCell }, - data(): { - infos: Array<{ - rowId: number; - rowTitle: string; - cells: Array<{ - cellId: number; - title: string; - colspan: number; - height: number; - textAlign: string; - fontSize: number; - fontStyle: string; - }>; - }>; - data: any; - - selectedRow: number; - selectedCell: number; - inputTitle: string; - inputColspan: number; - inputHeight: number; - textAlign: string; - fontSize: number; - fontStyle: string; - recordHistory: string[]; - importedData: any; - currentCell: { - cellId: number; - title: string; - colspan: number; - height: number; - textAlign: string; - fontSize: number; - fontStyle: string; - }; - banCaiHeadStartLineIndex: string; - banCaiHeadEndLineIndex: string; - tags: string[]; - designTemplate: any; - } { + data(): TypeDefinition.Data { return { infos: startUpRowColumn, data, @@ -187,7 +161,7 @@ export default Vue.extend({ }, banCaiHeadStartLineIndex: '5', banCaiHeadEndLineIndex: '8', - tags: [ + orderTags: [ '${订单号}', '${客户名}', '${出售日期}', @@ -195,8 +169,9 @@ export default Vue.extend({ '${联系电话}', '${送货地址}', '${订单备注}', - '${板材材料}', - '${板材颜色}', + ], + banCaiHeadTags: ['${板材材料}', '${板材颜色}'], + banCaiBodyTags: [ '${板材房名}', '${板材柜名}', '${板材号}', @@ -212,6 +187,19 @@ export default Vue.extend({ '${条纹}', '${板材备注}', ], + otherTags: [ + '${长度小计}', + '${宽度小计}', + '${厚度小计}', + '${数量小计}', + '${面积小计}', + '${长度总计}', + '${宽度总计}', + '${厚度总计}', + '${数量总计}', + '${面积总计}', + '${板材数量}', + ], designTemplate: 0, }; }, @@ -310,6 +298,7 @@ export default Vue.extend({ backToDesignTemplate() { if (this.designTemplate) { this.infos = this.designTemplate; + copiedRemaingForm = []; } else { alert('没有保存的设计报表'); } diff --git a/src/components/reportTemplate/rescource/methodTool.ts b/src/components/reportTemplate/rescource/methodTool.ts index 21234b1..e6973df 100644 --- a/src/components/reportTemplate/rescource/methodTool.ts +++ b/src/components/reportTemplate/rescource/methodTool.ts @@ -1,77 +1,23 @@ import data from '@/components/reportTemplate/rescource/orderDetails'; // use data for testing use +import * as TypeDefinition from '@/components/reportTemplate/rescource/tyscriptDefinition'; -const orderDetails: { - [index: string]: string | object; - orderNo: string; - clientName: string; - soldDate: string; - contactName: string; - contactNo: string; - deliveryAddress: string; - addOn: string; - boards: Array<{ - [index: string]: number | string | object; - id: number; - material: string; - color: string; - boardInfos: Array<{ - houseName: string; - closetName: string; - boardNo: string; - boardName: string; - length: number; - width: number; - thickness: number; - quantity: number; - area: number; - mutation: string; - shape: string; - direction: string; - stripe: string; - boardAddOn: string; +const orderDetails: TypeDefinition.OrderDetails = data; - [index: string]: number | string; - }>; - }>; -} = data; - -interface BoardFormat { - id: number; - material: string; - color: string; - boardInfos: Array<{ - houseName: string; - closetName: string; - boardNo: string; - boardName: string; - length: number; - width: number; - thickness: number; - quantity: number; - area: number; - mutation: string; - shape: string; - direction: string; - stripe: string; - boardAddOn: string; - [index: string]: number | string; - }>; -} -const subKeyWords = [ - 'sublength', - 'subwidth', - 'subthickness', - 'subquantity', - 'subarea', -]; -const totalKeyWords = [ - 'totallength', - 'totalwidth', - 'totalthickness', - 'totalquantity', - 'totalarea', -]; -const tagsObject: any = { +const subKeyWords: TypeDefinition.SubKeyWords = { + '${长度小计}': 'length', + '${宽度小计}': 'width', + '${厚度小计}': 'thickness', + '${数量小计}': 'quantity', + '${面积小计}': 'area', +}; +const totalKeyWords: TypeDefinition.TotalKeyWords = { + '${长度总计}': 'length', + '${宽度总计}': 'width', + '${厚度总计}': 'thickness', + '${数量总计}': 'quantity', + '${面积总计}': 'area', +}; +const tagsObject: TypeDefinition.TagsObject = { '${订单号}': 'orderNo', '${客户名}': 'clientName', '${出售日期}': 'soldDate', @@ -192,7 +138,7 @@ const Tool = { } that.selectedCell = 9000; }, - isTagName(cellTitle: string) { + isTagName: (cellTitle: string) => { if (cellTitle.slice(0, 2) === '${') { return true; } else { @@ -201,11 +147,11 @@ const Tool = { }, addTotalAmount: (query: string) => { let total: any = 0; - const query1 = query.slice(5); + for (const board of orderDetails.boards) { for (const eachBoardInfo of board.boardInfos) { - if (Object.keys(eachBoardInfo).indexOf(query1) !== -1) { - total += eachBoardInfo[query1]; + if (Object.keys(eachBoardInfo).indexOf(query) !== -1) { + total += eachBoardInfo[query]; } } } @@ -215,13 +161,12 @@ const Tool = { return total.toFixed(3); } }, - addSubAmount: (query: string, board: BoardFormat) => { + addSubAmount: (query: string, board: TypeDefinition.Board) => { let sub: any = 0; - const query1 = query.slice(3); for (const eachBoardInfo of board.boardInfos) { - if (Object.keys(eachBoardInfo).indexOf(query1) !== -1) { - sub += eachBoardInfo[query1]; + if (Object.keys(eachBoardInfo).indexOf(query) !== -1) { + sub += eachBoardInfo[query]; } } if (Number.isInteger(sub)) { @@ -230,10 +175,10 @@ const Tool = { return sub.toFixed(3); } }, - addBoardInfoAmount: (that: any, board: BoardFormat) => { + addBoardInfoAmount: (that: any, board: TypeDefinition.Board) => { for (const row of that.infos) { for (const cell of row.cells) { - if (cell.title === 'bancaiinfoamount') { + if (cell.title === '${板材数量}') { cell.title = board.boardInfos.length; } } @@ -280,8 +225,8 @@ const Tool = { } for (const row of that.infos) { for (const cell of row.cells) { - if (totalKeyWords.indexOf(cell.title) !== -1) { - cell.title = that.addTotalAmount(cell.title); + if (Object.keys(totalKeyWords).indexOf(cell.title) !== -1) { + cell.title = that.addTotalAmount(totalKeyWords[cell.title]); } } } @@ -310,11 +255,11 @@ const Tool = { pasteBanCaiBody: (that: any, boardIndex: number) => { const boardInfosTemplateHolder = []; - const copyBanCaiBodyTemplateIndex: any = Tool.copyBanCaiBodyTemplate(that); + const BanCaiBodyTemplateIndex: any = Tool.copyBanCaiBodyTemplate(that); for (const i of orderDetails.boards[boardIndex].boardInfos) { boardInfosTemplateHolder.push( - that.copySingleRow(that.infos[copyBanCaiBodyTemplateIndex].rowId), + that.copySingleRow(that.infos[BanCaiBodyTemplateIndex].rowId), ); } @@ -328,10 +273,10 @@ const Tool = { } } - that.infos.splice(copyBanCaiBodyTemplateIndex, 1); + that.infos.splice(BanCaiBodyTemplateIndex, 1); for (let i = 0; i < boardInfosTemplateHolder.length; i++) { that.infos.splice( - copyBanCaiBodyTemplateIndex + i, + BanCaiBodyTemplateIndex + i, 0, boardInfosTemplateHolder[i], ); @@ -362,8 +307,8 @@ const Tool = { addsubQuantity: (that: any, board: any) => { for (const row of that.infos) { for (const cell of row.cells) { - if (subKeyWords.indexOf(cell.title) !== -1) { - cell.title = that.addSubAmount(cell.title, board); + if (Object.keys(subKeyWords).indexOf(cell.title) !== -1) { + cell.title = that.addSubAmount(subKeyWords[cell.title], board); } } } diff --git a/src/components/reportTemplate/rescource/templateInitialData.ts b/src/components/reportTemplate/rescource/templateInitialData.ts index 4de422e..bf16cc4 100644 --- a/src/components/reportTemplate/rescource/templateInitialData.ts +++ b/src/components/reportTemplate/rescource/templateInitialData.ts @@ -431,7 +431,7 @@ const initialTemplateData = [ }, { cellId: 9060, - title: 'bancaiinfoamount', + title: '${板材数量}', colspan: 4, height: 30, textAlign: 'left', @@ -719,7 +719,7 @@ const initialTemplateData = [ }, { cellId: 9048, - title: 'subquantity', + title: '${数量小计}', colspan: 14, height: 30, textAlign: 'left', @@ -743,7 +743,7 @@ const initialTemplateData = [ }, { cellId: 9050, - title: 'totalquantity', + title: '${数量总计}', colspan: 14, height: 30, textAlign: 'left', diff --git a/src/components/reportTemplate/rescource/tyscriptDefinition.ts b/src/components/reportTemplate/rescource/tyscriptDefinition.ts new file mode 100644 index 0000000..425694c --- /dev/null +++ b/src/components/reportTemplate/rescource/tyscriptDefinition.ts @@ -0,0 +1,156 @@ +interface SingleInfo { + rowId: number; + rowTitle: string; + cells: Array<{ + cellId: number; + title: string; + colspan: number; + height: number; + textAlign: string; + fontSize: number; + fontStyle: string; + }>; +} + +interface CurrentCell { + cellId: number; + title: string; + colspan: number; + height: number; + textAlign: string; + fontSize: number; + fontStyle: string; +} + +interface OrderDetails { + [index: string]: string | object; + orderNo: string; + clientName: string; + soldDate: string; + contactName: string; + contactNo: string; + deliveryAddress: string; + addOn: string; + boards: Array<{ + [index: string]: number | string | object; + id: number; + material: string; + color: string; + boardInfos: Array<{ + houseName: string; + closetName: string; + boardNo: string; + boardName: string; + length: number; + width: number; + thickness: number; + quantity: number; + area: number; + mutation: string; + shape: string; + direction: string; + stripe: string; + boardAddOn: string; + + [index: string]: number | string; + }>; + }>; +} +interface Board { + id: number; + material: string; + color: string; + boardInfos: Array<{ + houseName: string; + closetName: string; + boardNo: string; + boardName: string; + length: number; + width: number; + thickness: number; + quantity: number; + area: number; + mutation: string; + shape: string; + direction: string; + stripe: string; + boardAddOn: string; + [index: string]: number | string; + }>; +} + +interface Data { + infos: Infos; + data: any; + selectedRow: number; + selectedCell: number; + inputTitle: string; + inputColspan: number; + inputHeight: number; + textAlign: string; + fontSize: number; + fontStyle: string; + recordHistory: string[]; + importedData: any; + currentCell: CurrentCell; + banCaiHeadStartLineIndex: string; + banCaiHeadEndLineIndex: string; + orderTags: string[]; + banCaiHeadTags: string[]; + banCaiBodyTags: string[]; + otherTags: string[]; + designTemplate: any; +} +interface SubKeyWords { + [index: string]: string; + '${长度小计}': string; + '${宽度小计}': string; + '${厚度小计}': string; + '${数量小计}': string; + '${面积小计}': string; +} +interface TotalKeyWords { + [index: string]: string; + '${长度总计}': string; + '${宽度总计}': string; + '${厚度总计}': string; + '${数量总计}': string; + '${面积总计}': string; +} +interface TagsObject { + [index: string]: string; + '${订单号}': string; + '${客户名}': string; + '${出售日期}': string; + '${联系人}': string; + '${联系电话}': string; + '${送货地址}': string; + '${订单备注}': string; + '${板材材料}': string; + '${板材颜色}': string; + '${板材房名}': string; + '${板材柜名}': string; + '${板材号}': string; + '${板材名}': string; + '${长度}': string; + '${宽度}': string; + '${厚度}': string; + '${数量}': string; + '${面积}': string; + '${变异}': string; + '${形状}': string; + '${方向}': string; + '${条纹}': string; + '${板材备注}': string; +} + +export interface Infos extends Array {} +export { + Data, + CurrentCell, + OrderDetails, + Board, + SubKeyWords, + TotalKeyWords, + TagsObject, +};