project_glj.js 2.1 KB

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