123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- 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: '<div class="temp-row" ng-class="{\'text-success\':row.entity.gateway==\'微信\',\'text-info\':row.entity.gateway==\'支付宝\'}">{{row.entity.gateway}}</div>'
- },
- {
- field: 'sex', displayName: '性别',
- filter: {
- term: '',
- type: uiGridConstants.filter.SELECT,
- selectOptions: $scope.enum.sex
- },
- cellTemplate: '<div class="temp-row">{{grid.appScope.formatterSex(row.entity.sex)}}</div>'
- },
- {
- 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: '<div class="grid-button">' +
- '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.payRecord(row.entity)"><i class="fa fa-rmb"></i> 支付记录</button>' +
- '<button class="btn btn-sm btn-rounded btn-dark" ng-click="grid.appScope.startRecord(row.entity)"><i class="fa fa-play"></i> 投币记录</button>' +
- '</div>'
- }
- ];
- 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: '<div class="temp-row" ng-bind="row.entity.time| date:\'yyyy-MM-dd HH:mm:ss\'"></div>'
- },
- {
- field: 'money',
- displayName: '金额',
- cellTemplate: '<div class="temp-row" ng-bind="row.entity.money| currency:\'¥\'"></div>'
- },
- {field: 'coins', displayName: '金币'},
- {field: 'devNo', displayName: '设备号'},
- {field: 'devType', displayName: '设备类型'},
- {field: 'groupName', displayName: '设备组名称'},
- {
- field: 'gateway',
- displayName: '支付方式',
- cellTemplate: '<div class="temp-row" ng-class="{\'text-success\':row.entity.gateway==\'微信\',\'text-info\':row.entity.gateway==\'支付宝\'}">{{row.entity.gateway}}</div>'
- },
- ];
- 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: '<div class="temp-row" ng-bind="row.entity.time| date:\'yyyy-MM-dd HH:mm:ss\'"></div>'
- },
- {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);
- }
- }]);
|