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.

204 lines
10 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: 'ModifyDate',
  10. sortOrder: 'desc'
  11. },
  12. /**
  13. * 獲取資料
  14. * @param {Object} args 查詢條件參數
  15. * @return {Object} Ajax 物件
  16. */
  17. fnGetPro = function (args) {
  18. var oQueryPm = getFormSerialize(oForm);
  19. oQueryPm.BillStatus = !oQueryPm.BillStatus ? '' : oQueryPm.BillStatus.join(',');
  20. $.extend(oQueryPm, oBaseQueryPm, args);
  21. oBaseQueryPm.pageIndex = oQueryPm.pageIndex;
  22. return g_api.ConnectLite(sProgramId, 'QueryPage', oQueryPm, function (res) {
  23. var oRes = res.DATA.rel;
  24. $.each(oRes.DataList, function (index, item) {
  25. item.RowNumber = index + 1;
  26. });
  27. });
  28. },
  29. /**
  30. * ToolBar 按鈕事件 function
  31. * @param {Object}inst 按鈕物件對象
  32. * @param {Object} e 事件對象
  33. */
  34. fnButtonHandler = function (inst, e) {
  35. var sId = inst.id;
  36. switch (sId) {
  37. case "Toolbar_Qry":
  38. var iNum = $('#PerPageNum').val();
  39. oGrid.pageSize = iNum === '' ? parent.SysSet.GridRecords || 10 : iNum;
  40. cacheQueryCondition();
  41. oGrid.openPage(window.bToFirstPage ? 1 : oBaseQueryPm.pageIndex);
  42. break;
  43. case "Toolbar_Save":
  44. break;
  45. case "Toolbar_ReAdd":
  46. break;
  47. case "Toolbar_Clear":
  48. clearPageVal();
  49. break;
  50. case "Toolbar_Leave":
  51. break;
  52. case "Toolbar_Add":
  53. break;
  54. case "Toolbar_Upd":
  55. break;
  56. case "Toolbar_Copy":
  57. break;
  58. case "Toolbar_Del":
  59. break;
  60. default:
  61. alert("No handle '" + sId + "'");
  62. break;
  63. }
  64. },
  65. /**
  66. * 頁面初始化
  67. */
  68. init = function () {
  69. commonInit({
  70. PrgId: 'BillChangeLog_Qry',
  71. ButtonHandler: fnButtonHandler,
  72. SearchBar: true
  73. });
  74. fnSetUserDrop([
  75. {
  76. Select: $('#ResponsiblePerson'),
  77. Select2: true,
  78. ShowId: true,
  79. CallBack: function (data) {
  80. var iHeight = $('body').height() - $('.page-title').height() - $('#searchbar').height() - 87;
  81. $("#jsGrid").jsGrid({
  82. width: "100%",
  83. height: iHeight + "px",
  84. autoload: true,
  85. pageLoading: true,
  86. inserting: false,
  87. editing: false,
  88. sorting: true,
  89. paging: true,
  90. pageIndex: window.bToFirstPage ? 1 : window.QueryPageidx || 1,
  91. pageSize: parent.SysSet.GridRecords || 10,
  92. pageButtonCount: parent.SysSet.GridPages || 15,
  93. confirmDeleting: true,
  94. pagePrevText: "<",
  95. pageNextText: ">",
  96. pageFirstText: "<<",
  97. pageLastText: ">>",
  98. rowClass: function (item) {
  99. var sClass = '';
  100. if (item.AuditVal === '6') {
  101. sClass = 'data-void';
  102. }
  103. return sClass;
  104. },
  105. onPageChanged: function (args) {
  106. cacheQueryCondition(args.pageIndex);
  107. },
  108. fields: [
  109. { name: "RowNumber", title: 'common.RowNumber', align: "center", type: "text", width: 60, sorting: false },
  110. {
  111. name: "BillNO", title: 'common.BillNO', align: "left", type: "text", width: 80
  112. },
  113. {
  114. name: "ExhibitioName", title: 'common.ExhibitionName', align: "left", type: "text", width: 150
  115. },
  116. {
  117. name: "PayerName", title: 'ExhibitionImport_Upd.Payer', align: "left", type: "text", width: 160
  118. },
  119. {
  120. name: "ResponsiblePersonName", title: 'common.ResponsiblePerson', align: "left", type: "text", width: 50
  121. },
  122. {
  123. name: "Currency", title: 'common.Financial_Currency', align: "left", type: "text", width: 40
  124. },
  125. {
  126. name: "ExchangeRate", title: 'common.ExchangeRate', align: "left", type: "text", width: 50
  127. },
  128. {
  129. name: "Advance", title: 'common.Financial_Advance', align: "right", type: "text", width: 50,
  130. itemTemplate: function (val, item) {
  131. return !val ? '' : fMoney(parseFloat(val.replaceAll(',', '')), 2, item.ForeignCurrencyCode);
  132. }
  133. },
  134. {// ╠common.NOTaxAmount⇒未稅金額╣
  135. name: "AmountSum", title: 'common.NOTaxAmount', align: "right", type: "text", width: 60,
  136. itemTemplate: function (val, item) {
  137. return !val ? '' : fMoney(parseFloat(val.replaceAll(',', '')), 2, item.ForeignCurrencyCode);
  138. }
  139. },
  140. {
  141. name: "TaxSum", title: 'common.TaxAmount', align: "right", type: "text", width: 70,
  142. itemTemplate: function (val, item) {
  143. return !val ? '' : fMoney(parseFloat(val.replaceAll(',', '')), 2, item.ForeignCurrencyCode);
  144. }
  145. },
  146. {// ╠common.Financial_Sum⇒合計╣
  147. name: "AmountTaxSum", title: 'common.Financial_Sum', align: "right", type: "text", width: 70,
  148. itemTemplate: function (val, item) {
  149. return !val ? '' : fMoney(parseFloat(val.replaceAll(',', '')), 2, item.ForeignCurrencyCode);
  150. }
  151. },
  152. {// ╠common.TotalReceivable⇒總應收╣
  153. name: "TotalReceivable", title: 'common.TotalReceivable', align: "right", type: "text", width: 70,
  154. itemTemplate: function (val, item) {
  155. return !val ? '' : fMoney(parseFloat(val.replaceAll(',', '')), 2, item.ForeignCurrencyCode);
  156. }
  157. },
  158. {
  159. name: "OpmBillCreateUserName", title: 'common.CreateUser', align: "left", type: "text", width: 50
  160. },
  161. {
  162. name: "Operation", title: 'common.Operation', type: "text", align: "center", width: 60,
  163. },
  164. {
  165. name: "ModifyDate", title: 'common.ModifyDateTime', type: "text", align: "center", width: 70,
  166. itemTemplate: function (val, item) {
  167. var rDate = !val ? item.ModifyDate : val;
  168. return newDate(rDate);
  169. }
  170. },
  171. {
  172. name: "ModifyUser", title: 'common.ModifyUser', type: "text", align: "center", width: 50
  173. }
  174. ],
  175. controller: {
  176. loadData: function (args) {
  177. return fnGetPro(args);
  178. }
  179. },
  180. onInit: function (args) {
  181. oGrid = args.grid;
  182. }
  183. });
  184. }
  185. }
  186. ]);
  187. };
  188. init();
  189. };
  190. require(['base', 'select2', 'jsgrid', 'util'], fnPageInit);