You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

2 years ago
  1. 'use strict';
  2. var ReportService = 'CostAndProfitReport';
  3. var sProgramId = getProgramId();
  4. var fnPageInit = function () {
  5. var canDo = new CanDo({
  6. /**
  7. * 客製化按鈕
  8. * @param {Object} pargs CanDo 對象
  9. */
  10. cusBtns: function (pargs) {
  11. var saCusBtns = [{
  12. id: 'Toolbar_PreviewReport',
  13. value: 'common.Toolbar_PreviewReport',// ╠common.Toolbar_PreviewReport⇒預覽報表╣
  14. action: function (pargs) {
  15. fnReport('pdf');
  16. }
  17. },
  18. {
  19. id: 'Toolbar_DownloadReport',
  20. value: 'common.Toolbar_DownloadReport',// ╠common.Toolbar_DownloadReport⇒下載報表╣
  21. action: function (pargs) {
  22. fnReport('excel');
  23. }
  24. }];
  25. return saCusBtns;
  26. },
  27. /**
  28. * 頁面初始化
  29. * @param {Object} pargs CanDo 對象
  30. */
  31. pageInit: function (pargs) {
  32. $.whenArray([
  33. fnSetArgDrop([
  34. {
  35. ArgClassID: 'Area',
  36. LevelOfArgument: 1,
  37. ParentID: '',
  38. CallBack: function (data) {
  39. data.splice(0, 6);
  40. data = Enumerable.From(data).OrderBy("x=>x.id").ToArray()
  41. $('#State').html(createOptions(data, 'id', 'text', true));
  42. $('#State').select2()
  43. }
  44. }
  45. ]),
  46. fnSetArgDrop([
  47. {
  48. OrgID: 'TE',
  49. ArgClassID: 'ExhibClass',
  50. Select: $('#Industry'),
  51. ShowId: true,
  52. Select2: true
  53. }
  54. ]),
  55. fnSetEpoDropWithExhibitionCode({
  56. Select: $('#ExhibitionCode'),
  57. Select2: true,
  58. })
  59. ]).done(function () { });
  60. var iheight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 107;
  61. $('#report').css('height', iheight + 'px');
  62. $('.slide-box').on('click', function () {
  63. if ($(this).hasClass('fa-arrow-down')) {
  64. $('#report').css('height', iheight + 80 + 'px');
  65. }
  66. else {
  67. $('#report').css('height', iheight + 'px');
  68. }
  69. });
  70. $('#ResponsibleDeptID').on('change', function () {
  71. //fnSetHandle_PersonDrop(this.value);
  72. });
  73. }
  74. }),
  75. /**
  76. * 預覽報表或下載報表
  77. * @param {String} flag 預覽或下載
  78. */
  79. fnReport = function (flag) {
  80. var oQuery = canDo._getFormSerialize();
  81. oQuery.Flag = flag;
  82. var AdminUser = parent.UserInfo.roles.toLowerCase().indexOf('admin') > -1;
  83. oQuery.ResponsibleDeptID = '';
  84. if (!AdminUser)
  85. oQuery.ResponsibleDeptID = parent.UserInfo.DepartmentID;
  86. return g_api.ConnectLite(ReportService, sProgramId, oQuery, function (res) {
  87. if (res.RESULT) {
  88. var sPath = res.DATA.rel;
  89. if (flag === 'pdf') {
  90. $('#report').attr('src', gServerUrl + '/' + sPath);
  91. }
  92. else {
  93. canDo._downLoadFile(sPath);
  94. }
  95. }
  96. else {
  97. showMsg("Fail", 'error');
  98. console.log(res.MSG);
  99. }
  100. });
  101. };
  102. };
  103. require(['base', 'select2', 'cando'], fnPageInit);