resource class definition
This commit is contained in:
parent
bf81c0d140
commit
9f71819b06
@ -26,97 +26,65 @@ class ControlPanel {
|
||||
}
|
||||
// 数据源类
|
||||
class DataResource {
|
||||
data: OrderDetailsFormat;
|
||||
constructor(orderDetails: OrderDetailsFormat) {
|
||||
this.data = orderDetails;
|
||||
}
|
||||
displayName: string;
|
||||
sourceName: string;
|
||||
sourceType: number;
|
||||
items: DataResourceItem[];
|
||||
}
|
||||
|
||||
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
|
||||
class DataResourceItem {
|
||||
displayName: string;
|
||||
dataField: string;
|
||||
|
||||
constructor(name, field) {
|
||||
this.displayName = name;
|
||||
this.dataField = field;
|
||||
}
|
||||
}
|
||||
|
||||
let orderDetailsMatches = new DataResource();
|
||||
orderDetailsMatches.displayName = "订单信息";
|
||||
orderDetailsMatches.sourceName = "orders";
|
||||
orderDetailsMatches.sourceType = 0;
|
||||
orderDetailsMatches.items = [
|
||||
new DataResourceItem("${订单号}", "orderNo"),
|
||||
new DataResourceItem("${客户名}", "clientName"),
|
||||
new DataResourceItem("${出售日期}", "soldDate"),
|
||||
new DataResourceItem("${联系名字}", "contactNo"),
|
||||
new DataResourceItem("${送货地址}", "deliveryAddress"),
|
||||
new DataResourceItem("${订单备注}", "addOn")
|
||||
];
|
||||
|
||||
let banCaiMatches = new DataResource();
|
||||
banCaiMatches.displayName = "板材头信息";
|
||||
banCaiMatches.sourceName = "banCaiHead";
|
||||
banCaiMatches.sourceType = 1;
|
||||
banCaiMatches.items = [
|
||||
new DataResourceItem("${板材材料}", "material"),
|
||||
new DataResourceItem("${板材颜色}", "color")
|
||||
];
|
||||
|
||||
let banCaiInfoMatches = new DataResource();
|
||||
banCaiInfoMatches.displayName = "板材身信息";
|
||||
banCaiInfoMatches.sourceName = "banCaiBody";
|
||||
banCaiInfoMatches.sourceType = 1;
|
||||
banCaiInfoMatches.items = [
|
||||
new DataResourceItem("${板材房名}", "houseName"),
|
||||
new DataResourceItem("${板材柜名}", "closetName"),
|
||||
new DataResourceItem("${板材编号}", "boardNo"),
|
||||
new DataResourceItem("${板材名}", "boardName"),
|
||||
new DataResourceItem("${板材长度}", "length"),
|
||||
new DataResourceItem("${板材宽度}", "width"),
|
||||
new DataResourceItem("${板材厚度}", "thickness"),
|
||||
new DataResourceItem("${板材数量}", "quantity"),
|
||||
new DataResourceItem("${板材面积}", "area"),
|
||||
new DataResourceItem("${板材异型}", "mutation"),
|
||||
new DataResourceItem("${板材形状}", "shape"),
|
||||
new DataResourceItem("${板材方向}", "direction"),
|
||||
new DataResourceItem("${板材条纹}", "stripe"),
|
||||
new DataResourceItem("${板材备注}", "boardAddOn")
|
||||
];
|
||||
|
||||
// typescript 类型定义
|
||||
|
||||
interface OrderDetailsFormat {
|
||||
|
Loading…
Reference in New Issue
Block a user