From cf5ab6da9ff676fab8a10d4299bd5a04a07bf50f Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期一, 17 五月 2021 10:05:53 +0800 Subject: [PATCH] 修复默认选中图层时出现的BUG --- src/components/LayerController/service/WmsLayerService.js | 44 +++++----- src/conf/layers/LayerPipeLines.js | 2 src/conf/Constants.js | 167 ++++++++++++++++++++++++++++++++++------- src/components/LayerController/service/LayerFactory.js | 13 +-- 4 files changed, 164 insertions(+), 62 deletions(-) diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js index 8d7c1c6..d88b9a6 100644 --- a/src/components/LayerController/service/LayerFactory.js +++ b/src/components/LayerController/service/LayerFactory.js @@ -17,16 +17,17 @@ this.layersLogic = {} this.minZoomLayers = {} this.wmsLayers = [] + this.wmsLayerService = null // todo 寰呬紭鍖栵紝wmslayerservice璋冪敤锛屾斁杩欓噷涓嶅悎閫� this.clickSwitch = true // 鍥惧眰鐐瑰嚮寮圭獥寮�鍏� this.hightlightLayer = options.L.featureGroup({}).addTo(window.map) } init (layerConfig) { - this.initConfig(layerConfig) // wms鏈嶅姟鍙渶瑕佸垵濮嬪寲涓�娆� - this.wmsLayerService = new WmsLayerService(this.wmsLayers) + this.wmsLayerService = new WmsLayerService() this.wmsLayerService.init() + this.initConfig(layerConfig) } initConfig (layerConfig) { @@ -42,8 +43,8 @@ wmsGroupLayerService.init() continue } */ - layers && this.init(config.layers) - childLayer && this.init(config.childLayer) + layers && this.initConfig(config.layers) + childLayer && this.initConfig(config.childLayer) this.initMinZoom(config) this.loadLogic(config) @@ -77,10 +78,6 @@ logic = new BusiLayer() } else if (type === SERVICE_TYPE.WFS) { logic = new WfsLayerService(config) - } else if (type === SERVICE_TYPE.WMS) { - var layer = {} - layer[config.code] = config - this.wmsLayers.push(layer) } } this.layersLogic[code] = logic diff --git a/src/components/LayerController/service/WmsLayerService.js b/src/components/LayerController/service/WmsLayerService.js index fbc74bd..3b25bc6 100644 --- a/src/components/LayerController/service/WmsLayerService.js +++ b/src/components/LayerController/service/WmsLayerService.js @@ -29,9 +29,11 @@ this.featureGroup = this.L.featureGroup({}).addTo(this.map) this.wmsLayerList = new WmsLayerList() - for (var i = 0; i < layersConfig.length; i++) { - const config = layersConfig[i] - this.wmsLayerList.addConfig(config) + if (layersConfig) { + for (var i = 0; i < layersConfig.length; i++) { + const config = layersConfig[i] + this.wmsLayerList.addConfig(config) + } } this.load() } @@ -41,28 +43,24 @@ } add (config) { + console.log(config) this.wmsLayerList.addConfig(config) - const layers = this.wmsLayerList.getLayers() - const filter = this.wmsLayerList.getFilters() + const layers = this.wmsLayerList.getLayers() || '' + const filter = this.wmsLayerList.getFilters() || '' const params = {} - if (filter) { - params.cql_filter = filter - } - if (layers) { - params.layers = layers - } + params.cql_filter = filter + params.layers = layers + console.log(this.wmsLayerList) this.wmsLayer.setParams(params) } remove (config) { console.log(config) this.wmsLayerList.remove(config.typeName, config.filter) - const layers = this.wmsLayerList.getLayers() - const filter = this.wmsLayerList.getFilters() + const layers = this.wmsLayerList.getLayers() || '' + const filter = this.wmsLayerList.getFilters() || '' const params = { layers: layers } - if (filter) { - params.cql_filter = filter - } + params.cql_filter = filter this.wmsLayer.setParams(params) } @@ -109,13 +107,13 @@ AjaxUtils.get4JsonDataByUrl(WMS_URL, params, (res) => { const features = res.data.features /** - * { - * title: 'New Tab', - * name: newTabName, - * content: 'New Tab content' - * } - * @type {*[]} - */ + * { + * title: 'New Tab', + * name: newTabName, + * content: 'New Tab content' + * } + * @type {*[]} + */ const popupDatas = [] if (features) { for (var i = 0; i < features.length; i++) { diff --git a/src/conf/Constants.js b/src/conf/Constants.js index 3bab997..e615e29 100644 --- a/src/conf/Constants.js +++ b/src/conf/Constants.js @@ -36,34 +36,141 @@ } export const props = { - code: '缂栧彿', - name: '鍚嶇О', - teamname: '鍚嶇О', - pfktype: '鎺掓斁鍙g被鍨�', - level: '绾у埆', - length: '闀垮害(m)', - unitname: '鍗曚綅鍚嶇О', - pipename: '绠$嚎鍚嶇О', - subchaname: '鏀嚎鍚嶇О', - subchacode: '鏀嚎缂栫爜', - mediumtype: '杈撻�佷粙璐�', - startposname: '璧风偣浣嶇疆鍚嶇О', - endposname: '缁堢偣浣嶇疆鍚嶇О', - pressureating: '璁捐鍘嬪姏锛圡Pa锛�', - designtranyear: '璁捐杈撻噺锛堜竾绔�/骞达級', - earningcapacity: '瀹為檯杈撻噺锛堜竾绔�/骞达級', - buriedtime: '鍩嬭鏃堕棿', - coatingmaterial: '闃茶厫鐘跺喌', - inservicetime: '鎶曚骇鏃堕棿', - reportname: '濉姤浜哄鍚�', - reportphone: '濉姤浜鸿仈绯绘柟寮�', - diameter: '绠″緞(mm)', - meterial: '鏉愯川', - pressuerating: '绠¢亾鍘嬪姏(Mpa)', - embeddingmode: '鍩嬭鏂瑰紡', - pipetrenchtype: '绠℃矡绫诲瀷', - datecollected: '鎺㈡祴鏃堕棿', - operationalstatus: '杩愯鐘舵��', - fourtype: '鍥涢�氱被鍨�', - fourm: '鍥涢�氭潗鏂�' + // 绠$綉 + pipenet: { + // 绠$綉 + name: '鍚嶇О', + LINENUMTYPE: '绠$嚎绫诲瀷', + PIPENAME: '绠$嚎鍚嶇О', + MEDIUMTYPE: '杈撻�佷粙璐�', + LENGTH: '闀垮害(m)', + STARTPOSNAME: '璧风偣浣嶇疆鍚嶇О', + ENDPOSNAME: '缁堢偣浣嶇疆鍚嶇О', + BURIEDTIME: '鍩嬭鏃堕棿', + COATINGMATERIAL: '闃茶厫鐘跺喌', + INSERVICETIME: '鎶曚骇鏃堕棿', + UNITNAME: '鎵�灞炲崟浣嶅悕绉�', + ORGNAME: '鎵�灞炰紒涓氬悕绉�', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 绠$嚎 + pipeline: { + + }, + // 绐ㄤ簳 + manhole: { + type: '绫诲瀷', + wellmaterial: '浜曠洊鏉愯川', + HAVESAFETYNET: '鏄惁鏈夊畨鍏ㄧ綉', + DATASOURCE: '鏁版嵁鏉ユ簮', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 闃�闂� + valve: { + VALVETYPE: '闃�闂ㄧ被鍨�', + EXECUTAGENCYF: '鎵ц鏈烘瀯褰㈠紡', + DATASOURCE: '鏁版嵁鏉ユ簮', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 绠″粖锛堝甫锛� + pipegallery: { + DATASOURCE: '鏁版嵁鏉ユ簮', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 绠℃灦锛堝ⅸ锛� + piperack: { + PIPERACKTYPE: '绫诲瀷', + PIPERACKST: '绠℃灦(澧╋級缁撴瀯绫诲瀷', + LONGITUDINALPIPERACK: '鏄惁鏈夌旱鍚戞灦', + DATASOURCE: '鏁版嵁鏉ユ簮', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 涓夐�� + tee: { + TEETYPE: '涓夐�氱被鍨�', + EXPORTCONNECTM: '鍑哄彛杩炴帴鏂瑰紡', + ENTRYCONTYPE: '鍏ュ彛杩炴帴鏂瑰紡', + TEEM: '涓夐�氭潗鏂�', + BRANCHCONNTYPE: '鏀杩炴帴绫诲瀷', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 鍥涢�� + fourlink: { + FOURTYPE: '鍥涢�氱被鍨�', + EXPORTCONTYPE: '鍑哄彛杩炴帴鏂瑰紡', + ENTRYCONTYPE: '鍏ュ彛杩炴帴鏂瑰紡', + FOURM: '鍥涢�氭潗鏂�', + BRANCHCONNTYPE1: '鏀嚎1杩炴帴鏂瑰紡', + BRANCHCONNTYPE2: '鏀嚎2杩炴帴鏂瑰紡', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 寮ご + elbow: { + ELBOWTYPE: '寮ご绫诲瀷', + ELBOWMATERIAL: '寮ご鏉愭枡', + ANTICORROS: '闃茶厫鏉愭枡', + ENTRYCONNTYPE: '鍏ュ彛杩炴帴鏂瑰紡', + OUTLETCONNTYPE: '鍑哄彛杩炴帴鏂瑰紡', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 闆ㄧ瀛� + raingate: { + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 闃茬伀鍫� + firedike: { + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 闆嗘按姹狅紙缃愶級 + collectingbasin: { + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 鎺掓斁鍙� + dischargeport: { + MEDIUMTYPE: '浠嬭川', + PFKTYPE: '鎺掓斁鍙g被鍨�', + LEVEL: '绾у埆', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 鎴祦闂� + + // 婧㈡祦鍫� + overflowweir: { + MEDIUMTYPE: '闃叉孩浠嬭川', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 闅旀补姹� + oilseparator: { + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 姘翠綋 + pointhydrology: { + HYDROTYPE: '姘寸郴绫诲瀷', + DRINKINGRESOURCEIND: '鏄惁鏄ギ鐢ㄦ按婧�', + SEASONALRIVERIND: '鏄惁鏄鑺傛�ф渤娴�', + RESERVOIRLOCATION: '姘村簱浣嶇疆', + OPERATIONALSTATUS: '杩愯鐘舵��' + }, + // 鑷劧淇濇姢鍖� + pointpreservationzone: { + DATASOURCE: '鏁版嵁鏉ユ簮' + }, + // 鍖婚櫌 + hospital: { + HOSPITALLEAVAL: '鍖婚櫌璧勮川绛夌骇', + SUBTYPECD: '鍖婚櫌绫诲瀷', + DATASOURCE: '鏁版嵁鏉ユ簮' + }, + // 绀句細涓撲笟搴旀�ユ晳鎻撮槦浼� + emergencyres: { + DATASOURCE: '鏁版嵁鏉ユ簮' + }, + // 搴旀�ョ墿璧� + emergencyesources: { + DATASOURCE: '鏁版嵁鏉ユ簮' + }, + // 娑堥槻鍗曚綅 + firefightingunit: { + DATASOURCE: '鏁版嵁鏉ユ簮' + } } diff --git a/src/conf/layers/LayerPipeLines.js b/src/conf/layers/LayerPipeLines.js index bbccde9..ff746f1 100644 --- a/src/conf/layers/LayerPipeLines.js +++ b/src/conf/layers/LayerPipeLines.js @@ -17,7 +17,7 @@ code: 'rainline', name: '闆ㄦ按绾�', sname: '绠$綉', - checked: false, + checked: true, type: SERVICE_TYPE.WMS, layerGroup: 'sewer:pipeline_group', typeName: 'sewer:pipeline', -- Gitblit v1.8.0