var prdType =@订单明细.prdType;
var hasSub = 订单子表 != null && 订单子表.length > 0;
var wth=@订单明细.wth;
var hgt=@订单明细.hgt;
var thk=@订单明细.thk;
var area =@订单明细.wth*@订单明细.hgt*@订单明细.qty_q* 0.001 * 0.001;
var isHunYou=@订单明细.matName!=null && @订单明细.matName.indexOf("混油")>-1;
var extParamstr=@订单明细.params;
var extParams=JSON.parse(extParamstr);
var prdName=@订单明细.prdName;
var dtlmatName=isHunYou?"素板":@订单明细.matName;
var dtlrem=@订单明细.rem==null?"":@订单明细.rem;
var res = [];
function 名称包含(name,filter) {
var list=filter==null?[]:filter.split(',');
for(var j=0;j<list.length;j++){
if(name.indexOf(list[j])>-1){
return true;
}
}
return false;
}
function 名称包含索引(name,filter) {
var list=filter==null?[]:filter.split(',');
for(var j=0;j<list.length;j++){
if(name.indexOf(list[j])>-1){
return j;
}
}
return -1;
}
function setArrayData(list,keyProp,findKey, valueProp,val){
val=val==null?0:val;
var find=false;
for(var i=0;i<list.length;i++){
var bean=list[i];
if(bean[keyProp]==findKey){
bean[valueProp]=bean[valueProp]+val;
return;
}
}
if(!find){
var objt={};
objt[keyProp]=findKey;
objt[valueProp]=val;
list.push(objt);
}
}
function setSubDtlArea(filterNames,parMatName,tiemianType) {
for (var i = 0; i < 订单子表.length; i++) {
var bean = 订单子表[i];
var submatName=bean.matName==null?"":bean.matName;
submatName=submatName!=""?submatName:parMatName;
var prdName=bean.prdName==null?bean.sPrdName:bean.prdName;
var prdSpc=bean.prdSpc==null?bean.sPrdSpc:bean.prdSpc;
prdSpc=prdSpc==null?"":prdSpc;
var rem=bean.rem==null?"":bean.rem;
var prdSpcRem=bean.prdSpc+rem;
prdSpcRem=prdSpcRem==null?"":prdSpcRem;
var thk=bean.thk;
if(thk==null || thk<3){
continue;
}
var index=名称包含索引(prdName,filterNames);
var tiemianlist=tiemianType.split(",");
if(filterNames==null ||filterNames=="" || index>-1){
var subarea = bean.wth * bean.hgt * bean.qty_q * 0.001 * 0.001;
var tiemian="";
if(index>-1){
tiemian=tiemianlist[index];
}else{
tiemian=tiemianType;
}
if(prdName.indexOf("背板")>-1){
tiemian="单贴";
}
if(prdSpcRem.indexOf("双贴")>-1){
tiemian="双贴";
}
if(prdSpcRem.indexOf("单贴")>-1){
tiemian="单贴";
}
submatName=getJiCaiName(submatName,bean.thk,bean.wth,bean.hgt,tiemian,dtlmatName);
setArrayData(res,"sumName",submatName,"qty_a",subarea);
}
}
}
function getParamValue(paramName){
for(var i=0;i<extParams.length;i++){
var name=extParams[i].paramName.substring(1);
if(name==paramName){
return extParams[i].paramValue;
}
}
return "";
}
function getJiCaiName( jicai,thk,wth,hgt,tiemian, mianCai,i){
wth=Number(wth);
hgt=Number(hgt);
var isHenWen=wth>hgt && wth>1220?"_横纹":"";
var max=wth>hgt?wth:hgt;
var len="";
if(max<=2440){
len="2440"
}else if(max>2440 && max<=2800){
len="2800"
}else if(max>2800 && max<=3050){
len="3050"
}else if(max>3050 && max<=3200){
len="3200"
}else if(max>3200 && max<=3600){
len="3600"
}else if(max>3600 && max<=4100){
len="4100"
}else{
len="5000"
}
if(String(thk).length<2){
thk="0"+thk;
}
if(tiemian=="不贴" || tiemian=="" || isHunYou){
mianCai="素板";
return jicai+"_"+thk+"mm_"+mianCai+"_"+len;
}else{
return jicai+"_"+thk+"mm_"+tiemian+"_"+mianCai+isHenWen;
}
}
//var muPi=getParamValue("@木皮纹理");
var jiCai=getParamValue("@基材");
var isDuocen=jiCai.indexOf("多层板")>-1 ;
var jiCaiName="";
if(prdType==0 ){
jiCai=getParamValue("@柜门基材");
if(jiCai==null || jiCai==""){
jiCai="未知";
}
if(hasSub){
setSubDtlArea("面板,格条板,底板","多层板","单贴,双贴,单贴")
}else{
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"双贴",dtlmatName);
setArrayData(res,"sumName",jiCaiName,"qty_a",area);
}
}else if(prdType==1){ //墙板
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"单贴",dtlmatName);
if(hasSub){
setSubDtlArea("",jiCai,"单贴")
}else{
setArrayData(res,"sumName",jiCaiName,"qty_a",area);
}
}else if(prdType==2){ //柜体
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"双贴",dtlmatName);
if(hasSub){
setSubDtlArea("",jiCai,"双贴")
}else{
setArrayData(res,"sumName",jiCaiName,"qty_a",area);
}
}else if(prdType==3){ //平直
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"双贴",dtlmatName);
if(dtlrem.indexOf("单贴")>-1){
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"单贴",dtlmatName);
}
if(hasSub){
setSubDtlArea("",jiCai,"双贴")
}else{
setArrayData(res,"sumName",jiCaiName,"qty_a",area);
}
}
else if(prdType==8){
jiCaiName=getJiCaiName(jiCai,thk,wth,hgt,"单贴",dtlmatName);
if(hasSub){
setSubDtlArea("面板,套板,背条,垫条,套线,门眉,挡板,挡条,侧板,顶板,底板",jiCai,
"单贴,单贴,不贴,不贴,单贴,单贴,单贴,单贴,单贴,单贴,单贴"
);
}else{
setArrayData(res,"sumName",jiCaiName,"qty_a",area);
}
}
for (var i = 0; i < res.length; i++) {
res[i].sumName = res[i].sumName + "_qty1";
}
res;
console