app.controller('endUserManageCtrl', ['$scope', '$http', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $http, $timeout, uiGridConstants, i18nService, toaster) { i18nService.setCurrentLang("zh-cn"); $scope.gridOptions = { data: 'myData', showGridFooter: true, //是否显示grid footer // rowHeight: 80, //-------- 分页属性 ---------------- 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); } }); } }; //查询条件 var condition = $scope.condition = { searchKey: "" }; //枚举常量 $scope.enum = { sex: [ {value: 0, label: "无"}, {value: 1, label: "男"}, {value: 2, label: "女"} ] }; //事件 $scope.event = { search: function () { $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize); } }; function setColumnDefs() { $scope.gridOptions.columnDefs = [ {field: 'nickname', displayName: '用户昵称'}, {field: 'openId', displayName: 'openId'}, { field: 'gateway', displayName: '用户来源', cellTemplate: '
{{row.entity.gateway}}
' }, { field: 'sex', displayName: '性别', filter: { term: '', type: uiGridConstants.filter.SELECT, selectOptions: $scope.enum.sex }, cellTemplate: '
{{grid.appScope.formatterSex(row.entity.sex)}}
' }, { field: 'country', displayName: '国家' }, { field: 'province', displayName: '省份' }, { field: 'city', displayName: '城市' }, { field: 'balance', displayName: '余额' }, { field: 'groupName', displayName: '地址名称' }, { field: 'oper', displayName: '操作', enableFiltering: false, enableSorting: false, enableHiding: false,//禁止在列选择器中隐藏 enableColumnMenu: false,// 是否显示列头部菜单按钮 width: 200, cellTemplate: '
' + '' + '' + '
' } ]; var fields = $scope.gridOptions.columnDefs; for (var index in fields) { var item = fields[index]; if (item && item['minWidth'] == null) { item['minWidth'] = 100; } } } //表格地址转换 $scope.formatterSex = function (sex) { var sexList = $scope.enum.sex; for (var index in sexList) { var item = sexList[index]; if (item.value == sex) { return item.label; } } }; $scope.setPagingData = function (data, curPage, pageSize) { var firstRow = (curPage - 1) * pageSize; var pagedData = data.data.dataList; $scope.myData = pagedData; $scope.gridOptions.totalItems = data.data.total; }; $scope.getPagedDataAsync = function (curPage, pageSize, searchText) { var params = { pageSize: pageSize, pageIndex: curPage }; if (condition.searchKey != "") { params.searchKey = condition.searchKey } $http.get('/user/getEndUserDetailList', { params: params }).then(function (data) { $scope.setPagingData(data.data, curPage, pageSize); }).catch(function (data) { toaster.pop("error", "提示", "获取数据列表失败"); }); }; function initDataGrid() { //首次加载表格 $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); } setColumnDefs(); initDataGrid(); //展示详情 $scope.showInfoDetail = function (title, content) { $scope.infoDetail = {title: title, content: JSON.parse(content)}; $("#detailInfoPanel").modal(); }; $scope.closeDetailInfoPanel = function () { $("#detailInfoPanel").modal("hide"); }; var selectId = null; //显示用户支付记录 $scope.payRecord = function (entity) { selectId = entity.id; $scope.payRecordShow = true; $scope.startRecordShow = false; $timeout(function () { setPayRecordColumnDefs(); initPayRecordDataGrid(); }); }; //显示用户投币记录 $scope.startRecord = function (entity) { selectId = entity.id; $scope.payRecordShow = false; $scope.startRecordShow = true; $timeout(function () { setStartRecordColumnDefs(); initStartRecordDataGrid(); }); }; /************************************用户支付记录**********************************************/ $scope.payRecordShow = false; //查询条件 var payRecordCondition = $scope.payRecordCondition = { searchKey: "" }; $scope.payRecordGridOptions = { data: 'payRecordData', showGridFooter: true, //是否显示grid footer // rowHeight: 80, //-------- 分页属性 ---------------- paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项 paginationCurrentPage: 1, //当前页码 paginationPageSize: 10, //每页显示个数 totalItems: 0,// 总数量 useExternalPagination: true,//是否使用分页按钮 //过滤 enableFiltering: true, columnDefs: [], //---------------api--------------------- onRegisterApi: function (gridApi) { $scope.payRecordGridApi = gridApi; gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { if ($scope.payRecordGridOptions) { $scope.getPayRecordPagedDataAsync(newPage, pageSize); } }); } }; function setPayRecordColumnDefs() { $scope.payRecordGridOptions.columnDefs = [ {field: 'orderNo', displayName: '订单号'}, { field: 'time', displayName: '时间', cellTemplate: '
' }, { field: 'money', displayName: '金额', cellTemplate: '
' }, {field: 'coins', displayName: '金币'}, {field: 'devNo', displayName: '设备号'}, {field: 'devType', displayName: '设备类型'}, {field: 'groupName', displayName: '设备组名称'}, { field: 'gateway', displayName: '支付方式', cellTemplate: '
{{row.entity.gateway}}
' }, ]; var fields = $scope.payRecordGridOptions.columnDefs; for (var index in fields) { var item = fields[index]; if (item && item['minWidth'] == null) { item['minWidth'] = 100; } } } //事件 $scope.payRecordEvent = { search: function () { $scope.getPayRecordPagedDataAsync(1, $scope.payRecordGridOptions.paginationPageSize); } }; $scope.setPayRecordPagingData = function (data, curPage, pageSize) { var pagedData = data.data.dataList; $scope.payRecordData = pagedData; $scope.payRecordGridOptions.totalItems = data.data.total; $(window).trigger("resize"); }; $scope.getPayRecordPagedDataAsync = function (curPage, pageSize) { var params = { pageSize: pageSize, pageIndex: curPage }; if (payRecordCondition.searchKey != "") { params.searchKey = payRecordCondition.searchKey } if (selectId != null) { params.id = selectId; } $http.get('/user/getEndUserRechargeRecords', { params: params }).then(function (data) { $scope.setPayRecordPagingData(data.data, curPage, pageSize); }).catch(function (data) { toaster.pop("error", "提示", "获取数据列表失败"); }); }; function initPayRecordDataGrid() { //首次加载表格 $scope.getPayRecordPagedDataAsync($scope.payRecordGridOptions.paginationCurrentPage, $scope.payRecordGridOptions.paginationPageSize); } /************************************用户投币记录**********************************************/ $scope.startRecordShow = false; //查询条件 var startRecordCondition = $scope.startRecordCondition = { searchKey: "" }; $scope.startRecordGridOptions = { data: 'startRecordData', showGridFooter: true, //是否显示grid footer // rowHeight: 80, //-------- 分页属性 ---------------- paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项 paginationCurrentPage: 1, //当前页码 paginationPageSize: 10, //每页显示个数 totalItems: 0,// 总数量 useExternalPagination: true,//是否使用分页按钮 //过滤 enableFiltering: true, columnDefs: [], //---------------api--------------------- onRegisterApi: function (gridApi) { $scope.startRecordGridApi = gridApi; gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { if ($scope.startRecordGridOptions) { $scope.getStartRecordPagedDataAsync(newPage, pageSize); } }); } }; function setStartRecordColumnDefs() { $scope.startRecordGridOptions.columnDefs = [ {field: 'orderNo', displayName: '订单号'}, { field: 'time', displayName: '时间', cellTemplate: '
' }, {field: 'coins', displayName: '金币'}, {field: 'devNo', displayName: '设备号'}, {field: 'devType', displayName: '设备类型'}, {field: 'groupName', displayName: '设备组名称'}, ]; var fields = $scope.startRecordGridOptions.columnDefs; for (var index in fields) { var item = fields[index]; if (item && item['minWidth'] == null) { item['minWidth'] = 100; } } } //事件 $scope.startRecordEvent = { search: function () { $scope.getStartRecordPagedDataAsync(1, $scope.startRecordGridOptions.paginationPageSize); } }; $scope.setStartRecordPagingData = function (data, curPage, pageSize) { var pagedData = data.data.dataList; $scope.startRecordData = pagedData; $scope.startRecordGridOptions.totalItems = data.data.total; $(window).trigger("resize"); }; $scope.getStartRecordPagedDataAsync = function (curPage, pageSize) { var params = { pageSize: pageSize, pageIndex: curPage }; if (selectId != null) { params.id = selectId; } if (startRecordCondition.searchKey != "") { params.searchKey = startRecordCondition.searchKey } $http.get('/user/getEndUserConsumeRecords', { params: params }).then(function (data) { $scope.setStartRecordPagingData(data.data, curPage, pageSize); }).catch(function (data) { toaster.pop("error", "提示", "获取数据列表失败"); }); }; function initStartRecordDataGrid() { //首次加载表格 $scope.getStartRecordPagedDataAsync($scope.startRecordGridOptions.paginationCurrentPage, $scope.startRecordGridOptions.paginationPageSize); } }]);