area-data-panel.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. (function(){
  2. Vue.component('area-data-panel',{
  3. template: '<div class="area-panel">\
  4. <div class="area-tab-panel">\
  5. <div v-show="level==4" class="area-tab" :class="{\'active\': level==4 && (!lowLevel || lowLevel==3)}" @click="getLowCodeData(3)"><span>各区</span></div>\
  6. <div v-show="level >= 3" class="area-tab" :class="{\'active\': (level==3 && lowLevel!=1) || lowLevel==2}" @click="getLowCodeData(2)"><span>社区</span></div>\
  7. <div v-show="showTeamTab" class="area-tab" :class="{\'active\': level==2 || lowLevel==1}" @click="getLowCodeData(1)"><span>团队</span></div>\
  8. </div>\
  9. <table class="bottom-list-table mb20" id="listTable">\
  10. <thead><tr>\
  11. <th v-for="th in headers">{{th}}</th>\
  12. <th v-show="level>2 && lowLevel != 1" width="20"></th>\
  13. </tr></thead>\
  14. <tbody>\
  15. <tr v-for="row in rows" class="data-row" @click="getLowLeverData(row)">\
  16. <td v-for="(col, index) in row.cols" :class="{\'area-name\': index == 0}">\
  17. <div v-if="index==0" class="ranking" :class="{\'ranking1\': row.rank==1, \'ranking2\': row.rank==2, \'ranking3\': row.rank==3}">{{row.rank}}</div>\
  18. <div v-if="index==0" class="ui-col-1 c-nowrap-multi">{{col}}</div>\
  19. <span v-else>{{col}}</span>\
  20. </td>\
  21. <td v-show="level>2 && lowLevel != 1"><i class="fa fa-angle-right"></i></td>\
  22. </tr>\
  23. </tbody>\
  24. </table>\
  25. </div>',
  26. props:[],
  27. data: function(){
  28. return {
  29. level: '',
  30. lowLevel: '',
  31. area: '',
  32. headers: [],
  33. rows: [],
  34. cityLevelNoShowTeamTab: false,
  35. districtLevelNoShowTeamTab: false
  36. }
  37. },
  38. mounted: function(){
  39. var vm = this;
  40. EventBus.$on("render-area-data", function(arg){
  41. vm.level = arg.level;
  42. vm.lowLevel = arg.lowLevel;
  43. vm.area = arg.area;
  44. vm.headers = arg.headers;
  45. vm.rows = arg.rows;
  46. vm.cityLevelNoShowTeamTab = arg.cityLevelNoShowTeamTab;
  47. vm.districtLevelNoShowTeamTab = arg.districtLevelNoShowTeamTab;
  48. })
  49. },
  50. computed: {
  51. showTeamTab: function(){
  52. if(this.cityLevelNoShowTeamTab){
  53. if(this.level == 4){
  54. return false;
  55. }else{
  56. if(this.districtLevelNoShowTeamTab){
  57. if(this.level == 3){
  58. return false;
  59. }else{
  60. return true;
  61. }
  62. }else{
  63. return true;
  64. }
  65. }
  66. }else{
  67. return true;
  68. }
  69. }
  70. },
  71. methods: {
  72. getLowLeverData: function(row){
  73. if(this.level > 2 && this.lowLevel != 1){
  74. //跳转去下一级数据
  75. if(this.lowLevel && (this.level - this.lowLevel) >= 2){
  76. //从次级tab的内容查看再下一级的数据
  77. this.level = this.level - 2;
  78. this.lowLevel --;
  79. }else{
  80. this.level --;
  81. this.lowLevel = '';
  82. }
  83. this.area = row.code;
  84. this.areaTitle = row.name;
  85. //触发组件监听事件,去父页面请求新的数据
  86. this.$emit("getnewdata", {
  87. level: this.level,
  88. area: this.area,
  89. areaTitle: this.areaTitle,
  90. lowLevel: this.lowLevel,
  91. });
  92. }else{
  93. //弹框显示团队信息
  94. Vuedals.Bus.$emit('new', {
  95. title: '团队信息',
  96. component: 'team-info',
  97. props: {
  98. teamId: row.code
  99. }
  100. });
  101. }
  102. },
  103. getLowCodeData: function(code){
  104. if(code == 3){
  105. this.lowLevel = '';
  106. }else{
  107. this.lowLevel = code;
  108. }
  109. //触发组件监听事件,去父页面请求新的数据
  110. this.$emit("getnewdata", {
  111. level: this.level,
  112. area: this.area,
  113. lowLevel: this.lowLevel
  114. });
  115. }
  116. }
  117. });
  118. })()