123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- 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: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'订单参数\',\'orderParams\',row.entity)" >{{row.entity.orderParams}}</div>'
- },
- {
- field: 'simOrderDict',
- displayName: '订单详情',
- cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'订单详情\',\'simOrderDict\',row.entity)" >{{row.entity.simOrderDict}}</div>'
- },
- {field: 'totalFee', displayName: '充值金额',},
- {field: 'dateTimeAdded', displayName: '充值日期',},
- {
- field: 'operation',
- displayName: '操作',
- enableFiltering: false,
- enableSorting: false,
- enableHiding: false,//禁止在列选择器中隐藏
- enableColumnMenu: false,// 是否显示列头部菜单按钮
- minWidth: 100,
- cellTemplate: '<div class="grid-button">' +
- '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.refundDealerRecharge(row.entity)">退费</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.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: '输入退费金额:<input type="text" id="refundMoney" placeholder="输入退费金额"/>',
- 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", "提示", "退费失败!");
- });
- }
- },
- }
- });
- };
- }]);
|