joinRecord.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. app.controller('joinRecordCtrl', ['$scope', '$filter', '$http', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $filter, $http, $stateParams, $timeout, uiGridConstants, i18nService, toaster) {
  2. i18nService.setCurrentLang("zh-cn");
  3. moment.locale('zh-cn');
  4. var searchKey = $stateParams.searchKey || "";
  5. $scope.startTimeOpen = false;
  6. $scope.endTimeOpen = false;
  7. $scope.timeChange = function (newDate, oldDate) {
  8. $scope.startTimeOpen = false;
  9. $scope.endTimeOpen = false;
  10. };
  11. $scope.gridOptions = {
  12. data: 'myData',
  13. showGridFooter: true, //是否显示grid footer
  14. // rowHeight: 80,
  15. //-------- 分页属性 ----------------
  16. paginationPageSizes: [10, 20, 50, 100], //每页显示个数可选项
  17. paginationCurrentPage: 1, //当前页码
  18. paginationPageSize: 10, //每页显示个数
  19. totalItems: 0,// 总数量
  20. useExternalPagination: true,//是否使用分页按钮
  21. //过滤
  22. // enableFiltering: true,
  23. columnDefs: [],
  24. //---------------api---------------------
  25. onRegisterApi: function (gridApi) {
  26. $scope.gridApi = gridApi;
  27. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  28. if ($scope.setPagingData) {
  29. $scope.getPagedDataAsync(newPage, pageSize, true);//翻页是强制刷新
  30. }
  31. });
  32. }
  33. };
  34. //查询条件
  35. var condition = $scope.condition = {
  36. searchKey: searchKey
  37. };
  38. //查询条件
  39. $scope.query = {
  40. startTime: moment().format("YYYY-MM-DD"),
  41. endTime: moment().format("YYYY-MM-DD"),
  42. };
  43. //枚举常量
  44. $scope.enum = {
  45. status:[
  46. {name: '未支付', value: 'UnPaid', className:''},
  47. {name: '取消订单', value: 'Cancel',className:'fadeNode' },
  48. {name: '已加盟', value: 'Paid',className:'text-success' },
  49. {name: '退出加盟', value: 'Quit',className:'text-danger' },
  50. ]
  51. };
  52. //事件
  53. $scope.ngEvent = {
  54. quickTime: function (event, passDay) {
  55. $scope.query.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD");
  56. $scope.query.endTime = moment().format("YYYY-MM-DD");
  57. },
  58. };
  59. //事件
  60. $scope.event = {
  61. search: function () {
  62. if (condition.searchKey === "") {
  63. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  64. } else {
  65. $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
  66. }
  67. }
  68. };
  69. function setColumnDefs() {
  70. $scope.gridOptions.columnDefs = [
  71. {
  72. field: 'orderNo',
  73. displayName: '单号',
  74. width: 100,
  75. },
  76. {
  77. field: 'name',
  78. displayName: '描述',
  79. width: 140,
  80. },
  81. {
  82. field: 'totalFee',
  83. displayName: '加盟费',
  84. },
  85. {
  86. field: 'createdTime',
  87. displayName: '创建时间',
  88. cellTemplate: '<div class="temp-row">{{row.entity.createdTime||"暂"}}</div>'
  89. },
  90. {
  91. field: 'payTime',
  92. displayName: '支付时间',
  93. cellTemplate: '<div class="temp-row">{{row.entity.payTime||"暂无"}}</div>'
  94. },
  95. {
  96. field: 'quitTime',
  97. displayName: '退出加盟时间',
  98. cellTemplate: '<div class="temp-row">{{row.entity.quitTime||"暂无"}}</div>'
  99. },
  100. {
  101. field: 'status',
  102. displayName: '状态',
  103. cellTemplate: '<div class="temp-row" ng-class="grid.appScope.formatterStatusStyle(row.entity.status)">{{grid.appScope.formatterStatus(row.entity.status)}}</div>'
  104. },
  105. ];
  106. var fields = $scope.gridOptions.columnDefs;
  107. for (var index in fields) {
  108. var item = fields[index];
  109. if (item && item['minWidth'] == null) {
  110. item['minWidth'] = 100;
  111. }
  112. }
  113. }
  114. $scope.setPagingData = function (data) {
  115. var pagedData = data.data.dataList;
  116. $scope.myData = pagedData;
  117. $scope.gridOptions.totalItems = data.data.total;
  118. };
  119. $scope.getPagedDataAsync = function (curPage, pageSize) {
  120. if ($scope.gridOptionsLoading) {
  121. return;
  122. }
  123. var params = {
  124. pageSize: pageSize,
  125. pageIndex: curPage,
  126. };
  127. if (condition.searchKey !== "") {
  128. params.searchKey = condition.searchKey
  129. }
  130. if ($scope.query.startTime !== "") {
  131. params.startDate = $scope.query.startTime
  132. }
  133. if ($scope.query.endTime !== "") {
  134. params.endDate = $scope.query.endTime
  135. }
  136. $scope.gridOptionsLoading = true;
  137. $http.get('/dealer/getJoinRecordList', {
  138. params: params
  139. }).then(function (data) {
  140. data = data.data
  141. $scope.gridOptionsLoading = false;
  142. $scope.setPagingData(data, curPage, pageSize);
  143. }).catch(function (data) {
  144. toaster.pop("error", "提示", "获取数据列表失败");
  145. });
  146. };
  147. $scope.formatterStatus = function (status) {
  148. var list = $scope.enum.status;
  149. for (var index in list) {
  150. var item = list[index];
  151. if (item.value === status) {
  152. return item.name;
  153. }
  154. }
  155. };
  156. $scope.formatterStatusStyle = function (status) {
  157. var list = $scope.enum.status;
  158. for (var index in list) {
  159. var item = list[index];
  160. if (item.value === status) {
  161. return item.className;
  162. }
  163. }
  164. };
  165. function initDataGrid() {
  166. //首次加载表格
  167. $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
  168. }
  169. setColumnDefs();
  170. initDataGrid();
  171. var dialogData = $scope.dialogData = {};
  172. $scope.joinStatistics = function () {
  173. $http.get('/manager/getJoinStat', {
  174. }).then(function (data) {
  175. $scope.dialogData = data.data.payload;
  176. }).catch(function (data) {
  177. toaster.pop("error", "提示", "获取数据列表失败");
  178. });
  179. $("#joinStatisticsForm").modal();
  180. }
  181. }]);