storeListCtrl.js 2.11 KB
(function (angular) {
  function storeListCtrl($scope, $rootScope, $state, toaster, routeConfig, DTColumnBuilder, DTOptionsBuilder, $uibModal, $http, Utils,financeService,parentData,$uibModalInstance) {
        console.log(parentData)
      let query = parentData.data;
      // 列表数据
      $scope.staticList = []

      // 月份
      $scope.monthList = []

      $scope.staticTime = query.time||'';

      // 获取本年度所有的月份,截止到当前月
      let getMonth = function(){
          let o = new Date();
          let y = o.getFullYear();
          let m = o.getMonth()+1;
          let arr = [];
          for(var i=m;i>=1;i--){
              let k = {
                  name:y + '年' + i + '月',
                  id:i.toString()
              }
              arr.push(k);
          }
          $scope.monthList = arr;
          //$scope.staticTime = arr[0].id
      }

      // 关闭弹框
      $scope.closeDialog = function(){
          $uibModalInstance.dismiss(0);
      }

      // 获取时间参数
      function getTimes(){
          let oParams = {};
          let o = $scope.staticTime;
          let d = new Date();
          if(o){
              let s = d.getFullYear() + '-' + (o<10?'0' + o:o) + '-01 00:00:01'
              let e = d.getFullYear() + '-' + (o<10?'0' + o:o) + '-31 23:59:59'
              oParams.payStartDateStr = s;
              oParams.payEndDateStr = e;
          }
          return oParams
      }


      // 获取统计数据
      $scope.getStatic = function(){
          let oParams = getTimes();
          financeService.getFinanceStatic(oParams,function(res){
              let obj = res.data||{};
              let list = obj.countList||[]
              list.map(k => {
                  k.name = k.shopMerchantName;
                  k.number = k.nums;
                  return k;
              })
              $scope.staticList = list;
          })
      }

      // 初始化
      $scope.init = function(){
          getMonth();
          $scope.getStatic();
      }

      $scope.init();


  }
  angular.module('finance').controller('storeListCtrl', storeListCtrl);
})(angular);