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
6.8 KiB

2 years ago
  1. 'use strict';
  2. var sProgramId = getProgramId(),
  3. oGrid = null,
  4. fnPageInit = function () {
  5. var canDo = new CanDo({
  6. sortField: 'QueryTime',
  7. sortOrder: 'desc',
  8. /**
  9. * 當前程式所有ID名稱集合
  10. */
  11. idKeys: ['NO'],
  12. /**
  13. * Grid欄位設置可以是 function
  14. */
  15. gridFields: function () {
  16. var saFeilds = [
  17. { name: "RowIndex", title: 'common.RowNumber', align: "center", type: "text", width: 50, sorting: false },
  18. {
  19. name: "QueryNumber", title: 'common.QueryNumber', type: "text", align: "center", width: 100
  20. },
  21. {
  22. name: "Exhibitioname_TW", title: 'Exhibition_Upd.Exhibitioname_TW', type: "text", width: 200
  23. },
  24. {
  25. name: "Exhibitioname_EN", title: 'ExhibitionImport_Upd.ImportBillEName', type: "text", width: 200
  26. },
  27. {
  28. name: "AgentName", title: 'ExhibitionImport_Upd.Agent', type: "text", width: 200
  29. },
  30. {
  31. name: "CustomerName", title: 'ExhibitionImport_Upd.Supplier', type: "text", width: 200
  32. },
  33. {
  34. name: "QueryIp", title: 'IP', type: "text", width: 120, align: "center"
  35. },
  36. {// ╠common.IPAddress⇒IP地址信息╣
  37. name: "IPInfo", title: 'common.IPAddress', type: "text", width: 150,
  38. itemTemplate: function (val, item) {
  39. if (val) {
  40. var oIPInfo = $.parseJSON(val);
  41. return traditionalized((oIPInfo.country || '') + ' ' + (oIPInfo.area || '') + ' ' + (oIPInfo.region || '') + ' ' + (oIPInfo.city || ''));
  42. }
  43. else {
  44. return '';
  45. }
  46. }
  47. },
  48. {
  49. name: "QueryTime", title: 'common.QueryTime', type: "text", align: "center", width: 100,
  50. itemTemplate: function (val, item) {
  51. return newDate(val);
  52. }
  53. }
  54. ];
  55. if (parent.UserInfo.roles.indexOf(parent.SysSet.Supervisor) > -1) {
  56. saFeilds.push({ type: "control", title: 'common.Action', editButton: false });
  57. }
  58. return saFeilds;
  59. },
  60. /**
  61. * 查詢后事件
  62. * @param {Object} pargs CanDo 對象
  63. */
  64. rowClick: function (pargs, args) {
  65. if (navigator.userAgent.match(/mobile/i)) {
  66. var sEditPrgId = 'ExhibitionImport_Upd',
  67. sActionId = 'ImportBillNO';
  68. if (args.item.QueryNumber.indexOf('CTEE') > -1) {
  69. sEditPrgId = 'ExhibitionExport_Upd';
  70. sActionId = 'ExportBillNO';
  71. }
  72. pargs._goToEdit(sEditPrgId, '?Action=Upd&' + sActionId + '=' + args.item.ParentId);
  73. }
  74. },
  75. /**
  76. * 查詢后事件
  77. * @param {Object} pargs CanDo 對象
  78. */
  79. rowDoubleClick: function (pargs, args) {
  80. var sEditPrgId = 'ExhibitionImport_Upd',
  81. sActionId = 'ImportBillNO';
  82. if (args.item.QueryNumber.indexOf('CTEE') > -1) {
  83. sEditPrgId = 'ExhibitionExport_Upd';
  84. sActionId = 'ExportBillNO';
  85. }
  86. parent.openPageTab(sEditPrgId, '?Action=Upd&' + sActionId + '=' + args.item.ParentId);
  87. },
  88. /**
  89. * 查詢后事件
  90. * @param {Object} pargs CanDo 對象
  91. */
  92. afterQuery: function (pargs) {
  93. if ($('#QueryNumber').val()) {
  94. $('.countinfo').show();
  95. fnGetGroupInfo();
  96. }
  97. else {
  98. $('.countinfo').hide();
  99. $('.list-unstyled,.counter').html('');
  100. }
  101. },
  102. /**
  103. * 頁面初始化
  104. * @param {Object} pargs CanDo 對象
  105. */
  106. pageInit: function (pargs) {
  107. fnSetDeptDrop($('#DepartmentID'), parent.SysSet.SearchDeptList).done(function () {
  108. pargs._reSetQueryPm();
  109. pargs._initGrid();
  110. });
  111. }
  112. }),
  113. /**
  114. * 獲取分佈資料
  115. * @param {Object} args 查詢條件參數
  116. */
  117. fnGetGroupInfo = function () {
  118. var oQueryPm = canDo._getFormSerialize();
  119. g_api.ConnectLite(canDo.ProgramId, 'GetGroupInfo', oQueryPm, function (res) {
  120. if (res.RESULT) {
  121. var sGroupInfo = '',
  122. iTotal = 0;
  123. if (res.DATA.rel.length > 0) {
  124. $.each(res.DATA.rel, function (idx, info) {
  125. var oIPInfo = $.parseJSON(info.IPInfo || '{}'),
  126. sCounry = traditionalized((oIPInfo.country || '') + ' ' + (oIPInfo.area || '') + ' ' + (oIPInfo.region || '') + ' ' + (oIPInfo.city || ''));
  127. sGroupInfo += '<li>\
  128. <div class="server-load">\
  129. <div class="server-stat">\
  130. <p>' + info.QueryIp + '</p>\
  131. </div>\
  132. <div class="server-stat">\
  133. <p>' + sCounry + '</p>\
  134. </div>\
  135. <div class="server-stat">\
  136. <p>' + info.Count + '</p>\
  137. </div>\
  138. </div>\
  139. </li>';
  140. iTotal += info.Count;
  141. });
  142. }
  143. $('.list-unstyled').html(sGroupInfo);
  144. $('.counter').html(iTotal.toString().toMoney());
  145. }
  146. });
  147. };
  148. };
  149. require(['base', 'jsgrid', 'convetlng', 'cando'], fnPageInit);