simCharge.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. app.controller('simChargeCtrl', ['$scope', '$filter', '$http', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $filter, $http, $stateParams, $timeout, uiGridConstants, i18nService, toaster,) {
  2. i18nService.setCurrentLang("zh-cn");
  3. $scope.gridOptions = {
  4. data: 'myData',
  5. showGridFooter: true, //是否显示grid footer
  6. // rowHeight: 80,
  7. //-------- 分页属性 ----------------
  8. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  9. paginationCurrentPage: 1, //当前页码
  10. paginationPageSize: 10, //每页显示个数
  11. totalItems: 0,// 总数量
  12. useExternalPagination: true,//是否使用分页按钮
  13. //过滤
  14. // enableFiltering: true,
  15. columnDefs: [],
  16. //---------------api---------------------
  17. onRegisterApi: function (gridApi) {
  18. $scope.gridApi = gridApi;
  19. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  20. if ($scope.setPagingData) {
  21. $scope.getPagedDataAsync(newPage, pageSize, true);//翻页是强制刷新
  22. }
  23. });
  24. }
  25. };
  26. //枚举常量
  27. $scope.enum = {};
  28. var searchType = $scope.enum.searchType = [
  29. {value: 'orderNo', label: "按订单编号查询", desc: '输入订单编号'},
  30. {value: 'logicalCode', label: "按设备编号查询", desc: '输入设备编号'},
  31. ];
  32. //查询条件
  33. var condition = $scope.condition = {
  34. searchType: searchType[0],
  35. searchKey: '',
  36. };
  37. //事件
  38. $scope.event = {
  39. statusChange: function (key, item) {
  40. condition[key] = {}
  41. condition[key].value = item.value;
  42. condition[key].label = item.label;
  43. condition[key].desc = item.desc;
  44. },
  45. search: function () {
  46. // 就在当前 厂商|代理商|经销商的域下进行搜索
  47. if (condition.searchKey === "") {
  48. $.confirm({
  49. content: '条件为空,数据量较大,确定继续?',
  50. buttons: {
  51. ok: {
  52. text: '搜索',
  53. action: function () {
  54. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize, true);
  55. }
  56. },
  57. }
  58. });
  59. } else {
  60. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  61. }
  62. },
  63. };
  64. function setColumnDefs() {
  65. $scope.gridOptions.columnDefs = [
  66. {
  67. field: 'orderNo',
  68. displayName: '订单编号',
  69. },
  70. {
  71. field: 'dealerStr',
  72. displayName: '经销商',
  73. },
  74. {
  75. field: 'orderParams', displayName: '订单参数',
  76. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'订单参数\',\'orderParams\',row.entity)" >{{row.entity.orderParams}}</div>'
  77. },
  78. {
  79. field: 'simOrderDict',
  80. displayName: '订单详情',
  81. cellTemplate: '<div class="temp-row" ng-click="grid.appScope.showInfoDetailInfo(\'订单详情\',\'simOrderDict\',row.entity)" >{{row.entity.simOrderDict}}</div>'
  82. },
  83. {field: 'totalFee', displayName: '充值金额',},
  84. {field: 'dateTimeAdded', displayName: '充值日期',},
  85. {
  86. field: 'operation',
  87. displayName: '操作',
  88. enableFiltering: false,
  89. enableSorting: false,
  90. enableHiding: false,//禁止在列选择器中隐藏
  91. enableColumnMenu: false,// 是否显示列头部菜单按钮
  92. minWidth: 100,
  93. cellTemplate: '<div class="grid-button">' +
  94. '<button class="btn btn-sm btn-rounded btn-danger" ng-click="grid.appScope.refundDealerRecharge(row.entity)">退费</button>' +
  95. '</div>'
  96. },
  97. ];
  98. var fields = $scope.gridOptions.columnDefs;
  99. for (var index in fields) {
  100. var item = fields[index];
  101. if (item && item['minWidth'] == null) {
  102. item['minWidth'] = 100;
  103. }
  104. }
  105. }
  106. $scope.setPagingData = function (data) {
  107. var pagedData = data.data.dataList;
  108. $scope.myData = pagedData;
  109. $scope.gridOptions.totalItems = data.data.total;
  110. };
  111. $scope.getPagedDataAsync = function (curPage, pageSize, force) {
  112. if ($scope.gridOptionsLoading) {
  113. return;
  114. }
  115. var params = {
  116. pageSize: pageSize,
  117. pageIndex: curPage,
  118. };
  119. if (condition.searchType.value !== '') {
  120. params.searchType = condition.searchType.value
  121. }
  122. if (condition.searchKey !== "") {
  123. params.searchKey = condition.searchKey
  124. }
  125. // 如果没有条件,则不查询,因为数据量太大,加载太卡!
  126. if (force) {
  127. // nothing
  128. } else if (!params.searchKey) {
  129. toaster.pop("info", "温馨提示", "请输入查询条件进行查询");
  130. return
  131. }
  132. $scope.gridOptionsLoading = true;
  133. $http.get('/superadmin/getDealerRechargeRecord', {
  134. params: params
  135. }).then(function (data) {
  136. data = data.data
  137. $scope.gridOptionsLoading = false;
  138. $scope.setPagingData(data, curPage, pageSize);
  139. }).catch(function (data) {
  140. toaster.pop("error", "提示", "获取数据列表失败");
  141. });
  142. };
  143. function initDataGrid() {
  144. //首次加载表格
  145. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  146. }
  147. setColumnDefs();
  148. initDataGrid();
  149. $scope.showInfoDetailInfo = function (title, key, content) {
  150. var detail = content[key]
  151. $scope.infoDetail = {title: title, content: detail};
  152. $(".devManageMain #detailInfoPanel").modal();
  153. };
  154. $scope.closeDetailPanel = function () {
  155. $(".devManageMain #detailInfoPanel").modal("hide");
  156. };
  157. $scope.refundDealerRecharge = function (entity) {
  158. var url = "/superadmin/refundDealerRecharge";
  159. $.confirm({
  160. content: '输入退费金额:<input type="text" id="refundMoney" placeholder="输入退费金额"/>',
  161. buttons: {
  162. ok: {
  163. btnClass: 'btn-red',
  164. action: function () {
  165. var refundMoney = $('#refundMoney').val()
  166. if(!refundMoney){
  167. return false
  168. }
  169. $http({
  170. method: 'POST',
  171. url: url,
  172. data: {
  173. orderNo: entity.orderNo,
  174. refundMoney: refundMoney,
  175. }
  176. }).then(function (response) {
  177. if (response.data.result) {
  178. toaster.pop("success", "提示", "退费成功!");
  179. } else {
  180. toaster.pop("error", "提示", "退费失败!");
  181. }
  182. }, function (response) {
  183. toaster.pop("error", "提示", "退费失败!");
  184. });
  185. }
  186. },
  187. }
  188. });
  189. };
  190. }]);