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.

150 lines
5.8 KiB

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