|  | @@ -15,6 +15,15 @@ function checkTzMeasureType () {
 | 
	
		
			
				|  |  |  function transExpr(expr) {
 | 
	
		
			
				|  |  |      return $.trim(expr).replace('\t', '').replace('=', '').replace('%', '/100');
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +function getExprInfo (field) {
 | 
	
		
			
				|  |  | +    const exprField = [
 | 
	
		
			
				|  |  | +        {qty: 'sgfh_qty', expr: 'sgfh_expr'},
 | 
	
		
			
				|  |  | +        {qty: 'sjcl_qty', expr: 'sjcl_expr'},
 | 
	
		
			
				|  |  | +        {qty: 'qtcl_qty', expr: 'qtcl_expr'},
 | 
	
		
			
				|  |  | +        {qty: 'contract_qty', expr: 'contract_expr'},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    return _.find(exprField, {qty: field});
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 从cookie中读取缓存的列显示设置,没有则取默认
 | 
	
	
		
			
				|  | @@ -136,7 +145,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |          stageId: 'id',
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      // 台账树结构计算相关设置
 | 
	
		
			
				|  |  | -    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used'];
 | 
	
		
			
				|  |  | +    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
 | 
	
		
			
				|  |  |      stageTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
 | 
	
		
			
				|  |  |          'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
 | 
	
		
			
				|  |  |      stageTreeSetting.calcFun = function (node) {
 | 
	
	
		
			
				|  | @@ -160,7 +169,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |      // 初始化 计量单元 数据结构
 | 
	
		
			
				|  |  |      const stagePosSetting = {
 | 
	
		
			
				|  |  |          id: 'id', ledgerId: 'lid',
 | 
	
		
			
				|  |  | -        updateFields: ['contract_qty', 'qc_qty', 'postil'],
 | 
	
		
			
				|  |  | +        updateFields: ['contract_qty', 'qc_qty', 'postil', 'contract_expr'],
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      stagePosSetting.calcFun = function (pos) {
 | 
	
		
			
				|  |  |          pos.pre_gather_qty = ZhCalc.add(pos.pre_contract_qty, pos.pre_qc_qty);
 | 
	
	
		
			
				|  | @@ -536,7 +545,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  if (nodePos && nodePos.length > 0) {
 | 
	
		
			
				|  |  |                      $('#bills-expr').val('').attr('readOnly', true);
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  | -                    $('#bills-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field]);
 | 
	
		
			
				|  |  | +                    const exprInfo = getExprInfo(col.field);
 | 
	
		
			
				|  |  | +                    const value = exprInfo && data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field];
 | 
	
		
			
				|  |  | +                    $('#bills-expr').val(value).attr('field', col.field).attr('org', data[col.field]);
 | 
	
		
			
				|  |  |                      if (col.field.indexOf('tp') >= 0) {
 | 
	
		
			
				|  |  |                          $('#bills-expr').attr('readOnly', readOnly || cell.locked() || data.is_tp !== 1);
 | 
	
		
			
				|  |  |                      } else {
 | 
	
	
		
			
				|  | @@ -618,6 +629,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          lid: node.id
 | 
	
		
			
				|  |  |                      };
 | 
	
		
			
				|  |  |                      updateData.stage[col.field] = newValue;
 | 
	
		
			
				|  |  | +                    const exprInfo = getExprInfo(col.field);
 | 
	
		
			
				|  |  | +                    if (exprInfo) {
 | 
	
		
			
				|  |  | +                        updateData.stage[exprInfo.expr] = trimInvalidChar(info.editingText);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  postData(window.location.href + '/update', {bills: updateData}, function (data) {
 | 
	
	
		
			
				|  | @@ -687,6 +702,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                                  filterMain = false;
 | 
	
		
			
				|  |  |                              } else {
 | 
	
		
			
				|  |  |                                  data[colSetting.field] = null;
 | 
	
		
			
				|  |  | +                                const exprInfo = getExprInfo(colSetting.field);
 | 
	
		
			
				|  |  | +                                if (exprInfo) {
 | 
	
		
			
				|  |  | +                                    data[exprInfo.expr] = '';
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  |                                  filter = false;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
	
		
			
				|  | @@ -708,6 +727,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              stageIm.loadUpdateLedgerData(result);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        stageTreeSpreadObj.loadExprToInput(sheet);
 | 
	
		
			
				|  |  |                      });
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -786,6 +806,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                                  } else {
 | 
	
		
			
				|  |  |                                      try {
 | 
	
		
			
				|  |  |                                          data[col.field] = math.evaluate(transExpr(text));
 | 
	
		
			
				|  |  | +                                        const exprInfo = getExprInfo(col.field);
 | 
	
		
			
				|  |  | +                                        if (exprInfo) {
 | 
	
		
			
				|  |  | +                                            data[exprInfo.expr] = text;
 | 
	
		
			
				|  |  | +                                        }
 | 
	
		
			
				|  |  |                                          filter = false;
 | 
	
		
			
				|  |  |                                      } catch(err) {
 | 
	
		
			
				|  |  |                                          if (!bHint) {
 | 
	
	
		
			
				|  | @@ -820,6 +844,7 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              stageIm.loadUpdateLedgerData(data);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | +                        stageTreeSpreadObj.loadExprToInput(sheet);
 | 
	
		
			
				|  |  |                      }, function () {
 | 
	
		
			
				|  |  |                          // todo
 | 
	
		
			
				|  |  |                          //stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), filterNodes);
 | 
	
	
		
			
				|  | @@ -990,12 +1015,15 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                      lid: select.id
 | 
	
		
			
				|  |  |                  };
 | 
	
		
			
				|  |  |                  updateData.stage[field] = newValue;
 | 
	
		
			
				|  |  | +                const exprInfo = getExprInfo(field);
 | 
	
		
			
				|  |  | +                if (exprInfo) {
 | 
	
		
			
				|  |  | +                    updateData.stage[exprInfo.expr] = expr.val();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // 更新至服务器
 | 
	
		
			
				|  |  |              postData(window.location.pathname + '/update', {bills: updateData}, function (result) {
 | 
	
		
			
				|  |  |                  const nodes = stageTree.loadPostStageData(result);
 | 
	
		
			
				|  |  | -                expr.val(select[field]);
 | 
	
		
			
				|  |  |                  stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
 | 
	
		
			
				|  |  |              });
 | 
	
		
			
				|  |  |          });
 | 
	
	
		
			
				|  | @@ -1011,7 +1039,9 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              if (col && col.type === 'Number') {
 | 
	
		
			
				|  |  |                  const data = SpreadJsObj.getSelectObject(sheet);
 | 
	
		
			
				|  |  |                  if (data) {
 | 
	
		
			
				|  |  | -                    $('#pos-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
 | 
	
		
			
				|  |  | +                    const exprInfo = getExprInfo(col.field);
 | 
	
		
			
				|  |  | +                    const value = exprInfo && data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field];
 | 
	
		
			
				|  |  | +                    $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
 | 
	
		
			
				|  |  |                          .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |                      $('#pos-expr').val('').attr('readOnly', true);
 | 
	
	
		
			
				|  | @@ -1108,6 +1138,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              try {
 | 
	
		
			
				|  |  |                                  data.updateData[col.field] = math.evaluate(transExpr(newText));
 | 
	
		
			
				|  |  | +                                const exprInfo = getExprInfo(col.field);
 | 
	
		
			
				|  |  | +                                if (exprInfo) {
 | 
	
		
			
				|  |  | +                                    data.updateData[exprInfo.expr] = newText;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  |                              } catch(err) {
 | 
	
		
			
				|  |  |                                  toastr.error('输入的表达式非法');
 | 
	
		
			
				|  |  |                                  SpreadJsObj.reLoadRowData(info.sheet, info.row);
 | 
	
	
		
			
				|  | @@ -1199,14 +1233,18 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                              const colSetting = info.sheet.zh_setting.cols[curCol];
 | 
	
		
			
				|  |  |                              if (!colSetting) continue;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                            newData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
 | 
	
		
			
				|  |  | +                            const newValue = trimInvalidChar(info.sheet.getText(curRow, curCol));
 | 
	
		
			
				|  |  |                              if (colSetting.type === 'Number') {
 | 
	
		
			
				|  |  | -                                const num = _.toNumber(newData[colSetting.field]);
 | 
	
		
			
				|  |  | +                                const num = _.toNumber(newValue);
 | 
	
		
			
				|  |  |                                  if (num) {
 | 
	
		
			
				|  |  |                                      newData[colSetting.field] = num;
 | 
	
		
			
				|  |  |                                  } else {
 | 
	
		
			
				|  |  |                                      try {
 | 
	
		
			
				|  |  | -                                        newData[colSetting.field] = math.evaluate(transExpr(newData[colSetting.field]));
 | 
	
		
			
				|  |  | +                                        newData[colSetting.field] = math.evaluate(transExpr(newValue));
 | 
	
		
			
				|  |  | +                                        const exprInfo = getExprInfo(colSetting.field);
 | 
	
		
			
				|  |  | +                                        if (exprInfo) {
 | 
	
		
			
				|  |  | +                                            newData[exprInfo.expr] = newValue;
 | 
	
		
			
				|  |  | +                                        }
 | 
	
		
			
				|  |  |                                      } catch(err) {
 | 
	
		
			
				|  |  |                                          toastr.error('输入的表达式非法');
 | 
	
		
			
				|  |  |                                          stagePosSpreadObj.loadCurPosData();
 | 
	
	
		
			
				|  | @@ -1214,6 +1252,8 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                                      }
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  | +                            } else {
 | 
	
		
			
				|  |  | +                                newData[colSetting.field] = newValue;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          data.updateData.push(newData);
 | 
	
	
		
			
				|  | @@ -1228,20 +1268,26 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                              for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 | 
	
		
			
				|  |  |                                  const curCol = info.cellRange.col + iCol;
 | 
	
		
			
				|  |  |                                  const colSetting = info.sheet.zh_setting.cols[curCol];
 | 
	
		
			
				|  |  | -                                newData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
 | 
	
		
			
				|  |  | +                                const newValue = trimInvalidChar(info.sheet.getText(curRow, curCol));
 | 
	
		
			
				|  |  |                                  if (colSetting.type === 'Number') {
 | 
	
		
			
				|  |  | -                                    const num = _.toNumber(newData[colSetting.field]);
 | 
	
		
			
				|  |  | +                                    const num = _.toNumber(newValue);
 | 
	
		
			
				|  |  |                                      if (num) {
 | 
	
		
			
				|  |  |                                          newData[colSetting.field] = num;
 | 
	
		
			
				|  |  |                                      } else {
 | 
	
		
			
				|  |  |                                          try {
 | 
	
		
			
				|  |  | -                                            newData[colSetting.field] = math.evaluate(transExpr(newData[colSetting.field]));
 | 
	
		
			
				|  |  | +                                            newData[colSetting.field] = math.evaluate(transExpr(newValue));
 | 
	
		
			
				|  |  | +                                            const exprInfo = getExprInfo(colSetting.field);
 | 
	
		
			
				|  |  | +                                            if (exprInfo) {
 | 
	
		
			
				|  |  | +                                                newData[exprInfo.expr] = newValue;
 | 
	
		
			
				|  |  | +                                            }
 | 
	
		
			
				|  |  |                                          } catch(err) {
 | 
	
		
			
				|  |  |                                              toastr.error('输入的表达式非法');
 | 
	
		
			
				|  |  |                                              stagePosSpreadObj.loadCurPosData();
 | 
	
		
			
				|  |  |                                              return;
 | 
	
		
			
				|  |  |                                          }
 | 
	
		
			
				|  |  |                                      }
 | 
	
		
			
				|  |  | +                                } else {
 | 
	
		
			
				|  |  | +                                    newData[colSetting.field] = newValue;
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                              data.updateData.push(newData);
 | 
	
	
		
			
				|  | @@ -1293,6 +1339,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                                  return;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                              data[colSetting.field] = null;
 | 
	
		
			
				|  |  | +                            const exprInfo = getExprInfo(colSetting.field);
 | 
	
		
			
				|  |  | +                            if (exprInfo) {
 | 
	
		
			
				|  |  | +                                data[exprInfo.expr] = '';
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          datas.push(data);
 | 
	
		
			
				|  |  |                          posSelects.push(node);
 | 
	
	
		
			
				|  | @@ -1419,6 +1469,10 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  try {
 | 
	
		
			
				|  |  |                      data[field] = math.evaluate(transExpr(newValue));
 | 
	
		
			
				|  |  | +                    const exprInfo = getExprInfo(field);
 | 
	
		
			
				|  |  | +                    if (exprInfo) {
 | 
	
		
			
				|  |  | +                        data[exprInfo.expr] = newValue;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  } catch (err) {
 | 
	
		
			
				|  |  |                      toastr.error('输入的表达式非法');
 | 
	
		
			
				|  |  |                      return;
 | 
	
	
		
			
				|  | @@ -1430,7 +1484,6 @@ $(document).ready(() => {
 | 
	
		
			
				|  |  |                  if (result.pos) {
 | 
	
		
			
				|  |  |                      stagePos.updateDatas(result.pos.pos);
 | 
	
		
			
				|  |  |                      stagePos.loadCurStageData(result.pos.curStageData);
 | 
	
		
			
				|  |  | -                    expr.val(select[field]);
 | 
	
		
			
				|  |  |                      SpreadJsObj.reLoadRowData(posSheet, _.toNumber(row));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  const refreshData = stageTree.loadPostStageData(result.ledger);
 |