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.

216 lines
9.3 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,CustomerCName',
  10. sortOrder: 'desc'
  11. },
  12. /**
  13. * 獲取資料
  14. * @param args{Object} 查詢條件參數
  15. * @return {Object} Ajax 物件
  16. */
  17. fnGet = function (args) {
  18. var oQueryPm = getFormSerialize(oForm);
  19. oQueryPm.SearchWords = '%' + oQueryPm.SearchWords + '%';
  20. $.extend(oQueryPm, oBaseQueryPm, args);
  21. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  22. return CallAjax(ComFn.W_Com, ComFn.GetPage, {
  23. Params: {
  24. Entity: 'ovw_importcustomers',
  25. OrderFields: oQueryPm.sortField || 'CreateDate',
  26. OrderType: oQueryPm.sortOrder || 'desc',
  27. PageIndex: oQueryPm.pageIndex,
  28. PageSize: oQueryPm.pageSize,
  29. ExhibitionNO: oQueryPm.ExhibitionNO,
  30. _OR_: [
  31. { CustomerCName: oQueryPm.SearchWords },
  32. { Contactor: oQueryPm.SearchWords },
  33. { Telephone: oQueryPm.SearchWords },
  34. { Email: oQueryPm.SearchWords },
  35. { Address: oQueryPm.SearchWords }
  36. ],
  37. OrgID: parent.OrgID
  38. }
  39. });
  40. },
  41. /**
  42. * 資料刪除
  43. * @param {Object} data 表單資料
  44. * @return {Object} Ajax 物件
  45. */
  46. fnDel = function (data) {
  47. return CallAjax(ComFn.W_Com, ComFn.GetDel, {
  48. Params: {
  49. importcustomers: {
  50. guid: data.guid
  51. }
  52. }
  53. }, function (res) {
  54. if (res.d > 0) {
  55. showMsg(i18next.t("message.Delete_Success"), 'success'); // ╠message.Delete_Success⇒刪除成功╣
  56. }
  57. else {
  58. showMsg(i18next.t("message.Delete_Failed"), 'error'); // ╠message.Delete_Failed⇒刪除失敗╣
  59. }
  60. });
  61. },
  62. /**
  63. * ToolBar 按鈕事件 function
  64. * @param {Object}inst 按鈕物件對象
  65. * @param {Object} e 事件對象
  66. */
  67. fnButtonHandler = function (inst, e) {
  68. var sId = inst.id;
  69. switch (sId) {
  70. case "Toolbar_Qry":
  71. var iNum = $('#PerPageNum').val();
  72. oGrid.pageSize = iNum === '' ? parent.SysSet.GridRecords || 10 : iNum;
  73. cacheQueryCondition();
  74. oGrid.openPage(window.bToFirstPage ? 1 : oBaseQueryPm.pageIndex);
  75. break;
  76. case "Toolbar_Save":
  77. break;
  78. case "Toolbar_ReAdd":
  79. break;
  80. case "Toolbar_Clear":
  81. clearPageVal();
  82. break;
  83. case "Toolbar_Leave":
  84. break;
  85. case "Toolbar_Add":
  86. break;
  87. case "Toolbar_Upd":
  88. break;
  89. case "Toolbar_Copy":
  90. break;
  91. case "Toolbar_Del": // ╠message.ConfirmToDelete⇒確定要刪除嗎 ?╣ ╠common.Tips⇒提示╣
  92. break;
  93. case "Toolbar_Exp":
  94. break;
  95. default:
  96. alert("No handle '" + sId + "'");
  97. break;
  98. }
  99. },
  100. /**
  101. * 頁面初始化
  102. */
  103. init = function () {
  104. $.whenArray([
  105. commonInit({
  106. PrgId: sProgramId,
  107. ButtonHandler: fnButtonHandler,
  108. SearchBar: true
  109. }),
  110. fnSetEpoDrop({
  111. Select: $('#ExhibitionNO'),
  112. Select2: true
  113. })
  114. ])
  115. .done(function () {
  116. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  117. $("#jsGrid").jsGrid({
  118. width: "100%",
  119. height: iHeight + "px",
  120. autoload: true,
  121. pageLoading: true,
  122. inserting: false,
  123. editing: false,
  124. sorting: true,
  125. paging: true,
  126. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  127. pageSize: parent.SysSet.GridRecords || 10,
  128. pageButtonCount: parent.SysSet.GridPages || 15,
  129. confirmDeleting: true,
  130. deleteConfirm: "確定要刪除嗎?",
  131. pagePrevText: "<",
  132. pageNextText: ">",
  133. pageFirstText: "<<",
  134. pageLastText: ">>",
  135. onPageChanged: function (args) {
  136. cacheQueryCondition(args.pageIndex);
  137. },
  138. rowClick: function (args) {
  139. },
  140. rowDoubleClick: function (args) {
  141. },
  142. fields: [
  143. {
  144. name: "RowIndex", title: 'common.RowNumber', width: 50, align: "center"
  145. },
  146. {
  147. name: "Exhibitioname_TW", title: 'ExhibitionExport_Upd.ExportBillName', width: 200
  148. },
  149. {
  150. name: "CustomerCName", type: 'text', title: 'Customers_Upd.CustomerCName', width: 200
  151. },
  152. {
  153. name: "Contactor", type: 'text', title: 'common.Contactor', width: 120
  154. },
  155. {
  156. name: "Telephone", type: 'text', title: 'common.Telephone', width: 100
  157. },
  158. {
  159. name: "Email", type: 'text', title: 'common.Email', width: 120
  160. },
  161. {
  162. name: "Address", type: 'text', title: 'common.Address', width: 200
  163. },
  164. {// ╠common.IsAppoint⇒預約狀態╣
  165. name: "IsAppoint", title: 'common.IsAppoint', width: 100, align: "center",
  166. itemTemplate: function (val, item) {
  167. return val == 'Y' ? $('<span />', { text: i18next.t('common.HasAppoint') }).css('color', 'green') : $('<span />', { text: i18next.t('common.NotAppoint') }).css('color', 'red');// ╠common.HasAppoint⇒已預約╣ ╠common.NotAppoint⇒未預約╣
  168. }
  169. },
  170. {// ╠common.IsFormal⇒資料狀態╣
  171. name: "IsFormal", title: 'common.IsFormal', width: 100, align: "center",
  172. itemTemplate: function (val, item) {
  173. return val ? $('<span />', { text: i18next.t('common.HasFormal') }).css('color', 'green') : $('<span />', { text: i18next.t('common.NotFormal') }).css('color', 'red');
  174. }
  175. }
  176. ],
  177. controller: {
  178. loadData: function (args) {
  179. return fnGet(args);
  180. },
  181. insertItem: function (args) {
  182. },
  183. updateItem: function (args) {
  184. fnUpd(args);
  185. },
  186. deleteItem: function (args) {
  187. return fnDel(args);
  188. }
  189. },
  190. onInit: function (args) {
  191. oGrid = args.grid;
  192. }
  193. });
  194. });
  195. };
  196. init();
  197. };
  198. require(['base', 'select2', 'jsgrid', 'util'], fnPageInit);