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.

176 lines
7.2 KiB

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