|  | @@ -51,7 +51,7 @@ function calcOneBQJC(xmj) {
 | 
	
		
			
				|  |  |  function getPasteHint (str, row = '') {
 | 
	
		
			
				|  |  |      let returnObj = str;
 | 
	
		
			
				|  |  |      if (row) {
 | 
	
		
			
				|  |  | -        returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
 | 
	
		
			
				|  |  | +        returnObj.msg = '清单第' + (row+1) + '行' + (str.msg ? str.msg : str);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return returnObj;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -156,6 +156,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          return item.qc_qty || item.contract_qty
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // let gclGatherData = gclGatherModel.gatherGclData()
 | 
	
		
			
				|  |  |      // 获取项目节数据
 | 
	
		
			
				|  |  |      function loadLeafXmjData(iGclRow) {
 | 
	
	
		
			
				|  | @@ -167,7 +168,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gcl.leafXmjs);
 | 
	
		
			
				|  |  |              // 对清单调差工料table的单位数量进行改变
 | 
	
		
			
				|  |  | -            materialSpreadSetting.cols[materialSpreadSetting.cols.length - 1].title = '|' + gcl.unit + '数量 �';
 | 
	
		
			
				|  |  | +            materialSpreadSetting.cols[materialSpreadSetting.cols.length - 2].title = '|' + gcl.unit + '数量 �';
 | 
	
		
			
				|  |  |              // SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              SpreadJsObj.loadSheetData(leafXmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, []);
 | 
	
	
		
			
				|  | @@ -225,10 +226,11 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |      const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
 | 
	
		
			
				|  |  |      const materialSpreadSetting = {
 | 
	
		
			
				|  |  |          cols: [
 | 
	
		
			
				|  |  | -            {title: '清单调差工料|编号', colSpan: '4|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  | +            {title: '清单工料含量|编号', colSpan: '5|1', rowSpan: '1|1', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  |              {title: '|名称', colSpan: '|1', rowSpan: '|1', field: 'name', hAlign: 0, width: 100, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  |              {title: '|单位', colSpan: '|1', rowSpan: '|1', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
 | 
	
		
			
				|  |  | -            {title: '|数量 �', colSpan: '1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number', readOnly: 'readOnly.isEdit'},
 | 
	
		
			
				|  |  | +            {title: '|数量 �', colSpan: '|1', rowSpan: '|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number', readOnly: 'readOnly.isEdit'},
 | 
	
		
			
				|  |  | +            {title: '|计算式', colSpan: '1', rowSpan: '|1', field: 'expr', hAlign: 2, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 | 
	
		
			
				|  |  |          ],
 | 
	
		
			
				|  |  |          emptyRows: 0,
 | 
	
		
			
				|  |  |          headRows: 2,
 | 
	
	
		
			
				|  | @@ -248,10 +250,11 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |      const materialCol = {
 | 
	
		
			
				|  |  |          readOnly: {
 | 
	
		
			
				|  |  |              isEdit: function (data) {
 | 
	
		
			
				|  |  | -                const sheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | -                const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | -                const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  | -                return !(!readOnly && notx === undefined && materialBase.isEdit(data));
 | 
	
		
			
				|  |  | +                // const sheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                // const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | +                // const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  | +                // return !(!readOnly && notx === undefined && materialBase.isEdit(data));
 | 
	
		
			
				|  |  | +                return !(!readOnly && materialBase.isEdit(data));
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |      };
 | 
	
	
		
			
				|  | @@ -335,22 +338,50 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          const leafXmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  |          const leafXmjSelect = SpreadJsObj.getSelectObject(leafXmjSheet);
 | 
	
		
			
				|  |  |          const gcl = gclGatherData[index].leafXmjs;
 | 
	
		
			
				|  |  | -        const leafXmjIndex = gcl.indexOf(leafXmjSelect);
 | 
	
		
			
				|  |  | -        const xmj = gcl[leafXmjIndex];
 | 
	
		
			
				|  |  | -        const data = {
 | 
	
		
			
				|  |  | -            xmj_id: xmj.id,
 | 
	
		
			
				|  |  | -            gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | -            mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | -            mb_id: mb_id,
 | 
	
		
			
				|  |  | -            gather_qty: xmj.gather_qty,
 | 
	
		
			
				|  |  | -        };
 | 
	
		
			
				|  |  | +        // const leafXmjIndex = gcl.indexOf(leafXmjSelect);
 | 
	
		
			
				|  |  | +        // const xmj = gcl[leafXmjIndex];
 | 
	
		
			
				|  |  | +        // const data = {
 | 
	
		
			
				|  |  | +        //     xmj_id: xmj.id,
 | 
	
		
			
				|  |  | +        //     gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | +        //     mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | +        //     mb_id: mb_id,
 | 
	
		
			
				|  |  | +        //     gather_qty: xmj.gather_qty,
 | 
	
		
			
				|  |  | +        // };
 | 
	
		
			
				|  |  | +        const datas = [];
 | 
	
		
			
				|  |  | +        for (const xmj of gcl) {
 | 
	
		
			
				|  |  | +            const notx = findNotJoinLeafXmj(xmj);
 | 
	
		
			
				|  |  | +            const data = {
 | 
	
		
			
				|  |  | +                xmj_id: xmj.id,
 | 
	
		
			
				|  |  | +                gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | +                mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | +                gather_qty: xmj.gather_qty,
 | 
	
		
			
				|  |  | +                is_join: notx === undefined ? 1 : 0,
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            datas.push(data);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 上传到数据库
 | 
	
		
			
				|  |  | -        postData(window.location.pathname + '/save', {type: 'add', postData: data}, function (result) {
 | 
	
		
			
				|  |  | -            // 添加到materialList里
 | 
	
		
			
				|  |  | +        console.log(datas, gcl);
 | 
	
		
			
				|  |  | +        postData(window.location.pathname + '/save', {type: 'adds', postData: {xmjs: datas, mbIds: mb_id}}, function (result) {
 | 
	
		
			
				|  |  |              materialListData = result;
 | 
	
		
			
				|  |  | -            loadMaterialData(index, leafXmjIndex);
 | 
	
		
			
				|  |  | +            // toastr.success('已成功应用');
 | 
	
		
			
				|  |  | +            calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +            // const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +            loadLeafXmjData(index);
 | 
	
		
			
				|  |  | +            const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +            const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | +            const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | +            loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | +            SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  |              $('#addgl').modal('hide');
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | +        // postData(window.location.pathname + '/save', {type: 'add', postData: data}, function (result) {
 | 
	
		
			
				|  |  | +            // // 添加到materialList里
 | 
	
		
			
				|  |  | +            // materialListData = result;
 | 
	
		
			
				|  |  | +            // loadMaterialData(index, leafXmjIndex);
 | 
	
		
			
				|  |  | +            // $('#addgl').modal('hide');
 | 
	
		
			
				|  |  | +        // });
 | 
	
		
			
				|  |  |          $('#materialBills').find('input:disabled').prop('checked', true);
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |      if (!readOnly) {
 | 
	
	
		
			
				|  | @@ -444,68 +475,146 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          // material-spread右键功能
 | 
	
		
			
				|  |  |          const materialSpreadObj = {
 | 
	
		
			
				|  |  |              del: function () {
 | 
	
		
			
				|  |  | -                const sheet = materialSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                const materialSheet = materialSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                const materialSelect = SpreadJsObj.getSelectObject(materialSheet);
 | 
	
		
			
				|  |  | +                const sheet = ledgerSpread.getActiveSheet();
 | 
	
		
			
				|  |  |                  const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | -                postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
 | 
	
		
			
				|  |  | -                    const index = materialList.indexOf(select);
 | 
	
		
			
				|  |  | -                    materialList.splice(index, 1);
 | 
	
		
			
				|  |  | -                    sheet.deleteRows(index, 1);
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  | -                    const sel = sheet.getSelections();
 | 
	
		
			
				|  |  | -                    sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
 | 
	
		
			
				|  |  | -                    const materialListIndex = materialListData.indexOf(select);
 | 
	
		
			
				|  |  | -                    materialListData.splice(materialListIndex, 1);
 | 
	
		
			
				|  |  | -                    const [iGclRow, iRow, lsheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | -                    gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | -                    calculateJiaCha(gclGatherData, iGclRow)
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadRowData(lsheet, iRow);
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                const index = gclGatherData.indexOf(select);
 | 
	
		
			
				|  |  | +                const gcl = gclGatherData[index].leafXmjs;
 | 
	
		
			
				|  |  | +                const datas = [];
 | 
	
		
			
				|  |  | +                for (const xmj of gcl) {
 | 
	
		
			
				|  |  | +                    const data = {
 | 
	
		
			
				|  |  | +                        xmj_id: xmj.id,
 | 
	
		
			
				|  |  | +                        gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | +                        mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                    datas.push(data);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                console.log(datas, materialSelect.mb_id);
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/save', {type: 'dels', postData: { xmjs: datas, mb_id: materialSelect.mb_id }}, function (result) {
 | 
	
		
			
				|  |  | +                    materialListData = result;
 | 
	
		
			
				|  |  | +                    calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +                    // const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +                    loadLeafXmjData(index);
 | 
	
		
			
				|  |  | +                    const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                    const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | +                    const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | +                    loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | +                // postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
 | 
	
		
			
				|  |  | +                    // const index = materialList.indexOf(select);
 | 
	
		
			
				|  |  | +                    // materialList.splice(index, 1);
 | 
	
		
			
				|  |  | +                    // sheet.deleteRows(index, 1);
 | 
	
		
			
				|  |  | +                    // SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +                    // const sel = sheet.getSelections();
 | 
	
		
			
				|  |  | +                    // sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
 | 
	
		
			
				|  |  | +                    // const materialListIndex = materialListData.indexOf(select);
 | 
	
		
			
				|  |  | +                    // materialListData.splice(materialListIndex, 1);
 | 
	
		
			
				|  |  | +                    // const [iGclRow, iRow, lsheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | +                    // gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | +                    // calculateJiaCha(gclGatherData, iGclRow);
 | 
	
		
			
				|  |  | +                    // SpreadJsObj.reLoadRowData(lsheet, iRow);
 | 
	
		
			
				|  |  | +                    // SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                // });
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              deletePress: function (sheet) {
 | 
	
		
			
				|  |  |                  return;
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | +            editStarting: function (e, info) {
 | 
	
		
			
				|  |  | +                const col = info.sheet.zh_setting.cols[info.col];
 | 
	
		
			
				|  |  | +                const select = SpreadJsObj.getSelectObject(info.sheet);
 | 
	
		
			
				|  |  | +                if (col.field === 'quantity') {
 | 
	
		
			
				|  |  | +                    if (select.expr && select.expr !== '') {
 | 
	
		
			
				|  |  | +                        info.sheet.getCell(info.row, info.col).text(select.expr);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  |              editEnded: function (e, info) {
 | 
	
		
			
				|  |  |                  if (info.sheet.zh_setting) {
 | 
	
		
			
				|  |  |                      const select = SpreadJsObj.getSelectObject(info.sheet);
 | 
	
		
			
				|  |  |                      const col = info.sheet.zh_setting.cols[info.col];
 | 
	
		
			
				|  |  |                      // 未改变值则不提交
 | 
	
		
			
				|  |  |                      // const validText = info.editingText ? (typeof(info.editingText) === 'String' ? info.editingText.replace('\n', '') : info.editingText) : null;
 | 
	
		
			
				|  |  | -                    const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
 | 
	
		
			
				|  |  | -                    const orgValue = select[col.field];
 | 
	
		
			
				|  |  | +                    // const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
 | 
	
		
			
				|  |  | +                    // let orgValue = select[col.field];
 | 
	
		
			
				|  |  | +                    const validText = info.editingText ? info.editingText.replace('\n', '') : null;
 | 
	
		
			
				|  |  | +                    let orgValue;
 | 
	
		
			
				|  |  | +                    if (col.field === 'quantity') {
 | 
	
		
			
				|  |  | +                        orgValue = validText && validText !== ''
 | 
	
		
			
				|  |  | +                            ? _.toNumber(validText) ? select.quantity : select.expr
 | 
	
		
			
				|  |  | +                            : (select.expr && select.expr !== '') ? select.expr : select.quantity;
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        orgValue = select[col.field];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 | 
	
		
			
				|  |  |                          SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  |                          return;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    if (col.field === 'quantity') {
 | 
	
		
			
				|  |  | -                        if (isNaN(validText)) {
 | 
	
		
			
				|  |  | -                            toastr.error('不能输入其它非数字类型字符');
 | 
	
		
			
				|  |  | -                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | -                            return;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        const num = parseFloat(validText);
 | 
	
		
			
				|  |  | -                        if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
 | 
	
		
			
				|  |  | -                            toastr.error('请输入大于0并且小于6位小数的浮点数');
 | 
	
		
			
				|  |  | -                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | -                            return;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | +                    const exprQuantity = {
 | 
	
		
			
				|  |  | +                        expr: '',
 | 
	
		
			
				|  |  | +                        quantity: 0,
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                    const [valid, msg] = materialSpreadObj._checkExpr(validText, exprQuantity);
 | 
	
		
			
				|  |  | +                    if (!valid) {
 | 
	
		
			
				|  |  | +                        toastr.error(msg);
 | 
	
		
			
				|  |  | +                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    // 更新至服务器
 | 
	
		
			
				|  |  | -                    postData(window.location.pathname + '/save', { type:'update', updateData: { id:select.id, quantity: validText, mb_id: select.mb_id } }, function (result) {
 | 
	
		
			
				|  |  | -                        const materialListIndex = materialListData.indexOf(select);
 | 
	
		
			
				|  |  | -                        const index = materialList.indexOf(select);
 | 
	
		
			
				|  |  | -                        select[col.field] = validText;
 | 
	
		
			
				|  |  | -                        materialListData.splice(materialListIndex, 1, select);
 | 
	
		
			
				|  |  | -                        materialList.indexOf(index, 1, select);
 | 
	
		
			
				|  |  | +                    if (isNaN(exprQuantity.quantity)) {
 | 
	
		
			
				|  |  | +                        toastr.error('不能输入其它非数字类型字符');
 | 
	
		
			
				|  |  | +                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    const num = parseFloat(exprQuantity.quantity);
 | 
	
		
			
				|  |  | +                    if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
 | 
	
		
			
				|  |  | +                        toastr.error('数量值必须大于0并且小于6位小数的浮点数');
 | 
	
		
			
				|  |  |                          SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | -                        const [iGclRow, iRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | -                        gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | -                        calculateJiaCha(gclGatherData, iGclRow)
 | 
	
		
			
				|  |  | -                        SpreadJsObj.reLoadRowData(sheet, iRow);
 | 
	
		
			
				|  |  | -                        SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                        return;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    // 更新至服务器
 | 
	
		
			
				|  |  | +                    const ledgerSheet = ledgerSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                    const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
 | 
	
		
			
				|  |  | +                    const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +                    const gcl = gclGatherData[index].leafXmjs;
 | 
	
		
			
				|  |  | +                    const datas = [];
 | 
	
		
			
				|  |  | +                    for (const xmj of gcl) {
 | 
	
		
			
				|  |  | +                        const data = {
 | 
	
		
			
				|  |  | +                            xmj_id: xmj.id,
 | 
	
		
			
				|  |  | +                            gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | +                            mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                        datas.push(data);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    console.log(exprQuantity, datas, select.mb_id);
 | 
	
		
			
				|  |  | +                    postData(window.location.pathname + '/save', { type:'updates', updateData: { xmjs: datas, expr: exprQuantity.expr, quantity: exprQuantity.quantity, mb_id: select.mb_id } }, function (result) {
 | 
	
		
			
				|  |  | +                        materialListData = result;
 | 
	
		
			
				|  |  | +                        calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +                        // const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +                        loadLeafXmjData(index);
 | 
	
		
			
				|  |  | +                        const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                        const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | +                        const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | +                        loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | +                        SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  |                      }, function () {
 | 
	
		
			
				|  |  |                          SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  |                      });
 | 
	
		
			
				|  |  | +                    // postData(window.location.pathname + '/save', { type:'update', updateData: { id:select.id, quantity: validText, mb_id: select.mb_id } }, function (result) {
 | 
	
		
			
				|  |  | +                    //     const materialListIndex = materialListData.indexOf(select);
 | 
	
		
			
				|  |  | +                    //     const index = materialList.indexOf(select);
 | 
	
		
			
				|  |  | +                    //     select[col.field] = validText;
 | 
	
		
			
				|  |  | +                    //     materialListData.splice(materialListIndex, 1, select);
 | 
	
		
			
				|  |  | +                    //     materialList.indexOf(index, 1, select);
 | 
	
		
			
				|  |  | +                    //     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                    //     const [iGclRow, iRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | +                    //     gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | +                    //     calculateJiaCha(gclGatherData, iGclRow)
 | 
	
		
			
				|  |  | +                    //     SpreadJsObj.reLoadRowData(sheet, iRow);
 | 
	
		
			
				|  |  | +                    //     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                    // }, function () {
 | 
	
		
			
				|  |  | +                    //     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  | +                    // });
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              clipboardPasted(e, info) {
 | 
	
	
		
			
				|  | @@ -522,7 +631,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                if (sortData.length > 0 && range.col + range.colCount > 4) {
 | 
	
		
			
				|  |  | +                if (sortData.length > 0 && range.col + range.colCount > 5) {
 | 
	
		
			
				|  |  |                      toastMessageUniq(hint.cellError);
 | 
	
		
			
				|  |  |                      SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
 | 
	
		
			
				|  |  |                      SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 | 
	
	
		
			
				|  | @@ -540,8 +649,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          const colSetting = info.sheet.zh_setting.cols[curCol];
 | 
	
		
			
				|  |  |                          if (!colSetting) continue;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                        let validText = info.sheet.getText(curRow, curCol);
 | 
	
		
			
				|  |  | -                        validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
 | 
	
		
			
				|  |  | +                        // let validText = info.sheet.getText(curRow, curCol);
 | 
	
		
			
				|  |  | +                        // validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
 | 
	
		
			
				|  |  | +                        const validText = info.sheet.getText(curRow, curCol).replace('\n', '');
 | 
	
		
			
				|  |  |                          const orgValue = sortData[curRow][colSetting.field];
 | 
	
		
			
				|  |  |                          if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 | 
	
		
			
				|  |  |                              sameCol++;
 | 
	
	
		
			
				|  | @@ -550,20 +660,30 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                              continue;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                        if (colSetting.field === 'quantity') {
 | 
	
		
			
				|  |  | -                            if (isNaN(validText)) {
 | 
	
		
			
				|  |  | -                                toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 | 
	
		
			
				|  |  | -                                bPaste = false;
 | 
	
		
			
				|  |  | -                                continue;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            const num = parseFloat(validText);
 | 
	
		
			
				|  |  | -                            if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
 | 
	
		
			
				|  |  | -                                toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
 | 
	
		
			
				|  |  | -                                bPaste = false;
 | 
	
		
			
				|  |  | -                                continue;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | +                        const exprQuantity = {
 | 
	
		
			
				|  |  | +                            expr: '',
 | 
	
		
			
				|  |  | +                            quantity: 0,
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                        const [valid, msg] = materialSpreadObj._checkExpr(validText, exprQuantity);
 | 
	
		
			
				|  |  | +                        if (!valid) {
 | 
	
		
			
				|  |  | +                            toastMessageUniq(getPasteHint(msg, hintRow));
 | 
	
		
			
				|  |  | +                            bPaste = false;
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (isNaN(exprQuantity.quantity)) {
 | 
	
		
			
				|  |  | +                            toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 | 
	
		
			
				|  |  | +                            bPaste = false;
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        const num = parseFloat(exprQuantity.quantity);
 | 
	
		
			
				|  |  | +                        if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
 | 
	
		
			
				|  |  | +                            toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
 | 
	
		
			
				|  |  | +                            bPaste = false;
 | 
	
		
			
				|  |  | +                            continue;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                        materialData[colSetting.field] = validText;
 | 
	
		
			
				|  |  | +                        // materialData[colSetting.field] = validText;
 | 
	
		
			
				|  |  | +                        materialData.expr = exprQuantity.expr;
 | 
	
		
			
				|  |  | +                        materialData.quantity = exprQuantity.quantity;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      if (bPaste) {
 | 
	
		
			
				|  |  |                          data.push(materialData);
 | 
	
	
		
			
				|  | @@ -576,19 +696,170 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  |                      return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                const ledgerSheet = ledgerSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
 | 
	
		
			
				|  |  | +                const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +                const gcl = gclGatherData[index].leafXmjs;
 | 
	
		
			
				|  |  | +                const datas = [];
 | 
	
		
			
				|  |  | +                for (const xmj of gcl) {
 | 
	
		
			
				|  |  | +                    const data2 = {
 | 
	
		
			
				|  |  | +                        xmj_id: xmj.id,
 | 
	
		
			
				|  |  | +                        gcl_id: xmj.gcl_id,
 | 
	
		
			
				|  |  | +                        mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                    datas.push(data2);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                console.log(data, datas);
 | 
	
		
			
				|  |  |                  // 更新至服务器
 | 
	
		
			
				|  |  | -                postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 | 
	
		
			
				|  |  | +                postData(window.location.pathname + '/save', { type:'pastes', updateData: { xmjs: datas, pasteData: data } }, function (result) {
 | 
	
		
			
				|  |  |                      materialListData = result;
 | 
	
		
			
				|  |  | -                    const [iGclRow, iRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | -                    gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | -                    calculateJiaCha(gclGatherData, iGclRow)
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadRowData(sheet, iRow);
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                    calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +                    // const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +                    loadLeafXmjData(index);
 | 
	
		
			
				|  |  | +                    const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                    const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | +                    const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | +                    loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  |                  }, function () {
 | 
	
		
			
				|  |  | -                    SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | +                // postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 | 
	
		
			
				|  |  | +                //     materialListData = result;
 | 
	
		
			
				|  |  | +                //     const [iGclRow, iRow, sheet, lselect] = leafXmjSpreadObj.getSelect();
 | 
	
		
			
				|  |  | +                //     gclGatherData[iGclRow].leafXmjs[iRow].jiacha = calcOneBQJC(lselect);
 | 
	
		
			
				|  |  | +                //     calculateJiaCha(gclGatherData, iGclRow);
 | 
	
		
			
				|  |  | +                //     SpreadJsObj.reLoadRowData(sheet, iRow);
 | 
	
		
			
				|  |  | +                //     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
 | 
	
		
			
				|  |  | +                // }, function () {
 | 
	
		
			
				|  |  | +                //     SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 | 
	
		
			
				|  |  | +                // });
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            _checkExprValid(expr) {
 | 
	
		
			
				|  |  | +                if (!expr) return [true, null];
 | 
	
		
			
				|  |  | +                const param = [];
 | 
	
		
			
				|  |  | +                let num = '', base = '';
 | 
	
		
			
				|  |  | +                for (let i = 0, iLen = expr.length; i < iLen; i++) {
 | 
	
		
			
				|  |  | +                    if (/^[\d\.%]+/.test(expr[i])) {
 | 
	
		
			
				|  |  | +                        if (base !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'base', value: base});
 | 
	
		
			
				|  |  | +                            base = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        num = num + expr[i];
 | 
	
		
			
				|  |  | +                    } else if (expr[i] === '(') {
 | 
	
		
			
				|  |  | +                        if (num !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'num', value: num});
 | 
	
		
			
				|  |  | +                            num = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (base !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'base', value: base});
 | 
	
		
			
				|  |  | +                            base = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        param.push({type: 'left', value: '('});
 | 
	
		
			
				|  |  | +                    } else if (expr[i] === ')') {
 | 
	
		
			
				|  |  | +                        if (num !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'num', value: num});
 | 
	
		
			
				|  |  | +                            num = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (base !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'base', value: base});
 | 
	
		
			
				|  |  | +                            base = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        param.push({type: 'right', value: ')'});
 | 
	
		
			
				|  |  | +                    } else if (/^[\+\-*\/]/.test(expr[i])) {
 | 
	
		
			
				|  |  | +                        if (num !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'num', value: num});
 | 
	
		
			
				|  |  | +                            num = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        if (base !== '') {
 | 
	
		
			
				|  |  | +                            param.push({type: 'base', value: base});
 | 
	
		
			
				|  |  | +                            base = '';
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        param.push({type: 'calc', value: expr[i]});
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        return [false, '输入的表达式含有非法字符: ' + expr[i]];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (num !== '') {
 | 
	
		
			
				|  |  | +                    param.push({type: 'num', value: num});
 | 
	
		
			
				|  |  | +                    num = '';
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (base !== '') {
 | 
	
		
			
				|  |  | +                    param.push({type: 'base', value: base});
 | 
	
		
			
				|  |  | +                    base = '';
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (param.length === 0) return true;
 | 
	
		
			
				|  |  | +                if (param.length > 1) {
 | 
	
		
			
				|  |  | +                    if (param[0].value === '-') {
 | 
	
		
			
				|  |  | +                        param[1].value = '-' + param[1];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    param.unshift();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                const iLen = param.length;
 | 
	
		
			
				|  |  | +                let iLeftCount = 0, iRightCount = 0;
 | 
	
		
			
				|  |  | +                for (const [i, p] of param.entries()) {
 | 
	
		
			
				|  |  | +                    if (p.type === 'calc') {
 | 
	
		
			
				|  |  | +                        if (i === 0 || i === iLen - 1)
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字'];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (p.type === 'num') {
 | 
	
		
			
				|  |  | +                        num = p.value.replace('%', '');
 | 
	
		
			
				|  |  | +                        if (p.value.length - num.length > 1)
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 | 
	
		
			
				|  |  | +                        num = _.toNumber(num);
 | 
	
		
			
				|  |  | +                        if (num === undefined || num === null || _.isNaN(num))
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 | 
	
		
			
				|  |  | +                        if (i > 0) {
 | 
	
		
			
				|  |  | +                            if (param[i - 1].type !== 'calc' && param[i - 1].type !== 'left') {
 | 
	
		
			
				|  |  | +                                return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 | 
	
		
			
				|  |  | +                            } else if (param[i - 1].value === '/' && num === 0) {
 | 
	
		
			
				|  |  | +                                return [false, '输入的表达式非法:请勿除0'];
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (p.type === 'base') {
 | 
	
		
			
				|  |  | +                        if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (p.type === 'left') {
 | 
	
		
			
				|  |  | +                        iLeftCount += 1;
 | 
	
		
			
				|  |  | +                        if (i !== 0 && param[i-1].type !== 'calc')
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:(前应有运算符'];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if (p.type === 'right') {
 | 
	
		
			
				|  |  | +                        iRightCount += 1;
 | 
	
		
			
				|  |  | +                        if (i !== iLen - 1 && param[i+1].type !== 'calc')
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:)后应有运算符'];
 | 
	
		
			
				|  |  | +                        if (iRightCount > iLeftCount)
 | 
	
		
			
				|  |  | +                            return [false, '输入的表达式非法:")"前无对应的"("'];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (iLeftCount > iRightCount)
 | 
	
		
			
				|  |  | +                    return [false, '输入的表达式非法:"("后无对应的")"'];
 | 
	
		
			
				|  |  | +                return [true, ''];
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            _checkExpr: function (text, data) {
 | 
	
		
			
				|  |  | +                if (text) {
 | 
	
		
			
				|  |  | +                    const num = _.toNumber(text);
 | 
	
		
			
				|  |  | +                    if (num) {
 | 
	
		
			
				|  |  | +                        data.quantity = num;
 | 
	
		
			
				|  |  | +                        data.expr = '';
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        const expr = $.trim(text).replace('\t', '').replace('=', '').toLowerCase();
 | 
	
		
			
				|  |  | +                        const [valid, msg] = this._checkExprValid(expr);
 | 
	
		
			
				|  |  | +                        if (!valid) return [valid, msg];
 | 
	
		
			
				|  |  | +                        data.expr = expr;
 | 
	
		
			
				|  |  | +                        const ce = new CalcEval();
 | 
	
		
			
				|  |  | +                        data.quantity = ce.eval(expr);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    data.quantity = 0;
 | 
	
		
			
				|  |  | +                    data.expr = '';
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                return [true, ''];
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | +        materialSpread.bind(spreadNS.Events.EditStarting, materialSpreadObj.editStarting);
 | 
	
		
			
				|  |  |          materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
 | 
	
		
			
				|  |  |          materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
 | 
	
		
			
				|  |  |          SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
 | 
	
	
		
			
				|  | @@ -614,19 +885,20 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  toastr.warning('没有需要应用调差工料的其它清单明细');
 | 
	
		
			
				|  |  |                  return false;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            console.log(needAddList, materialList);
 | 
	
		
			
				|  |  |              // 更新至服务器
 | 
	
		
			
				|  |  | -            postData(window.location.pathname + '/save', { type:'useOther', postData: { addXmj: needAddList, materialBills: materialList } }, function (result) {
 | 
	
		
			
				|  |  | -                materialListData = result;
 | 
	
		
			
				|  |  | -                toastr.success('已成功应用');
 | 
	
		
			
				|  |  | -                calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | -                const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | -                loadLeafXmjData(index);
 | 
	
		
			
				|  |  | -                const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | -                const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | -                const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | -                loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | -                SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | +            // postData(window.location.pathname + '/save', { type:'useOther', postData: { addXmj: needAddList, materialBills: materialList } }, function (result) {
 | 
	
		
			
				|  |  | +            //     materialListData = result;
 | 
	
		
			
				|  |  | +            //     toastr.success('已成功应用');
 | 
	
		
			
				|  |  | +            //     calculateJiaCha(gclGatherData);
 | 
	
		
			
				|  |  | +            //     const index = gclGatherData.indexOf(ledgerSelect);
 | 
	
		
			
				|  |  | +            //     loadLeafXmjData(index);
 | 
	
		
			
				|  |  | +            //     const xmjSheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +            //     const xmjSelect = SpreadJsObj.getSelectObject(xmjSheet);
 | 
	
		
			
				|  |  | +            //     const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
 | 
	
		
			
				|  |  | +            //     loadMaterialData(index, xmjIndex);
 | 
	
		
			
				|  |  | +            //     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
 | 
	
		
			
				|  |  | +            // });
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          $.contextMenu({
 | 
	
		
			
				|  |  |              selector: '#material-spread',
 | 
	
	
		
			
				|  | @@ -646,15 +918,16 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      disabled: function (key, opt) {
 | 
	
		
			
				|  |  |                          const sheet = leafXmjSpread.getActiveSheet();
 | 
	
		
			
				|  |  |                          const select = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  | -                        const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  | +                        // const notx = findNotJoinLeafXmj(select);
 | 
	
		
			
				|  |  |                          if (!select) {
 | 
	
		
			
				|  |  |                              return true;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                        if (!readOnly && notx === undefined) {
 | 
	
		
			
				|  |  | -                            return false;
 | 
	
		
			
				|  |  | -                        } else {
 | 
	
		
			
				|  |  | -                            return true;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | +                        // if (!readOnly && notx === undefined) {
 | 
	
		
			
				|  |  | +                        //     return false;
 | 
	
		
			
				|  |  | +                        // } else {
 | 
	
		
			
				|  |  | +                        //     return true;
 | 
	
		
			
				|  |  | +                        // }
 | 
	
		
			
				|  |  | +                        return readOnly;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  'delete': {
 | 
	
	
		
			
				|  | @@ -763,4 +1036,53 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              materialSpread.refresh();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $.divResizer({
 | 
	
		
			
				|  |  | +        select: '#right-spr',
 | 
	
		
			
				|  |  | +        callback: function () {
 | 
	
		
			
				|  |  | +            ledgerSpread.refresh();
 | 
	
		
			
				|  |  | +            leafXmjSpread.refresh();
 | 
	
		
			
				|  |  | +            materialSpread.refresh();
 | 
	
		
			
				|  |  | +            const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
 | 
	
		
			
				|  |  | +            setLocalCache('material_list_' + materialID, width);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 展开收起月信息价并浏览器记住本期展开收起
 | 
	
		
			
				|  |  | +    $('a', '.right-nav').bind('click', function () {
 | 
	
		
			
				|  |  | +        //const main = $('#main-view'), tool = $('#tools-view');
 | 
	
		
			
				|  |  | +        const tab = $(this), tabPanel = $(tab.attr('content'));
 | 
	
		
			
				|  |  | +        if (!tab.hasClass('active')) {
 | 
	
		
			
				|  |  | +            $('a', '.side-menu').removeClass('active');
 | 
	
		
			
				|  |  | +            $('.tab-content .tab-select-show').removeClass('active');
 | 
	
		
			
				|  |  | +            tab.addClass('active');
 | 
	
		
			
				|  |  | +            tabPanel.addClass('active');
 | 
	
		
			
				|  |  | +            showSideTools(tab.hasClass('active'));
 | 
	
		
			
				|  |  | +            if (tab.attr('content') === '#material-tab') {
 | 
	
		
			
				|  |  | +                const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
 | 
	
		
			
				|  |  | +                setLocalCache('material_list_' + materialID, width);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            removeLocalCache('material_list_' + materialID);
 | 
	
		
			
				|  |  | +            tab.removeClass('active');
 | 
	
		
			
				|  |  | +            tabPanel.removeClass('active');
 | 
	
		
			
				|  |  | +            showSideTools(tab.hasClass('active'));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        ledgerSpread.refresh();
 | 
	
		
			
				|  |  | +        leafXmjSpread.refresh();
 | 
	
		
			
				|  |  | +        materialSpread.refresh();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    // 根据浏览器记录展开收起
 | 
	
		
			
				|  |  | +    if (getLocalCache('material_list_' + materialID)) {
 | 
	
		
			
				|  |  | +        const tab = $('.right-nav a[content="#material-tab"]'), tabPanel = $(tab.attr('content'));
 | 
	
		
			
				|  |  | +        $('a', '.side-menu').removeClass('active');
 | 
	
		
			
				|  |  | +        $('.tab-content .tab-select-show').removeClass('active');
 | 
	
		
			
				|  |  | +        tab.addClass('active');
 | 
	
		
			
				|  |  | +        tabPanel.addClass('active');
 | 
	
		
			
				|  |  | +        $('#right-view').width(getLocalCache('material_list_' + materialID) + '%');
 | 
	
		
			
				|  |  | +        showSideTools(tab.hasClass('active'));
 | 
	
		
			
				|  |  | +        ledgerSpread.refresh();
 | 
	
		
			
				|  |  | +        leafXmjSpread.refresh();
 | 
	
		
			
				|  |  | +        materialSpread.refresh();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  });
 |