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.

200 lines
7.3 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. sEditPrgId = getEditPrgId(),
  4. oGrid = null,
  5. fnPageInit = function () {
  6. var saContactorList = [],
  7. oForm = $('#form_main'),
  8. oBaseQueryPm = {
  9. pageIndex: 1,
  10. pageSize: parent.SysSet.GridRecords || 10,
  11. sortField: 'SN',
  12. sortOrder: 'desc'
  13. },
  14. /**
  15. * 獲取資料
  16. * @param {Object} args 查詢參數
  17. * @return {Object} Ajax 物件
  18. */
  19. fnGet = function (args) {
  20. var oQueryPm = getFormSerialize(oForm);
  21. $.extend(oQueryPm, oBaseQueryPm, args);
  22. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  23. return g_api.ConnectLite(sProgramId, ComFn.GetPage, oQueryPm, function (res) {
  24. if (res.RESULT) {
  25. var oRes = res.DATA.rel;
  26. if (args.Excel) {//匯出
  27. DownLoadFile(oRes);
  28. layer.close(args.Index);
  29. }
  30. }
  31. });
  32. },
  33. /**
  34. * 打開要匯出的pop選擇匯出類別
  35. */
  36. fnOpenPopToExcel = function () {
  37. layer.confirm("確定要匯出嗎?", { icon: 3, title: i18next.t('common.Tips') }, function (index) {
  38. fnGet({
  39. Excel: true,
  40. Index: index
  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. 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. parent.openPageTab(sEditPrgId, '?Action=Add');
  70. break;
  71. case "Toolbar_Upd":
  72. break;
  73. case "Toolbar_Copy":
  74. break;
  75. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  76. break;
  77. case "Toolbar_Exp":
  78. if (oGrid.data.length === 0) {
  79. showMsg(i18next.t("message.NoDataExport"));// ╠message.NoDataExport⇒沒有資料匯出╣
  80. return false;
  81. }
  82. fnOpenPopToExcel();
  83. break;
  84. default:
  85. alert("No handle '" + sId + "'");
  86. break;
  87. }
  88. },
  89. /**
  90. * 初始化 function
  91. */
  92. init = function () {
  93. commonInit({
  94. PrgId: sProgramId,
  95. ButtonHandler: fnButtonHandler,
  96. SearchBar: true
  97. });
  98. $.whenArray([
  99. fnSetUserDrop([
  100. {
  101. Select: $('#CreateUser'),
  102. Select2: true,
  103. ShowId: true
  104. }
  105. ])
  106. ])
  107. .done(function () {
  108. reSetQueryPm(sProgramId);
  109. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  110. $("#jsGrid").jsGrid({
  111. width: "100%",
  112. height: iHeight + "px",
  113. autoload: true,
  114. pageLoading: true,
  115. sorting: true,
  116. paging: true,
  117. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  118. pageSize: parent.SysSet.GridRecords || 10,
  119. pageButtonCount: parent.SysSet.GridPages || 15,
  120. pagePrevText: "<",
  121. pageNextText: ">",
  122. pageFirstText: "<<",
  123. pageLastText: ">>",
  124. onPageChanged: function (args) {
  125. cacheQueryCondition(args.pageIndex);
  126. },
  127. rowClick: function (args) {
  128. if (navigator.userAgent.match(/mobile/i)) {
  129. goToEdit(sEditPrgId, '?Action=Upd&SN=' + args.item.SN);
  130. }
  131. },
  132. rowDoubleClick: function (args) {
  133. parent.openPageTab(sEditPrgId, '?Action=Upd&SN=' + args.item.SN);
  134. },
  135. fields: [
  136. {
  137. name: "RowIndex", title: 'common.RowNumber', type: "text", width: 30, align: "center", sorting: false
  138. },
  139. {
  140. name: "CaseName", title: '滿意度案件名稱', type: "text", width: 60
  141. },
  142. {
  143. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 180
  144. },
  145. {
  146. name: "ExhibitionDateStart", title: 'Exhibition_Upd.ExhibitionDateRange', type: "text", align: "center", width: 150, itemTemplate: function (val, item) {
  147. var sDateRange = newDate(item.ExhibitionDateStart, 'date', true) + '~' + newDate(item.ExhibitionDateEnd, 'date', true);
  148. return sDateRange === '~' ? '' : sDateRange;
  149. }
  150. },
  151. {
  152. name: "CreateUser", title: 'common.CreateUser', type: "text", width: 70
  153. },
  154. {
  155. name: "CreateDate", title: 'common.CreateDate', type: "text", align: "center", width: 100, itemTemplate: function (val, item) {
  156. if(val != null){
  157. return newDate(val);
  158. }
  159. }
  160. },
  161. {
  162. name: "ModifyDate", title: 'common.ModifyDate', type: "text", align: "center", width: 100, itemTemplate: function (val, item) {
  163. if(val != null){
  164. return newDate(val);
  165. }
  166. }
  167. }
  168. ],
  169. controller: {
  170. loadData: function (args) {
  171. return fnGet(args);
  172. }
  173. },
  174. onInit: function (args) {
  175. oGrid = args.grid;
  176. }
  177. });
  178. });
  179. };
  180. init();
  181. };
  182. require(['base', 'select2', 'jsgrid', 'util'], fnPageInit);