数据源定义
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user