删除标记 = "酷导";
var 公共函数 = {
//获取产品Id
getPrdIdByDtl: function (dtl, bean) {
dtl.prdName = dtl.prdName == null ? "" : dtl.prdName;
//返回柜体的产品Id
return 120403;
},
获取材质By基材颜色: function (baseMat, clrName) {
var res = null;
var mats = helper.getMatListByClr(clrName);//通过颜色来匹配系统后台花色对应的材质列表,返回材质对象为数组;
if (mats == null || mats.size() == 0) {
res = null;
} else if (mats.size() == 1) {
res = mats.get(0);
} else {
for (var i = 0; i < mats.size(); i++) {
var matName = mats.get(i).matName;
if (matName.indexOf(baseMat) > -1) {
res = mats.get(i);
break;
}
}
}
if (res == null) {
throw "基材[" + baseMat + "]颜色[" + clrName + "]在系统中没有建档案";
}
// throw res;
return res;
},
getMat: function (matName) {
var 材质 = matName;
var 颜色 = 材质.substr(材质.indexOf("板") + 1)
var 基材 = 材质.replace(颜色, "");
基材 = 基材.replace(/[0-9]/ig, "");
return 公共函数.获取材质By基材颜色(基材, 颜色);
},
汇总明细金额: function (柜体对象) {
var amt = 0;
for (var i = 0; i < 柜体对象.dtls.length; i++) {
amt = amt + 柜体对象.dtls[i].amt;
}
return Math.round(amt);
},
门板参数: function (dtl) {
var 参数 = JSON.parse(dtl.param4);
var 门型 = 参数.M材质;
var 开门 = 参数.M开门;
var 名称 = 参数.M名称;
var 材质 = 参数.M材质;
var 颜色 = 参数.M颜色;
var 高 = 参数.M高;
var 宽 = 参数.M宽;
var 厚 = 参数.M厚;
var 面积 = 参数.M面积;
var 加价 = 参数.M加价;
var 拉直器 = 参数.M拉直器;
var 孔A = 参数.孔A;
var 孔B = 参数.孔B;
var 孔C = 参数.孔C;
var 孔D = 参数.孔D;
var 孔E = 参数.孔E;
var 孔F = 参数.孔F;
var mbbeanA = {
// prdId: 120406,/////////
prdName: 名称,
prdSpc: 门型,
// matId: 0,
matName: 材质,
//gbMatId: mat.matId,
wth: 宽,
hgt: 高,
thk: 厚,
qty_q: 1,
qty_a: 面积,
// barCode: dtl.param3,
孔A : 孔A,
孔B: 孔B,
孔C: 孔C,
孔D: 孔D,
孔E: 孔E,
孔F: 孔F,
lzq:拉直器
};
return mbbeanA;
}
};
var cs = 公共函数.门板参数;
return cs;
//柜体板件处理
function doDealWithBanSubDtl(bean, prdt, subDtl) {
var fsubDtl = {
prdName: subDtl.sPrdName,
prdSpc: subDtl.sPrdSpc,
matId: "",
matName: subDtl.matName,
wth: subDtl.wth,
hgt: subDtl.hgt,
thk: subDtl.thk,
qty_q: subDtl.qty,
qty_a: subDtl.qty_a,
ut: subDtl.ut,
barCode: subDtl.barCode
};
//材质处理
var mat = 公共函数.getMat(subDtl.matName);
//throw mat.upAddDef;
fsubDtl.qty_a = fsubDtl.wth * fsubDtl.hgt * 0.001 * 0.001 * fsubDtl.qty_q;
fsubDtl.up = helper.getStepByVal(mat.upAddDef, subDtl.thk);
fsubDtl.amt = fsubDtl.qty_a * fsubDtl.up;
fsubDtl.amt = Math.round(fsubDtl.amt * 100) / 100;
fsubDtl.ut = "平方";
return fsubDtl;
}
//处理五金
function getWjDtlBean(dtl) {
var bean = {
prdId: 120666,////
prdName: dtl.prdName,
prdSpc: dtl.prdSpc,
wth: dtl.wth,
hgt: dtl.hgt,
thk: dtl.thk,
qty_q: dtl.qty_q,
qty_a: dtl.qty_q,
barCode: dtl.barCode
};
//处理五金单价;
//返回单个五金信息到订单明细;
return bean;
}
//处理门板
function getMbDtlBean(dtl) {
var mbbean = {
prdId: 120406,/////////
prdName: dtl.prdName,
prdSpc: dtl.prdSpc,
matId: 0,
//matName: mat.matName,
//gbMatId: mat.matId,
wth: dtl.wth,
hgt: dtl.hgt,
thk: dtl.thk,
qty_q: dtl.qty,
qty_a: dtl.qty_q,
barCode: dtl.param3,
dtls:[]
};
var 门板参数=JSON.parse(dtl.param4);
//处理门板单价;
//处理门板的子表
if (dtl.subDtls.length > 0) {
for (var i = 0; i < dtl.subDtls.length; i++) {
var subDtl = dtl.subDtls[i];
var newSubDtl = {
prdName: subDtl.sPrdName,
prdSpc: subDtl.sPrdSpc,
matId: "",
matName: subDtl.matName,
wth: subDtl.wth,
hgt: subDtl.hgt,
thk: subDtl.thk,
qty_q: subDtl.qty,
qty_a: subDtl.qty_a,
ut: subDtl.ut,
barCode: subDtl.barCode
};
mbbean.dtls.push(newSubDtl);
}
};
//返回单个门板信息到订单明细;
return mbbean;
}
//处理产品单项
function doDealWithDtl(dtl) {
if (dtl.param1 == "五金") {
//throw dtl.prdName;
return getWjDtlBean(dtl);
} else if (dtl.param1 == "门板") {
return getMbDtlBean(dtl);
} else if(dtl.param1 == "" ){
return doDealWithBanSubDtl(bean, prdt, subDtl);
}
var mat = { matId: 0, matName: dtl.matName }
var bean = {
prdName: dtl.prdName,
prdSpc: dtl.prdSpc,
matId: 0,
matName: mat.matName,
gbMatId: mat.matId,
wth: dtl.wth,
hgt: dtl.hgt,
thk: dtl.thk,
qty_q: dtl.qty_q,
qty_a: dtl.qty_q,
barCode: dtl.barCode
};
helper.setDtlBeanParam(bean, 删除标记, "是");
bean.prdId = 公共函数.getPrdIdByDtl(dtl, bean);
var prdt = helper.getPrdInfo(bean.prdId);
if (prdt == null) {
throw "产品<<" + bean.prdName + ">>对应的产品id" + bean.prdId + "在MIS系统中不存在!";
}
bean.ut = prdt.prdUt;
bean.dtls = [];
if (dtl.subDtls.length > 0) {
for (var i = 0; i < dtl.subDtls.length; i++) {
var sub = null;
//if (dtl.subDtls[i].param1 == "柜体") {
sub = doDealWithBanSubDtl(bean, prdt, dtl.subDtls[i]);
bean.dtls.push(sub);
// }
}
};
bean.amt = 公共函数.汇总明细金额(bean);
bean.ndisAmt = bean.amt;
return bean;
}
//处理
function doDeal() {
for (var i = 0; i < 产品明细.length; i++) {
var bean = doDealWithDtl(产品明细[i]);
订单明细.push(bean);
}
}
doDeal();
console