init.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. pageOprObj.initPage();
  43. $("#linkGLJ").click(function(){
  44. rationGLJOprObj.bindRationGljDelOpr();
  45. rdSpread.setActiveSheetIndex(0);
  46. });
  47. $("#linkFZDE").click(function(){
  48. rationAssistOprObj.bindRationAssDel();
  49. rdSpread.setActiveSheetIndex(1);
  50. });
  51. $("#linkFZTJ").click(function(){
  52. rationCoeOprObj.bindRationCoeDel();
  53. rdSpread.setActiveSheetIndex(2);
  54. });
  55. $("#linkAZZJ").click(function(){
  56. rationInstObj.bindRationInstDel();
  57. rdSpread.setActiveSheetIndex(3);
  58. });
  59. }
  60. $.bootstrapLoading.end();
  61. });
  62. //解决spreadjs sheet初始化没高度宽度
  63. $('#modalCon').width($(window).width()*0.5);
  64. $('#gljSelTreeDiv').height($(window).height() - 300);
  65. $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
  66. $("#gljSelSheet").width($('#modalCon').width() * 0.63);
  67. $(window).resize(function () {
  68. $('#modalCon').width($(window).width()*0.5);
  69. $('#gljSelTreeDiv').height($(window).height() - 300);
  70. $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
  71. $("#gljSelSheet").width($('#modalCon').width()* 0.63);
  72. });
  73. });
  74. })();