endUserManage.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. app.controller('endUserManageCtrl', ['$scope', '$http', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $http, $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);
  22. }
  23. });
  24. }
  25. };
  26. //查询条件
  27. var condition = $scope.condition = {
  28. searchKey: ""
  29. };
  30. //枚举常量
  31. $scope.enum = {
  32. sex: [
  33. {value: 0, label: "无"},
  34. {value: 1, label: "男"},
  35. {value: 2, label: "女"}
  36. ]
  37. };
  38. //事件
  39. $scope.event = {
  40. search: function () {
  41. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  42. }
  43. };
  44. function setColumnDefs() {
  45. $scope.gridOptions.columnDefs = [
  46. {field: 'nickname', displayName: '用户昵称'},
  47. {field: 'openId', displayName: 'openId'},
  48. {
  49. field: 'gateway',
  50. displayName: '用户来源',
  51. cellTemplate: '<div class="temp-row" ng-class="{\'text-success\':row.entity.gateway==\'微信\',\'text-info\':row.entity.gateway==\'支付宝\'}">{{row.entity.gateway}}</div>'
  52. },
  53. {
  54. field: 'sex', displayName: '性别',
  55. filter: {
  56. term: '',
  57. type: uiGridConstants.filter.SELECT,
  58. selectOptions: $scope.enum.sex
  59. },
  60. cellTemplate: '<div class="temp-row">{{grid.appScope.formatterSex(row.entity.sex)}}</div>'
  61. },
  62. {
  63. field: 'country',
  64. displayName: '国家'
  65. },
  66. {
  67. field: 'province',
  68. displayName: '省份'
  69. },
  70. {
  71. field: 'city',
  72. displayName: '城市'
  73. },
  74. {
  75. field: 'balance',
  76. displayName: '余额'
  77. },
  78. {
  79. field: 'groupName',
  80. displayName: '地址名称'
  81. },
  82. {
  83. field: 'oper', displayName: '操作',
  84. enableFiltering: false,
  85. enableSorting: false,
  86. enableHiding: false,//禁止在列选择器中隐藏
  87. enableColumnMenu: false,// 是否显示列头部菜单按钮
  88. width: 200,
  89. cellTemplate: '<div class="grid-button">' +
  90. '<button class="btn btn-sm btn-rounded btn-success" ng-click="grid.appScope.payRecord(row.entity)"><i class="fa fa-rmb"></i> 支付记录</button>' +
  91. '<button class="btn btn-sm btn-rounded btn-dark" ng-click="grid.appScope.startRecord(row.entity)"><i class="fa fa-play"></i> 投币记录</button>' +
  92. '</div>'
  93. }
  94. ];
  95. var fields = $scope.gridOptions.columnDefs;
  96. for (var index in fields) {
  97. var item = fields[index];
  98. if (item && item['minWidth'] == null) {
  99. item['minWidth'] = 100;
  100. }
  101. }
  102. }
  103. //表格地址转换
  104. $scope.formatterSex = function (sex) {
  105. var sexList = $scope.enum.sex;
  106. for (var index in sexList) {
  107. var item = sexList[index];
  108. if (item.value == sex) {
  109. return item.label;
  110. }
  111. }
  112. };
  113. $scope.setPagingData = function (data, curPage, pageSize) {
  114. var firstRow = (curPage - 1) * pageSize;
  115. var pagedData = data.data.dataList;
  116. $scope.myData = pagedData;
  117. $scope.gridOptions.totalItems = data.data.total;
  118. };
  119. $scope.getPagedDataAsync = function (curPage, pageSize, searchText) {
  120. var params = {
  121. pageSize: pageSize,
  122. pageIndex: curPage
  123. };
  124. if (condition.searchKey != "") {
  125. params.searchKey = condition.searchKey
  126. }
  127. $http.get('/user/getEndUserDetailList', {
  128. params: params
  129. }).then(function (data) {
  130. $scope.setPagingData(data.data, curPage, pageSize);
  131. }).catch(function (data) {
  132. toaster.pop("error", "提示", "获取数据列表失败");
  133. });
  134. };
  135. function initDataGrid() {
  136. //首次加载表格
  137. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  138. }
  139. setColumnDefs();
  140. initDataGrid();
  141. //展示详情
  142. $scope.showInfoDetail = function (title, content) {
  143. $scope.infoDetail = {title: title, content: JSON.parse(content)};
  144. $("#detailInfoPanel").modal();
  145. };
  146. $scope.closeDetailInfoPanel = function () {
  147. $("#detailInfoPanel").modal("hide");
  148. };
  149. var selectId = null;
  150. //显示用户支付记录
  151. $scope.payRecord = function (entity) {
  152. selectId = entity.id;
  153. $scope.payRecordShow = true;
  154. $scope.startRecordShow = false;
  155. $timeout(function () {
  156. setPayRecordColumnDefs();
  157. initPayRecordDataGrid();
  158. });
  159. };
  160. //显示用户投币记录
  161. $scope.startRecord = function (entity) {
  162. selectId = entity.id;
  163. $scope.payRecordShow = false;
  164. $scope.startRecordShow = true;
  165. $timeout(function () {
  166. setStartRecordColumnDefs();
  167. initStartRecordDataGrid();
  168. });
  169. };
  170. /************************************用户支付记录**********************************************/
  171. $scope.payRecordShow = false;
  172. //查询条件
  173. var payRecordCondition = $scope.payRecordCondition = {
  174. searchKey: ""
  175. };
  176. $scope.payRecordGridOptions = {
  177. data: 'payRecordData',
  178. showGridFooter: true, //是否显示grid footer
  179. // rowHeight: 80,
  180. //-------- 分页属性 ----------------
  181. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  182. paginationCurrentPage: 1, //当前页码
  183. paginationPageSize: 10, //每页显示个数
  184. totalItems: 0,// 总数量
  185. useExternalPagination: true,//是否使用分页按钮
  186. //过滤
  187. enableFiltering: true,
  188. columnDefs: [],
  189. //---------------api---------------------
  190. onRegisterApi: function (gridApi) {
  191. $scope.payRecordGridApi = gridApi;
  192. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  193. if ($scope.payRecordGridOptions) {
  194. $scope.getPayRecordPagedDataAsync(newPage, pageSize);
  195. }
  196. });
  197. }
  198. };
  199. function setPayRecordColumnDefs() {
  200. $scope.payRecordGridOptions.columnDefs = [
  201. {field: 'orderNo', displayName: '订单号'},
  202. {
  203. field: 'time', displayName: '时间',
  204. cellTemplate: '<div class="temp-row" ng-bind="row.entity.time| date:\'yyyy-MM-dd HH:mm:ss\'"></div>'
  205. },
  206. {
  207. field: 'money',
  208. displayName: '金额',
  209. cellTemplate: '<div class="temp-row" ng-bind="row.entity.money| currency:\'¥\'"></div>'
  210. },
  211. {field: 'coins', displayName: '金币'},
  212. {field: 'devNo', displayName: '设备号'},
  213. {field: 'devType', displayName: '设备类型'},
  214. {field: 'groupName', displayName: '设备组名称'},
  215. {
  216. field: 'gateway',
  217. displayName: '支付方式',
  218. cellTemplate: '<div class="temp-row" ng-class="{\'text-success\':row.entity.gateway==\'微信\',\'text-info\':row.entity.gateway==\'支付宝\'}">{{row.entity.gateway}}</div>'
  219. },
  220. ];
  221. var fields = $scope.payRecordGridOptions.columnDefs;
  222. for (var index in fields) {
  223. var item = fields[index];
  224. if (item && item['minWidth'] == null) {
  225. item['minWidth'] = 100;
  226. }
  227. }
  228. }
  229. //事件
  230. $scope.payRecordEvent = {
  231. search: function () {
  232. $scope.getPayRecordPagedDataAsync(1, $scope.payRecordGridOptions.paginationPageSize);
  233. }
  234. };
  235. $scope.setPayRecordPagingData = function (data, curPage, pageSize) {
  236. var pagedData = data.data.dataList;
  237. $scope.payRecordData = pagedData;
  238. $scope.payRecordGridOptions.totalItems = data.data.total;
  239. $(window).trigger("resize");
  240. };
  241. $scope.getPayRecordPagedDataAsync = function (curPage, pageSize) {
  242. var params = {
  243. pageSize: pageSize,
  244. pageIndex: curPage
  245. };
  246. if (payRecordCondition.searchKey != "") {
  247. params.searchKey = payRecordCondition.searchKey
  248. }
  249. if (selectId != null) {
  250. params.id = selectId;
  251. }
  252. $http.get('/user/getEndUserRechargeRecords', {
  253. params: params
  254. }).then(function (data) {
  255. $scope.setPayRecordPagingData(data.data, curPage, pageSize);
  256. }).catch(function (data) {
  257. toaster.pop("error", "提示", "获取数据列表失败");
  258. });
  259. };
  260. function initPayRecordDataGrid() {
  261. //首次加载表格
  262. $scope.getPayRecordPagedDataAsync($scope.payRecordGridOptions.paginationCurrentPage, $scope.payRecordGridOptions.paginationPageSize);
  263. }
  264. /************************************用户投币记录**********************************************/
  265. $scope.startRecordShow = false;
  266. //查询条件
  267. var startRecordCondition = $scope.startRecordCondition = {
  268. searchKey: ""
  269. };
  270. $scope.startRecordGridOptions = {
  271. data: 'startRecordData',
  272. showGridFooter: true, //是否显示grid footer
  273. // rowHeight: 80,
  274. //-------- 分页属性 ----------------
  275. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  276. paginationCurrentPage: 1, //当前页码
  277. paginationPageSize: 10, //每页显示个数
  278. totalItems: 0,// 总数量
  279. useExternalPagination: true,//是否使用分页按钮
  280. //过滤
  281. enableFiltering: true,
  282. columnDefs: [],
  283. //---------------api---------------------
  284. onRegisterApi: function (gridApi) {
  285. $scope.startRecordGridApi = gridApi;
  286. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  287. if ($scope.startRecordGridOptions) {
  288. $scope.getStartRecordPagedDataAsync(newPage, pageSize);
  289. }
  290. });
  291. }
  292. };
  293. function setStartRecordColumnDefs() {
  294. $scope.startRecordGridOptions.columnDefs = [
  295. {field: 'orderNo', displayName: '订单号'},
  296. {
  297. field: 'time', displayName: '时间',
  298. cellTemplate: '<div class="temp-row" ng-bind="row.entity.time| date:\'yyyy-MM-dd HH:mm:ss\'"></div>'
  299. },
  300. {field: 'coins', displayName: '金币'},
  301. {field: 'devNo', displayName: '设备号'},
  302. {field: 'devType', displayName: '设备类型'},
  303. {field: 'groupName', displayName: '设备组名称'},
  304. ];
  305. var fields = $scope.startRecordGridOptions.columnDefs;
  306. for (var index in fields) {
  307. var item = fields[index];
  308. if (item && item['minWidth'] == null) {
  309. item['minWidth'] = 100;
  310. }
  311. }
  312. }
  313. //事件
  314. $scope.startRecordEvent = {
  315. search: function () {
  316. $scope.getStartRecordPagedDataAsync(1, $scope.startRecordGridOptions.paginationPageSize);
  317. }
  318. };
  319. $scope.setStartRecordPagingData = function (data, curPage, pageSize) {
  320. var pagedData = data.data.dataList;
  321. $scope.startRecordData = pagedData;
  322. $scope.startRecordGridOptions.totalItems = data.data.total;
  323. $(window).trigger("resize");
  324. };
  325. $scope.getStartRecordPagedDataAsync = function (curPage, pageSize) {
  326. var params = {
  327. pageSize: pageSize,
  328. pageIndex: curPage
  329. };
  330. if (selectId != null) {
  331. params.id = selectId;
  332. }
  333. if (startRecordCondition.searchKey != "") {
  334. params.searchKey = startRecordCondition.searchKey
  335. }
  336. $http.get('/user/getEndUserConsumeRecords', {
  337. params: params
  338. }).then(function (data) {
  339. $scope.setStartRecordPagingData(data.data, curPage, pageSize);
  340. }).catch(function (data) {
  341. toaster.pop("error", "提示", "获取数据列表失败");
  342. });
  343. };
  344. function initStartRecordDataGrid() {
  345. //首次加载表格
  346. $scope.getStartRecordPagedDataAsync($scope.startRecordGridOptions.paginationCurrentPage, $scope.startRecordGridOptions.paginationPageSize);
  347. }
  348. }]);