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.

178 lines
7.4 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sEditPrgId = getEditPrgId(),
  4. oGrid = null,
  5. fnPageInit = function () {
  6. var oForm = $('#form_main'),
  7. oBaseQueryPm = {
  8. pageIndex: 1,
  9. pageSize: parent.SysSet.GridRecords || 10,
  10. sortField: 'CreateDate',
  11. sortOrder: 'desc'
  12. },
  13. /**
  14. * 獲取資料
  15. * @param {Object} args 查詢條件參數
  16. * @return {Object} Ajax 物件
  17. */
  18. fnGet = function (args) {
  19. var oQueryPm = {},
  20. oQuery = getFormSerialize(oForm),
  21. sSearchWords = '%' + oQuery.SearchWords + '%',
  22. sQueryTimeStart = oQuery.QueryTimeStart,
  23. sQueryTimeEnd = oQuery.QueryTimeEnd;
  24. $.extend(oQueryPm, oBaseQueryPm, args);
  25. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  26. return CallAjax(ComFn.W_Com, ComFn.GetPage, {
  27. Params: {
  28. Entity: 'exhibitionrules',
  29. OrderFields: oQueryPm.sortField || 'CreateDate',
  30. OrderType: oQueryPm.sortOrder || 'desc',
  31. PageIndex: oQueryPm.pageIndex,
  32. PageSize: oQueryPm.pageSize,
  33. _OR_: [{ Title: sSearchWords }, { CostRules: sSearchWords }, { CostInstruction: sSearchWords }, { Memo: sSearchWords }],
  34. _AND_: [{ key: 'CreateDate', name: 'QueryTimeStart', value: sQueryTimeStart === '' ? '' : '>>=' + sQueryTimeStart }
  35. , { key: 'CreateDate', name: 'QueryTimeEnd', value: sQueryTimeEnd === '' ? '' : '<<=' + sQueryTimeEnd + ' 23:59:59' }],
  36. OrgID: parent.OrgID
  37. }
  38. });
  39. },
  40. /**
  41. * ToolBar 按鈕事件 function
  42. * @param {Object}inst 按鈕物件對象
  43. * @param {Object} e 事件對象
  44. */
  45. fnButtonHandler = function (inst, e) {
  46. var sId = inst.id;
  47. switch (sId) {
  48. case "Toolbar_Qry":
  49. var iNum = $('#PerPageNum').val();
  50. oGrid.pageSize = iNum === '' ? parent.SysSet.GridRecords || 10 : iNum;
  51. cacheQueryCondition();
  52. oGrid.openPage(window.bToFirstPage ? 1 : oBaseQueryPm.pageIndex);
  53. break;
  54. case "Toolbar_Save":
  55. break;
  56. case "Toolbar_ReAdd":
  57. break;
  58. case "Toolbar_Clear":
  59. clearPageVal();
  60. break;
  61. case "Toolbar_Leave":
  62. break;
  63. case "Toolbar_Add":
  64. parent.openPageTab(sEditPrgId, '?Action=Add');
  65. break;
  66. case "Toolbar_Upd":
  67. break;
  68. case "Toolbar_Copy":
  69. break;
  70. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  71. break;
  72. case "Toolbar_Exp":
  73. break;
  74. default:
  75. alert("No handle '" + sId + "'");
  76. break;
  77. }
  78. },
  79. /**
  80. * 頁面初始化
  81. */
  82. init = function () {
  83. commonInit({
  84. PrgId: sProgramId,
  85. ButtonHandler: fnButtonHandler,
  86. SearchBar: true
  87. }).done(function () {
  88. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  89. $("#jsGrid").jsGrid({
  90. width: "100%",
  91. height: iHeight + "px",
  92. autoload: true,
  93. pageLoading: true,
  94. inserting: false,
  95. editing: false,
  96. sorting: true,
  97. paging: true,
  98. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  99. pageSize: parent.SysSet.GridRecords || 10,
  100. pageButtonCount: parent.SysSet.GridPages || 15,
  101. pagePrevText: "<",
  102. pageNextText: ">",
  103. pageFirstText: "<<",
  104. pageLastText: ">>",
  105. onPageChanged: function (args) {
  106. cacheQueryCondition(args.pageIndex);
  107. },
  108. rowClick: function (args) {
  109. if (navigator.userAgent.match(/mobile/i)) {
  110. goToEdit(sEditPrgId, '?Action=Upd&Guid=' + args.item.Guid);
  111. }
  112. },
  113. rowDoubleClick: function (args) {
  114. parent.openPageTab(sEditPrgId, '?Action=Upd&Guid=' + args.item.Guid);
  115. },
  116. fields: [
  117. { name: "RowIndex", title: 'common.RowNumber', align: "center", type: "text", width: 50, sorting: false },
  118. {
  119. name: "Title", title: 'common.Title', type: "text", width: 200
  120. },
  121. {
  122. name: "PackingPrice", title: 'common.PackingPrice', align: "right", type: "text", width: 150,
  123. itemTemplate: function (val, item) {
  124. return fMoney(val, 2, 'NTD');
  125. }
  126. },
  127. {
  128. name: "FeedingPrice", title: 'common.FeedingAndStoragePrice', align: "right", type: "text", width: 150,
  129. itemTemplate: function (val, item) {
  130. return fMoney(val, 2, 'NTD');
  131. }
  132. },
  133. {
  134. name: "Memo", title: 'common.Memo', type: "text", width: 200,
  135. itemTemplate: function (val, item) {
  136. return val.length > 266 ? val.substr(0, 266) + '...' : val;
  137. }
  138. },
  139. {
  140. name: "CreateDate", title: 'common.CreateDate', type: "text", align: "center", width: 100,
  141. itemTemplate: function (val, item) {
  142. return newDate(val);
  143. }
  144. }
  145. ],
  146. controller: {
  147. loadData: function (args) {
  148. return fnGet(args);
  149. }
  150. },
  151. onInit: function (args) {
  152. oGrid = args.grid;
  153. }
  154. });
  155. });
  156. };
  157. init();
  158. };
  159. require(['base', 'jsgrid', 'util'], fnPageInit);