|  | @@ -29,24 +29,41 @@ let exportUtil = {
 | 
	
		
			
				|  |  |  async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      let tenderProjects = [];
 | 
	
		
			
				|  |  | +    let errorMap = {};
 | 
	
		
			
				|  |  |      let result = await ajaxPost("/project/getSEIProjects",{projectID:projectID});
 | 
	
		
			
				|  |  |      let pr = new SCComponent.InitProgressBar();
 | 
	
		
			
				|  |  |      pr.start('导出数据接口', '正在导出文件,请稍候……');
 | 
	
		
			
				|  |  | -    console.log(result);
 | 
	
		
			
				|  |  |      let project = getProject(result);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      await prepareTenderDatas(tenderProjects,project);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    if(!_.isEmpty(errorMap)){
 | 
	
		
			
				|  |  | +        showError(errorMap);
 | 
	
		
			
				|  |  | +        return pr.end();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      toXml(project);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      pr.end();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    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);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(infoList.length > 20){
 | 
	
		
			
				|  |  | +            $('#hintBox_caption').addClass('export-check');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        let msg = infoList.join(`<br>`);
 | 
	
		
			
				|  |  | +        alert(msg);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function getProject(orignal) {//取建设项目信息
 | 
	
		
			
				|  |  |          let basicInformation = getBaseInfo(orignal);
 | 
	
		
			
				|  |  | +        let textTpye =  orignal.property.taxType == 1 ?"一般计税":"简易计税";
 | 
	
		
			
				|  |  |          let project = {
 | 
	
		
			
				|  |  |              name: "建设项目",
 | 
	
		
			
				|  |  |              attrs: [
 | 
	
	
		
			
				|  | @@ -54,7 +71,8 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |                  {name:"建设单位",value:getItemValueBykey(basicInformation.items,"constructionUnit")},
 | 
	
		
			
				|  |  |                  {name:"施工单位",value:getItemValueBykey(basicInformation.items,"buildingUnit")},
 | 
	
		
			
				|  |  |                  {name: "标准名称", value: "重庆市建设工程造价指标采集标准(清单计价)"},
 | 
	
		
			
				|  |  | -                {name: "标准版本号", value: "1.1"}
 | 
	
		
			
				|  |  | +                {name: "标准版本号", value: "1.1"},
 | 
	
		
			
				|  |  | +                {name: "计税模式", value: textTpye}
 | 
	
		
			
				|  |  |              ],
 | 
	
		
			
				|  |  |              basicInformation:basicInformation,
 | 
	
		
			
				|  |  |              children:[]
 | 
	
	
		
			
				|  | @@ -93,7 +111,8 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |              children:[],
 | 
	
		
			
				|  |  |              valuationType:source.property.valuationType,
 | 
	
		
			
				|  |  |              taxType:source.property.taxType,
 | 
	
		
			
				|  |  | -            property:source.property
 | 
	
		
			
				|  |  | +            property:source.property,
 | 
	
		
			
				|  |  | +            name:source.name
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          return tender;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -141,6 +160,7 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |              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);
 | 
	
		
			
				|  |  |              for(let m of materials){
 | 
	
		
			
				|  |  | +                if(m.name == "其他材料") continue;//2020-01-08  其他材料 不输出字段(不管是否有值)。
 | 
	
		
			
				|  |  |                  mainIndex.children.push(getMaterial(m))
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              let index = {
 | 
	
	
		
			
				|  | @@ -151,8 +171,9 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |              return index;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              function getMaterial(m) {
 | 
	
		
			
				|  |  | +                let mname = m.exportName?m.exportName:m.name;
 | 
	
		
			
				|  |  |                  let material = {
 | 
	
		
			
				|  |  | -                    name:m.name,
 | 
	
		
			
				|  |  | +                    name:mname,
 | 
	
		
			
				|  |  |                      attrs:[
 | 
	
		
			
				|  |  |                          {name:"综合单价",value:scMathUtil.roundToString(m.unitPrice,2)},
 | 
	
		
			
				|  |  |                          {name:"数量",value:scMathUtil.roundToString(m.quantity,2)},
 | 
	
	
		
			
				|  | @@ -184,8 +205,9 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |              return index;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              function getQuantity(q) {
 | 
	
		
			
				|  |  | +                let qname = q.exportName?q.exportName:q.name;
 | 
	
		
			
				|  |  |                  let quantity = {
 | 
	
		
			
				|  |  | -                    name:q.name,
 | 
	
		
			
				|  |  | +                    name:qname,
 | 
	
		
			
				|  |  |                      attrs:[
 | 
	
		
			
				|  |  |                          {name:"工程量指标",value:scMathUtil.roundToString(q.quantity,3)},
 | 
	
		
			
				|  |  |                          {name:"单位",value:q.quantityIndexUnit}
 | 
	
	
		
			
				|  | @@ -213,8 +235,9 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |              return index;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              function getEco(e) {
 | 
	
		
			
				|  |  | +                let ename = e.exportName?e.exportName:e.name;
 | 
	
		
			
				|  |  |                  let eco = {
 | 
	
		
			
				|  |  | -                  name:e.name,
 | 
	
		
			
				|  |  | +                  name:ename,
 | 
	
		
			
				|  |  |                    attrs:[
 | 
	
		
			
				|  |  |                        {name:"综合合价",value:scMathUtil.roundToString(e.cost,2)},
 | 
	
		
			
				|  |  |                        {name:"单方指标",value:scMathUtil.roundToString(e.unitCost,2)},
 | 
	
	
		
			
				|  | @@ -264,13 +287,35 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |                  {name: "备注", value: source.remark}
 | 
	
		
			
				|  |  |              ]
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | +        handleXMLEntity(g.attrs);
 | 
	
		
			
				|  |  |          return g;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    // 对每个元素的所有属性值进行特殊字符处理
 | 
	
		
			
				|  |  | +    function handleXMLEntity(attrs) {
 | 
	
		
			
				|  |  | +        let _xmlEntity = {
 | 
	
		
			
				|  |  | +            '&': '&',
 | 
	
		
			
				|  |  | +            '\n': '
',
 | 
	
		
			
				|  |  | +            '"': '"',
 | 
	
		
			
				|  |  | +            '\'': ''',
 | 
	
		
			
				|  |  | +            '<': '<',
 | 
	
		
			
				|  |  | +            '>': '>'
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        for (let attr of attrs) {
 | 
	
		
			
				|  |  | +            if (!attr.value) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (let [key, value] of Object.entries(_xmlEntity)) {
 | 
	
		
			
				|  |  | +                attr.value = attr.value+"";
 | 
	
		
			
				|  |  | +                attr.value = attr.value.replace(new RegExp(key, 'g'), value);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function setEngineerInfo(tender) {//设置工程信息
 | 
	
		
			
				|  |  |          let infos = tender.property.engineerInfos?tender.property.engineerInfos:[];
 | 
	
		
			
				|  |  | +        let errors =  infoRequireChecking(infos);
 | 
	
		
			
				|  |  | +        if(errors.length > 0) errorMap[tender.name] = errors;
 | 
	
		
			
				|  |  |          let info = {
 | 
	
		
			
				|  |  |              name:"工程信息",
 | 
	
		
			
				|  |  |              attrs:[
 | 
	
	
		
			
				|  | @@ -289,8 +334,7 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |                  {name:"计价方式及依据",value:getItemValueByDispName(infos,"计价方式及依据")},
 | 
	
		
			
				|  |  |                  {name:"工程类别",value:getItemValueByDispName(infos,"工程类别")},
 | 
	
		
			
				|  |  |                  {name:"编制日期",value:getItemValueByDispName(infos,"编制日期")},
 | 
	
		
			
				|  |  | -                {name:"审查日期",value:getItemValueByDispName(infos,"审查日期")}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +                {name:"审查日期",value:getItemValueByDispName(infos,"审查日期"),required:false}
 | 
	
		
			
				|  |  |              ]
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          initAtts(info.attrs);
 | 
	
	
		
			
				|  | @@ -348,7 +392,7 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          function getValue(node) {
 | 
	
		
			
				|  |  |              let value = node.value;
 | 
	
		
			
				|  |  | -            if(node.required == true){//必填项的值为空时导出0
 | 
	
		
			
				|  |  | +            if(node.required == true || node.cellType == "number"){//必填项的值为空时导出0
 | 
	
		
			
				|  |  |                  if(value == undefined || value == null || value == "") value = "0";
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return value;
 | 
	
	
		
			
				|  | @@ -367,6 +411,15 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    function infoRequireChecking(items) {
 | 
	
		
			
				|  |  | +        let error = [];
 | 
	
		
			
				|  |  | +        for(let i of items){
 | 
	
		
			
				|  |  | +            if(i.required == true && _.isEmpty(i.value)) error.push(`工程信息 - ${i.dispName}不能为空。`);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return error;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      function getItemValueBykey(items,key) {
 | 
	
		
			
				|  |  |          let item = _.find(items,{"key":key});
 | 
	
		
			
				|  |  |          if(item) return item.value;
 | 
	
	
		
			
				|  | @@ -374,7 +427,9 @@ async function exportSEI(projectID) {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      function getItemValueByDispName(items,dispName) {
 | 
	
		
			
				|  |  |          let item = _.find(items,{"dispName":dispName});
 | 
	
		
			
				|  |  | -        if(item) return item.value;
 | 
	
		
			
				|  |  | +        if(item){
 | 
	
		
			
				|  |  | +            return item.value;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return ""
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |