派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-05-30 1f0e9a20cd76e21538b4ca77a3ed7ce2a979de90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
    <div class="inner-panel">
        <div class="panel-title"> 图层控制 </div>
        <div class="wms-panel">
            <el-scrollbar class="wms-panel-scrollbar">
                <div v-for="(item,index1) in serviceLayers" :key="index1" class="layerbox">
                    <i class="downUp el-icon-caret-bottom" @click="item.isShow=!item.isShow" :class="item.isShow?'':'active'" ></i><!-- el-icon-arrow-down -->
                    <!-- 一级图层遍历 -->
                    <div style="padding-left:25px;padding-top:10px;color:#fff;font-size: 16px;">
                        <input type="checkbox" :class="{ 'active': item.type === 1 }" :name="'wmsLayer_'+item.code" :checked="item.checked" :value="item.code" @change="swAllLayers(item)"/>{{ item.name }}
                    </div>
                    <div class="layerbox-item" v-show="item.isShow" >
                        <!-- 二级图层遍历 -->
                        <div class="basemap-layer-item" v-for="(itm,index2) in item.layers" :key="index2" :class="!itm.layers?'felxs':''" >
                            <input type="checkbox" :class="{ 'active': itm.type === 1 }" :name="'wmsSublayers_'+item.code+'_'+itm.code" :checked="itm.checked" :value="itm.code" @change="swAllLayers(itm)"/>{{ itm.name }}
                            <!-- 三级图层遍历 -->
                            <div class="layerbox-item-3" v-show="itm.layers">
                                <div class="basemap-layer-item" v-for="(layer,index3) in itm.layers" :key="index3">
                                    <input type="checkbox"
                                           :class="{ 'active': layer.type === 1 }"
                                           :name="'wmsSublayers_'+item.code+'_'+layer.code"
                                           :checked="layer.checked"
                                           :value="layer.code"
                                           @change="swAllLayers(layer)"/>
                                    <span :style="'color:'+layer.color">{{ layer.name }}</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </el-scrollbar>
        </div>
        <lc-service-layer-filter ref="serviceLayerFilter"></lc-service-layer-filter>
    </div>
</template>
 
<script>
import LcServiceLayerFilter from '@components/LayerController/modules/LcServiceLayerFilter'
import bus from '@/eventBus'
export default {
  name: 'LcServiceLayer',
  components: { LcServiceLayerFilter },
  data () {
    return {
      changeList: []
    }
  },
  computed: {
    serviceLayers () {
      return this.$store.state.map.serviceLayers.LayerSewersLine
    }
  },
  mounted () {
  },
  methods: {
    swAllLayers (item) {
      // eslint-disable-next-line no-debugger
      item.checked = !item.checked
      // this.toggleLayer(item)
      if (item.layers && item.layers.length > 0) {
        this.swLayers(item.layers, item.checked)
        if (item.checked) {
          window.layerFactory.showAll(this.changeList)
        } else {
          window.layerFactory.hideAll(this.changeList)
        }
        this.changeList = []
      } else {
        this.toggleLayer(item)
      }
      bus.$emit('changeSearchBar', item)
 
      // console.log(this.serviceLayers)
    },
    swLayers (configs, checked) {
      if (configs) {
        for (let i = 0, len = configs.length; i < len; ++i) {
          var config = configs[i]
          config.checked = checked
          this.changeList.push(config)
          if (config.layers) {
            this.swLayers(config.layers, checked)
          }
        }
      }
    },
    setLayerType (configs, checkedSum) {
      if (configs) {
        for (let i = 0, len = configs.length; i < len; ++i) {
          const config = configs[i]
          const checked = config.checked
          if (config.layers) {
            checkedSum = this.setLayerType(config.layers, checkedSum || 0)
            if (checkedSum === config.layers.length) {
              config.type = 2
              config.checked = true
            } else if (checkedSum === 0) {
              config.type = 0
              config.checked = false
            } else {
              config.type = 1
            }
            checkedSum = 0
            continue
          }
          checkedSum = checkedSum + (checked ? 1 : 0)
        }
        return checkedSum
      }
    },
    toggleLayer (itm) {
      if (itm.checked) {
        window.layerFactory.show(itm)
      } else {
        window.layerFactory.hide(itm)
      }
      // this.updateWms()
    }
  },
  watch: {
    serviceLayers: {
      handler: function (val) {
        this.setLayerType(val, 0)
      },
      immediate: true,
      deep: true
    }
  }
}
</script>
 
<style scoped lang="less">
    .inner-panel {
        .btn-filter {
            cursor: pointer;
            color: #ffffff;
        }
        .felxs{
            display: flex;
            flex-wrap:wrap;
            width: 50% !important;
        }
 
        .wms-panel {
 
            .wms-panel-scrollbar{
                // height: 600px;
                //width: 285px;
               // width: 1.79rem;
                height: 70vh;
                width:2.1rem;
                font-size: 14px;
            }
            .layerbox {
                width: 100%;
                position: relative;
                .downUp{
                    position: absolute;
                    top:3px;
                    left: -2px;
                    height: 30px;
                    width: 30px;
                    text-align: center;
                    line-height: 30px;
                    cursor: pointer;
                    font-size: 20px;
                    transition: all 1.5s;
                }
                .downUp.active{
                    transform: rotate(-90deg);
                }
                .downUp:hover{font-size: 26px;font-weight: 900}
                .layerbox-item {
                    padding-left: 25px;
                    padding-top: 5px;
                    display: flex;
                    flex-wrap:wrap;
                    .basemap-layer-item {margin-bottom: 5px;
                        width: 100%;
                      input[type="checkbox"]{width:10px;height:10px;display: inline-block;text-align: center;vertical-align: middle; line-height: 10px;position: relative;}
                      input[type="checkbox"]::before{content: "";position: absolute;top: 0;left: 0;background: #fff;width: 100%;height: 100%;border: 1px solid #d9d9d9}
                      input[type="checkbox"]:checked::before{content: "\2713";background-color: @color-highlight;position: absolute;top: 0;left: 0;width:100%;border: 1px solid #fff700;
                          color:@background-color;font-size: 10px;font-weight: bold;}
                        input.active[type="checkbox"]::before,
                        input.active[type="checkbox"]:checked::before{content: "\2713";background: @background-color;position: absolute;top: 0;left: 0;width:100%;border: 1px solid @background-color;
                            color:@color-highlight;font-size: 10px;font-weight: bold;}
                    }
                }
                .layerbox-item-3{
                    padding-left: 20px;
                    padding-top: 5px;
                    display: flex;
                    flex-wrap: wrap;
                    .basemap-layer-item{width: 50%}
                }
            }
        }
    }
 
</style>