e005d42f564f488192731bac2c29a0acf25f16a8.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div id="legendId" class="legendwrapper" :style="{'max-width':testWidth+'px'}" :class="status ? 'active': ''">
  3. <el-collapse-transition>
  4. <div v-show="status" class="legendbody">
  5. <div v-for="(val,index1) in legendShowArr" :key="index1">
  6. <p style="padding-left:10px">{{val.title}}:</p>
  7. <div v-for="(item,index) in val.list" :key="index" style="display: flex;align-items: center;padding-left:10px;
  8. padding-right:10px;min-width: 75px;">
  9. <el-checkbox :checked="true" @change="checkedChange(item)"></el-checkbox>
  10. <img :src="item.url" style="width:16px;height:16px;" :alt="item.name">
  11. <div style="padding-left: 5px;color:#2C9EFF;font-size: 14px;">{{item.name}}</div>
  12. </div>
  13. <div v-show="index1<legendShowArr.length-1" style="float:left;width: 1px;height: 15px; background: #000;"></div>
  14. </div>
  15. </div>
  16. </el-collapse-transition>
  17. </div>
  18. </template>
  19. <script>
  20. import {legendData} from '../config/legendConfig.js'
  21. export default {
  22. props: ['checkedLayerList'],
  23. data() {
  24. return {
  25. checked:true,
  26. status: true,
  27. legendShowArr:[],
  28. legendShowData:{},
  29. checkedLayerList1:[],
  30. testWidth:window.innerWidth,
  31. };
  32. },
  33. watch:{
  34. checkedLayerList(n,o){
  35. this.checkedLayerList1 = n;
  36. this.handleLayerChange();
  37. }
  38. },
  39. mounted(){
  40. this.checkedLayerList1 = this.checkedLayerList;
  41. this.handleLayerChange();
  42. },
  43. methods:{
  44. handleLayerChange(){
  45. var _self = this;
  46. _self.legendShowArr = [];
  47. legendData.forEach((item)=>{
  48. _self.checkedLayerList1.forEach((val)=>{
  49. if(item.id == val.id){
  50. _self.legendShowArr.push(item);
  51. }
  52. })
  53. })
  54. },
  55. checkedChange(val){
  56. this.$emit('lengendChangeHandler',val);
  57. }
  58. }
  59. };
  60. </script>
  61. <style scoped>
  62. .el-checkbox__inner{
  63. border: 1.2px solid #2C9EFF;
  64. }
  65. .legendwrapper {
  66. position: fixed;
  67. right: 0;
  68. bottom: 0;
  69. min-width: 80px;
  70. color: #000000;
  71. border: 1px solid #edebec;
  72. background-color: #ffffff;
  73. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.5);
  74. border-radius:4px;
  75. overflow-x:auto;
  76. }
  77. .legendtitle {
  78. position: relative;
  79. line-height: 30px;
  80. font-size: 16px;
  81. text-align: center;
  82. cursor: pointer;
  83. user-select: none;
  84. }
  85. .legendtitle::after {
  86. position: absolute;
  87. content: "";
  88. top: 10px;
  89. right: 10px;
  90. width: 14px;
  91. height: 10px;
  92. /* background: url(/src/views/zongHeXinXiNew/assets/row.png) 0 0 no-repeat; */
  93. background-size: 14px 10px;
  94. transform: rotate(180deg);
  95. }
  96. .active .legendtitle::after {
  97. transform: rotate(0deg);
  98. }
  99. .legendbody {
  100. display:flex;
  101. flex-wrap: wrap;
  102. /* box-sizing: border-box; */
  103. padding: 0 10px;
  104. /* display: flex;
  105. flex-direction: column;
  106. flex-wrap: wrap;
  107. justify-content: space-between;
  108. border-top: 1px solid #edebec; */
  109. }
  110. .legendbody > div {
  111. display: flex;
  112. align-items: center;
  113. /* width: 100%; */
  114. height: 46px;
  115. font-size: 16px;
  116. }
  117. .legendbody img {
  118. flex-shrink: 0;
  119. padding: 4px;
  120. flex-grow: 0;
  121. width: 12px;
  122. height: 12px;
  123. }
  124. </style>