composition.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * 配合比相关
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/10
  6. * @version
  7. */
  8. let mixRatioSpread = null;
  9. let machineSpread = null;
  10. let mixRatioRightClickTarget = null;
  11. let isDeleting = false;
  12. $(document).ready(function() {
  13. // 切换tab触发refresh
  14. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  15. currentTag = $(e.target).data('name');
  16. // 获取工料机当前选中的行号
  17. let projectGLJId = 0;
  18. if (currentTag === "mix-ratio") {
  19. if (mixRatioSpread === null) {
  20. mixRatioSpread = new CompositionSpread();
  21. mixRatioSpread.init(currentTag);
  22. mixRatioSpread.initRightClick(currentTag);
  23. mixRatioSpread.successCallback = mixRatioSuccess;
  24. }
  25. // 筛选数据显示(显示混凝土、砂浆、配合比)
  26. projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR, GLJTypeConst.MIX_RATIO]);
  27. projectGLJSheet.selectRow(projectGLJSpread.firstMixRatioRow);
  28. projectGLJId = projectGLJSheet.getActiveDataByField('id');
  29. // 获取数据
  30. mixRatioSpread.getRatioData(projectGLJId);
  31. }
  32. if (currentTag === "machine") {
  33. if (machineSpread === null) {
  34. machineSpread = new CompositionSpread();
  35. machineSpread.init(currentTag);
  36. machineSpread.initRightClick(currentTag);
  37. machineSpread.successCallback = mixRatioSuccess;
  38. }
  39. // 筛选数据显示(显示普通机械)
  40. projectGLJSheet.filterData('unit_price.type', [GLJTypeConst.GENERAL_MACHINE]);
  41. projectGLJSheet.selectRow(projectGLJSpread.firstMachineRow);
  42. projectGLJId = projectGLJSheet.getActiveDataByField('id');
  43. // 获取数据
  44. machineSpread.getRatioData(projectGLJId);
  45. }
  46. });
  47. });
  48. /**
  49. * 成功事件
  50. *
  51. * @param {object} info
  52. * @return {void}
  53. */
  54. function mixRatioSuccess(info) {
  55. // 成功则对相应的总消耗量进行设置
  56. projectGLJSheet.setCellByField('quantity', info.change, true);
  57. // 设置父级3个价格
  58. projectGLJSheet.setCellByField('unit_price.market_price', info.parentMarketPrice, false);
  59. projectGLJSheet.setCellByField('unit_price.base_price', info.parentBasePrice, false);
  60. projectGLJSheet.setCellByField('adjust_price', info.parentMarketPrice, false);
  61. }