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.

103 lines
3.5 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([fnSetDeptDropWithLimtedDeptId($('#ResponsibleDeptID')),
  33. fnSetUserDrop([
  34. {
  35. Select: $('#ResponsiblePerson'),
  36. Select2: true,
  37. ShowId: true,
  38. }
  39. ]),
  40. fnSetCustomerWithGuid({
  41. Select: $('#AgentGuid'),
  42. Select2: true,
  43. })
  44. ]).done(function () { });
  45. var iheight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 107;
  46. $('#report').css('height', iheight + 'px');
  47. $('.slide-box').on('click', function () {
  48. if ($(this).hasClass('fa-arrow-down')) {
  49. $('#report').css('height', iheight + 80 + 'px');
  50. }
  51. else {
  52. $('#report').css('height', iheight + 'px');
  53. }
  54. });
  55. $('#ResponsibleDeptID').on('change', function () {
  56. //fnSetHandle_PersonDrop(this.value);
  57. });
  58. }
  59. }),
  60. /**
  61. * 設置部門資料連動業務
  62. * @param {String} deptid 部門ID
  63. */
  64. fnSetHandle_PersonDrop = function (deptid) {
  65. var sDepartmentID = deptid || '';
  66. fnSetUserDrop([
  67. {
  68. Action: 'add',
  69. DepartmentID: sDepartmentID,
  70. CallBack: function (data) {
  71. var saList = data;
  72. $('#ResponsiblePerson').html(createOptions(saList, 'MemberID', 'MemberName', true));
  73. }
  74. }
  75. ]);
  76. },
  77. /**
  78. * 預覽報表或下載報表
  79. * @param {String} flag 預覽或下載
  80. */
  81. fnReport = function (flag) {
  82. var oQuery = canDo._getFormSerialize();
  83. oQuery.Flag = flag;
  84. return g_api.ConnectLite(ReportService, sProgramId, oQuery, function (res) {
  85. if (res.RESULT) {
  86. var sPath = res.DATA.rel;
  87. if (flag === 'pdf') {
  88. $('#report').attr('src', gServerUrl + '/' + sPath);
  89. }
  90. else {
  91. canDo._downLoadFile(sPath);
  92. }
  93. }
  94. else {
  95. showMsg("Fail", 'error');
  96. console.log(res.MSG);
  97. }
  98. });
  99. };
  100. };
  101. require(['base', 'select2', 'cando'], fnPageInit);