|  | @@ -26,40 +26,92 @@ let exportUtil = {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -async function exportSEI(projectID) {
 | 
	
		
			
				|  |  | +let SEIObject = {};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    let tenderProjects = [];
 | 
	
		
			
				|  |  | -    let errorMap = {};
 | 
	
		
			
				|  |  | -    let result = await ajaxPost("/project/getSEIProjects",{projectID:projectID});
 | 
	
		
			
				|  |  | +async function selfChecking(projectID,exprotCall=false) {//自检和正式导出共用接口
 | 
	
		
			
				|  |  |      let pr = new SCComponent.InitProgressBar();
 | 
	
		
			
				|  |  | -    pr.start('导出数据接口', '正在导出文件,请稍候……');
 | 
	
		
			
				|  |  | -    let project = getProject(result);
 | 
	
		
			
				|  |  | -    await prepareTenderDatas(tenderProjects,project);
 | 
	
		
			
				|  |  | +   if(!exprotCall) pr.start('导出数据接口', '正在自检,请稍候……');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if(!_.isEmpty(errorMap)){
 | 
	
		
			
				|  |  | -        showError(errorMap);
 | 
	
		
			
				|  |  | -        return pr.end();
 | 
	
		
			
				|  |  | +    //先检查招投标数据  - todo
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //检查重庆指标接口数量
 | 
	
		
			
				|  |  | +    if(_.isEmpty(SEIObject.errorMap)){
 | 
	
		
			
				|  |  | +        let [errorMap,SEIFile] = await getSEIIndexFile(projectID);
 | 
	
		
			
				|  |  | +        if(errorMap) {
 | 
	
		
			
				|  |  | +            SEIObject.errorMap = errorMap;
 | 
	
		
			
				|  |  | +        }else {
 | 
	
		
			
				|  |  | +            SEIObject.fileCache.push(SEIFile);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    _.isEmpty(SEIObject.errorMap)?alert("自检完成,未检测到错误数据。"): showExportError(SEIObject.errorMap);
 | 
	
		
			
				|  |  | +    SEIObject.selfChecked = true;
 | 
	
		
			
				|  |  | +    if(!exprotCall) pr.end();
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    toXml(project);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    pr.end();
 | 
	
		
			
				|  |  | +async function exportSEI(projectID){
 | 
	
		
			
				|  |  | +    if(!_.isEmpty(SEIObject.errorMap)) return showExportError(SEIObject.errorMap);//如果自检的时候已经有错误,直接提示;
 | 
	
		
			
				|  |  | +    let pr = new SCComponent.InitProgressBar();
 | 
	
		
			
				|  |  | +    pr.start('导出数据接口', '正在导出文件,请稍候……');
 | 
	
		
			
				|  |  | +    SEIObject.exporting = true;
 | 
	
		
			
				|  |  | +    try {
 | 
	
		
			
				|  |  | +        if(!SEIObject.selfChecked){//没有经过自检,则从招投标接口开始取数据
 | 
	
		
			
				|  |  | +            await selfChecking(projectID,true);
 | 
	
		
			
				|  |  | +            if(!_.isEmpty(SEIObject.errorMap)) return  pr.end();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //导出建设项目数据
 | 
	
		
			
				|  |  | +        //导出压缩包
 | 
	
		
			
				|  |  | +       // saveZBFX(SEIObject.fileCache);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }catch (e){
 | 
	
		
			
				|  |  | +        console.log(e);
 | 
	
		
			
				|  |  | +    }finally {
 | 
	
		
			
				|  |  | +        pr.end();
 | 
	
		
			
				|  |  | +        $('#exportCode').modal('show');
 | 
	
		
			
				|  |  | +        //SEIObject.exporting = false;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | -    function showError(errorMap) {
 | 
	
		
			
				|  |  | -        let infoList = [];
 | 
	
		
			
				|  |  | -        for(let name in errorMap){
 | 
	
		
			
				|  |  | -            infoList.push(`<span style="font-weight: bold">单位工程“${name}”下:</span>`);
 | 
	
		
			
				|  |  | -            for(let err of errorMap[name]){
 | 
	
		
			
				|  |  | -                infoList.push(err);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    async function saveZBFX(fileData) {
 | 
	
		
			
				|  |  | +        let zip = new JSZip();
 | 
	
		
			
				|  |  | +        for (let file of fileData) {
 | 
	
		
			
				|  |  | +            zip.file(file.fileName, file.blob, {binary: true});
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(infoList.length > 20){
 | 
	
		
			
				|  |  | -            $('#hintBox_caption').addClass('export-check');
 | 
	
		
			
				|  |  | +        let zipFile = await zip.generateAsync({type: 'blob'});
 | 
	
		
			
				|  |  | +        saveAs(zipFile, '经济指标.ZBFX');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +function showExportError(errorMap) {
 | 
	
		
			
				|  |  | +    let infoList = [];
 | 
	
		
			
				|  |  | +    for(let name in errorMap){
 | 
	
		
			
				|  |  | +        infoList.push(`<span style="font-weight: bold">单位工程“${name}”下:</span>`);
 | 
	
		
			
				|  |  | +        for(let err of errorMap[name]){
 | 
	
		
			
				|  |  | +            infoList.push(err);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        let msg = infoList.join(`<br>`);
 | 
	
		
			
				|  |  | -        alert(msg);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    if(infoList.length > 20){
 | 
	
		
			
				|  |  | +        $('#hintBox_caption').addClass('export-check');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    let msg = infoList.join(`<br>`);
 | 
	
		
			
				|  |  | +    alert(msg);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +async function getSEIIndexFile(projectID) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    let tenderProjects = [];
 | 
	
		
			
				|  |  | +    let errorMap = {};
 | 
	
		
			
				|  |  | +    let result = await ajaxPost("/project/getSEIProjects",{projectID:projectID});
 | 
	
		
			
				|  |  | +    let project = getProject(result);
 | 
	
		
			
				|  |  | +    await prepareTenderDatas(tenderProjects,project);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    if(!_.isEmpty(errorMap)){
 | 
	
		
			
				|  |  | +        return [errorMap,null];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    let file = toXml(project);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    return [null,file];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function getProject(orignal) {//取建设项目信息
 | 
	
		
			
				|  |  |          let basicInformation = getBaseInfo(orignal);
 | 
	
	
		
			
				|  | @@ -158,7 +210,7 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |                  children:[]
 | 
	
		
			
				|  |  |              };
 | 
	
		
			
				|  |  |              if(projectData) gljUtil.calcProjectGLJQuantity(projectData.projectGLJs,projectData.ration_gljs,projectData.rations,projectData.bills,getDecimal("glj.quantity"),_,scMathUtil);
 | 
	
		
			
				|  |  | -            let materials = indexObj.getMainMaterialDatas(tender.property.materials,projectData.projectGLJs,tender.property.calcOptions,tender.property.decimal,false,_,scMathUtil);
 | 
	
		
			
				|  |  | +            let materials = indexObj.getMainMaterialDatas(tender.property,tender.property.materials,projectData.projectGLJs,tender.property.calcOptions,tender.property.decimal,false,_,scMathUtil);
 | 
	
		
			
				|  |  |              for(let m of materials){
 | 
	
		
			
				|  |  |                  if(m.name == "其他材料") continue;//2020-01-08  其他材料 不输出字段(不管是否有值)。
 | 
	
		
			
				|  |  |                  mainIndex.children.push(getMaterial(m))
 | 
	
	
		
			
				|  | @@ -262,11 +314,12 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function setGLJDetail(projectData,property,gljs) {
 | 
	
		
			
				|  |  |          if(projectData){
 | 
	
		
			
				|  |  | -            gljUtil.calcProjectGLJQuantity(projectData.projectGLJs,projectData.ration_gljs,projectData.rations,projectData.bills,getDecimal("glj.quantity"),_,scMathUtil);
 | 
	
		
			
				|  |  | +            gljUtil.calcProjectGLJQuantity(projectData.projectGLJs,projectData.ration_gljs,projectData.rations,projectData.bills,getDecimal("glj.quantity"),_,scMathUtil,true);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          for(let g of projectData.projectGLJs.gljList) {
 | 
	
		
			
				|  |  |              if (!g.quantity || g.quantity == "") continue;
 | 
	
		
			
				|  |  | -            g.marketPrice = gljUtil.getMarketPrice(g,projectData.projectGLJs,property.calcOptions,property.decimal,false,_,scMathUtil);
 | 
	
		
			
				|  |  | +            let tenderCoe = gljUtil.getTenderPriceCoe(g,property);
 | 
	
		
			
				|  |  | +            g.marketPrice = gljUtil.getMarketPrice(g,projectData.projectGLJs,property.calcOptions,property.decimal,false,_,scMathUtil,tenderCoe);
 | 
	
		
			
				|  |  |              gljs.children.push(setEachGLJ(g));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -514,15 +567,32 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |           //格式化
 | 
	
		
			
				|  |  |           xmlStr = formatXml(xmlStr);
 | 
	
		
			
				|  |  |           let blob = new Blob([xmlStr], {type: 'text/plain;charset=utf-8'});
 | 
	
		
			
				|  |  | -         saveAs(blob, '经济指标.ZBF');
 | 
	
		
			
				|  |  | +         return {
 | 
	
		
			
				|  |  | +             blob: blob,
 | 
	
		
			
				|  |  | +             fileName: "经济指标.ZBF"
 | 
	
		
			
				|  |  | +         };
 | 
	
		
			
				|  |  | +         //saveAs(blob, '经济指标.ZBF');
 | 
	
		
			
				|  |  |       }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  $(function () {
 | 
	
		
			
				|  |  | -   $("#SEIMenu").click(async function () {
 | 
	
		
			
				|  |  | -       await exportSEI(projectObj.project.property.rootProjectID);
 | 
	
		
			
				|  |  | -       $("#exportMenu").removeClass("show");
 | 
	
		
			
				|  |  | -   })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $("#export-index-check").click( function (){
 | 
	
		
			
				|  |  | +        selfChecking(projectObj.project.property.rootProjectID);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    $("#export-index-confirm").click(async function (){
 | 
	
		
			
				|  |  | +        await  exportSEI(projectObj.project.property.rootProjectID);
 | 
	
		
			
				|  |  | +       // $("#exportIndex").modal("hide");
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#exportIndex').on('hide.bs.modal', function() {
 | 
	
		
			
				|  |  | +        SEIObject = {
 | 
	
		
			
				|  |  | +            exporting:false,
 | 
	
		
			
				|  |  | +            fileCache:[],
 | 
	
		
			
				|  |  | +            errorMap:{},
 | 
	
		
			
				|  |  | +            selfChecked:false
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  });
 |