class commonRender{
    renderTrs(contentArr,showType,inGroupFieldIdArr,isView){
        if(!inGroupFieldIdArr){
            inGroupFieldIdArr = [];
        }
        let fieldInclue = 0;
        let obj = {tds:[]};
        let rowNumber = 1;
        let rowspanObj = {};
        let renderArr = [obj];
        let hideArr = [];
        let contentAllObj = {};
        let isHasVisiable = false;
        let isShowOneline = false;
        if(showType == 'mobile'){ // 手机端仅展示一行
            isShowOneline = true;
        }
        (contentArr || []).forEach(td => {
            contentAllObj[td.fieldId] = td;
            if(td.tdType == "controlTitle" || td.isCupJoint || inGroupFieldIdArr.indexOf(td.code) > -1){//控件嵌套不显示
                return;
            }
            if(isView == 'view' && td.controlType === 'ejectData'){
                return;
            }
            if(td.controlType === 'sequence' && td.linkFieldId){
                return;
            }
            if(td.visible == "true"){
                isHasVisiable = true;
                if(fieldInclue + Number(td.fieldInclue || 0) > (24 - Number(rowspanObj[rowNumber] || 0))){
                    if(24 - Number(rowspanObj[rowNumber + 1] || 0) - Number(td.fieldInclue || 0) < 0){
                        // 补齐空列
                        do {
                            let blankColClude = 24 - Number(rowspanObj[rowNumber + 1] || 0);
                            if(blankColClude > 0){
                                obj = {tds:[]};
                                let templateId = rowNumber + "_blankCol";
                                let templateObj = {'controlType':'blankCol','fieldInclue':blankColClude,'visible':'true','fieldId':templateId,'code':templateId,'hideShowName':'是'};
                                contentAllObj[templateId] = templateObj;
                                obj.tds.push(templateObj);
                                renderArr.push(obj);
                            }else{
                                obj = {tds:[]};
                                renderArr.push(obj);
                            }
                            fieldInclue = 0;
                            rowNumber++;
                        }while (24 - Number(rowspanObj[rowNumber + 1] || 0) - Number(td.fieldInclue || 0) < 0);
                    }

                    obj = {tds:[]};
                    fieldInclue = 0;
                    renderArr.push(obj);
                    rowNumber++;
                }
                if(Number(td.rowspan || 0) > 1){ // 根据跨行数为下行计算已被占据的列数
                    for(let i = 1 ; i < Number(td.rowspan || 0) ; i++){
                        rowspanObj[rowNumber + i] = Number(rowspanObj[rowNumber + i] || 0) + Number(td.fieldInclue || 0);
                    }
                }
                let fieldInclueTmp = td.fieldInclue;
                td.titleWidth = 0;
                obj.tds.push(td);
                fieldInclue += Number(fieldInclueTmp || 0);
                if(isShowOneline){
                    fieldInclue = 24;
                }
            }else{
                hideArr.push({tds:[td]});
            }
        });
        if(isHasVisiable){
            renderArr = renderArr.concat(hideArr);
        }else{
            renderArr = hideArr;
        }
        // renderArr = renderArr.concat(hideArr);
        return [renderArr,contentAllObj];
    }
}
export { commonRender }