123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- angular.module('push')
- .controller('reportCompanyListCtrl', ['$scope','statisticsReportService','$stateParams','ConfigService','UserService','CommonService','$q','$timeout','ResourceLibraryService','ConstantService',function($scope,statisticsReportService,$stateParams,ConfigService,UserService,CommonService,$q,$timeout,ResourceLibraryService,ConstantService){
- //虚拟搜索框
- // $scope.filterList=[
- // {
- // title:'地区筛选',
- // items:[
- // {
- // label:'不限',
- // value:0,
- // selected:true,
- // },{
- // label:'东屏',
- // value:1,
- // selected:false,
- // },{
- // label:'和凤',
- // value:2,
- // selected:false,
- // },{
- // label:'开发区',
- // value:3,
- // selected:false,
- // },{
- // label:'永阳',
- // value:4,
- // selected:false,
- // },
- // ]
- // },{
- // title:'规模选择',
- // items:[
- // {
- // label:'不限',
- // value:5,
- // selected:true,
- // },{
- // label:'规上企业',
- // value:6,
- // selected:false,
- // },{
- // label:'独角兽',
- // value:7,
- // selected:false,
- // },{
- // label:'A轮',
- // value:8,
- // selected:false,
- // },{
- // label:'天使轮',
- // value:9,
- // selected:false,
- // },
- // ]
- // }
- // ];
- //TODO 放开注释
- if($scope.app){
- if (device.platform != "Android") {
- $scope.isIos=true;
- }else{
- $scope.isIos=false;
- }
- }
- $scope.pageTitle=$stateParams.pageTitle;
- $scope.isShowSearchButton = true;
- $scope.keyfilter = {key: ""};//搜索关键词
- $scope.pageSize=15;
- $scope.currentpage=1;
- moduleid=0;
- groupid=0;
- var checkedsort="visitcount,DESC";
- var activity = ['task', 'mytask'];
- $scope.act =activity[1];//默认选择全部资源
- $scope.showSearchButtonLeft = function () {
- $scope.isShowSearchButton = false;
- // $(".showSearchInput").focus();
- $timeout(function(){
- $(".showSearchInput").focus();
- },300)
- };
- //清空搜索内容
- $scope.clearSearch = function () {
- $scope.isShowSearchButton = true;
- $scope.keyfilter.key = "";
- if ($scope.act == 'task') {
- if(!$scope.islogin){
- if (localStorage.wxFlag == "true") {
- if (localStorage.isUserFocusXW == 0) {
- var title = localStorage.appidStr;
- $ionicPopup.alert({
- title: '提示',
- template: '请先关注微信公众号"' + title + '"!'
- });
- return;
- } else {
- if (localStorage.isUserBindWx == 0) {
- var wxFlag = JSON.parse(localStorage.params);
- if (wxFlag.weChatModel) {
- $scope.go('bindPhone', {
- params: localStorage.params,
- comfrom: 'maincontroller',
- url: window.location.href.split('#/')[1]
- });
- } else {
- $scope.go('login');
- return;
- }
- } else {
- $scope.go('login');
- return;
- }
- }
- } else {
- $scope.go('login');
- return;
- }
- }else{
- //TODO
- // userid = UserService.id;
- getMyData(0).then(function(data){
- $scope.reportCompanyList=data;
- })
- }
- } else if ($scope.act == 'mytask') {
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- }
- };
- $scope.searchData=function(){
- // getData(1).then(function(data){
- // // console.log(data);
- // $scope.reportCompanyList=data;
- // });
- if ($scope.act == 'task') {
- if(!$scope.islogin){
- if (localStorage.wxFlag == "true") {
- if (localStorage.isUserFocusXW == 0) {
- var title = localStorage.appidStr;
- $ionicPopup.alert({
- title: '提示',
- template: '请先关注微信公众号"' + title + '"!'
- });
- return;
- } else {
- if (localStorage.isUserBindWx == 0) {
- var wxFlag = JSON.parse(localStorage.params);
- if (wxFlag.weChatModel) {
- $scope.go('bindPhone', {
- params: localStorage.params,
- comfrom: 'maincontroller',
- url: window.location.href.split('#/')[1]
- });
- } else {
- $scope.go('login');
- return;
- }
- } else {
- $scope.go('login');
- return;
- }
- }
- } else {
- $scope.go('login');
- return;
- }
- }else{
- //TODO
- getMyData(0).then(function(data){
- $scope.reportCompanyList=data;
- })
- }
- } else if ($scope.act == 'mytask') {
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- }
- }
- $scope.allpagestotal=0;
- $scope.mypagestotal=0;
- $scope.currentnode=UserService.node;
- var showSide=false;
- $scope.showSideBar=function(){
- document.getElementById('rightSlide').style.height=document.documentElement.clientHeight+'px'
- if(showSide){
- showSide=false;
- document.getElementById('rightSlide').style.right='-350px';
- document.getElementById('rightSlide').style.width=0;
- }else{
- showSide=true;
- document.getElementById('rightSlide').style.right='0';
- document.getElementById('rightSlide').style.width='350px';
- }
- }
- $scope.closeSideBar=function(){
- document.getElementById('rightSlide').style.right='-350px';
- document.getElementById('rightSlide').style.width=0;
- showSide=false;
- }
- $scope.changSelected=function(outerIndex,index){
- angular.forEach($scope.filterList[outerIndex].items,function(val){
- val.selected=false;
- })
- $scope.filterList[outerIndex].items[index].selected=true;
- }
- $scope.resetSelected=function(){
- angular.forEach($scope.filterList,function(val){
- angular.forEach(val.items,function(value){
- value.selected=false;
- })
- val.items[0].selected=true;
- })
- $scope.filterList.key='';
- $scope.currentnode=UserService.node;
- if ($scope.act == 'task') {
- if(!$scope.islogin){
- if (localStorage.wxFlag == "true") {
- if (localStorage.isUserFocusXW == 0) {
- var title = localStorage.appidStr;
- $ionicPopup.alert({
- title: '提示',
- template: '请先关注微信公众号"' + title + '"!'
- });
- return;
- } else {
- if (localStorage.isUserBindWx == 0) {
- var wxFlag = JSON.parse(localStorage.params);
- if (wxFlag.weChatModel) {
- $scope.go('bindPhone', {
- params: localStorage.params,
- comfrom: 'maincontroller',
- url: window.location.href.split('#/')[1]
- });
- } else {
- $scope.go('login');
- return;
- }
- } else {
- $scope.go('login');
- return;
- }
- }
- } else {
- $scope.go('login');
- return;
- }
- }else{
- //TODO
- getMyData(0).then(function(data){
- $scope.reportCompanyList=data;
- })
- }
- } else if ($scope.act == 'mytask') {
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- }
- }
- $scope.submitSelected=function(){
- // 向后台提交查询数据
- console.log($scope.filterList);
- var temp=$scope.filterList[0].items.filter(function(val,index){
- return val.selected==true;
- });
- console.log(temp);
- if(temp.length>0&&temp[0].value!=0){
- $scope.currentnode=temp[0].value;
- getMyData(0).then(function(data){
- $scope.reportCompanyList=data;
- })
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- $scope.closeSideBar();
- }
- };
- // 查询我的收藏企业
- // 获取节点信息
- var getNodeInfo=function() {
- var def = $q.defer();
- ResourceLibraryService.getResourceLibrary('', $scope.currentnode).then(function (res) {
- if (res.code == 3350) {
- console.log(res.data);
- var temp=res.data.filter(function(val){
- return val.moduleid==6;
- })
- def.resolve(temp[0]);
- } else {
- def.reject('加载失败');
- }
- });
- return def.promise;
- }
- var getMyData=function(pagenum){
- var def=$q.defer();
- getNodeInfo().then(function(data){
- console.log(data);
- ResourceLibraryService.getFirstResourceList(6, data.parentid, pagenum,
- $scope.keyfilter.key, checkedsort, UserService.id, ConstantService.TRACE_TYPE_2619).then(function(res){
- console.log(res);
- if(res.code==3350){
- $scope.mypagestotal=res.page.totalCount;
- def.resolve(res.data);
- }else{
- def.reject('加载失败')
- }
- })
- })
- return def.promise;
- }
- // 查询所有列表数据
- var getFilterList=true;
- var getData=function(pagenum){
- var def=$q.defer();
- console.log($scope.keyfilter.key);
- statisticsReportService.getEnterpriseList($scope.currentnode,pagenum,$scope.pageSize,$scope.keyfilter.key).then(function(res){
- console.log(res);
- if(res.code==3350){
- $scope.allpagestotal=res.page.totalCount;
- if(getFilterList){
- getFilterList=false;
- $scope.filterList=[];
- $scope.filterList.push({
- title:'地区筛选',
- items:[]
- })
- $scope.filterList[0].items.push({
- label:'不限',
- value:UserService.node,
- selected:true
- });
- angular.forEach(res.arrayList,function(val){
- $scope.filterList[0].items.push({
- label:val.areaname,
- value:val.id,
- selected:false,
- })
- })
- }
- $scope.currentpage=pagenum+1;
- def.resolve(res.data);
- }else{
- def.reject('加载失败');
- }
- })
- return def.promise;
- }
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- getMyData(0);
- $scope.changeAct = function (num) {
- $scope.islogin = ConfigService.islogin;
- $scope.act = activity[num];
- if (num == 0) {
- if(!$scope.islogin){
- if (localStorage.wxFlag == "true") {
- if (localStorage.isUserFocusXW == 0) {
- var title = localStorage.appidStr;
- $ionicPopup.alert({
- title: '提示',
- template: '请先关注微信公众号"' + title + '"!'
- });
- return;
- } else {
- if (localStorage.isUserBindWx == 0) {
- var wxFlag = JSON.parse(localStorage.params);
- if (wxFlag.weChatModel) {
- $scope.go('bindPhone', {
- params: localStorage.params,
- comfrom: 'maincontroller',
- url: window.location.href.split('#/')[1]
- });
- } else {
- $scope.go('login');
- return;
- }
- } else {
- $scope.go('login');
- return;
- }
- }
- } else {
- $scope.go('login');
- return;
- }
- }else{
- //TODO
- // userid = UserService.id;
- getMyData(0).then(function(data){
- $scope.reportCompanyList=data;
- })
- }
- } else if (num == 1) {
- getData(1).then(function(data){
- // console.log(data);
- $scope.reportCompanyList=data;
- });
- }
- };
- $scope.showLoadmore = true;
- $scope.loadmore=false;
- $scope.loadMore=function(){
- $scope.loadmore=true;
- getData($scope.currentpage).then(function(data){
- if(data.length<$scope.pageSize){
- $scope.showLoadmore = false;
- $scope.loadmore=false;
- }
- angular.forEach(data,function(val){
- $scope.reportCompanyList.push(val);
- })
- // $timeout(function(){
- // },2000)
- $scope.loadmore = false;
- $scope.$broadcast('scroll.infiniteScrollComplete');
- },function(){
- $scope.loadmore = false;
- })
- // $scope.$on('stateChangeSuccess', function() {
- // $scope.loadMore();
- // });
- }
- // 新建报表
- $scope.goCreateNewReport=function(){
- $scope.go('reportEditModal',{pageTitle:'报表录入'})
- }
- $scope.goCheckCompanyDetail=function(title,orgid){
- if(!ConfigService.islogin){
- if (localStorage.wxFlag == "true") {
- if (localStorage.isUserFocusXW == 0) {
- var title = localStorage.appidStr;
- $ionicPopup.alert({
- title: '提示',
- template: '请先关注微信公众号"' + title + '"!'
- });
- return;
- } else {
- if (localStorage.isUserBindWx == 0) {
- var wxFlag = JSON.parse(localStorage.params);
- if (wxFlag.weChatModel) {
- $scope.go('bindPhone', {
- params: localStorage.params,
- comfrom: 'maincontroller',
- url: window.location.href.split('#/')[1]
- });
- } else {
- $scope.go('login');
- return;
- }
- } else {
- $scope.go('login');
- return;
- }
- }
- } else {
- $scope.go('login');
- return;
- }
- }else{
- statisticsReportService.getCompayReport(orgid,0).then(function(res){
- console.log(res);
- if(res.code==3350&&res.data==null){
- if($scope.app){
- UtilService.showMess('该公司没有报表信息');
- }else{
- CommonService.showMessage('该公司没有报表信息',$scope)
- }
- }else{
- $scope.go('reportDetail',{orgid:orgid,pageTitle:title})
- }
- })
- }
- }
- }]);
|