project_glj.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * 工料机汇总相关
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/6/15
  6. * @version
  7. */
  8. let projectGLJSpread = null;
  9. let projectGLJSheet = null;
  10. let currentTag = '';
  11. let isChanging = false;
  12. $(document).ready(function () {
  13. projectInfoObj.showProjectInfo();
  14. projectGLJSpread = new ProjectGLJSpread();
  15. projectGLJSpread.successCallback = successTrigger;
  16. projectGLJSheet = projectGLJSpread.init();
  17. // 绑定单击事件
  18. let lastRow = 0;
  19. projectGLJSheet.bind(GC.Spread.Sheets.Events.CellClick, function (element, info) {
  20. let currentRow = info.row;
  21. if (currentRow === undefined || currentRow === lastRow) {
  22. return;
  23. }
  24. if (currentTag !== 'mix-ratio' && currentTag !== 'machine') {
  25. return;
  26. }
  27. let spread = currentTag === 'mix-ratio' ? mixRatioSpread : machineSpread;
  28. if (spread === null) {
  29. return;
  30. }
  31. let projectGLJId = projectGLJSheet.getActiveDataByField('id');
  32. spread.getRatioData(projectGLJId);
  33. lastRow = currentRow;
  34. });
  35. // 切换tab触发refresh
  36. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  37. currentTag = $(e.target).data('name');
  38. if (currentTag === 'ration') {
  39. projectGLJSheet.filterData('unit_price.type', []);
  40. }
  41. });
  42. // 是否主动更改数据
  43. // $("#message").on('click', '#load-data', function() {
  44. // $("#notify").slideUp('fast');
  45. // if (changeInfo.length > 0) {
  46. // for (let index in changeInfo) {
  47. // let cell = gljSheet.getCell(changeInfo[index].row, changeInfo[index].col, GC.Spread.Sheets.SheetArea.viewport);
  48. // cell.value(changeInfo[index].newValue);
  49. // }
  50. // }
  51. // changeInfo = [];
  52. // });
  53. });
  54. /**
  55. * 成功事件
  56. *
  57. * @param {string} field
  58. * @param {object} info
  59. * @return {void}
  60. */
  61. function successTrigger(field, info) {
  62. switch (field) {
  63. case 'unit_price.market_price':
  64. // 计算价格
  65. projectGLJSpread.priceCalculate(info);
  66. // 触发websocket通知
  67. socket.emit('dataNotify', JSON.stringify(info));
  68. break;
  69. }
  70. }