init.js 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author CaiAoLin
  6. * @date 2019/9/24
  7. * @version
  8. */
  9. const initialization = (() => {
  10. $(document).ready(function () {
  11. $.bootstrapLoading.start();
  12. CommonAjax.get('/complementaryRation/api/initData', {}, res => {
  13. if (res.error) {
  14. alert('数据初始化失败,请重试。');
  15. setTimeout(() => {
  16. window.location.href = '/'
  17. }, 1200);
  18. } else {
  19. const data = res.data;
  20. pageOprObj.rationTreeData = data.rationTreeData;
  21. pageOprObj.mixedTreeData = data.mixedTreeData;
  22. pageOprObj.mixedGLJData = data.mixedGLJData;
  23. rationGLJOprObj.distTypeTree = data.gljDistTypeCache;
  24. rationOprObj.rationsCodes = data.rationsCodes;
  25. rationOprObj.buildSheet($("#rationItemsSheet")[0]);
  26. // tabPanel 下有多个Spread时,相互之间不能正确显示。改成一个Spread下多个Sheet。
  27. var rdSpread = sheetCommonObj.createSpread($("#rdSpread")[0], 4);
  28. rdSpread.options.allowUserDragFill = false;
  29. rdSpread.options.allowUserDragDrop = false;
  30. sheetCommonObj.spreadDefaultStyle(rdSpread);
  31. rationGLJOprObj.buildSheet(rdSpread.getSheet(0));
  32. rationAssistOprObj.buildSheet(rdSpread.getSheet(1));
  33. rationCoeOprObj.buildSheet(rdSpread.getSheet(2));
  34. rationInstObj.buildSheet(rdSpread.getSheet(3));
  35. rationInstObj.getInstallation(data.installationData);
  36. let rdSpreadEscSheets = [];
  37. rdSpreadEscSheets.push({sheet: rdSpread.getSheet(0), editStarting: rationGLJOprObj.onEditStarting, editEnded: rationGLJOprObj.onCellEditEnd});
  38. rdSpreadEscSheets.push({sheet: rdSpread.getSheet(1), editStarting: rationAssistOprObj.onEditStarting, editEnded: rationAssistOprObj.onEditEnded});
  39. rdSpreadEscSheets.push({sheet: rdSpread.getSheet(2), editStarting: rationCoeOprObj.onEditStarting, editEnded: rationCoeOprObj.onEditEnded});
  40. rdSpreadEscSheets.push({sheet: rdSpread.getSheet(3), editStarting: rationInstObj.onEditStarting, editEnded: rationInstObj.onEditEnded});
  41. sheetCommonObj.bindEscKey(rdSpread, rdSpreadEscSheets);
  42. gljAdjOprObj.gljList = data.mixedGLJData.stdGljs.concat(data.mixedGLJData.complementaryGljs);
  43. pageOprObj.initPage();
  44. $("#linkGLJ").click(function(){
  45. rationGLJOprObj.bindRationGljDelOpr();
  46. rdSpread.setActiveSheetIndex(0);
  47. });
  48. $("#linkFZDE").click(function(){
  49. rationAssistOprObj.bindRationAssDel();
  50. rdSpread.setActiveSheetIndex(1);
  51. });
  52. $("#linkFZTJ").click(function(){
  53. rationCoeOprObj.bindRationCoeDel();
  54. rdSpread.setActiveSheetIndex(2);
  55. });
  56. $("#linkAZZJ").click(function(){
  57. rationInstObj.bindRationInstDel();
  58. rdSpread.setActiveSheetIndex(3);
  59. });
  60. }
  61. $.bootstrapLoading.end();
  62. });
  63. //解决spreadjs sheet初始化没高度宽度
  64. /* $('#modalCon').width($(window).width()*0.5);
  65. $('#gljSelTreeDiv').height($(window).height() - 300);
  66. $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
  67. $("#gljSelSheet").width($('#modalCon').width() * 0.63);
  68. $(window).resize(function () {
  69. $('#modalCon').width($(window).width()*0.5);
  70. $('#gljSelTreeDiv').height($(window).height() - 300);
  71. $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
  72. $("#gljSelSheet").width($('#modalCon').width()* 0.63);
  73. }); */
  74. });
  75. })();