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.

121 lines
4.2 KiB

2 years ago
  1. 'use strict';
  2. var fnPageInit = function () {
  3. var canDo = new CanDo({
  4. /**
  5. * 客製化按鈕
  6. * @param {Object} pargs CanDo 對象
  7. */
  8. cusBtns: function (pargs) {
  9. var saCusBtns = [{
  10. id: 'Toolbar_PreviewReport',
  11. value: 'common.Toolbar_PreviewReport',// ╠common.Toolbar_PreviewReport⇒預覽報表╣
  12. action: function (pargs) {
  13. fnReport('pdf');
  14. }
  15. },
  16. {
  17. id: 'Toolbar_DownloadReport',
  18. value: 'common.Toolbar_DownloadReport',// ╠common.Toolbar_DownloadReport⇒下載報表╣
  19. action: function (pargs) {
  20. fnReport('excel');
  21. }
  22. }];
  23. return saCusBtns;
  24. },
  25. /**
  26. * 頁面初始化
  27. * @param {Object} pargs CanDo 對象
  28. */
  29. pageInit: function (pargs) {
  30. $.whenArray([fnSetProjectDrop(), fnSetPayerDrop(), fnSetDeptDropWithLimtedDeptId($('#ResponsibleDeptID')), fnSetUserDrop([
  31. {
  32. Select: $('#ResponsiblePerson'),
  33. Select2: true,
  34. ShowId: true,
  35. }
  36. ])]).done(function () {
  37. });
  38. var iheight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 107;
  39. $('#report').css('height', iheight + 'px');
  40. $('.slide-box').on('click', function () {
  41. if ($(this).hasClass('fa-arrow-down')) {
  42. $('#report').css('height', iheight + 80 + 'px');
  43. }
  44. else {
  45. $('#report').css('height', iheight + 'px');
  46. }
  47. });
  48. $('#ResponsibleDeptID').on('change', function () {
  49. //fnSetHandle_PersonDrop(this.value);
  50. });
  51. }
  52. }),
  53. /**
  54. * 設置部門資料連動業務
  55. * @param {String} deptid 部門ID
  56. */
  57. fnSetHandle_PersonDrop = function (deptid) {
  58. var sDepartmentID = deptid || '';
  59. fnSetUserDrop([
  60. {
  61. Action: 'add',
  62. DepartmentID: sDepartmentID,
  63. CallBack: function (data) {
  64. var saList = data;
  65. $('#ResponsiblePerson').html(createOptions(saList, 'MemberID', 'MemberName', true));
  66. }
  67. }
  68. ]);
  69. },
  70. /**
  71. * 設定展覽名稱選單
  72. * @return ajax 物件
  73. */
  74. fnSetProjectDrop = function () {
  75. return g_api.ConnectLite(canDo.ProgramId, 'GetProjects', {}, function (res) {
  76. if (res.RESULT) {
  77. var saCustomers = res.DATA.rel;
  78. if (saCustomers.length > 0) {
  79. $('#ProjectNO').html(createOptions(saCustomers, 'id', 'text')).select2();
  80. }
  81. }
  82. });
  83. },
  84. /**
  85. * 設定客戶(廠商)下拉選單
  86. * @return ajax 物件
  87. */
  88. fnSetPayerDrop = function () {
  89. return g_api.ConnectLite(canDo.ProgramId, 'GetPayers', {}, function (res) {
  90. if (res.RESULT) {
  91. var saCustomers = res.DATA.rel;
  92. if (saCustomers.length > 0) {
  93. $('#Payer').html(createOptions(saCustomers, 'id', 'text')).select2();
  94. }
  95. }
  96. });
  97. },
  98. /**
  99. * 預覽報表或下載報表
  100. * @param {String} flag 預覽或下載
  101. */
  102. fnReport = function (flag) {
  103. var oQuery = canDo._getFormSerialize();
  104. oQuery.Flag = flag;
  105. return g_api.ConnectLite(canDo.ProgramId, 'ReportPro', oQuery, function (res) {
  106. if (res.RESULT) {
  107. var sPath = res.DATA.rel;
  108. if (flag === 'pdf') {
  109. $('#report').attr('src', gServerUrl + '/' + sPath);
  110. }
  111. else {
  112. canDo._downLoadFile(sPath);
  113. }
  114. }
  115. });
  116. };
  117. };
  118. require(['base', 'select2', 'cando'], fnPageInit);