From afa11720ee1670c6c474803b5a63dc919b74718c Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Fri, 12 Oct 2018 09:55:19 +0800 Subject: [PATCH] fix re-import bug going to restruture... --- .../reportTemplate/ReportTemplate.vue | 15 ++++-- .../reportTemplate/rescource/methodTool.ts | 50 +++++++++++-------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/components/reportTemplate/ReportTemplate.vue b/src/components/reportTemplate/ReportTemplate.vue index 045df3f..fca0b65 100644 --- a/src/components/reportTemplate/ReportTemplate.vue +++ b/src/components/reportTemplate/ReportTemplate.vue @@ -93,7 +93,8 @@ import { hightlight } from '@/components/reportTemplate/rescource/hightlight'; let rowId = 30; // this figure is for testing use let cellId = 9060; // this figure is for testing use let copiedRowHolder: any; -let orderHeadTags = [ +let copiedRemaingForm: any[] = []; +const orderHeadTags = [ '${订单号}', '${客户名}', '${出售日期}', @@ -102,8 +103,8 @@ let orderHeadTags = [ '${送货地址}', '${订单备注}', ]; -let banCaiHeadTags = ['${板材材料}', '${板材颜色}']; -let banCaiBodyTags = [ +const banCaiHeadTags = ['${板材材料}', '${板材颜色}']; +const banCaiBodyTags = [ '${板材房名}', '${板材柜名}', '${板材号}', @@ -371,12 +372,16 @@ export default Vue.extend({ this.selectedCell = 0; // 如果selectedCell 不等于0 选择的cell 将不会被更新 this.designTemplate = JSON.parse(JSON.stringify(this.infos)); // 复制设计好的表 + Tool.addOrderDetails(this); // 添加表单头部信息 + const copiedBanCaiTemplateRows = []; for (const board of data.boards) { copiedBanCaiTemplateRows.push(this.copyBanCaiTemplate()); } - const copiedRemaingForm = this.copyRemainingForm(); // 复制板材之外的剩余表格 - Tool.addOrderDetails(this); // 添加表单头部信息 + // 复制板材之外的剩余表格 + if (copiedRemaingForm.length === 0) { + copiedRemaingForm = this.copyRemainingForm(); + } if (this.hasBanCaiBodyTags()) { for (let i = 0; i < data.boards.length; i++) { diff --git a/src/components/reportTemplate/rescource/methodTool.ts b/src/components/reportTemplate/rescource/methodTool.ts index c833eb0..21234b1 100644 --- a/src/components/reportTemplate/rescource/methodTool.ts +++ b/src/components/reportTemplate/rescource/methodTool.ts @@ -96,23 +96,33 @@ const tagsObject: any = { '${条纹}': 'stripe', '${板材备注}': 'boardAddOn', }; -const orderDetailsKeys: string[] = []; -const banCaiHeaderKeys: string[] = []; -const banCaiDetailsKeys: string[] = []; +const orderDetailsKeys: string[] = [ + 'orderNo', + 'clientName', + 'soldDate', + 'contactName', + 'contactNo', + 'deliveryAddress', + 'addOn', +]; +const banCaiHeaderKeys: string[] = ['id', 'material', 'color']; +const banCaiDetailsKeys: string[] = [ + 'houseName', + 'closetName', + 'boardNo', + 'boardName', + 'length', + 'width', + 'thickness', + 'quantity', + 'area', + 'mutation', + 'shape', + 'direction', + 'stripe', + 'boardAddOn', +]; const temRowHolder: string[] = []; -for (const key in orderDetails) { - if (key !== 'boards') { - orderDetailsKeys.push(key); - } -} -for (const key in orderDetails.boards[0]) { - if (key !== 'boardInfos') { - banCaiHeaderKeys.push(key); - } -} -for (const key of Object.keys(orderDetails.boards[0].boardInfos[0])) { - banCaiDetailsKeys.push(key); -} const Tool = { addRow: (that: any, rowId: number) => { @@ -288,14 +298,10 @@ const Tool = { } } }, - copyBanCaiBodyTemplate: (that) => { + copyBanCaiBodyTemplate: (that: any) => { for (const row of that.infos) { for (const cell of row.cells) { - if ( - Object.keys(data.boards[0].boardInfos[0]).indexOf( - tagsObject[cell.title], - ) !== -1 - ) { + if (banCaiDetailsKeys.indexOf(tagsObject[cell.title]) !== -1) { return that.infos.indexOf(row); } }