123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- app.controller('expiredSimListCtrl', ['$scope', '$http', "$state", '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $http, $state, $timeout, uiGridConstants, i18nService, toaster) {
- i18nService.setCurrentLang("zh-cn");
- moment.locale('zh-cn');
- $scope.startTimeOpen = false;
- $scope.endTimeOpen = false;
- $scope.timeChange = function (newDate, oldDate) {
- $scope.startTimeOpen = false;
- $scope.endTimeOpen = false;
- };
- $scope.gridOptions = {
- data: 'myData',
- showGridFooter: true, //是否显示grid footer
- //-------- 分页属性 ----------------
- paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
- paginationCurrentPage: 1, //当前页码
- paginationPageSize: 10, //每页显示个数
- totalItems: 0,// 总数量
- useExternalPagination: true,//是否使用分页按钮
- //过滤
- // enableFiltering: true,
- columnDefs: [],
- //---------------api---------------------
- onRegisterApi: function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- if ($scope.setPagingData) {
- $scope.getPagedDataAsync(newPage, pageSize);
- }
- });
- }
- };
- //枚举常量
- $scope.enum = {
- simCardSource: [
- {name: '选择卡商', value: ''},
- {name: '合宙', value: 'hezhou'},
- {name: '齐犇', value: 'qiben'},
- {name: '揭阳', value: 'jieyang'},
- ],
- simCardStatus: [
- {name: '选择卡状态', value: ''},
- {name: '已充值待更新', value: 'chargedUnUpdated'},
- {name: '正常', value: 'normal'},
- ],
- searchType: [
- {name: '按ICCID搜索', value: 'ICCID'},
- {name: '按IMSI搜索', value: 'IMSI'},
- ]
- };
- //查询条件
- $scope.query = {
- simCardSource: {name: '选择卡商', value: ''},
- searchType: {name: '按ICCID搜索', value: 'ICCID'},
- startTime: moment().format("YYYY-MM-DD 00:00"),
- endTime: moment().format("YYYY-MM-DD 23:59"),
- searchKey: "",
- };
- $scope.ngEvent = {
- quickTime: function (event, passDay) {
- $scope.query.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD 00:00");
- $scope.query.endTime = moment().format("YYYY-MM-DD 23:59");
- },
- //查询
- query: function () {
- if ($scope.query.startTime > $scope.query.endTime) {
- toaster.pop("info", "提示", "开始时间必须小于结束时间!");
- return;
- }
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- },
- exportExcelOpen: false,
- //导出
- exportExcel: function () {
- var params = {};
- var query = $scope.query;
- params.startTime = query.startTime
- params.endTime = query.endTime
- params.simCardSource = query.simCardSource.value
- params.searchType = query.searchType.value
- params.searchKey = query.searchKey
- if ($scope.ngEvent.exportExcelOpen) {
- toaster.pop("info", "提示", "有一份报表正在生成,请稍候!");
- return;
- } else {
- $scope.ngEvent.exportExcelOpen = true;
- }
- $http.get('/superadmin/exportExpiredSimList', {params: params}).then(function (res) {
- var data = res.data
- $scope.ngEvent.exportExcelOpen = false;
- if (data.result == 1) {
- var payload = data.payload;
- toaster.pop("success", data.description);
- $state.go('app.tool.offlineTask', {
- searchKey: payload
- });
- }
- }).catch(function (data) {
- $scope.ngEvent.exportExcelOpen = false;
- if (data.status == 504) {
- toaster.pop("error", "计算超时,请前往任务->执行离线生成报表");
- } else {
- toaster.pop("error", "系统错误,请重试");
- }
- });
- }
- };
- function setColumnDefs() {
- $scope.gridOptions.columnDefs = [
- {field: 'imsi', displayName: 'IMSI',},
- {field: 'iccid', displayName: 'ICCID',},
- {field: 'simCardSource', displayName: '卡商',},
- {field: 'expireDate', displayName: '过期时间',},
- {field: 'logicalCode', displayName: '设备号'},
- {
- field: 'dealerStr',
- displayName: '经销商',
- cellTemplate: '<div class="temp-row">{{row.entity.dealerStr}}</div>'
- },
- {
- field: 'agentStr',
- displayName: '代理商',
- cellTemplate: '<div class="temp-row">{{row.entity.agentStr }}</div>'
- },
- {
- field: 'managerStr',
- displayName: '厂商',
- cellTemplate: '<div class="temp-row">{{row.entity.managerStr}}</div>'
- },
- ];
- var fields = $scope.gridOptions.columnDefs;
- for (var index in fields) {
- var item = fields[index];
- if (item && item['minWidth'] == null) {
- item['minWidth'] = 100;
- }
- }
- }
- $scope.formatterStatus = function (entity) {
- var status = entity.simCardStatus;
- var list = $scope.enum.simCardStatus;
- var name = "";
- for (var index = 0; index < list.length; index++) {
- var item = list[index];
- if (item.value === status) {
- name = item.name
- }
- }
- return name;
- };
- $scope.setPagingData = function (data) {
- var pagedData = data.data.dataList;
- $scope.myData = pagedData;
- $scope.gridOptions.totalItems = data.data.total;
- };
- $scope.getPagedDataAsync = function (curPage, pageSize) {
- var params = {
- pageSize: pageSize,
- pageIndex: curPage
- };
- var query = $scope.query;
- params.startTime = query.startTime
- params.endTime = query.endTime
- params.simCardSource = query.simCardSource.value
- params.searchType = query.searchType.value
- params.searchKey = query.searchKey
- $http.get('/superadmin/getExpiredSIMRechargeRecord', {
- params: params
- }).then(function (data) {
- data = data.data
- $scope.setPagingData(data, curPage, pageSize);
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据列表失败");
- });
- };
- function initDataGrid() {
- //首次加载表格
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- }
- setColumnDefs();
- initDataGrid();
- // 必须先声明,否则ui-select无法双绑
- $scope.dialogData = {};
- }]);
|