app.controller('simChargeCtrl', ['$scope', '$filter', '$http', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $filter, $http, $stateParams, $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, true);//翻页是强制刷新 } }); } }; //枚举常量 $scope.enum = {}; var searchType = $scope.enum.searchType = [ {value: 'orderNo', label: "按订单编号查询", desc: '输入订单编号'}, {value: 'logicalCode', label: "按设备编号查询", desc: '输入设备编号'}, ]; //查询条件 var condition = $scope.condition = { searchType: searchType[0], searchKey: '', }; //事件 $scope.event = { statusChange: function (key, item) { condition[key] = {} condition[key].value = item.value; condition[key].label = item.label; condition[key].desc = item.desc; }, search: function () { // 就在当前 厂商|代理商|经销商的域下进行搜索 if (condition.searchKey === "") { $.confirm({ content: '条件为空,数据量较大,确定继续?', buttons: { ok: { text: '搜索', action: function () { $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize, true); } }, } }); } else { $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize); } }, }; function setColumnDefs() { $scope.gridOptions.columnDefs = [ { field: 'orderNo', displayName: '订单编号', }, { field: 'dealerStr', displayName: '经销商', }, { field: 'orderParams', displayName: '订单参数', cellTemplate: '
{{row.entity.orderParams}}
' }, { field: 'simOrderDict', displayName: '订单详情', cellTemplate: '
{{row.entity.simOrderDict}}
' }, {field: 'totalFee', displayName: '充值金额',}, {field: 'dateTimeAdded', displayName: '充值日期',}, { field: 'operation', displayName: '操作', enableFiltering: false, enableSorting: false, enableHiding: false,//禁止在列选择器中隐藏 enableColumnMenu: false,// 是否显示列头部菜单按钮 minWidth: 100, cellTemplate: '
' + '' + '
' }, ]; var fields = $scope.gridOptions.columnDefs; for (var index in fields) { var item = fields[index]; if (item && item['minWidth'] == null) { item['minWidth'] = 100; } } } $scope.setPagingData = function (data) { var pagedData = data.data.dataList; $scope.myData = pagedData; $scope.gridOptions.totalItems = data.data.total; }; $scope.getPagedDataAsync = function (curPage, pageSize, force) { if ($scope.gridOptionsLoading) { return; } var params = { pageSize: pageSize, pageIndex: curPage, }; if (condition.searchType.value !== '') { params.searchType = condition.searchType.value } if (condition.searchKey !== "") { params.searchKey = condition.searchKey } // 如果没有条件,则不查询,因为数据量太大,加载太卡! if (force) { // nothing } else if (!params.searchKey) { toaster.pop("info", "温馨提示", "请输入查询条件进行查询"); return } $scope.gridOptionsLoading = true; $http.get('/superadmin/getDealerRechargeRecord', { params: params }).then(function (data) { data = data.data $scope.gridOptionsLoading = false; $scope.setPagingData(data, curPage, pageSize); }).catch(function (data) { toaster.pop("error", "提示", "获取数据列表失败"); }); }; function initDataGrid() { //首次加载表格 $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize); } setColumnDefs(); initDataGrid(); $scope.showInfoDetailInfo = function (title, key, content) { var detail = content[key] $scope.infoDetail = {title: title, content: detail}; $(".devManageMain #detailInfoPanel").modal(); }; $scope.closeDetailPanel = function () { $(".devManageMain #detailInfoPanel").modal("hide"); }; $scope.refundDealerRecharge = function (entity) { var url = "/superadmin/refundDealerRecharge"; $.confirm({ content: '输入退费金额:', buttons: { ok: { btnClass: 'btn-red', action: function () { var refundMoney = $('#refundMoney').val() if(!refundMoney){ return false } $http({ method: 'POST', url: url, data: { orderNo: entity.orderNo, refundMoney: refundMoney, } }).then(function (response) { if (response.data.result) { toaster.pop("success", "提示", "退费成功!"); } else { toaster.pop("error", "提示", "退费失败!"); } }, function (response) { toaster.pop("error", "提示", "退费失败!"); }); } }, } }); }; }]);