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.

192 lines
7.7 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. oGrid = null,
  4. fnPageInit = function () {
  5. var oForm = $('#form_main'),
  6. fnGetAllFeeClass = function () {
  7. var sStr = [];
  8. $('#FeeClass option').each(function () {
  9. if (this.value) {
  10. sStr.push(this.value);
  11. }
  12. });
  13. return sStr.join(',');
  14. },
  15. /**
  16. * 獲取資料
  17. * @return {Object} Ajax 物件
  18. */
  19. fnGet = function () {
  20. var oQuery = getFormSerialize(oForm),
  21. sFeeClass = oQuery.FeeClass === '' ? fnGetAllFeeClass() : oQuery.FeeClass;
  22. return g_api.ConnectLite(sProgramId, 'GetBillsList', {
  23. FeeClass: sFeeClass,
  24. CheckDateStart: oQuery.CheckDateStart,
  25. CheckDateEnd: oQuery.CheckDateEnd
  26. });
  27. },
  28. /**
  29. * 匯出資料
  30. * @return {Object} Ajax 物件
  31. */
  32. fnExcel = function () {
  33. var oQuery = getFormSerialize(oForm),
  34. sFeeClass = oQuery.FeeClass === '' ? fnGetAllFeeClass() : oQuery.FeeClass;
  35. return g_api.ConnectLite(sProgramId, 'ExcelBillsList', {
  36. FeeClass: sFeeClass,
  37. CheckDateStart: oQuery.CheckDateStart,
  38. CheckDateEnd: oQuery.CheckDateEnd
  39. }, function (res) {
  40. if (res.RESULT) {
  41. DownLoadFile(res.DATA.rel);
  42. }
  43. });
  44. },
  45. /**
  46. * ToolBar 按鈕事件 function
  47. * @param {Object}inst 按鈕物件對象
  48. * @param {Object} e 事件對象
  49. */
  50. fnButtonHandler = function (inst, e) {
  51. var sId = inst.id;
  52. switch (sId) {
  53. case "Toolbar_Qry":
  54. var iNum = $('#PerPageNum').val();
  55. cacheQueryCondition();
  56. oGrid.openPage(1);
  57. break;
  58. case "Toolbar_Save":
  59. fnSave('add');
  60. break;
  61. case "Toolbar_ReAdd":
  62. break;
  63. case "Toolbar_Clear":
  64. clearPageVal();
  65. break;
  66. case "Toolbar_Leave":
  67. break;
  68. case "Toolbar_Add":
  69. break;
  70. case "Toolbar_Upd":
  71. break;
  72. case "Toolbar_Copy":
  73. break;
  74. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  75. break;
  76. case "Toolbar_Exp":
  77. if (oGrid.data.length === 0) {
  78. showMsg(i18next.t("message.NoDataExport"));// ╠message.NoDataExport⇒沒有資料匯出╣
  79. return false;
  80. }
  81. fnExcel();
  82. break;
  83. default:
  84. alert("No handle '" + sId + "'");
  85. break;
  86. }
  87. },
  88. /**
  89. * 頁面初始化
  90. */
  91. init = function () {
  92. commonInit({
  93. PrgId: sProgramId,
  94. ButtonHandler: fnButtonHandler,
  95. GoTop: true,
  96. SearchBar: true
  97. });
  98. fnSetArgDrop([
  99. {
  100. ArgClassID: 'FeeClass',
  101. Select: $('#FeeClass'),
  102. ShowId: true,
  103. Ids: parent.SysSet.FeeClassList
  104. }
  105. ])
  106. .done(function () {
  107. reSetQueryPm(sProgramId);
  108. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  109. $("#jsGrid").jsGrid({
  110. width: "100%",
  111. height: iHeight + "px",
  112. autoload: true,
  113. pageLoading: true,
  114. inserting: false,
  115. editing: false,
  116. sorting: true,
  117. paging: true,
  118. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  119. pageSize: 100000,
  120. pageButtonCount: parent.SysSet.GridPages || 15,
  121. invalidMessage: '输入的数据无效!',
  122. confirmDeleting: true,
  123. deleteConfirm: "確定要刪除嗎?",
  124. pagePrevText: "<",
  125. pageNextText: ">",
  126. pageFirstText: "<<",
  127. pageLastText: ">>",
  128. onPageChanged: function (args) {
  129. cacheQueryCondition(args.pageIndex);
  130. },
  131. rowClick: function (args) {
  132. if (navigator.userAgent.match(/mobile/i)) {
  133. }
  134. },
  135. rowDoubleClick: function (args) {
  136. },
  137. fields: [
  138. { name: "RowIndex", title: 'common.RowNumber', align: "center", type: "text", width: 50, sorting: false },
  139. {
  140. name: "BillNO", title: 'common.BillNO', align: "left", type: "text", width: 100, sorting: false
  141. },
  142. {
  143. name: "ExhibitioName", title: 'Exhibition_Upd.Exhibitioname_TW', align: "left", type: "text", width: 350, sorting: false
  144. },
  145. {
  146. name: "Payer", title: 'ExhibitionImport_Upd.Payer', align: "left", type: "text", width: 350, sorting: false
  147. },
  148. {
  149. name: "Amount", title: 'common.Financial_Amount', align: "right", type: "text", width: 100, sorting: false,
  150. itemTemplate: function (val, item) {
  151. return !val ? '' : fMoney(parseFloat(val), 2, item.ForeignCurrencyCode);
  152. }
  153. },
  154. {
  155. name: "CreateDate", title: 'common.CreateDate', type: "text", align: "center", width: 150, sorting: false,
  156. itemTemplate: function (val, item) {
  157. return !val ? '' : newDate(val);
  158. }
  159. }
  160. ],
  161. controller: {
  162. loadData: function (args) {
  163. return fnGet();
  164. }
  165. },
  166. onInit: function (args) {
  167. oGrid = args.grid;
  168. }
  169. });
  170. });
  171. };
  172. init();
  173. };
  174. require(['base', 'jsgrid', 'util'], fnPageInit);