reportCompanyListCtrl.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. angular.module('push')
  2. .controller('reportCompanyListCtrl', ['$scope','statisticsReportService','$stateParams','ConfigService','UserService','CommonService','$q','$timeout','ResourceLibraryService','ConstantService',function($scope,statisticsReportService,$stateParams,ConfigService,UserService,CommonService,$q,$timeout,ResourceLibraryService,ConstantService){
  3. //虚拟搜索框
  4. // $scope.filterList=[
  5. // {
  6. // title:'地区筛选',
  7. // items:[
  8. // {
  9. // label:'不限',
  10. // value:0,
  11. // selected:true,
  12. // },{
  13. // label:'东屏',
  14. // value:1,
  15. // selected:false,
  16. // },{
  17. // label:'和凤',
  18. // value:2,
  19. // selected:false,
  20. // },{
  21. // label:'开发区',
  22. // value:3,
  23. // selected:false,
  24. // },{
  25. // label:'永阳',
  26. // value:4,
  27. // selected:false,
  28. // },
  29. // ]
  30. // },{
  31. // title:'规模选择',
  32. // items:[
  33. // {
  34. // label:'不限',
  35. // value:5,
  36. // selected:true,
  37. // },{
  38. // label:'规上企业',
  39. // value:6,
  40. // selected:false,
  41. // },{
  42. // label:'独角兽',
  43. // value:7,
  44. // selected:false,
  45. // },{
  46. // label:'A轮',
  47. // value:8,
  48. // selected:false,
  49. // },{
  50. // label:'天使轮',
  51. // value:9,
  52. // selected:false,
  53. // },
  54. // ]
  55. // }
  56. // ];
  57. //TODO 放开注释
  58. if($scope.app){
  59. if (device.platform != "Android") {
  60. $scope.isIos=true;
  61. }else{
  62. $scope.isIos=false;
  63. }
  64. }
  65. $scope.pageTitle=$stateParams.pageTitle;
  66. $scope.isShowSearchButton = true;
  67. $scope.keyfilter = {key: ""};//搜索关键词
  68. $scope.pageSize=15;
  69. $scope.currentpage=1;
  70. moduleid=0;
  71. groupid=0;
  72. var checkedsort="visitcount,DESC";
  73. var activity = ['task', 'mytask'];
  74. $scope.act =activity[1];//默认选择全部资源
  75. $scope.showSearchButtonLeft = function () {
  76. $scope.isShowSearchButton = false;
  77. // $(".showSearchInput").focus();
  78. $timeout(function(){
  79. $(".showSearchInput").focus();
  80. },300)
  81. };
  82. //清空搜索内容
  83. $scope.clearSearch = function () {
  84. $scope.isShowSearchButton = true;
  85. $scope.keyfilter.key = "";
  86. if ($scope.act == 'task') {
  87. if(!$scope.islogin){
  88. if (localStorage.wxFlag == "true") {
  89. if (localStorage.isUserFocusXW == 0) {
  90. var title = localStorage.appidStr;
  91. $ionicPopup.alert({
  92. title: '提示',
  93. template: '请先关注微信公众号"' + title + '"!'
  94. });
  95. return;
  96. } else {
  97. if (localStorage.isUserBindWx == 0) {
  98. var wxFlag = JSON.parse(localStorage.params);
  99. if (wxFlag.weChatModel) {
  100. $scope.go('bindPhone', {
  101. params: localStorage.params,
  102. comfrom: 'maincontroller',
  103. url: window.location.href.split('#/')[1]
  104. });
  105. } else {
  106. $scope.go('login');
  107. return;
  108. }
  109. } else {
  110. $scope.go('login');
  111. return;
  112. }
  113. }
  114. } else {
  115. $scope.go('login');
  116. return;
  117. }
  118. }else{
  119. //TODO
  120. // userid = UserService.id;
  121. getMyData(0).then(function(data){
  122. $scope.reportCompanyList=data;
  123. })
  124. }
  125. } else if ($scope.act == 'mytask') {
  126. getData(1).then(function(data){
  127. // console.log(data);
  128. $scope.reportCompanyList=data;
  129. });
  130. }
  131. };
  132. $scope.searchData=function(){
  133. // getData(1).then(function(data){
  134. // // console.log(data);
  135. // $scope.reportCompanyList=data;
  136. // });
  137. if ($scope.act == 'task') {
  138. if(!$scope.islogin){
  139. if (localStorage.wxFlag == "true") {
  140. if (localStorage.isUserFocusXW == 0) {
  141. var title = localStorage.appidStr;
  142. $ionicPopup.alert({
  143. title: '提示',
  144. template: '请先关注微信公众号"' + title + '"!'
  145. });
  146. return;
  147. } else {
  148. if (localStorage.isUserBindWx == 0) {
  149. var wxFlag = JSON.parse(localStorage.params);
  150. if (wxFlag.weChatModel) {
  151. $scope.go('bindPhone', {
  152. params: localStorage.params,
  153. comfrom: 'maincontroller',
  154. url: window.location.href.split('#/')[1]
  155. });
  156. } else {
  157. $scope.go('login');
  158. return;
  159. }
  160. } else {
  161. $scope.go('login');
  162. return;
  163. }
  164. }
  165. } else {
  166. $scope.go('login');
  167. return;
  168. }
  169. }else{
  170. //TODO
  171. getMyData(0).then(function(data){
  172. $scope.reportCompanyList=data;
  173. })
  174. }
  175. } else if ($scope.act == 'mytask') {
  176. getData(1).then(function(data){
  177. // console.log(data);
  178. $scope.reportCompanyList=data;
  179. });
  180. }
  181. }
  182. $scope.allpagestotal=0;
  183. $scope.mypagestotal=0;
  184. $scope.currentnode=UserService.node;
  185. var showSide=false;
  186. $scope.showSideBar=function(){
  187. document.getElementById('rightSlide').style.height=document.documentElement.clientHeight+'px'
  188. if(showSide){
  189. showSide=false;
  190. document.getElementById('rightSlide').style.right='-350px';
  191. document.getElementById('rightSlide').style.width=0;
  192. }else{
  193. showSide=true;
  194. document.getElementById('rightSlide').style.right='0';
  195. document.getElementById('rightSlide').style.width='350px';
  196. }
  197. }
  198. $scope.closeSideBar=function(){
  199. document.getElementById('rightSlide').style.right='-350px';
  200. document.getElementById('rightSlide').style.width=0;
  201. showSide=false;
  202. }
  203. $scope.changSelected=function(outerIndex,index){
  204. angular.forEach($scope.filterList[outerIndex].items,function(val){
  205. val.selected=false;
  206. })
  207. $scope.filterList[outerIndex].items[index].selected=true;
  208. }
  209. $scope.resetSelected=function(){
  210. angular.forEach($scope.filterList,function(val){
  211. angular.forEach(val.items,function(value){
  212. value.selected=false;
  213. })
  214. val.items[0].selected=true;
  215. })
  216. $scope.filterList.key='';
  217. $scope.currentnode=UserService.node;
  218. if ($scope.act == 'task') {
  219. if(!$scope.islogin){
  220. if (localStorage.wxFlag == "true") {
  221. if (localStorage.isUserFocusXW == 0) {
  222. var title = localStorage.appidStr;
  223. $ionicPopup.alert({
  224. title: '提示',
  225. template: '请先关注微信公众号"' + title + '"!'
  226. });
  227. return;
  228. } else {
  229. if (localStorage.isUserBindWx == 0) {
  230. var wxFlag = JSON.parse(localStorage.params);
  231. if (wxFlag.weChatModel) {
  232. $scope.go('bindPhone', {
  233. params: localStorage.params,
  234. comfrom: 'maincontroller',
  235. url: window.location.href.split('#/')[1]
  236. });
  237. } else {
  238. $scope.go('login');
  239. return;
  240. }
  241. } else {
  242. $scope.go('login');
  243. return;
  244. }
  245. }
  246. } else {
  247. $scope.go('login');
  248. return;
  249. }
  250. }else{
  251. //TODO
  252. getMyData(0).then(function(data){
  253. $scope.reportCompanyList=data;
  254. })
  255. }
  256. } else if ($scope.act == 'mytask') {
  257. getData(1).then(function(data){
  258. // console.log(data);
  259. $scope.reportCompanyList=data;
  260. });
  261. }
  262. }
  263. $scope.submitSelected=function(){
  264. // 向后台提交查询数据
  265. console.log($scope.filterList);
  266. var temp=$scope.filterList[0].items.filter(function(val,index){
  267. return val.selected==true;
  268. });
  269. console.log(temp);
  270. if(temp.length>0&&temp[0].value!=0){
  271. $scope.currentnode=temp[0].value;
  272. getMyData(0).then(function(data){
  273. $scope.reportCompanyList=data;
  274. })
  275. getData(1).then(function(data){
  276. // console.log(data);
  277. $scope.reportCompanyList=data;
  278. });
  279. $scope.closeSideBar();
  280. }
  281. };
  282. // 查询我的收藏企业
  283. // 获取节点信息
  284. var getNodeInfo=function() {
  285. var def = $q.defer();
  286. ResourceLibraryService.getResourceLibrary('', $scope.currentnode).then(function (res) {
  287. if (res.code == 3350) {
  288. console.log(res.data);
  289. var temp=res.data.filter(function(val){
  290. return val.moduleid==6;
  291. })
  292. def.resolve(temp[0]);
  293. } else {
  294. def.reject('加载失败');
  295. }
  296. });
  297. return def.promise;
  298. }
  299. var getMyData=function(pagenum){
  300. var def=$q.defer();
  301. getNodeInfo().then(function(data){
  302. console.log(data);
  303. ResourceLibraryService.getFirstResourceList(6, data.parentid, pagenum,
  304. $scope.keyfilter.key, checkedsort, UserService.id, ConstantService.TRACE_TYPE_2619).then(function(res){
  305. console.log(res);
  306. if(res.code==3350){
  307. $scope.mypagestotal=res.page.totalCount;
  308. def.resolve(res.data);
  309. }else{
  310. def.reject('加载失败')
  311. }
  312. })
  313. })
  314. return def.promise;
  315. }
  316. // 查询所有列表数据
  317. var getFilterList=true;
  318. var getData=function(pagenum){
  319. var def=$q.defer();
  320. console.log($scope.keyfilter.key);
  321. statisticsReportService.getEnterpriseList($scope.currentnode,pagenum,$scope.pageSize,$scope.keyfilter.key).then(function(res){
  322. console.log(res);
  323. if(res.code==3350){
  324. $scope.allpagestotal=res.page.totalCount;
  325. if(getFilterList){
  326. getFilterList=false;
  327. $scope.filterList=[];
  328. $scope.filterList.push({
  329. title:'地区筛选',
  330. items:[]
  331. })
  332. $scope.filterList[0].items.push({
  333. label:'不限',
  334. value:UserService.node,
  335. selected:true
  336. });
  337. angular.forEach(res.arrayList,function(val){
  338. $scope.filterList[0].items.push({
  339. label:val.areaname,
  340. value:val.id,
  341. selected:false,
  342. })
  343. })
  344. }
  345. $scope.currentpage=pagenum+1;
  346. def.resolve(res.data);
  347. }else{
  348. def.reject('加载失败');
  349. }
  350. })
  351. return def.promise;
  352. }
  353. getData(1).then(function(data){
  354. // console.log(data);
  355. $scope.reportCompanyList=data;
  356. });
  357. getMyData(0);
  358. $scope.changeAct = function (num) {
  359. $scope.islogin = ConfigService.islogin;
  360. $scope.act = activity[num];
  361. if (num == 0) {
  362. if(!$scope.islogin){
  363. if (localStorage.wxFlag == "true") {
  364. if (localStorage.isUserFocusXW == 0) {
  365. var title = localStorage.appidStr;
  366. $ionicPopup.alert({
  367. title: '提示',
  368. template: '请先关注微信公众号"' + title + '"!'
  369. });
  370. return;
  371. } else {
  372. if (localStorage.isUserBindWx == 0) {
  373. var wxFlag = JSON.parse(localStorage.params);
  374. if (wxFlag.weChatModel) {
  375. $scope.go('bindPhone', {
  376. params: localStorage.params,
  377. comfrom: 'maincontroller',
  378. url: window.location.href.split('#/')[1]
  379. });
  380. } else {
  381. $scope.go('login');
  382. return;
  383. }
  384. } else {
  385. $scope.go('login');
  386. return;
  387. }
  388. }
  389. } else {
  390. $scope.go('login');
  391. return;
  392. }
  393. }else{
  394. //TODO
  395. // userid = UserService.id;
  396. getMyData(0).then(function(data){
  397. $scope.reportCompanyList=data;
  398. })
  399. }
  400. } else if (num == 1) {
  401. getData(1).then(function(data){
  402. // console.log(data);
  403. $scope.reportCompanyList=data;
  404. });
  405. }
  406. };
  407. $scope.showLoadmore = true;
  408. $scope.loadmore=false;
  409. $scope.loadMore=function(){
  410. $scope.loadmore=true;
  411. getData($scope.currentpage).then(function(data){
  412. if(data.length<$scope.pageSize){
  413. $scope.showLoadmore = false;
  414. $scope.loadmore=false;
  415. }
  416. angular.forEach(data,function(val){
  417. $scope.reportCompanyList.push(val);
  418. })
  419. // $timeout(function(){
  420. // },2000)
  421. $scope.loadmore = false;
  422. $scope.$broadcast('scroll.infiniteScrollComplete');
  423. },function(){
  424. $scope.loadmore = false;
  425. })
  426. // $scope.$on('stateChangeSuccess', function() {
  427. // $scope.loadMore();
  428. // });
  429. }
  430. // 新建报表
  431. $scope.goCreateNewReport=function(){
  432. $scope.go('reportEditModal',{pageTitle:'报表录入'})
  433. }
  434. $scope.goCheckCompanyDetail=function(title,orgid){
  435. if(!ConfigService.islogin){
  436. if (localStorage.wxFlag == "true") {
  437. if (localStorage.isUserFocusXW == 0) {
  438. var title = localStorage.appidStr;
  439. $ionicPopup.alert({
  440. title: '提示',
  441. template: '请先关注微信公众号"' + title + '"!'
  442. });
  443. return;
  444. } else {
  445. if (localStorage.isUserBindWx == 0) {
  446. var wxFlag = JSON.parse(localStorage.params);
  447. if (wxFlag.weChatModel) {
  448. $scope.go('bindPhone', {
  449. params: localStorage.params,
  450. comfrom: 'maincontroller',
  451. url: window.location.href.split('#/')[1]
  452. });
  453. } else {
  454. $scope.go('login');
  455. return;
  456. }
  457. } else {
  458. $scope.go('login');
  459. return;
  460. }
  461. }
  462. } else {
  463. $scope.go('login');
  464. return;
  465. }
  466. }else{
  467. statisticsReportService.getCompayReport(orgid,0).then(function(res){
  468. console.log(res);
  469. if(res.code==3350&&res.data==null){
  470. if($scope.app){
  471. UtilService.showMess('该公司没有报表信息');
  472. }else{
  473. CommonService.showMessage('该公司没有报表信息',$scope)
  474. }
  475. }else{
  476. $scope.go('reportDetail',{orgid:orgid,pageTitle:title})
  477. }
  478. })
  479. }
  480. }
  481. }]);