|  | @@ -252,7 +252,6 @@ const BillsElf = (function() {
 | 
	
		
			
				|  |  |      //清单焦点变换-清单精灵操作,获取清单前九位编码的标准清单清单精灵选项
 | 
	
		
			
				|  |  |      //@param {String}code @return {void}
 | 
	
		
			
				|  |  |      function billsSelElf(code) {
 | 
	
		
			
				|  |  | -        console.log('enterS');
 | 
	
		
			
				|  |  |          let elfSheet = elfItem.workBook.getActiveSheet();
 | 
	
		
			
				|  |  |          cleanData(elfSheet, elfItem.headers, -1);
 | 
	
		
			
				|  |  |          if (!code || code === '') {
 | 
	
	
		
			
				|  | @@ -634,7 +633,7 @@ const BillsElf = (function() {
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          return new OptionsCellType();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    //获取清单精灵生成的定额数据
 | 
	
		
			
				|  |  | +    //获取清单精灵生成的定额数据(跳过重复,不允许重复插入)
 | 
	
		
			
				|  |  |      //@return {Array}
 | 
	
		
			
				|  |  |      function getInsertElfRationData(){
 | 
	
		
			
				|  |  |          let rst = [];
 | 
	
	
		
			
				|  | @@ -645,17 +644,29 @@ const BillsElf = (function() {
 | 
	
		
			
				|  |  |          if(!tree){
 | 
	
		
			
				|  |  |              return rst;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        let mainSelected = projectObj.project.mainTree.selected;
 | 
	
		
			
				|  |  | +        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
 | 
	
		
			
				|  |  | +            return c.data && c.data.type === rationType.ration;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        //原本清单存在此定额
 | 
	
		
			
				|  |  | +        function existTheRation(rationID) {
 | 
	
		
			
				|  |  | +            let r = _.find(mainSelRationNodes, function (node) {
 | 
	
		
			
				|  |  | +                return node.data && node.data.stdID && node.data.stdID == rationID;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            return r;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //造价书当前选中清单下的定额
 | 
	
		
			
				|  |  |          for(let node of tree.items){
 | 
	
		
			
				|  |  |              for(let perChecked of node.data.optionChecked){
 | 
	
		
			
				|  |  |                  //选项直接是定额
 | 
	
		
			
				|  |  | -                if(perChecked.type === itemType.ration){
 | 
	
		
			
				|  |  | +                if(perChecked.type === itemType.ration && !existTheRation(perChecked.rationID)){
 | 
	
		
			
				|  |  |                      rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  //选项下子选项是定额
 | 
	
		
			
				|  |  |                  else {
 | 
	
		
			
				|  |  |                      let rationOpts = getOptions(perChecked, bills.selected.elf.datas);
 | 
	
		
			
				|  |  |                      for(let ration of rationOpts){
 | 
	
		
			
				|  |  | -                        if(ration.type === itemType.ration){
 | 
	
		
			
				|  |  | +                        if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
 | 
	
		
			
				|  |  |                              rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -679,14 +690,25 @@ const BillsElf = (function() {
 | 
	
		
			
				|  |  |          if (!elfSelected || !elfSelected.data.optionChecked || !elfSelected.data.optionChecked[0]) {
 | 
	
		
			
				|  |  |              return rst;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        let mainSelected = projectObj.project.mainTree.selected;
 | 
	
		
			
				|  |  | +        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
 | 
	
		
			
				|  |  | +            return c.data && c.data.type === rationType.ration;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        //原本清单存在此定额
 | 
	
		
			
				|  |  | +        function existTheRation(rationID) {
 | 
	
		
			
				|  |  | +            let r = _.find(mainSelRationNodes, function (node) {
 | 
	
		
			
				|  |  | +                return node.data && node.data.stdID && node.data.stdID == rationID;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            return r;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          //选中的节点第一个选项时定额选项或第一个选项下的子选项时定额选项
 | 
	
		
			
				|  |  |          let firstOptionChecked = elfSelected.data.optionChecked[0];
 | 
	
		
			
				|  |  | -        if (firstOptionChecked.type === itemType.ration) {
 | 
	
		
			
				|  |  | +        if (firstOptionChecked.type === itemType.ration && !existTheRation(firstOptionChecked.rationID)) {
 | 
	
		
			
				|  |  |              rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              let rationOpts = getOptions(firstOptionChecked, bills.selected.elf.datas);
 | 
	
		
			
				|  |  |              for(let ration of rationOpts){
 | 
	
		
			
				|  |  | -                if(ration.type === itemType.ration){
 | 
	
		
			
				|  |  | +                if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
 | 
	
		
			
				|  |  |                      rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  }
 |