| | |
| | | <template> |
| | | <div class="inner-panel"> |
| | | <div class="panel-title"> 图层控制 </div> |
| | | <div class="wms-panel"> |
| | | <div v-for="item in serviceLayers" :key="item.code" class="layerbox"> |
| | | <div><input type="checkbox" :name="'wmsLayer_'+item.code" :checked="item.checked" :value="item.code" |
| | | @change="swAllLayers(item)"/>{{ item.name }} <span @click="swFilter(item)" |
| | | class="btn-filter">过滤</span><span @click="loadWfs()" |
| | | class="btn-filter">测试</span> |
| | | </div> |
| | | <div class="layerbox-item"> |
| | | <div class="basemap-layer-item" v-for="itm in item.layers" :key="itm.code"><input type="checkbox" |
| | | :name="'wmsSublayers_'+item.code+'_'+itm.code" |
| | | :checked="itm.checked" |
| | | :value="itm.code" |
| | | @change="swWmsLayer(item.url,itm)"/>{{ |
| | | itm.name }} |
| | | <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> |
| | | </div> |
| | | </el-scrollbar> |
| | | </div> |
| | | <lc-service-layer-filter v-if="layerFilterVisible" ref="serviceLayerFilter"></lc-service-layer-filter> |
| | | <lc-service-layer-filter ref="serviceLayerFilter"></lc-service-layer-filter> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import WfsHelper from '../../helpers/WfsHelper' |
| | | import LcServiceLayerFilter from '@components/LayerController/modules/LcServiceLayerFilter' |
| | | import AjaxUtils from '../../../utils/AjaxUtils' |
| | | |
| | | export default { |
| | | name: 'LcServiceLayer', |
| | | components: { LcServiceLayerFilter }, |
| | | data () { |
| | | return { |
| | | layerFilterVisible: false |
| | | changeList: [] |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | } |
| | | }, |
| | | mounted () { |
| | | // console.log('03步骤:', this.helper) |
| | | this.updateServiceLayerList() |
| | | }, |
| | | methods: { |
| | | swAllLayers (item) { |
| | | // eslint-disable-next-line no-debugger |
| | | item.checked = !item.checked |
| | | for (let i = 0, len = item.layers.length; i < len; ++i) { |
| | | item.layers[i].checked = item.checked |
| | | } |
| | | this.updateWms() |
| | | }, |
| | | loadWfs () { |
| | | var wfsHelper = new WfsHelper() |
| | | wfsHelper.addTypeName('管线点') |
| | | wfsHelper.appendEquals('pipename', '研究院01路YS000001') |
| | | |
| | | AjaxUtils.GetDataAsynByUrl(wfsHelper.getUrl(), {}, (res) => { |
| | | console.log(res) |
| | | }) |
| | | }, |
| | | swWmsLayer (url, itm) { |
| | | itm.checked = !itm.checked |
| | | if (itm.checked) { |
| | | window.serviceLayerHelper.loadGeojsonLayer(url, itm) |
| | | // 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 { |
| | | window.serviceLayerHelper.removeLayer(itm) |
| | | this.toggleLayer(item) |
| | | } |
| | | // this.updateWms() |
| | | /* <<<<<<< HEAD |
| | | bus.$emit('changeSearchBar', item) |
| | | this.serviceLayers.forEach(function (item1, index1) { |
| | | if (item1.layers) { |
| | | item1.istrue = 0 |
| | | item1.isfalse = 0 |
| | | item1.layers.forEach(function (item2, index2) { |
| | | if (item2.layers) { |
| | | item2.istrue = 0 |
| | | item2.isfalse = 0 |
| | | item2.layers.forEach(function (item3, index3) { |
| | | if (item3.checked) { item2.istrue += 1 } else { item2.isfalse += 1 } |
| | | }) |
| | | // console.log(item2.layers.length, item2.istrue, item2.isfalse, item2.type) |
| | | if (item2.istrue === item2.layers.length) { |
| | | item2.type = 2 |
| | | item2.checked = true |
| | | } else if (item2.isfalse === item2.layers.length) { |
| | | item2.type = 0 |
| | | item2.checked = false |
| | | } else { |
| | | item2.type = 1 |
| | | } |
| | | if (item1.name === '专题图层') { |
| | | bus.$emit('changeSearchBar', item2) |
| | | // console.log(item2, 'item2') |
| | | } |
| | | if (item2.checked) { item1.istrue += 1 } else { item1.isfalse += 1 } |
| | | } |
| | | }) |
| | | if (item1.istrue === item1.layers.length) { |
| | | item1.type = 2 // 全选 |
| | | item1.checked = true |
| | | } else if (item1.isfalse === item1.layers.length) { |
| | | item1.type = 0 // 不选 |
| | | item1.checked = false |
| | | } else { |
| | | item1.type = 1 // 半选 |
| | | } |
| | | if (item1.name === '企业应急') { |
| | | // console.log(item1) |
| | | bus.$emit('changeSearchBar', item1) |
| | | } |
| | | // console.log(item1.layers.length, item1.istrue, item1.isfalse, item1.type) |
| | | } |
| | | }) |
| | | >>>>>>> de7390c66ef3e3fe316e804495a78d05a01f0160 */ |
| | | // console.log(this.serviceLayers) |
| | | }, |
| | | swFilter (item) { |
| | | this.layerFilterVisible = !this.layerFilterVisible |
| | | }, |
| | | updateServiceLayerList () { |
| | | |
| | | }, |
| | | updateWms () { |
| | | var mapConfig = this.mapConfig |
| | | var wmsHelper = new WfsHelper() |
| | | wmsHelper.initMapConfig(mapConfig) |
| | | var wmsLayersMap = wmsHelper.getWmsLayersMap() |
| | | for (var k in wmsLayersMap) { |
| | | var layers = wmsLayersMap[k] |
| | | var tileLayer = window.serviceLayerHelper.getTileLayer(k) |
| | | if (tileLayer) { |
| | | tileLayer.setParams({ layers: layers.join(',') }, false) |
| | | tileLayer.setUrl(tileLayer.config.url, false) |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | <style scoped lang="less"> |
| | | .inner-panel { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | |
| | | .btn-filter { |
| | | cursor: pointer; |
| | | color: #ffffff; |
| | | } |
| | | .felxs{ |
| | | display: flex; |
| | | flex-wrap:wrap; |
| | | width: 50% !important; |
| | | } |
| | | |
| | | .wms-panel { |
| | | display: flex; |
| | | flex-flow: column; |
| | | |
| | | .wms-panel-scrollbar{ |
| | | // height: 600px; |
| | | //width: 285px; |
| | | // width: 1.79rem; |
| | | height: 70vh; |
| | | width:2.1rem; |
| | | font-size: 14px; |
| | | } |
| | | .layerbox { |
| | | width: 100%; |
| | | display: flex; |
| | | flex-flow: column; |
| | | |
| | | 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-flow: row wrap; |
| | | margin-left: 15px; |
| | | margin-top: 5px; |
| | | |
| | | .basemap-layer-item { |
| | | width: 50%; |
| | | 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%} |
| | | } |
| | | } |
| | | } |
| | | } |