From 0039429882f8434000a0f61d6995324f1589633a Mon Sep 17 00:00:00 2001 From: seatonwan9 <seatonwan9@163.com> Date: 星期日, 30 五月 2021 13:36:06 +0800 Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop --- src/components/LayerController/modules/LcServiceLayer.vue | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 66 insertions(+), 15 deletions(-) diff --git a/src/components/LayerController/modules/LcServiceLayer.vue b/src/components/LayerController/modules/LcServiceLayer.vue index 4bd7e82..eb0472f 100644 --- a/src/components/LayerController/modules/LcServiceLayer.vue +++ b/src/components/LayerController/modules/LcServiceLayer.vue @@ -7,17 +7,17 @@ <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="item.type==1?'active':''" :name="'wmsLayer_'+item.code" :checked="item.checked" :value="item.code" @change="swAllLayers(item)"/>{{ item.name }} + <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="itm.type==1?'active':''" :name="'wmsSublayers_'+item.code+'_'+itm.code" :checked="itm.checked" :value="itm.code" @change="swAllLayers(itm)"/>{{ itm.name }} + <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="layer.type==1?'active':''" + :class="{ 'active': layer.type === 1 }" :name="'wmsSublayers_'+item.code+'_'+layer.code" :checked="layer.checked" :value="layer.code" @@ -36,10 +36,15 @@ <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 @@ -51,8 +56,20 @@ swAllLayers (item) { // eslint-disable-next-line no-debugger item.checked = !item.checked - this.toggleLayer(item) - this.swLayers(item.layers, 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) + } + /* <<<<<<< HEAD + bus.$emit('changeSearchBar', item) this.serviceLayers.forEach(function (item1, index1) { if (item1.layers) { item1.istrue = 0 @@ -91,24 +108,49 @@ item1.type = 1 // 鍗婇�� } if (item1.name === '浼佷笟搴旀��') { - console.log(item1) + // console.log(item1) bus.$emit('changeSearchBar', item1) } // console.log(item1.layers.length, item1.istrue, item1.isfalse, item1.type) } }) +>>>>>>> de7390c66ef3e3fe316e804495a78d05a01f0160 */ // console.log(this.serviceLayers) }, - swLayers (layers, checked) { - if (layers) { - for (let i = 0, len = layers.length; i < len; ++i) { - var layer = layers[i] - layer.checked = checked - this.toggleLayer(layer) - if (layer.layers) { - this.swLayers(layer.layers, checked) + 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) { @@ -119,6 +161,15 @@ } // this.updateWms() } + }, + watch: { + serviceLayers: { + handler: function (val) { + this.setLayerType(val, 0) + }, + immediate: true, + deep: true + } } } </script> -- Gitblit v1.8.0