area-data-panel3.js 4.7 KB

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