|  | @@ -13,11 +13,11 @@ const importView = (() => {
 | 
	
		
			
				|  |  |      let xmlObj = null;  //导入xml转化后的对象
 | 
	
		
			
				|  |  |      let tbcObj = null;  //待确认对象
 | 
	
		
			
				|  |  |      //显示、隐藏提示上传文件窗口相关提示信息
 | 
	
		
			
				|  |  | -    function showUploadAlert(success, msg){
 | 
	
		
			
				|  |  | -        if(!success){
 | 
	
		
			
				|  |  | +    function showUploadAlert(success, msg) {
 | 
	
		
			
				|  |  | +        if (!success) {
 | 
	
		
			
				|  |  |              $('#uploadAlert').removeClass('alert-success');
 | 
	
		
			
				|  |  |              $('#uploadAlert').addClass('alert-danger');
 | 
	
		
			
				|  |  | -        } else{
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              $('#uploadAlert').removeClass('alert-danger');
 | 
	
		
			
				|  |  |              $('#uploadAlert').addClass('alert-success');
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -122,7 +122,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |              $('#tbc-tenderName').val(curData.name || '');
 | 
	
		
			
				|  |  |              $('#tbc-engineering').val(curData.engineering || '');
 | 
	
		
			
				|  |  |              curData.temp.confirmed = true;   //增加确认信息(已读)
 | 
	
		
			
				|  |  | -            if (this.curIdx === this.datas.length -1) { //到最后一个数据了,无法点击下一工程
 | 
	
		
			
				|  |  | +            if (this.curIdx === this.datas.length - 1) { //到最后一个数据了,无法点击下一工程
 | 
	
		
			
				|  |  |                  $('#tbc-next').prop('disabled', true);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  $('#tbc-next').prop('disabled', false);
 | 
	
	
		
			
				|  | @@ -150,7 +150,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  $('#tbc-prev').prop('disabled', false);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if (this.curIdx !== this.datas.length -1 ) {    //不为最后一个数据了,可以点击下一工程
 | 
	
		
			
				|  |  | +            if (this.curIdx !== this.datas.length - 1) {    //不为最后一个数据了,可以点击下一工程
 | 
	
		
			
				|  |  |                  $('#tbc-next').prop('disabled', false);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  $('#tbc-next').prop('disabled', true);
 | 
	
	
		
			
				|  | @@ -190,8 +190,8 @@ const importView = (() => {
 | 
	
		
			
				|  |  |              //工程专业名称去重
 | 
	
		
			
				|  |  |              let engineeringNames = [...new Set(this.engineeringList.map(data => data.lib.name))];
 | 
	
		
			
				|  |  |              let engineeringHtml = engineeringNames.map(name =>
 | 
	
		
			
				|  |  | -             `<option ${tenderData.temp.engineering === name ? 'selected' : ''} value="${name}">${name}</option>`);
 | 
	
		
			
				|  |  | -             $('#tbc-engineering').html(engineeringHtml);
 | 
	
		
			
				|  |  | +                `<option ${tenderData.temp.engineering === name ? 'selected' : ''} value="${name}">${name}</option>`);
 | 
	
		
			
				|  |  | +            $('#tbc-engineering').html(engineeringHtml);
 | 
	
		
			
				|  |  |              //$('#tbc-engineering').html(`<option selected value="${tenderData.engineering}">${tenderData.engineering}</option>`);
 | 
	
		
			
				|  |  |              //费用标准,若当前工程有费用标准数据(该数据本身没有费用标准数据,选择过了,就会记录),则选中该费用标准
 | 
	
		
			
				|  |  |              let feeOptsHtml = engineerings.map(data =>
 | 
	
	
		
			
				|  | @@ -218,12 +218,12 @@ const importView = (() => {
 | 
	
		
			
				|  |  |      function getTaxData(query, engineeringList) {
 | 
	
		
			
				|  |  |          //工程专业名称 + 费用标准名称 确定一个工程专业数据
 | 
	
		
			
				|  |  |          let engineering = engineeringList.find(data => query.engineeringName === data.lib.name &&
 | 
	
		
			
				|  |  | -                                                       query.feeStandard === data.lib.feeName);
 | 
	
		
			
				|  |  | +            query.feeStandard === data.lib.feeName);
 | 
	
		
			
				|  |  |          if (!engineering || !Array.isArray(engineering.lib.tax_group)) {
 | 
	
		
			
				|  |  |              return null;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return engineering.lib.tax_group.find(data => query.taxType == data.taxType &&
 | 
	
		
			
				|  |  | -                                                          query.calcProgram === data.program_lib.name);
 | 
	
		
			
				|  |  | +            query.calcProgram === data.program_lib.name);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      //获取单位工程项目属性的一些数据(新建单位工程需要,前端能获取到的一些数据,还有一些数据需要后端获取: rootProjectID, projectFeature..)
 | 
	
		
			
				|  |  |      /*
 | 
	
	
		
			
				|  | @@ -247,7 +247,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //当前工程专业数据
 | 
	
		
			
				|  |  |          let curEngineering = tbcObj.engineeringList.find(data => query.engineeringName === data.lib.name &&
 | 
	
		
			
				|  |  | -        query.feeStandard === data.lib.feeName);
 | 
	
		
			
				|  |  | +            query.feeStandard === data.lib.feeName);
 | 
	
		
			
				|  |  |          return {
 | 
	
		
			
				|  |  |              region: '全省',   //地区
 | 
	
		
			
				|  |  |              valuationType: tbcObj.valuationType,    //计价方式
 | 
	
	
		
			
				|  | @@ -264,19 +264,19 @@ const importView = (() => {
 | 
	
		
			
				|  |  |              indexName: curEngineering.lib.indexName,    // 指标名称
 | 
	
		
			
				|  |  |              engineerInfoLibID: curEngineering.lib.engineer_info_lib[0] ? curEngineering.lib.engineer_info_lib[0].id : '',   // 工程信息指标
 | 
	
		
			
				|  |  |              engineerFeatureLibID: curEngineering.lib.engineer_feature_lib[0] ? curEngineering.lib.engineer_feature_lib[0].id : '',  //工程特征指标
 | 
	
		
			
				|  |  | -            economicLibID: curEngineering.lib.economic_lib[0] ?  curEngineering.lib.economic_lib[0].id : '',    // 主要经济指标
 | 
	
		
			
				|  |  | +            economicLibID: curEngineering.lib.economic_lib[0] ? curEngineering.lib.economic_lib[0].id : '',    // 主要经济指标
 | 
	
		
			
				|  |  |              mainQuantityLibID: curEngineering.lib.main_quantity_lib[0] ? curEngineering.lib.main_quantity_lib[0].id : '',   // 主要工程量指标
 | 
	
		
			
				|  |  |              materialLibID: curEngineering.lib.material_lib[0] ? curEngineering.lib.material_lib[0].id : '', // 主要工料指标
 | 
	
		
			
				|  |  | -            calcProgram: {name: taxData.program_lib.name, id: taxData.program_lib.id},  //计算程序
 | 
	
		
			
				|  |  | +            calcProgram: { name: taxData.program_lib.name, id: taxData.program_lib.id },  //计算程序
 | 
	
		
			
				|  |  |              colLibID: taxData.col_lib.id,   //列设置
 | 
	
		
			
				|  |  |              templateLibID: taxData.template_lib.id, //清单模板
 | 
	
		
			
				|  |  | -            unitPriceFile: {name: curData.name, id: ''},    //新建单价文件
 | 
	
		
			
				|  |  | -            feeFile: {name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}`}  //新建费率文件
 | 
	
		
			
				|  |  | +            unitPriceFile: { name: curData.name, id: '' },    //新建单价文件
 | 
	
		
			
				|  |  | +            feeFile: { name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}` }  //新建费率文件
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      function eventListen() {
 | 
	
		
			
				|  |  |          //选择文件
 | 
	
		
			
				|  |  | -        $('#customFile').change(async function() {
 | 
	
		
			
				|  |  | +        $('#customFile').change(async function () {
 | 
	
		
			
				|  |  |              let file = $(this)[0].files[0];
 | 
	
		
			
				|  |  |              $('#import-confirm').prop('disabled', true);    //确认导入无效
 | 
	
		
			
				|  |  |              $('.custom-file-label').text(`${file ? file.name : ''}`);   //设置选择框文本
 | 
	
	
		
			
				|  | @@ -285,7 +285,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |              hideTBCInfo();
 | 
	
		
			
				|  |  |              if (file) {
 | 
	
		
			
				|  |  |                  let reg = /(xml|XML|qtf|QTF)$/;
 | 
	
		
			
				|  |  | -                if(file.name && !reg.test(file.name)){
 | 
	
		
			
				|  |  | +                if (file.name && !reg.test(file.name)) {
 | 
	
		
			
				|  |  |                      $('.selFile').hide();
 | 
	
		
			
				|  |  |                      showUploadAlert(false, '请选择xml或qtf文件。');
 | 
	
		
			
				|  |  |                      return;
 | 
	
	
		
			
				|  | @@ -425,7 +425,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |                      data.property = getProperty(tbcObj, data);
 | 
	
		
			
				|  |  |                      //默认定额库
 | 
	
		
			
				|  |  |                      let curEngineering = tbcObj.engineeringList.find(enData => data.temp.engineering === enData.lib.name &&
 | 
	
		
			
				|  |  | -                    data.temp.feeStandard === enData.lib.feeName);
 | 
	
		
			
				|  |  | +                        data.temp.feeStandard === enData.lib.feeName);
 | 
	
		
			
				|  |  |                      let defaultLib = curEngineering.lib.ration_lib.find(data => data.isDefault) || curEngineering.lib.ration_lib[0];
 | 
	
		
			
				|  |  |                      data.defaultRationLib = parseInt(defaultLib.id);
 | 
	
		
			
				|  |  |                      //此费用定额下可用的定额库id,人材机库id
 | 
	
	
		
			
				|  | @@ -433,7 +433,7 @@ const importView = (() => {
 | 
	
		
			
				|  |  |                      data.gljLibIDs = curEngineering.lib.glj_lib.map(data => parseInt(data.id));
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |                  //确定生成建设项目的父、前、后节点ID
 | 
	
		
			
				|  |  | -                let {parentProjectID, preProjectID, nextProjectID} = projTreeObj.getRelProjectID(projTreeObj.tree.selected);
 | 
	
		
			
				|  |  | +                let { parentProjectID, preProjectID, nextProjectID } = projTreeObj.getRelProjectID(projTreeObj.tree.selected);
 | 
	
		
			
				|  |  |                  xmlObj.ParentID = parentProjectID;
 | 
	
		
			
				|  |  |                  xmlObj.preID = preProjectID;
 | 
	
		
			
				|  |  |                  xmlObj.NextSiblingID = nextProjectID;
 | 
	
	
		
			
				|  | @@ -443,44 +443,31 @@ const importView = (() => {
 | 
	
		
			
				|  |  |                      xmlObj.name += `(${moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')})`;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  $('#importInterface').modal('hide');
 | 
	
		
			
				|  |  | -                //TEST======================
 | 
	
		
			
				|  |  | -                /*let importData = await importXML.transformData(xmlObj);
 | 
	
		
			
				|  |  | -                console.log(importData);*/
 | 
	
		
			
				|  |  | -                //TEST======================
 | 
	
		
			
				|  |  |                  pr.start('导入文件', '正在生成文件,请稍候……');
 | 
	
		
			
				|  |  |                  let importData = await importXML.transformData(xmlObj);
 | 
	
		
			
				|  |  | -                let blob = new Blob([JSON.stringify(importData)], {type: 'text/plain;charset=utf-8'});
 | 
	
		
			
				|  |  | -                let formData = new FormData();
 | 
	
		
			
				|  |  | -                formData.append('file', blob);
 | 
	
		
			
				|  |  | -                $.ajax({
 | 
	
		
			
				|  |  | -                    url: '/pm/import/importInterface',
 | 
	
		
			
				|  |  | -                    type: 'POST',
 | 
	
		
			
				|  |  | -                    data: formData,
 | 
	
		
			
				|  |  | -                    cache: false,
 | 
	
		
			
				|  |  | -                    contentType: false,
 | 
	
		
			
				|  |  | -                    processData: false,
 | 
	
		
			
				|  |  | -                    timeout: 1000 * 60 * 3, //3分钟
 | 
	
		
			
				|  |  | -                    success: function(response){
 | 
	
		
			
				|  |  | -                        if (response.data && Array.isArray(response.data)) {
 | 
	
		
			
				|  |  | -                            doAfterImport(response.data);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        pr.end();
 | 
	
		
			
				|  |  | -                        setTimeout(function () {
 | 
	
		
			
				|  |  | -                            STATE.importing = false;
 | 
	
		
			
				|  |  | -                        }, 500);
 | 
	
		
			
				|  |  | -                    },
 | 
	
		
			
				|  |  | -                    error: function(jqXHR){
 | 
	
		
			
				|  |  | -                        pr.end();
 | 
	
		
			
				|  |  | -                        throw `与服务器通信发生错误${jqXHR.status} ${jqXHR.statusText}`;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +                let blob = new Blob([JSON.stringify(importData)], { type: 'text/plain;charset=utf-8' });
 | 
	
		
			
				|  |  | +                // 转换成File实例
 | 
	
		
			
				|  |  | +                const key = `${uuid.v1()}.json`;
 | 
	
		
			
				|  |  | +                const file = new File([blob], key);
 | 
	
		
			
				|  |  | +                // 上传文件
 | 
	
		
			
				|  |  | +                console.time();
 | 
	
		
			
				|  |  | +                await projTreeObj.getUploadToken();
 | 
	
		
			
				|  |  | +                await UPLOAD_CDN.uploadSync(file, key, projTreeObj.uptoken);
 | 
	
		
			
				|  |  | +                // 下载并处理文件
 | 
	
		
			
				|  |  | +                const rstData = await ajaxPost('/pm/import/importInterface', { key });
 | 
	
		
			
				|  |  | +                console.timeEnd();
 | 
	
		
			
				|  |  | +                if (Array.isArray(rstData)) {
 | 
	
		
			
				|  |  | +                    doAfterImport(rstData);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              } catch (err) {
 | 
	
		
			
				|  |  | +                console.log(err);
 | 
	
		
			
				|  |  | +                alert(err);
 | 
	
		
			
				|  |  | +            } finally {
 | 
	
		
			
				|  |  | +                projTreeObj.uptoken = null;
 | 
	
		
			
				|  |  |                  setTimeout(function () {
 | 
	
		
			
				|  |  |                      STATE.importing = false;
 | 
	
		
			
				|  |  |                  }, 500);
 | 
	
		
			
				|  |  |                  pr.end();
 | 
	
		
			
				|  |  | -                console.log(err);
 | 
	
		
			
				|  |  | -                alert(err);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          // 导入窗口激活
 | 
	
	
		
			
				|  | @@ -515,9 +502,9 @@ const importView = (() => {
 | 
	
		
			
				|  |  |                  next = projTreeObj.tree.items.find(node => node.data.ID === data.NextSiblingID);
 | 
	
		
			
				|  |  |              lastNode = projTreeObj.insert(data, parent, next);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(lastNode) {
 | 
	
		
			
				|  |  | +        if (lastNode) {
 | 
	
		
			
				|  |  |              projTreeObj.workBook.getSheet(0).showRow(lastNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    return {eventListen};
 | 
	
		
			
				|  |  | +    return { eventListen };
 | 
	
		
			
				|  |  |  })();
 |