composition.js 2.5 KB

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