123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- app.controller('joinRecordCtrl', ['$scope', '$filter', '$http', '$stateParams', '$timeout', 'uiGridConstants', 'i18nService', 'toaster', function ($scope, $filter, $http, $stateParams, $timeout, uiGridConstants, i18nService, toaster) {
- i18nService.setCurrentLang("zh-cn");
- moment.locale('zh-cn');
- var searchKey = $stateParams.searchKey || "";
- $scope.startTimeOpen = false;
- $scope.endTimeOpen = false;
- $scope.timeChange = function (newDate, oldDate) {
- $scope.startTimeOpen = false;
- $scope.endTimeOpen = false;
- };
- $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);//翻页是强制刷新
- }
- });
- }
- };
- //查询条件
- var condition = $scope.condition = {
- searchKey: searchKey
- };
- //查询条件
- $scope.query = {
- startTime: moment().format("YYYY-MM-DD"),
- endTime: moment().format("YYYY-MM-DD"),
- };
- //枚举常量
- $scope.enum = {
- status:[
- {name: '未支付', value: 'UnPaid', className:''},
- {name: '取消订单', value: 'Cancel',className:'fadeNode' },
- {name: '已加盟', value: 'Paid',className:'text-success' },
- {name: '退出加盟', value: 'Quit',className:'text-danger' },
- ]
- };
- //事件
- $scope.ngEvent = {
- quickTime: function (event, passDay) {
- $scope.query.startTime = moment().add(-(passDay - 1), "day").format("YYYY-MM-DD");
- $scope.query.endTime = moment().format("YYYY-MM-DD");
- },
- };
- //事件
- $scope.event = {
- search: function () {
- if (condition.searchKey === "") {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- } else {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- }
- }
- };
- function setColumnDefs() {
- $scope.gridOptions.columnDefs = [
- {
- field: 'orderNo',
- displayName: '单号',
- width: 100,
- },
- {
- field: 'name',
- displayName: '描述',
- width: 140,
- },
- {
- field: 'totalFee',
- displayName: '加盟费',
- },
- {
- field: 'createdTime',
- displayName: '创建时间',
- cellTemplate: '<div class="temp-row">{{row.entity.createdTime||"暂"}}</div>'
- },
- {
- field: 'payTime',
- displayName: '支付时间',
- cellTemplate: '<div class="temp-row">{{row.entity.payTime||"暂无"}}</div>'
- },
- {
- field: 'quitTime',
- displayName: '退出加盟时间',
- cellTemplate: '<div class="temp-row">{{row.entity.quitTime||"暂无"}}</div>'
- },
- {
- field: 'status',
- displayName: '状态',
- cellTemplate: '<div class="temp-row" ng-class="grid.appScope.formatterStatusStyle(row.entity.status)">{{grid.appScope.formatterStatus(row.entity.status)}}</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) {
- if ($scope.gridOptionsLoading) {
- return;
- }
- var params = {
- pageSize: pageSize,
- pageIndex: curPage,
- };
- if (condition.searchKey !== "") {
- params.searchKey = condition.searchKey
- }
- if ($scope.query.startTime !== "") {
- params.startDate = $scope.query.startTime
- }
- if ($scope.query.endTime !== "") {
- params.endDate = $scope.query.endTime
- }
- $scope.gridOptionsLoading = true;
- $http.get('/dealer/getJoinRecordList', {
- params: params
- }).then(function (data) {
- data = data.data
- $scope.gridOptionsLoading = false;
- $scope.setPagingData(data, curPage, pageSize);
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据列表失败");
- });
- };
- $scope.formatterStatus = function (status) {
- var list = $scope.enum.status;
- for (var index in list) {
- var item = list[index];
- if (item.value === status) {
- return item.name;
- }
- }
- };
- $scope.formatterStatusStyle = function (status) {
- var list = $scope.enum.status;
- for (var index in list) {
- var item = list[index];
- if (item.value === status) {
- return item.className;
- }
- }
- };
- function initDataGrid() {
- //首次加载表格
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- }
- setColumnDefs();
- initDataGrid();
- var dialogData = $scope.dialogData = {};
- $scope.joinStatistics = function () {
- $http.get('/manager/getJoinStat', {
- }).then(function (data) {
- $scope.dialogData = data.data.payload;
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据列表失败");
- });
- $("#joinStatisticsForm").modal();
- }
- }]);
|