simList.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. app.controller('simListCtrl', ['$scope', '$http', "$state", '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $http, $state, $timeout, uiGridConstants, i18nService, toaster) {
  2. i18nService.setCurrentLang("zh-cn");
  3. moment.locale('zh-cn');
  4. $scope.startTimeOpen = false;
  5. $scope.endTimeOpen = false;
  6. $scope.timeChange = function (newDate, oldDate) {
  7. $scope.startTimeOpen = false;
  8. $scope.endTimeOpen = false;
  9. };
  10. $scope.gridOptions = {
  11. data: 'myData',
  12. showGridFooter: true, //是否显示grid footer
  13. //-------- 分页属性 ----------------
  14. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  15. paginationCurrentPage: 1, //当前页码
  16. paginationPageSize: 10, //每页显示个数
  17. totalItems: 0,// 总数量
  18. useExternalPagination: true,//是否使用分页按钮
  19. //过滤
  20. // enableFiltering: true,
  21. columnDefs: [],
  22. //---------------api---------------------
  23. onRegisterApi: function (gridApi) {
  24. $scope.gridApi = gridApi;
  25. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  26. if ($scope.setPagingData) {
  27. $scope.getPagedDataAsync(newPage, pageSize);
  28. }
  29. });
  30. }
  31. };
  32. //枚举常量
  33. $scope.enum = {
  34. simCardSource: [
  35. {name: '选择卡商', value: ''},
  36. {name: '合宙', value: 'hezhou'},
  37. {name: '齐犇', value: 'qiben'},
  38. {name: '揭阳', value: 'jieyang'},
  39. ],
  40. simCardStatus: [
  41. {name: '选择卡状态', value: ''},
  42. {name: '已充值待更新', value: 'chargedUnUpdated'},
  43. {name: '正常', value: 'normal'},
  44. ],
  45. searchType: [
  46. {name: '按ICCID搜索', value: 'ICCID'},
  47. {name: '按IMSI搜索', value: 'IMSI'},
  48. ]
  49. };
  50. //查询条件
  51. $scope.query = {
  52. simCardSource: {name: '选择卡商', value: ''},
  53. searchType: {name: '按ICCID搜索', value: 'ICCID'},
  54. startTime: moment().format("YYYY-MM-DD"),
  55. endTime: moment().format("YYYY-MM-DD"),
  56. searchKey: "",
  57. };
  58. $scope.ngEvent = {
  59. quickTime: function (event, passDay) {
  60. $scope.query.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD");
  61. $scope.query.endTime = moment().format("YYYY-MM-DD");
  62. },
  63. //查询
  64. query: function () {
  65. if ($scope.query.startTime > $scope.query.endTime) {
  66. toaster.pop("info", "提示", "开始时间必须小于结束时间!");
  67. return;
  68. }
  69. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  70. },
  71. exportExcelOpen: false,
  72. //导出
  73. exportExcel: function () {
  74. var params = {};
  75. var query = $scope.query;
  76. params.startTime = query.startTime
  77. params.endTime = query.endTime
  78. params.simCardSource = query.simCardSource.value
  79. params.searchType = query.searchType.value
  80. params.searchKey = query.searchKey
  81. if ($scope.ngEvent.exportExcelOpen) {
  82. toaster.pop("info", "提示", "有一份报表正在生成,请稍候!");
  83. return;
  84. } else {
  85. $scope.ngEvent.exportExcelOpen = true;
  86. }
  87. $http.get('/superadmin/exportExcel', {params: params}).then(function (res) {
  88. var data = res.data
  89. $scope.ngEvent.exportExcelOpen = false;
  90. if (data.result == 1) {
  91. var payload = data.payload;
  92. toaster.pop("success", data.description);
  93. $state.go('app.tool.offlineTask', {
  94. searchKey: payload
  95. });
  96. }
  97. }).catch(function (data) {
  98. $scope.ngEvent.exportExcelOpen = false;
  99. if (data.status == 504) {
  100. toaster.pop("error", "计算超时,请前往任务->执行离线生成报表");
  101. } else {
  102. toaster.pop("error", "系统错误,请重试");
  103. }
  104. });
  105. }
  106. };
  107. function setColumnDefs() {
  108. $scope.gridOptions.columnDefs = [
  109. {field: 'imsi', displayName: 'IMSI',},
  110. {field: 'iccid', displayName: 'ICCID',},
  111. {field: 'simCardBrand', displayName: '卡商',},
  112. {field: 'expireDate', displayName: '过期时间',},
  113. {field: 'logicalCode', displayName: '设备号'},
  114. {
  115. field: 'dealerStr',
  116. displayName: '经销商',
  117. cellTemplate: '<div class="temp-row">{{row.entity.dealerStr}}</div>'
  118. },
  119. {
  120. field: 'agentStr',
  121. displayName: '代理商',
  122. cellTemplate: '<div class="temp-row">{{row.entity.agentStr }}</div>'
  123. },
  124. {
  125. field: 'managerStr',
  126. displayName: '厂商',
  127. cellTemplate: '<div class="temp-row">{{row.entity.managerStr}}</div>'
  128. },
  129. ];
  130. var fields = $scope.gridOptions.columnDefs;
  131. for (var index in fields) {
  132. var item = fields[index];
  133. if (item && item['minWidth'] == null) {
  134. item['minWidth'] = 100;
  135. }
  136. }
  137. }
  138. $scope.formatterStatus = function (entity) {
  139. var status = entity.simCardStatus;
  140. var list = $scope.enum.simCardStatus;
  141. var name = "";
  142. for (var index = 0; index < list.length; index++) {
  143. var item = list[index];
  144. if (item.value === status) {
  145. name = item.name
  146. }
  147. }
  148. return name;
  149. };
  150. $scope.setPagingData = function (data) {
  151. var pagedData = data.data.dataList;
  152. $scope.myData = pagedData;
  153. $scope.gridOptions.totalItems = data.data.total;
  154. };
  155. $scope.getPagedDataAsync = function (curPage, pageSize) {
  156. var params = {
  157. pageSize: pageSize,
  158. pageIndex: curPage
  159. };
  160. var query = $scope.query;
  161. params.startTime = query.startTime
  162. params.endTime = query.endTime
  163. params.simCardSource = query.simCardSource.value
  164. params.searchType = query.searchType.value
  165. params.searchKey = query.searchKey
  166. $http.get('/superadmin/getSimCardList', {
  167. params: params
  168. }).then(function (data) {
  169. data = data.data
  170. $scope.setPagingData(data, curPage, pageSize);
  171. }).catch(function (data) {
  172. toaster.pop("error", "提示", "获取数据列表失败");
  173. });
  174. };
  175. function initDataGrid() {
  176. //首次加载表格
  177. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  178. }
  179. setColumnDefs();
  180. initDataGrid();
  181. // 必须先声明,否则ui-select无法双绑
  182. $scope.dialogData = {};
  183. }]);