area-data-panel.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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}" @click="getLowCodeData(3)"><span>各区</span></div>\
  6. <div v-show="level >= 3" class="area-tab" :class="{\'active\': level==3 || lowLevel==2}" @click="getLowCodeData(2)"><span>社区</span></div>\
  7. <div 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. }
  35. },
  36. mounted: function(){
  37. var vm = this;
  38. EventBus.$on("render-area-data", function(arg){
  39. vm.level = arg.level;
  40. vm.lowLevel = arg.lowLevel;
  41. vm.area = arg.area;
  42. vm.headers = arg.headers;
  43. vm.rows = arg.rows;
  44. })
  45. },
  46. methods: {
  47. getLowLeverData: function(row){
  48. if(this.level > 2 && this.lowLevel != 1){
  49. //跳转去下一级数据
  50. this.level --;
  51. this.area = row.code;
  52. //触发组件监听事件,去父页面请求新的数据
  53. this.$emit("getnewdata", {
  54. level: this.level,
  55. area: this.area,
  56. lowLevel: this.lowLevel
  57. });
  58. }else{
  59. //弹框显示团队信息
  60. Vuedals.Bus.$emit('new', {
  61. title: '团队信息',
  62. component: 'team-info',
  63. props: {
  64. teamId: 644
  65. }
  66. });
  67. }
  68. },
  69. getLowCodeData: function(code){
  70. if(code == 3){
  71. this.lowLevel = '';
  72. }else{
  73. this.lowLevel = code;
  74. }
  75. //触发组件监听事件,去父页面请求新的数据
  76. this.$emit("getnewdata", {
  77. level: this.level,
  78. area: this.area,
  79. lowLevel: this.lowLevel
  80. });
  81. }
  82. }
  83. });
  84. })()