index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!--
  2. * @description: 图层列表
  3. * @Author: xing.heng
  4. * @Date: 2023/3/16 11:32
  5. -->
  6. <template>
  7. <div class="layer-list-wrap">
  8. <draggable
  9. v-model="chartList"
  10. :options="{ group: 'chart' }"
  11. @change="change"
  12. >
  13. <div
  14. v-for="(chart) in chartList"
  15. :key="chart.code"
  16. :class="{
  17. 'layer-list-item': true,
  18. 'layer-list-item-hover': chart.code === hoverCode,
  19. 'layer-list-item-active': chart.code === activeCode
  20. }"
  21. @mouseenter.stop="changeHoverCode(chart.code)"
  22. @click.stop="changeActiveCode(chart.code)"
  23. @contextmenu="onContextmenu($event, chart)"
  24. >
  25. <div class="layer-list-item-icon el-icon-rank" />
  26. <div
  27. class="layer-list-item-name"
  28. :title="chart.title"
  29. >
  30. {{ chart.title }}
  31. </div>
  32. </div>
  33. </draggable>
  34. <el-empty
  35. v-if="!chartList.length"
  36. :image-size="90"
  37. description="未拖拽任何组件"
  38. />
  39. </div>
  40. </template>
  41. <script>
  42. import { mapMutations, mapState } from 'vuex'
  43. import draggable from 'vuedraggable'
  44. import chartContextMenu from 'data-room-ui/js/mixins/chartContextMenu'
  45. export default {
  46. name: 'LayerList',
  47. components: {
  48. draggable
  49. },
  50. mixins: [chartContextMenu],
  51. props: {},
  52. data () {
  53. return {
  54. }
  55. },
  56. computed: {
  57. ...mapState({
  58. chartList: state => state.bigScreen.pageInfo.chartList,
  59. activeCode: state => state.bigScreen.activeCode,
  60. activeItemConfig: state => state.bigScreen.activeItemConfig
  61. }),
  62. chartList: {
  63. get () {
  64. return this.$store.state.bigScreen.pageInfo.chartList
  65. },
  66. set (val) {
  67. this.changeLayout(val)
  68. }
  69. }
  70. },
  71. mounted () {},
  72. methods: {
  73. ...mapMutations({
  74. changeLayout: 'bigScreen/changeLayout',
  75. changeZIndex: 'bigScreen/changeZIndex',
  76. changeHoverCode: 'bigScreen/changeHoverCode',
  77. changeActiveCode: 'bigScreen/changeActiveCode'
  78. }),
  79. change (e) {
  80. this.changeZIndex(this.chartList)
  81. },
  82. changeActive (code) {
  83. this.changeActiveCode(code)
  84. this.$emit('openRightPanel')
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. @import '../../BigScreenDesign/fonts/iconfont.css';
  91. .layer-list-wrap {
  92. width: 100%;
  93. height: 100%;
  94. overflow: auto;
  95. .layer-list-item {
  96. width: 100%;
  97. height: 40px;
  98. display: flex;
  99. align-items: center;
  100. padding: 0 10px;
  101. cursor: move;
  102. &-icon {
  103. width: 20px;
  104. height: 20px;
  105. margin-right: 16px;
  106. display: flex;
  107. align-items: center;
  108. }
  109. &-name {
  110. font-size: 14px;
  111. color: #fff;
  112. // 超出省略
  113. overflow: hidden;
  114. text-overflow: ellipsis;
  115. white-space: nowrap;
  116. }
  117. &-hover {
  118. background-color: #007aff80;
  119. }
  120. &-active {
  121. background-color: #007aff;
  122. }
  123. }
  124. }
  125. </style>