|  | @@ -406,8 +406,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      visible: function (key, opt) {
 | 
	
		
			
				|  |  |                          const sheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  |                          const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | +                        const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  |                          const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  | -                        if (!select) {
 | 
	
		
			
				|  |  | +                        if (!select || sel.rowCount !== 1) {
 | 
	
		
			
				|  |  |                              return false;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          if (!readOnly && select && notx === undefined) {
 | 
	
	
		
			
				|  | @@ -426,8 +427,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      visible: function (key, opt) {
 | 
	
		
			
				|  |  |                          const sheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  |                          const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | +                        const sel = sheet.getSelections()[0];
 | 
	
		
			
				|  |  |                          const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  | -                        if (!select) {
 | 
	
		
			
				|  |  | +                        if (!select || sel.rowCount !== 1) {
 | 
	
		
			
				|  |  |                              return false;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          if (!readOnly && select && notx === undefined) {
 | 
	
	
		
			
				|  | @@ -593,40 +595,20 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
 | 
	
		
			
				|  |  |          // 应用调差工料至其他清单明细
 | 
	
		
			
				|  |  |          $('#user_all_material').click(function () {
 | 
	
		
			
				|  |  | -            const sheet = materialSpread.getActiveSheet();
 | 
	
		
			
				|  |  | -            const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | -            if (select === undefined) {
 | 
	
		
			
				|  |  | -                toastr.warning('请选中需要应用到其他清单明细的调差工料');
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            const leafXmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | -            const leafXmjSelect = SpreadJsObj.getSelectObject(leafXmjSheet);
 | 
	
		
			
				|  |  | -            const notl = findNotJoinLeafXmj(leafXmjSelect);
 | 
	
		
			
				|  |  | -            if (notl !== undefined) {
 | 
	
		
			
				|  |  | -                toastr.error('该清单不参与调差,调差工料无法应用到其它清单中');
 | 
	
		
			
				|  |  | -                return false;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              const ledgerSheet = ledgerSpread.getActiveSheet();
 | 
	
		
			
				|  |  |              const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
 | 
	
		
			
				|  |  |              if (ledgerSelect.leafXmjs.length < 2) {
 | 
	
		
			
				|  |  |                  toastr.warning('没有需要应用调差工料的其它清单明细');
 | 
	
		
			
				|  |  |                  return false;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +            const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  |              // 判断需要应用调差工料的清单明细
 | 
	
		
			
				|  |  |              const needAddList = [];
 | 
	
		
			
				|  |  | -            // const gather_qty = [];
 | 
	
		
			
				|  |  |              for (const xmj of ledgerSelect.leafXmjs) {
 | 
	
		
			
				|  |  | -                if (xmj.mx_id !== undefined) {
 | 
	
		
			
				|  |  | -                    const notx = findNotJoinLeafXmj(xmj);
 | 
	
		
			
				|  |  | -                    if (notx === undefined) {
 | 
	
		
			
				|  |  | -                        const ml = materialListData.find(function (item) {
 | 
	
		
			
				|  |  | -                            return xmj.mx_id === item.mx_id && select.mb_id === item.mb_id;
 | 
	
		
			
				|  |  | -                        });
 | 
	
		
			
				|  |  | -                        if (ml === undefined) {
 | 
	
		
			
				|  |  | -                            needAddList.push(xmj);
 | 
	
		
			
				|  |  | -                            // gather_qty.push(xmj.gather_qty);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | +                const notx = findNotJoinLeafXmj(xmj);
 | 
	
		
			
				|  |  | +                if (notx === undefined && xmjSelect !== xmj) {
 | 
	
		
			
				|  |  | +                    needAddList.push(xmj);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (needAddList.length === 0) {
 | 
	
	
		
			
				|  | @@ -634,10 +616,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  return false;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 更新至服务器
 | 
	
		
			
				|  |  | -            postData(window.location.pathname + '/save', { type:'useOther', postData: { addXmj: needAddList, select: select } }, function (result) {
 | 
	
		
			
				|  |  | +            postData(window.location.pathname + '/save', { type:'useOther', postData: { addXmj: needAddList, materialBills: materialList } }, function (result) {
 | 
	
		
			
				|  |  |                  materialListData = result;
 | 
	
		
			
				|  |  | -                toastr.success('成功添加了' + needAddList.length + '条调差工料到其他清单明细中');
 | 
	
		
			
				|  |  | -                calculateJiaCha(gclGatherData)
 | 
	
		
			
				|  |  | +                toastr.success('已成功应用');
 | 
	
		
			
				|  |  | +                calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  |                  const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  |                  loadLeafXmjData(index);
 | 
	
		
			
				|  |  |                  const xmjSheet = leafXmjSpread.getActiveSheet();
 |