From 00e8253c3343147ea683b0c8de15c14f84bbe6fc Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Wed, 17 Oct 2018 10:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rescource/orderDetails.ts | 180 ++++++++++++++++++++++++++++++++++ src/script/designerClasses.ts | 94 +++++++++++++++++- 2 files changed, 269 insertions(+), 5 deletions(-) create mode 100644 src/rescource/orderDetails.ts diff --git a/src/rescource/orderDetails.ts b/src/rescource/orderDetails.ts new file mode 100644 index 0000000..2204b62 --- /dev/null +++ b/src/rescource/orderDetails.ts @@ -0,0 +1,180 @@ +const data = { + orderNo: "101808023922", + clientName: "SongQingyang3", + soldDate: "2018-08-23", + contactName: "K01", + contactNo: "12345678901", + deliveryAddress: "D01", + addOn: "测试PTP-G刀偏置", + boards: [ + { + id: 1234, + material: "颗粒板", + color: "暖白", + boardInfos: [ + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "背板", + length: 944, + width: 59, + thickness: 18, + quantity: 10, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "1" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "层板", + length: 944, + width: 598, + thickness: 18, + quantity: 1, + area: 0.568, + mutation: "", + shape: "造型", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "2" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478875", + boardName: "右侧板", + length: 1198, + width: 548, + thickness: 18, + quantity: 1, + area: 0.66, + mutation: "", + shape: "造型", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "3" + } + ] + }, + { + id: 1235, + material: "生态板 ", + color: "暖黑", + boardInfos: [ + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "背板", + length: 944, + width: 598, + thickness: 18, + quantity: 1, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "4" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478861", + + boardName: "背板", + length: 944, + width: 598, + thickness: 18, + quantity: 1, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "5" + } + ] + }, + { + id: 1235, + material: "生态板 ", + color: "暖黑", + boardInfos: [ + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "背板", + length: 944, + width: 59, + thickness: 18, + quantity: 10, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "1" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "背板", + length: 944, + width: 59, + thickness: 18, + quantity: 10, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "1" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478862", + boardName: "背板", + length: 944, + width: 598, + thickness: 18, + quantity: 1, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "4" + }, + { + houseName: "F01", + closetName: "G01", + boardNo: "B1816478861", + + boardName: "背板", + length: 944, + width: 598, + thickness: 18, + quantity: 1, + area: 0.568, + mutation: "", + shape: "", + direction: "1/1/1/1 ", + stripe: "正纹", + boardAddOn: "5" + } + ] + } + ] +}; + +export default data; diff --git a/src/script/designerClasses.ts b/src/script/designerClasses.ts index 0071995..f3655e3 100644 --- a/src/script/designerClasses.ts +++ b/src/script/designerClasses.ts @@ -85,16 +85,100 @@ class ControlPanel { } // 数据源类 class DataResource { - data: OrderDetails; - constructor(inputdata: OrderDetails) { - this.data = inputdata; + data: OrderDetailsFormat; + constructor(orderDetails: OrderDetailsFormat) { + this.data = orderDetails; + } + + getOrderNo() { + return this.data.orderNo; + } + getClientName() { + return this.data.clientName; + } + getSoldDate() { + return this.data.soldDate; + } + getContactName() { + return this.data.contactName; + } + getContactNo() { + return this.data.contactNo; + } + getDeliveryAddress() { + return this.data.deliveryAddress; + } + getAddOn() { + return this.data.addOn; + } + getBoards() { + return this.data.boards; + } + getBoardMaterial() { + const BoardMaterial = []; + for (let item of this.data.boards) { + BoardMaterial.push(item.material); + } + return BoardMaterial; // BoardMaterial=['string', 'string'] + } + getBoardColor() { + const BoardColor = []; + for (let item of this.data.boards) { + BoardColor.push(item.color); + } + return BoardColor; // BoardColor=['string', 'string'] + } + getBoardInfo(key: string) { + const houseName = []; + for (const board of this.data.boards) { + const tem = []; + for (const boardInfo of board.boardInfos) { + if (Object.keys(boardInfo).indexOf(key) !== -1) { + tem.push(boardInfo[key]); + } else { + console.log("没有找到对应的key"); + return; + } + } + houseName.push(tem); + } + return houseName; // 返回数据结构:hosueName=[['string||number','string||number'],[]] + } + getEachBanCaiToTal(boardKey: string) { + const banCaiTotalArray = []; + for (const board of this.data.boards) { + let tem = 0; + for (const boardInfo of board.boardInfos) { + if ( + Object.keys(boardInfo).indexOf(boardKey) !== -1 && + typeof boardInfo[boardKey] === "number" + ) { + tem += Number(boardInfo[boardKey]); + } + } + banCaiTotalArray.push(tem); + } + return banCaiTotalArray; // 返回数据类型 eg :banCaiTotal=[number,number,....] + } + getAllBanCaiTotal(boardKey: string) { + let banCaiTotal = 0; + for (const board of this.data.boards) { + for (const boardInfo of board.boardInfos) { + if ( + Object.keys(boardInfo).indexOf(boardKey) !== -1 && + typeof boardInfo[boardKey] === "number" + ) { + banCaiTotal += Number(boardInfo[boardKey]); + } + } + } + return banCaiTotal; // 返回数据类型 eg :banCaiTotal:80 } - sortOutData() {} } // typescript 类型定义 -interface OrderDetails { +interface OrderDetailsFormat { [index: string]: string | object; orderNo: string; clientName: string;