| 
					
				 | 
			
			
				@@ -310,13 +310,16 @@ $(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const insertList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const insertGclList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const hadQtySelfList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (const one of insertGcl) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (one.leafXmjs && one.leafXmjs.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     for (const xmj of one.leafXmjs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         const is_self = _.findIndex(selfList, { gcl_id: xmj.gcl_id, xmj_id: xmj.id, mx_id: xmj.mx_id ? xmj.mx_id : null }) !== -1;// 区分单独计量的明细工料含量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (is_self) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             const billsList = _.filter(materialListForSelf, { gcl_id: xmj.gcl_id, xmj_id: xmj.id, mx_id: xmj.mx_id ? xmj.mx_id : null }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            console.log(billsList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             for (const bill of billsList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                hadQtySelfList.push(bill); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 insertSelfList.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     gcl_id: xmj.gcl_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     mx_id: xmj.mx_id ? xmj.mx_id : null, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -326,7 +329,7 @@ $(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     expr: bill.expr, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     mb_id: bill.mb_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     order: bill.order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             const newgcl = _.find(gclList, { gcl_id: xmj.gcl_id }); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -357,12 +360,29 @@ $(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 通过比较materialListForSelf和hadQtySelfList不重合部分,得出本期为null的gather_qty列表,插入到insertSelfList中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const pushSelfList = _.xorWith(materialListForSelf, hadQtySelfList, _.isEqual); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (pushSelfList.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (const ps of pushSelfList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    insertSelfList.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        gcl_id: ps.gcl_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        mx_id: ps.mx_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        xmj_id: ps.xmj_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        gather_qty: null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        quantity: ps.quantity, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        expr: ps.expr, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        mb_id: ps.mb_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        order: ps.order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 可能需要新增list_gcl表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             newMaterialData.material_list = insertList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             newMaterialData.material_self_list = insertSelfList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             newMaterialData.insertGclList = insertGclList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             newMaterialData.removeGclList = removeGclList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             console.log(newMaterialData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log(insertSelfList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             postData(preUrl + '/measure/material/add', newMaterialData, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 window.location.href = preUrl + '/measure/material/' + result.order; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }, function () { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -374,7 +394,7 @@ $(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // _self.parents('div[id="add-qi"]').modal('show'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _self.attr('disabled', false).text('确认添加'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // $(this).parents('form').submit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 |