From 77f7281ff7cee541aaa51339512e6443b7d89e42 Mon Sep 17 00:00:00 2001 From: YANGDL <114714267@qq.com> Date: 星期二, 05 一月 2021 12:04:25 +0800 Subject: [PATCH] 修改eslint配置增加mock配置 --- src/components/panel/MonitorPanel.vue | 116 src/router/routes.js | 44 src/components/mapmodules/SafetyIndexBar.js | 222 +- src/utils/AjaxUtils.js | 162 src/store/modules/map.js | 78 .eslintrc.js | 28 src/components/helpers/VectorLayerHelper.js | 60 src/utils/MiscUtils.js | 178 src/store/modules/app.js | 28 aliases.config.js | 52 src/components/mapmodules/SafetyIndexLine.js | 188 + src/utils/wfsQueryUtils.js | 78 src/utils/GISUtil.js | 262 +- src/components/helpers/WmsHelper.js | 124 src/components/LayerController/BaseMapController.vue | 51 src/components/LayerController/modules/LcBaseMap.vue | 36 src/views/MapTemplate.vue | 95 src/components/LayerController/layerControllerPresets.js | 18 src/base/BaseVectorLayer.js | 144 src/components/LayerController/LayerController.vue | 120 src/components/helpers/ServiceLayerHelper.js | 196 +- src/components/LayerController/modules/LcServiceLayer.vue | 303 +- src/utils/DateUtils.js | 36 src/components/mapmodules/SafetyIndexPie.js | 65 src/utils/JsonUtils.js | 74 /dev/null | 1154 ------------ src/components/mapmodules/CommonLayerLoad.js | 125 src/main.js | 8 src/conf/MapConfig.js | 1150 ++++++------ package.json | 26 src/components/helpers/BasemapHelper.js | 141 src/components/panel/MonitorHZ.vue | 278 +- 32 files changed, 2,275 insertions(+), 3,365 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..654134e --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,28 @@ +module.exports = { + root: true, + env: { + node: true + }, + extends: [ + 'plugin:vue/essential', + '@vue/standard' + ], + parserOptions: { + parser: 'babel-eslint' + }, + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' + }, + overrides: [ + { + files: [ + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' + ], + env: { + mocha: true + } + } + ] +} diff --git a/aliases.config.js b/aliases.config.js index 41e0168..a01418b 100644 --- a/aliases.config.js +++ b/aliases.config.js @@ -1,26 +1,26 @@ -// const path = require('path') -// -// function resolveSrc(_path) { -// return path.join(__dirname, _path) -// } -// -// const aliases = { -// '@src': 'src', -// '@router': 'src/router', -// '@views': 'src/views', -// '@components': 'src/components', -// '@assets': 'src/assets', -// '@utils': 'src/utils', -// '@styles': 'src/styles' -// } -// -// module.exports = { -// webpack: {}, -// jest: {} -// } -// -// for (const alias in aliases) { -// module.exports.webpack[alias] = resolveSrc(aliases[alias]) -// module.exports.jest['^' + alias + '/(.*)$'] = -// '<rootDir>/' + aliases[alias] + '/$1' -// } +const path = require('path') + +function resolveSrc(_path) { + return path.join(__dirname, _path) +} + +const aliases = { + '@src': 'src', + '@router': 'src/router', + '@views': 'src/views', + '@components': 'src/components', + '@assets': 'src/assets', + '@utils': 'src/utils', + '@styles': 'src/styles' +} + +module.exports = { + webpack: {}, + jest: {} +} + +for (const alias in aliases) { + module.exports.webpack[alias] = resolveSrc(aliases[alias]) + module.exports.jest['^' + alias + '/(.*)$'] = + '<rootDir>/' + aliases[alias] + '/$1' +} diff --git a/package.json b/package.json index 4f30062..a9d5e32 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,11 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", + "serve-test": "vue-cli-service serve --mode test", + "serve-production": "vue-cli-service serve --mode production", + "build": "vue-cli-service build --mode development", + "build-test": "vue-cli-service build --mode test", + "build-production": "vue-cli-service build --mode production", "lint": "vue-cli-service lint" }, "dependencies": { @@ -32,30 +36,22 @@ "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-service": "~4.5.0", + "@vue/eslint-config-standard": "^5.1.2", "babel-eslint": "^10.1.0", "babel-loader": "^8.2.2", "cache-loader": "^4.1.0", "css-loader": "^5.0.1", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.0", + "mockjs": "^1.1.0", "less": "^3.13.0", "less-loader": "^7.1.0", "vue-loader": "^15.9.5", "vue-template-compiler": "^2.6.11" - }, - "eslintConfig": { - "root": true, - "env": { - "node": true - }, - "extends": [ - "plugin:vue/essential", - "eslint:recommended" - ], - "parserOptions": { - "parser": "babel-eslint" - }, - "rules": {} }, "browserslist": [ "> 1%", diff --git a/src/base/BaseVectorLayer.js b/src/base/BaseVectorLayer.js index 7bc8396..2f417cd 100644 --- a/src/base/BaseVectorLayer.js +++ b/src/base/BaseVectorLayer.js @@ -8,12 +8,12 @@ LOAD_TYPE_URL = 'url' // ajax鍔犺浇鏂规硶 /** * 鍒濆鍖栧浘灞� - * @param {*} options + * @param {*} options * <code> * { * map : '鍦板浘寮曠敤' * params : 鍦板浘鍔犺浇鍙傛暟 - * + * * code : 鍥惧眰缂栧彿 * name : 鍥惧眰鍚嶇О * loadType : 鍥惧眰鍔犺浇绫诲瀷锛� json鎴栬�卽rl @@ -22,114 +22,114 @@ * } * </code> */ - constructor(options){ - this.map = options.map // 蹇呭~椤� - this.params = options.params // 蹇呭~椤癸紝鍔犺浇鍥惧眰鏁版嵁鐨勫弬鏁帮紝 瀛愮被闇�瑕侊紝鍙互鏄瘂}绌哄璞� + constructor (options) { + this.map = options.map // 蹇呭~椤� + this.params = options.params // 蹇呭~椤癸紝鍔犺浇鍥惧眰鏁版嵁鐨勫弬鏁帮紝 瀛愮被闇�瑕侊紝鍙互鏄瘂}绌哄璞� - this.layerCode = options.code || '' // 鍥惧眰缂栫爜 - this.layerName = options.name || '' // 鍥惧眰鍚嶇О - this.layerLoadType = options.loadType || BaseVectorLayer.LOAD_TYPE_JSON // 鍥惧眰鍔犺浇绫诲瀷 - this.layerUrl = options.url || '' // 鏁版嵁璇锋眰鍦板潃 - this.layerData = options.data || '' // 鍘熷GeoJson鏁版嵁 + this.layerCode = options.code || '' // 鍥惧眰缂栫爜 + this.layerName = options.name || '' // 鍥惧眰鍚嶇О + this.layerLoadType = options.loadType || BaseVectorLayer.LOAD_TYPE_JSON // 鍥惧眰鍔犺浇绫诲瀷 + this.layerUrl = options.url || '' // 鏁版嵁璇锋眰鍦板潃 + this.layerData = options.data || '' // 鍘熷GeoJson鏁版嵁 - this.layerHandler = null // 鍥惧眰寮曠敤 + this.layerHandler = null // 鍥惧眰寮曠敤 - this.features = [] // 鎵�鏈夎鏋勫缓鍑烘潵鐨凢eatures - this.featuresArray = [] // 鎵�鏈夎鏋勫缓鍑烘潵鐨凢eatures淇濆瓨澶囦唤锛岄伩鍏嶅啀娆¤鍔犺浇銆� load鏂规硶鍏ㄧ敓鍛藉懆鏈熷彧琚皟鐢ㄤ竴娆� + this.features = [] // 鎵�鏈夎鏋勫缓鍑烘潵鐨凢eatures + this.featuresArray = [] // 鎵�鏈夎鏋勫缓鍑烘潵鐨凢eatures淇濆瓨澶囦唤锛岄伩鍏嶅啀娆¤鍔犺浇銆� load鏂规硶鍏ㄧ敓鍛藉懆鏈熷彧琚皟鐢ㄤ竴娆� - this.featuresGroup = new Map() // 瀵瑰姞杞界殑鏁版嵁杩涜鍒嗙粍锛屼究浜庡悗缁帶鍒躲�� 浣嗗湪鏁版嵁鍒濆鍖栨椂锛岄渶瑕佹墜鍔ㄥ垎缁勩�傚惁鍒欙紝鍒嗙粍 + this.featuresGroup = new Map() // 瀵瑰姞杞界殑鏁版嵁杩涜鍒嗙粍锛屼究浜庡悗缁帶鍒躲�� 浣嗗湪鏁版嵁鍒濆鍖栨椂锛岄渶瑕佹墜鍔ㄥ垎缁勩�傚惁鍒欙紝鍒嗙粍 - this._init(this.map, this.params) + this._init(this.map, this.params) } /** * 鍒濆鍖栧熀鏈殑鍥惧眰骞跺姞杞藉埌map涓� */ - _init(map){ - this.layerHandler = L.layerGroup().addTo(map) + _init (map) { + this.layerHandler = L.layerGroup().addTo(map) } /** * 鍔犺浇鏁版嵁 * @param boolean isAddToMap 鏄惁鐩存帴灏唌arker娣诲姞鍒板湴鍥句腑, 榛樿鏄姞杞� */ - load(isAddToMap = true){ - if(this.layerHandler) { // 榛樿锛屽簲璇ュ彧浼氬姞杞戒竴娆★紝浣嗘槸濡傛灉鏈夌殑鍥惧眰瑕佸畾鏃跺埛鏂帮紝鍒欓渶瑕佸厛娓呴櫎鍘熷浘灞傜殑鏁版嵁 - this.layerHandler.clearLayers() - } + load (isAddToMap = true) { + if (this.layerHandler) { // 榛樿锛屽簲璇ュ彧浼氬姞杞戒竴娆★紝浣嗘槸濡傛灉鏈夌殑鍥惧眰瑕佸畾鏃跺埛鏂帮紝鍒欓渶瑕佸厛娓呴櫎鍘熷浘灞傜殑鏁版嵁 + this.layerHandler.clearLayers() + } - let features = [] + const features = [] - // 渚濇嵁鍔犺浇鏂瑰紡鍔犺浇鏁版嵁 - if(this.layerLoadType === BaseVectorLayer.LOAD_TYPE_JSON) { - this.features = this._loadFromJSON() - - }else if(this.layerLoadType === BaseVectorLayer.LOAD_TYPE_URL) { - this.features = this._loadFromURL() - }else { - console.log('鍥惧眰銆�'+this.layerCode+'_'+this.layerName+'銆戠殑'+this.loadType+'鍔犺浇鏂瑰紡鏆備笉鏀寔锛�') - } + // 渚濇嵁鍔犺浇鏂瑰紡鍔犺浇鏁版嵁 + if (this.layerLoadType === BaseVectorLayer.LOAD_TYPE_JSON) { + this.features = this._loadFromJSON() + } else if (this.layerLoadType === BaseVectorLayer.LOAD_TYPE_URL) { + this.features = this._loadFromURL() + } else { + console.log('鍥惧眰銆�' + this.layerCode + '_' + this.layerName + '銆戠殑' + this.loadType + '鍔犺浇鏂瑰紡鏆備笉鏀寔锛�') + } - if(isAddToMap){ // 娣诲姞鍒板湴鍥句腑 - this.layerHandler.addLayer(features) - } + if (isAddToMap) { // 娣诲姞鍒板湴鍥句腑 + this.layerHandler.addLayer(features) + } } - _loadFromJSON(){ - console.log('璇ユ柟娉曟槸鎶借薄鏂规硶锛屽湪瀛愮被灏氭湭瀹炵幇锛�') + _loadFromJSON () { + console.log('璇ユ柟娉曟槸鎶借薄鏂规硶锛屽湪瀛愮被灏氭湭瀹炵幇锛�') } - _loadFromURL(){ - console.log('璇ユ柟娉曟槸鎶借薄鏂规硶锛屽湪瀛愮被灏氭湭瀹炵幇锛�') + + _loadFromURL () { + console.log('璇ユ柟娉曟槸鎶借薄鏂规硶锛屽湪瀛愮被灏氭湭瀹炵幇锛�') } /** * 鏄剧ず鍥惧眰锛� 濡傛灉groups鍙傛暟锛屽垯鍙樉绀篻roup瀵瑰簲鐨勫浘灞� * @param {} groups 鏁扮粍锛屽厓绱犱箣涓巐ayerGroups閿�煎搴斻�� */ - show(groups){ - if(typeof groups !== 'undefined') { // 濡傛灉浼犻�掍簡groups锛� 鍒欐寜鍒嗙粍鐨勮姹傚姞杞藉浘灞� - if(this.layerHandler) { - for(let i = 0, len = groups.length; i < len; i++) { - let gFeaturesArray = this.featuresGroup.get(groups[i]) - if(gFeaturesArray || gFeaturesArray.length > 0){ - gFeaturesArray.forEach(element => { - this.layerHandler.removeLayer(element) // 閬垮厤琚噸澶嶅姞杞� - this.layerHandler.addLayer(element) - }); - } - } + show (groups) { + if (typeof groups !== 'undefined') { // 濡傛灉浼犻�掍簡groups锛� 鍒欐寜鍒嗙粍鐨勮姹傚姞杞藉浘灞� + if (this.layerHandler) { + for (let i = 0, len = groups.length; i < len; i++) { + const gFeaturesArray = this.featuresGroup.get(groups[i]) + if (gFeaturesArray || gFeaturesArray.length > 0) { + gFeaturesArray.forEach(element => { + this.layerHandler.removeLayer(element) // 閬垮厤琚噸澶嶅姞杞� + this.layerHandler.addLayer(element) + }) } - } else { // 鍚﹀垯鍔犺浇鍏ㄩ儴鐨勬暟鎹� - if(this.layerHandler) { - this.layerHandler.clearLayers() - for(let i = 0, len = this.featuresArray.length; i < len; ++i){ - this.layerHandler.addLayer(this.featuresArray[i]) - } - } + } } + } else { // 鍚﹀垯鍔犺浇鍏ㄩ儴鐨勬暟鎹� + if (this.layerHandler) { + this.layerHandler.clearLayers() + for (let i = 0, len = this.featuresArray.length; i < len; ++i) { + this.layerHandler.addLayer(this.featuresArray[i]) + } + } + } } /** * 闅愯棌鍥惧眰锛� 濡傛灉groups鍙傛暟锛屽垯鍙殣钘廹roup瀵瑰簲鐨勫浘灞� * @param {} groups 鏁扮粍锛屽厓绱犱箣涓巐ayerGroups閿�煎搴斻�� 濡傛灉鍥惧眰鍦ㄥ垵濮嬪姞杞芥椂锛屾病鏈夊鏁版嵁鍒嗙粍锛岃鏂规硶涓嶄細鏈夋晥鏋溿�� */ - hide(groups){ - if(typeof groups !== 'undefined') { // 濡傛灉浼犻�掍簡groups锛� 鍒欐寜鍒嗙粍鐨勮姹傚姞杞藉浘灞� - if(this.layerHandler) { - for(let i = 0, len = groups.length; i < len; i++) { - let gFeaturesArray = this.featuresGroup.get(groups[i]) - if(gFeaturesArray || gFeaturesArray.length > 0){ - gFeaturesArray.forEach(element => { - this.layerHandler.removeLayer(element) - }); - } - } + hide (groups) { + if (typeof groups !== 'undefined') { // 濡傛灉浼犻�掍簡groups锛� 鍒欐寜鍒嗙粍鐨勮姹傚姞杞藉浘灞� + if (this.layerHandler) { + for (let i = 0, len = groups.length; i < len; i++) { + const gFeaturesArray = this.featuresGroup.get(groups[i]) + if (gFeaturesArray || gFeaturesArray.length > 0) { + gFeaturesArray.forEach(element => { + this.layerHandler.removeLayer(element) + }) } - } else { // 鍚﹀垯鍗歌浇鍏ㄩ儴鐨勬暟鎹� - if(this.layerHandler) { - this.layerHandler.clearLayers() - } + } } + } else { // 鍚﹀垯鍗歌浇鍏ㄩ儴鐨勬暟鎹� + if (this.layerHandler) { + this.layerHandler.clearLayers() + } + } } } diff --git a/src/components/LayerController/BaseMapController.vue b/src/components/LayerController/BaseMapController.vue index b47c1d8..e31db75 100644 --- a/src/components/LayerController/BaseMapController.vue +++ b/src/components/LayerController/BaseMapController.vue @@ -1,7 +1,7 @@ <template> -<div class="floatPanel frontMap basemapLayer"> - <div v-for="item in basemapLayers" :key="item.id" class="basemapLayerItem">{{item.text}}</div> -</div> + <div class="floatPanel frontMap basemapLayer"> + <div v-for="item in basemapLayers" :key="item.id" class="basemapLayerItem">{{ item.text }}</div> + </div> </template> <script> @@ -9,7 +9,7 @@ name: 'BaseMapController', mixins: [], components: [], - data() { + data () { return { basemapLayers: [ { @@ -79,25 +79,28 @@ </script> <style scoped lang="less"> - .frontMap{ - z-index: 1000; - } - .floatPanel{ - position: absolute; - top: 5px; - left: 5px; - width: 94px; - height: 32px; - } - .basemapLayer{ - border: lightgray 1px solid; - } - .basemapLayerItem{ - width: 26px; - height: 26px; - margin: 2px; +.frontMap { + z-index: 1000; +} - float: left; - background-color: white; - } +.floatPanel { + position: absolute; + top: 5px; + left: 5px; + width: 94px; + height: 32px; +} + +.basemapLayer { + border: lightgray 1px solid; +} + +.basemapLayerItem { + width: 26px; + height: 26px; + margin: 2px; + + float: left; + background-color: white; +} </style> diff --git a/src/components/LayerController/LayerController.vue b/src/components/LayerController/LayerController.vue index 5481419..743f80c 100644 --- a/src/components/LayerController/LayerController.vue +++ b/src/components/LayerController/LayerController.vue @@ -1,15 +1,13 @@ <template> <div class="float-panel"> - <!-- <i class="horn horn-tl"></i> --> - <!-- <i class="horn horn-tr"></i> --> <i class="horn horn-br"></i> <i class="horn horn-bl"></i> - <div class="head title-border"> <div class="title-text-border"> <div class="title-icon"></div> <div class="title-text">涓氬姟鐪嬫澘</div> - <div class="title-button" :class="{'switch-head-up':true, 'switch-head-down': !panelSwitch.main}" @click="switchPanel"> + <div class="title-button" :class="{'switch-head-up':true, 'switch-head-down': !panelSwitch.main}" + @click="switchPanel"> <!-- <i class="el-icon-arrow-down"></i> --> </div> </div> @@ -23,17 +21,14 @@ </template> <script> -import api from './LayerControllerAPI' -// import { mapState, mapMutations } from 'vuex' import '@assets/css/map/magic.min.css' import presets from './layerControllerPresets' -// import $ from 'jquery' import iconSetting from '@/assets/images/map-pages/icon/setting.png' export default { name: 'LayerController', - components: { }, + components: {}, props: { preset: { type: String, @@ -41,66 +36,65 @@ } }, computed: { - map(){ + map () { return this.$store.state.map.map }, - L(){ + L () { return this.$store.state.map.L }, - layerHelper(){ + layerHelper () { return this.$store.state.map.layerHelper }, - layerControllerVisible(){ + layerControllerVisible () { return this.$store.state.map.layerControllerVisible } }, - data() { + data () { return { - height:'200px', - icons:{ - setting:iconSetting + height: '200px', + icons: { + setting: iconSetting }, panelSwitch: { main: true // 涓荤獥鍙� } } }, - mounted() { - this.$nextTick(function() { - this.init() - console.log(api) - }) + mounted () { + this.$nextTick(function () { + this.init() + }) }, methods: { - init() { + init () { this.initPreset() }, - initPreset() { + initPreset () { if (this.preset !== 'default') { - let prmPreset = presets[this.preset] + const prmPreset = presets[this.preset] Object.assign(this.layerControllerVisible, prmPreset) // 闃叉棰勮鍙傛暟涓庨粯璁ゅ弬鏁颁笉涓�鑷村鑷存姤閿欙紝濡傛灉娌℃湁鎸夌収鎮ㄧ殑閰嶇疆鍙戠敓鏀瑰彉锛岃妫�鏌ユ嫾鍐欐槸鍚︽纭� if (prmPreset === 'undefined') { console.log('璇ュ浘灞傛帶鍒堕潰鏉跨殑棰勮娌℃湁鎵惧埌锛岃妫�鏌ラ璁惧悕绉版槸鍚︽纭紒') } else { - this.$store.commit('updateLayerControllerVisible', this.layerControllerVisible); + this.$store.commit('updateLayerControllerVisible', this.layerControllerVisible) } } }, - switchPanel() { + switchPanel () { this.panelSwitch.main = !this.panelSwitch.main if (this.panelSwitch.main) { this.height = '200px' } else { this.height = '0px' } - }, + } } } </script> <style lang="less"> -.float-panel{ +.float-panel { position: absolute; left: 10px; bottom: 10px; @@ -108,14 +102,17 @@ height: auto; font-size: 11px; z-index: 1000; - div{ - color:#90c8e0; + + div { + color: #90c8e0; } - #panelInnerContent{ + + #panelInnerContent { overflow: hidden; transition: all 0.5s linear; } - .title-border{ + + .title-border { width: 100%; height: 28px; background: #10488c; @@ -123,6 +120,7 @@ clip-path: polygon(0px 0px, 0px 28px, 230px 28px, 230px 9px, 95px 9px, 86px 0px); position: relative; } + .title-border:before { content: ""; display: block; @@ -133,6 +131,7 @@ left: 0; background-color: #38c8ef; } + .title-border:after { content: ""; display: block; @@ -145,6 +144,7 @@ -webkit-clip-path: polygon(0px 0px, 0px 1px, 5px 1px, 5px 6px, 6px 6px, 6px 0px); clip-path: polygon(0px 0px, 0px 1px, 5px 1px, 5px 6px, 6px 6px, 6px 0px); } + .title-text-border { width: 100%; height: 28px; @@ -152,7 +152,8 @@ -webkit-clip-path: polygon(1px 1px, 1px 27px, 229px 27px, 229px 10px, 94px 10px, 85px 1px); clip-path: polygon(1px 1px, 1px 27px, 229px 27px, 229px 10px, 94px 10px, 85px 1px); } - .title-icon{ + + .title-icon { float: left; width: 22px; height: 22px; @@ -160,7 +161,8 @@ margin-left: 2px; background-image: url(/assets/images/map-pages/icon/setting.png); } - .title-text{ + + .title-text { float: left; width: 150px; color: #00d0f9; @@ -172,7 +174,8 @@ filter: brightness(100%); text-shadow: 0 0 5px #00d0f9, 0 0 0 #00d0f9, 0 0 0 #00d0f9, 0 0 0 #0258c5, 0 0 0 #0258c5, 0 0 2px #0258c5, 0 0 5px #0258c5, 0 0 15px #0258c5; } - .title-line{ + + .title-line { display: inline-block; width: 120px; height: 1px; @@ -182,7 +185,8 @@ line-height: 5px; vertical-align: middle; } - .title-point{ + + .title-point { display: inline-block; width: 5px; height: 5px; @@ -191,25 +195,27 @@ line-height: 5px; vertical-align: middle; } - .title-button{ + + .title-button { float: right; width: 28px; height: 28px; cursor: pointer; - :hover{ + + :hover { font-weight: bold; color: white; } } - .body-box{ - background-color: rgba(44,62,80, 0.6); + .body-box { + background-color: rgba(44, 62, 80, 0.6); border: 1px solid #10488c; margin-top: -1px; height: auto; } - .switch-head-up{ + .switch-head-up { width: 22px; height: 16px; float: right; @@ -221,12 +227,14 @@ transform-origin: 50% 50%; transition: transform 0.5s linear 0s; } - .switch-head-down{ + + .switch-head-down { transform: rotateX(180deg); transform-origin: 50% 50%; transition: transform 0.5s linear 0s; } - select{ + + select { background: transparent; margin: 6px; border: .5px solid #569EB7; @@ -234,48 +242,56 @@ color: #569EB7; padding: 0 16px; } - .horn{ + + .horn { width: 6px; height: 6px; float: left; position: absolute; } - .horn-tl{ + + .horn-tl { background-image: url(/assets/images/map-pages/cosmetics/horn_tl.png) center center no-repeat; left: -1px; top: -1px; } - .horn-tr{ + + .horn-tr { background-image: url(/assets/images/map-pages/cosmetics/horn_tr.png) center center no-repeat; right: -1px; top: -1px; } - .horn-bl{ + + .horn-bl { background-image: url(/assets/images/map-pages/cosmetics/horn_bl.png) center center no-repeat; left: -1px; bottom: -1px; } - .horn-br{ + + .horn-br { background-image: url(/assets/images/map-pages/cosmetics/horn_br.png) center center no-repeat; right: -1px; bottom: -1px; } - ::-webkit-scrollbar{ + + ::-webkit-scrollbar { width: 7px; height: 5px !important; } + ::-webkit-scrollbar-thumb { /*婊氬姩鏉¢噷闈㈠皬鏂瑰潡*/ border-radius: 10px; - box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2); - background : #0661AE; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + background: #0661AE; border: 1px solid transparent; } + ::-webkit-scrollbar-track { /*婊氬姩鏉¢噷闈㈣建閬�*/ // box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2); border-radius: 0px; - background : #0E3565; + background: #0E3565; } } diff --git a/src/components/LayerController/LayerControllerAPI.js b/src/components/LayerController/LayerControllerAPI.js deleted file mode 100644 index c342984..0000000 --- a/src/components/LayerController/LayerControllerAPI.js +++ /dev/null @@ -1,5 +0,0 @@ -import mapApi from '@/api/mapApi' -console.log(mapApi) - -export default { -} diff --git a/src/components/LayerController/layerControllerPresets.js b/src/components/LayerController/layerControllerPresets.js index 386a6cc..a092886 100644 --- a/src/components/LayerController/layerControllerPresets.js +++ b/src/components/LayerController/layerControllerPresets.js @@ -1,26 +1,26 @@ /** * 澶у浘鍥惧眰鎺у埗闈㈡澘鐨勬樉绀洪璁� */ -let bigmapPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� - layerController: true, // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� +const bigmapPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� + layerController: true // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� } /** * 缁煎悎鎶ヨ鍥惧眰鎺у埗闈㈡澘鐨勬樉绀洪璁� */ -let warningPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� - layerController: true, // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� +const warningPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� + layerController: true // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� } /** * 缁煎悎鎶ヨ鍥惧眰鎺у埗闈㈡澘鐨勬樉绀洪璁� */ -let vehicleWarningPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� - layerController: true, // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� +const vehicleWarningPreset = { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� + layerController: true // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� } export default { - bigmapPreset, - warningPreset, - vehicleWarningPreset + bigmapPreset, + warningPreset, + vehicleWarningPreset } diff --git a/src/components/LayerController/modules/LcBaseMap.vue b/src/components/LayerController/modules/LcBaseMap.vue index 81d9b56..315c641 100644 --- a/src/components/LayerController/modules/LcBaseMap.vue +++ b/src/components/LayerController/modules/LcBaseMap.vue @@ -1,14 +1,16 @@ <template> - <div class="inner-panel"> + <div class="inner-panel" v-show="isShow"> <div v-for="item in basemapList" :key="item.code" class="basemap-layer-item"> - <el-checkbox style="position: absolute;" name="basemap" v-model="selectedBasemap" :value="item.code" label="item.code" @change="changeBasemap">鏍囨敞</el-checkbox> -<!-- <el-popover--> -<!-- placement="top-start"--> -<!-- trigger="hover"--> -<!-- content="item.name">--> - <img :src="item.conf.icon_actived" width="50" height="50" :title="item.name" @click="changeBasemap"/> -<!-- </el-popover>--> -<!-- <input style="position: absolute;" type="radio" name="basemap" v-model="selectedBasemap" :value="item.code" title="鏄剧ず鏍囨敞" @change="changeBasemap"/>鏍囨敞--> + <div style="display: flex;"> + <el-checkbox :src="item.conf.icon_actived" style="display: flex;" name="basemap" v-model="selectedBasemap" + :value="item.code" label="item.code" @change="changeBasemap">鏍囨敞 + </el-checkbox> + <img style="position: absolute;" :src="item.conf.icon_actived" width="50" height="50" :title="item.name" + @click="changeBasemap"/> + </div> + + + <!-- <input style="position: absolute;" type="radio" name="basemap" v-model="selectedBasemap" :value="item.code" title="鏄剧ず鏍囨敞" @change="changeBasemap"/>鏍囨敞--> </div> </div> @@ -20,6 +22,7 @@ components: {}, data() { return { + isShow: true, basemapList: [], selectedBasemap: "tianditu_img", }; @@ -32,6 +35,9 @@ mounted() { }, methods: { + toggleShow() { + this.isShow = !this.isShow + }, updateBasemapList() { let list = this.basemapHelper.getBasemapList(); this.basemapList = list; @@ -39,8 +45,14 @@ changeBasemap() { this.basemapHelper.showBasemap(this.selectedBasemap, true) }, - } - + }, + watch: { + basemapHelper(newVal) { + if (newVal != null) { + this.updateBasemapList(); + } + }, + }, }; </script> @@ -50,6 +62,7 @@ justify-content: center; align-items: center; } + .basemap-layer-item { display: flex; width: 50px; @@ -62,6 +75,7 @@ left: 0px; top: -53px; } + .basemap-layer-item-name { position: relative; left: 0px; diff --git a/src/components/LayerController/modules/LcServiceLayer.vue b/src/components/LayerController/modules/LcServiceLayer.vue index 621be78..e7674d5 100644 --- a/src/components/LayerController/modules/LcServiceLayer.vue +++ b/src/components/LayerController/modules/LcServiceLayer.vue @@ -1,168 +1,169 @@ <template> - <div class="inner-panel"> - <div class="tile-panel"> - <div v-for="item in serviceTileLayerList" :key="item.code"><input type="checkbox" :value="item.name" - @change="swTileLayer"/></div> - </div> - <div class="wmts-panel"> - <div v-for="item in serviceWmtsLayerList" :key="item.code"><input type="checkbox" :value="item.name" - @change="swWmtsLayer"/></div> - </div> - <div class="wms-panel"> - <div v-for="item in serviceWmsLayerList" :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> - </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(itm)"/>{{itm.sname}} - </div> - </div> - </div> - </div> + <div class="inner-panel"> + <div class="tile-panel"> + <div v-for="item in serviceTileLayerList" :key="item.code"><input type="checkbox" :value="item.name" + @change="swTileLayer"/></div> </div> + <div class="wmts-panel"> + <div v-for="item in serviceWmtsLayerList" :key="item.code"><input type="checkbox" :value="item.name" + @change="swWmtsLayer"/></div> + </div> + <div class="wms-panel"> + <div v-for="item in serviceWmsLayerList" :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> + </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(itm)"/>{{ itm.sname }} + </div> + </div> + </div> + </div> + </div> </template> <script> - import WmsHelper from "../../helpers/WmsHelper"; +import WmsHelper from "../../helpers/WmsHelper"; - export default { - name: "LcServiceLayer", - components: {}, - data() { - return { - selectedLineLayer: [], // 閫変腑鐨勭绾垮浘灞� - selectedSubsidiaryLayer: [], // 閫変腑鐨勯檮灞炶绱� - serviceTileLayerList: [], // Tile鍥惧眰鍒楄〃 - serviceWmtsLayerList: [], // Wmts鍥惧眰鍒楄〃 - serviceWmsLayerList: [] // 鍥惧眰鍒楄〃 - }; - }, - computed: { - serviceLayerHelper(){ - return this.$store.state.map.serviceLayerHelper - }, - mapConfig(){ - return this.$store.state.map.mapConfig - } - }, - mounted() { - // console.log('03姝ラ锛�', this.helper) - }, - 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() - - console.log(this.mapConfig) - }, - swTileLayer() { - console.log('璇ILE鏂规硶鏈疄鐜帮紒') - }, - swWmtsLayer() { - console.log('璇MTS鏂规硶鏈疄鐜帮紒') - }, - swWmsLayer(itm) { - console.log('22222222') - itm.checked = !itm.checked - this.updateWms() - }, - swFilter(item) { - this.$store.commit('setSelectedServiceLayer', item.code) - this.$store.commit('toggleServiceLayerFilter') - }, - updateServiceLayerList() { - // eslint-disable-next-line no-debugger - // debugger - let tileCfg = this.serviceLayerHelper.getTileLayers() - this.serviceTileLayerList = [] - for (let i = 0, len = tileCfg.length; i < len; ++i) { - if (tileCfg[i].config.inLegend) { - console.log(tileCfg[i]) - } - } - let wmtsCfg = this.serviceLayerHelper.getWmtsLayers() - this.serviceWmtsLayerList = [] - for (let i = 0, len = wmtsCfg.length; i < len; ++i) { - if (wmtsCfg[i].config.inLegend) { - console.log(wmtsCfg[i]) - } - } - let wmsCfg = this.serviceLayerHelper.getWmsLayers() - this.serviceWmsLayerList = [] - for (let i = 0, len = wmsCfg.length; i < len; ++i) { - if (wmsCfg[i].config.inLegend) { - this.serviceWmsLayerList.push(wmsCfg[i].config) - } - } - }, - updateWms() { - console.log('------') - var mapConfig = this.mapConfig - var wmsHelper = new WmsHelper() - wmsHelper.initMapConfig(mapConfig) - var wmsLayersMap = wmsHelper.getWmsLayersMap() - //var filterURL = wmsHelper.getFilterURL() - console.log(wmsLayersMap) - for (var k in wmsLayersMap) { - var layers = wmsLayersMap[k] - var tileLayer = this.serviceLayerHelper.getTileLayer(k) - if (tileLayer) { - tileLayer.setParams({layers: layers.join(',')}, false) - tileLayer.setUrl(tileLayer.config.url,false) - } - } - } - }, - watch: { - serviceLayerHelper(newVal) { - if (newVal != null) { - this.updateServiceLayerList(); - } - }, - }, +export default { + name: "LcServiceLayer", + components: {}, + data() { + return { + selectedLineLayer: [], // 閫変腑鐨勭绾垮浘灞� + selectedSubsidiaryLayer: [], // 閫変腑鐨勯檮灞炶绱� + serviceTileLayerList: [], // Tile鍥惧眰鍒楄〃 + serviceWmtsLayerList: [], // Wmts鍥惧眰鍒楄〃 + serviceWmsLayerList: [] // 鍥惧眰鍒楄〃 }; + }, + computed: { + serviceLayerHelper() { + return this.$store.state.map.serviceLayerHelper + }, + mapConfig() { + return this.$store.state.map.mapConfig + } + }, + mounted() { + // console.log('03姝ラ锛�', this.helper) + }, + 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() + + console.log(this.mapConfig) + }, + swTileLayer() { + console.log('璇ILE鏂规硶鏈疄鐜帮紒') + }, + swWmtsLayer() { + console.log('璇MTS鏂规硶鏈疄鐜帮紒') + }, + swWmsLayer(itm) { + console.log('22222222') + itm.checked = !itm.checked + this.updateWms() + }, + swFilter(item) { + this.$store.commit('setSelectedServiceLayer', item.code) + this.$store.commit('toggleServiceLayerFilter') + }, + updateServiceLayerList() { + // eslint-disable-next-line no-debugger + // debugger + let tileCfg = this.serviceLayerHelper.getTileLayers() + this.serviceTileLayerList = [] + for (let i = 0, len = tileCfg.length; i < len; ++i) { + if (tileCfg[i].config.inLegend) { + console.log(tileCfg[i]) + } + } + let wmtsCfg = this.serviceLayerHelper.getWmtsLayers() + this.serviceWmtsLayerList = [] + for (let i = 0, len = wmtsCfg.length; i < len; ++i) { + if (wmtsCfg[i].config.inLegend) { + console.log(wmtsCfg[i]) + } + } + let wmsCfg = this.serviceLayerHelper.getWmsLayers() + this.serviceWmsLayerList = [] + for (let i = 0, len = wmsCfg.length; i < len; ++i) { + if (wmsCfg[i].config.inLegend) { + this.serviceWmsLayerList.push(wmsCfg[i].config) + } + } + }, + updateWms() { + console.log('------') + var mapConfig = this.mapConfig + var wmsHelper = new WmsHelper() + wmsHelper.initMapConfig(mapConfig) + var wmsLayersMap = wmsHelper.getWmsLayersMap() + //var filterURL = wmsHelper.getFilterURL() + console.log(wmsLayersMap) + for (var k in wmsLayersMap) { + var layers = wmsLayersMap[k] + var tileLayer = this.serviceLayerHelper.getTileLayer(k) + if (tileLayer) { + tileLayer.setParams({layers: layers.join(',')}, false) + tileLayer.setUrl(tileLayer.config.url, false) + } + } + } + }, + watch: { + serviceLayerHelper(newVal) { + if (newVal != null) { + this.updateServiceLayerList(); + } + }, + }, +}; </script> <style scoped lang="less"> - .inner-panel { +.inner-panel { + display: flex; + justify-content: center; + align-items: center; + + .btn-filter { + cursor: pointer; + } + + .wms-panel { + display: flex; + flex-flow: column; + + .layerbox { + width: 100%; + display: flex; + flex-flow: column; + + .layerbox-item { display: flex; - justify-content: center; - align-items: center; + flex-flow: row wrap; + margin-left: 15px; + margin-top: 5px; - .btn-filter { - cursor: pointer; + .basemap-layer-item { + width: 50%; } - - .wms-panel { - display: flex; - flex-flow: column; - - .layerbox { - width: 100%; - display: flex; - flex-flow: column; - - .layerbox-item { - display: flex; - flex-flow: row wrap; - margin-left: 15px; - margin-top: 5px; - - .basemap-layer-item { - width: 50%; - } - } - } - } + } } + } +} </style> diff --git a/src/components/helpers/BasemapHelper.js b/src/components/helpers/BasemapHelper.js index aa8c72f..d9a0801 100644 --- a/src/components/helpers/BasemapHelper.js +++ b/src/components/helpers/BasemapHelper.js @@ -1,16 +1,17 @@ /* eslint-disable no-debugger */ import AjaxUtils from '@/utils/AjaxUtils' + /** * 搴曞浘绠$悊鍔╂墜锛岃礋璐e簳鍥惧垱寤哄強寮�鍏� */ -class BasemapHelper{ - constructor(options) { - this.map = options.map - this.L = options.L - this.basemapList = [] - this.basemapMap = new Map() - this.basemapLayerGroup = options.L.layerGroup().addTo(options.map) - } +class BasemapHelper { + constructor (options) { + this.map = options.map + this.L = options.L + this.basemapList = [] + this.basemapMap = new Map() + this.basemapLayerGroup = options.L.layerGroup().addTo(options.map) + } /** * 璇ユ柟娉曡礋璐e悇绉嶅簳鍥惧姞杞藉埌鍦板浘涓� @@ -18,13 +19,13 @@ * @param defBasemapName 鍒濆鍖栧畬鎴愬悗锛岄粯璁ゆ樉绀虹殑鍥惧眰 */ initBasemap = (mapConfig, isIntranet) => { - if(isIntranet) { // 鍐呯綉 - this._getToken(mapConfig); // 鑾峰彇token鍚庯紝骞舵寜閰嶇疆鍔犺浇鍦板浘 - }else { // 澶栫綉 - this._createBasemapByConfig(mapConfig) - } + if (isIntranet) { // 鍐呯綉 + this._getToken(mapConfig) // 鑾峰彇token鍚庯紝骞舵寜閰嶇疆鍔犺浇鍦板浘 + } else { // 澶栫綉 + this._createBasemapByConfig(mapConfig) + } - return this.basemapMap + return this.basemapMap } /** @@ -32,7 +33,7 @@ * @returns {null} 缁撴瀯锛歔{鍚嶇О, 鍥惧眰寮曠敤}] */ getBasemapList = () => { - return this.basemapList + return this.basemapList } /** @@ -41,7 +42,7 @@ * @param code 鍚嶇О */ getBasemap = (map, code) => { - return this.basemapMap.get(code) + return this.basemapMap.get(code) } /** @@ -50,15 +51,15 @@ * @param isHideOthers 鏄惁鍏堝叧闂叾浠栧浘灞傦紝榛樿鏄痶rue */ showBasemap = (code, isHideOthers = true) => { - let basemap = this.basemapMap.get(code) - if(isHideOthers) { - for(let i = 0, len = this.basemapList.length; i < len; ++i){ - this.map.removeLayer(this.basemapList[i].layer) - this.map.removeLayer(this.basemapList[i].annotation) - } + const basemap = this.basemapMap.get(code) + if (isHideOthers) { + for (let i = 0, len = this.basemapList.length; i < len; ++i) { + this.map.removeLayer(this.basemapList[i].layer) + this.map.removeLayer(this.basemapList[i].annotation) } - this.map.addLayer(basemap.layer) - this.map.addLayer(basemap.annotation) + } + this.map.addLayer(basemap.layer) + this.map.addLayer(basemap.annotation) } /** @@ -66,68 +67,68 @@ * @param layer 寰呭叧闂浘灞傚紩鐢� */ hideBasemap = (code) => { - let basemap = this.basemapMap.get(code) - this.map.removeLayer(basemap.layer) - this.map.removeLayer(basemap.annotation) + const basemap = this.basemapMap.get(code) + this.map.removeLayer(basemap.layer) + this.map.removeLayer(basemap.annotation) } // 鍏綉鍒涘缓鍦板浘閮ㄥ垎 - _createBasemapByConfig(mapConfig){ - let internetBasemaps = mapConfig.mapConfig.InternetBaseMaps - for(let i = 0, len = internetBasemaps.length; i < len; ++i) { - let basemapConfig = internetBasemaps[i] - let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) - let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) + _createBasemapByConfig (mapConfig) { + const internetBasemaps = mapConfig.mapConfig.InternetBaseMaps + for (let i = 0, len = internetBasemaps.length; i < len; ++i) { + const basemapConfig = internetBasemaps[i] + const basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) + const basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) - let basemap = { - code: basemapConfig.code, - name: basemapConfig.name, - conf: basemapConfig, - layer: basemapLayer, - annotation: basemapAnnotationLayer - } - - this.basemapList.push(basemap); - this.basemapMap.set(basemapConfig.code, basemap) - if(typeof basemapConfig.isAddToMap !== 'undefined' && basemapConfig.isAddToMap) { - this.basemapLayerGroup.addLayer(basemapLayer) - this.basemapLayerGroup.addLayer(basemapAnnotationLayer) - } + const basemap = { + code: basemapConfig.code, + name: basemapConfig.name, + conf: basemapConfig, + layer: basemapLayer, + annotation: basemapAnnotationLayer } + + this.basemapList.push(basemap) + this.basemapMap.set(basemapConfig.code, basemap) + if (typeof basemapConfig.isAddToMap !== 'undefined' && basemapConfig.isAddToMap) { + this.basemapLayerGroup.addLayer(basemapLayer) + this.basemapLayerGroup.addLayer(basemapAnnotationLayer) + } + } } // 鍐呯綉鍦板浘鍒涘缓閮ㄥ垎 // 鑾峰彇鍐呯綉鍦板浘token锛屽苟鍔犺浇鍒板湴鍥句腑 _getToken = (mapConfig) => { - let params = mapConfig.TokenConfig - AjaxUtils.GetDataAsynByUrl(params.url, params.option, (token) => { - this._showTDT(token, mapConfig) - }) + const params = mapConfig.TokenConfig + AjaxUtils.GetDataAsynByUrl(params.url, params.option, (token) => { + this._showTDT(token, mapConfig) + }) } // 鍐呯綉鍦板浘鍔犺浇锛屽苟鍔犺浇鍒板湴鍥� _showTDT = (token, mapConfig) => { - let intranetBasemaps = mapConfig.mapConfig.IntranetBaseMaps - for(let i = 0, len = intranetBasemaps.length; i < len; ++i) { - let basemapConfig = intranetBasemaps[i] - let basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) - let basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) + const intranetBasemaps = mapConfig.mapConfig.IntranetBaseMaps + for (let i = 0, len = intranetBasemaps.length; i < len; ++i) { + const basemapConfig = intranetBasemaps[i] + const basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option) + const basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option) - let basemap = { - code: basemapConfig.code, - name: basemapConfig.name, - conf: basemapConfig, - layer: basemapLayer, - annotation: basemapAnnotationLayer - } - - this.basemapList.push(basemap); - this.basemapMap.set(basemapConfig.code, basemap) - if(typeof basemapConfig.isAddToMap !== 'undefined' && basemapConfig.isAddToMap) { - this.basemapLayerGroup.addLayer(basemapLayer) - this.basemapLayerGroup.addLayer(basemapAnnotationLayer) - } + const basemap = { + code: basemapConfig.code, + name: basemapConfig.name, + conf: basemapConfig, + layer: basemapLayer, + annotation: basemapAnnotationLayer } + + this.basemapList.push(basemap) + this.basemapMap.set(basemapConfig.code, basemap) + if (typeof basemapConfig.isAddToMap !== 'undefined' && basemapConfig.isAddToMap) { + this.basemapLayerGroup.addLayer(basemapLayer) + this.basemapLayerGroup.addLayer(basemapAnnotationLayer) + } + } } } diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js index 21573a9..7175040 100644 --- a/src/components/helpers/ServiceLayerHelper.js +++ b/src/components/helpers/ServiceLayerHelper.js @@ -5,159 +5,159 @@ import L from 'leaflet' class ServiceLayerHelper { - constructor(options) { - this.map = options.map - this.L = options.L - this.tileLayersMap = new Map() - this.tileLayersWMSArray = [] - this.tileLayersWMTSArray = [] - this.tileLayersTileArray = [] - this.mapConfig = {} - } + constructor (options) { + this.map = options.map + this.L = options.L + this.tileLayersMap = new Map() + this.tileLayersWMSArray = [] + this.tileLayersWMTSArray = [] + this.tileLayersTileArray = [] + this.mapConfig = {} + } - getTileLayer(code) { - return this.tileLayersMap.get(code) - } + getTileLayer (code) { + return this.tileLayersMap.get(code) + } - /** + /** * 鏍规嵁閰嶇疆鏂囦欢鍒濆鍖栦笟鍔″簳鍥� */ - initServiceLayers(mapConfig) { - this.mapConfig = mapConfig - this._loadLayers(mapConfig) - } + initServiceLayers (mapConfig) { + this.mapConfig = mapConfig + this._loadLayers(mapConfig) + } - /** + /** * 鎸夐厤缃枃浠跺姞杞戒笁绉嶄笉鍚岀被鍨嬬殑 * @param {*} mapConfig * @param {*} isAddToMap */ - _loadLayers(mapConfig, isAddToMap = true) { - console.debug('ServiceLayerHelper鍔犺浇鍙傛暟锛�', mapConfig) - for (let i = 0, len = mapConfig.mapConfig.ServiceLayers.length; i < len; ++i) { - let opt = mapConfig.mapConfig.ServiceLayers[i] - if (opt.type === 'wmts') { - this.loadWmtsLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) - } else if (opt.type === 'wms') { - this.loadWmsLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) - } else if (opt.type === 'tile') { - this.loadTileLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) - } - } + _loadLayers (mapConfig, isAddToMap = true) { + console.debug('ServiceLayerHelper鍔犺浇鍙傛暟锛�', mapConfig) + for (let i = 0, len = mapConfig.mapConfig.ServiceLayers.length; i < len; ++i) { + const opt = mapConfig.mapConfig.ServiceLayers[i] + if (opt.type === 'wmts') { + this.loadWmtsLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) + } else if (opt.type === 'wms') { + this.loadWmsLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) + } else if (opt.type === 'tile') { + this.loadTileLayer(opt, isAddToMap, mapConfig.mapConfig.ServiceLayers[i]) + } } + } - /** + /** * 寰�鍦板浘涓姞鍏ヤ竴涓猈MTS鏈嶅姟 * @param {}} options * @param {*} isAddToMap */ - loadWmtsLayer(options, isAddToMap = true, config) { - const layer = this.L.tileLayer(options.url, options.option); - layer.config = config + loadWmtsLayer (options, isAddToMap = true, config) { + const layer = this.L.tileLayer(options.url, options.option) + layer.config = config - if (isAddToMap) { - layer.addTo(this.map) - } - this.tileLayersMap.set(options.code, layer) - this.tileLayersWMTSArray.push(layer) + if (isAddToMap) { + layer.addTo(this.map) } + this.tileLayersMap.set(options.code, layer) + this.tileLayersWMTSArray.push(layer) + } - /** + /** * 寰�鍦板浘涓姞鍏ヤ竴涓猈MS鏈嶅姟 * @param {}} options * @param {*} isAddToMap */ - loadWmsLayer(options, isAddToMap = true, config) { - const layer = this.L.tileLayer.wms(options.url, options.option); - layer.config = config + loadWmsLayer (options, isAddToMap = true, config) { + const layer = this.L.tileLayer.wms(options.url, options.option) + layer.config = config - if (isAddToMap) { - layer.addTo(this.map) - } - this.tileLayersMap.set(options.code, layer) - this.tileLayersWMSArray.push(layer) + if (isAddToMap) { + layer.addTo(this.map) } + this.tileLayersMap.set(options.code, layer) + this.tileLayersWMSArray.push(layer) + } - /** + /** * 寰�鍦板浘涓姞鍏ヤ竴涓猅ILE鏈嶅姟 * @param {}} options * @param {*} isAddToMap */ - loadTileLayer(options, isAddToMap = true, config) { - const layer = this.L.tileLayer(options.url, { - layers: options.layers || 'all',//country - format: options.format || "image/png", - transparent: options.true || true, - crs: options.crs || L.CRS.EPSG4326, - maxZoom: options.maxZoom || 21, - minZoom: options.minZoom || 1, - zoomOffset: options.zoomOffset || 0 - }); - layer.config = config + loadTileLayer (options, isAddToMap = true, config) { + const layer = this.L.tileLayer(options.url, { + layers: options.layers || 'all', // country + format: options.format || 'image/png', + transparent: options.true || true, + crs: options.crs || L.CRS.EPSG4326, + maxZoom: options.maxZoom || 21, + minZoom: options.minZoom || 1, + zoomOffset: options.zoomOffset || 0 + }) + layer.config = config - if (isAddToMap) { - layer.addTo(this.map) - } - this.tileLayersMap.set(options.code, layer) - this.tileLayersTileArray.push(layer) + if (isAddToMap) { + layer.addTo(this.map) } + this.tileLayersMap.set(options.code, layer) + this.tileLayersTileArray.push(layer) + } - /** + /** * 闅愯棌鏈嶅姟鍥惧眰 * @param {*} name */ - hideTileLayer(code) { - if (this.tileLayersMap) { - let tileLayer = this.tileLayersMap.get(code) - this.map.removeLayer(tileLayer) - } + hideTileLayer (code) { + if (this.tileLayersMap) { + const tileLayer = this.tileLayersMap.get(code) + this.map.removeLayer(tileLayer) } + } - /** + /** * 灞曠ず鏈嶅姟鍥惧眰 * @param {*} name */ - showTileLayer(code) { - if (this.tileLayersMap) { - let tileLayer = this.tileLayersMap.get(code) - this.map.addLayer(tileLayer) - } + showTileLayer (code) { + if (this.tileLayersMap) { + const tileLayer = this.tileLayersMap.get(code) + this.map.addLayer(tileLayer) } + } - /** + /** * 鑾峰彇鎵�鏈夌殑TILE鏈嶅姟鍥惧眰 */ - getTileLayers() { - return this.tileLayersTileArray - } + getTileLayers () { + return this.tileLayersTileArray + } - /** + /** * 鑾峰彇鎵�鏈夌殑WMTS鏈嶅姟鍥惧眰 */ - getWmtsLayers() { - return this.tileLayersWMTSArray - } + getWmtsLayers () { + return this.tileLayersWMTSArray + } - /** + /** * 鑾峰彇鎵�鏈夌殑WMS鏈嶅姟鍥惧眰 */ - getWmsLayers() { - return this.tileLayersWMSArray - } + getWmsLayers () { + return this.tileLayersWMSArray + } - /** + /** * 閫氳繃code鏌ユ壘WMS鐨勬湇鍔¢厤缃� * @param {} code wms鏈嶅姟閰嶇疆鐨刢ode */ - getWMSConfig(code) { - let mc = this.mapConfig - for (let i = 0, len = mc.mapConfig.ServiceLayers.length; i < len; ++i) { - if (code == mc.mapConfig.ServiceLayers[i].code && mc.mapConfig.ServiceLayers[i].type === 'wms') { - return mc.mapConfig.ServiceLayers[i] - } - } - return null + getWMSConfig (code) { + const mc = this.mapConfig + for (let i = 0, len = mc.mapConfig.ServiceLayers.length; i < len; ++i) { + if (code == mc.mapConfig.ServiceLayers[i].code && mc.mapConfig.ServiceLayers[i].type === 'wms') { + return mc.mapConfig.ServiceLayers[i] + } } + return null + } } export default ServiceLayerHelper diff --git a/src/components/helpers/VectorLayerHelper.js b/src/components/helpers/VectorLayerHelper.js index 2ebcbc9..38b9102 100644 --- a/src/components/helpers/VectorLayerHelper.js +++ b/src/components/helpers/VectorLayerHelper.js @@ -1,56 +1,56 @@ /** * 涓氬姟鐩稿叧鐭㈤噺鍥剧鐞嗗姪鎵嬶紝璐熻矗涓氬姟鐩稿叧鐭㈤噺鍥惧垱寤哄強寮�鍏� */ -function VectorLayerHelper(options) { - this.map = options.map - this.L = options.L - this.vectorLayerMap = new Map() - this.vectorLayerList = [] - this.vectorLayerGroup = null - this.vueState = {} // 鐢ㄦ埛鍥惧眰鏉冮檺 - /** +function VectorLayerHelper (options) { + this.map = options.map + this.L = options.L + this.vectorLayerMap = new Map() + this.vectorLayerList = [] + this.vectorLayerGroup = null + this.vueState = {} // 鐢ㄦ埛鍥惧眰鏉冮檺 + /** * 璇ユ柟娉曡礋璐e悇绉嶅簳鍥惧姞杞藉埌鍦板浘涓� * 涓嶅悓椤甸潰鍔犺浇鍥惧眰涓嶅悓鏍规嵁妯″潡绫诲瀷閫夋嫨鍔犺浇涓嶅悓鍥惧眰 * @param map */ - this.initVectorLayers = (vueState) => { - this.vectorLayerGroup = options.L.layerGroup().addTo(options.map) - this.vueState = vueState - } + this.initVectorLayers = (vueState) => { + this.vectorLayerGroup = options.L.layerGroup().addTo(options.map) + this.vueState = vueState + } - /** + /** * 鑾峰彇鎵�鏈夌殑鍥惧眰鍒楄〃 * @returns {null} 缁撴瀯锛歔{鍚嶇О, 鍥惧眰寮曠敤}] */ - this.getVectorLayerList = () => { - return this.vectorLayerList - } + this.getVectorLayerList = () => { + return this.vectorLayerList + } - /** + /** * 閫氳繃鍚嶇О鑾峰彇鍥惧眰瀵硅薄 * @param name 鍚嶇О */ - this.getVectorLayer = (code) => { - return this.vectorLayerMap[code] - } + this.getVectorLayer = (code) => { + return this.vectorLayerMap[code] + } - /** + /** * 鏄剧ず鏌愪釜鍥惧眰 * @param name 鍥惧眰鍚嶇О */ - this.showVectorLayer = (code) => { - let layer = this.vectorLayerMap.get(code) - this.map.addLayer(layer) - } + this.showVectorLayer = (code) => { + const layer = this.vectorLayerMap.get(code) + this.map.addLayer(layer) + } - /** + /** * 闅愯棌鏌愪釜鍥惧眰 * @param name 鍥惧眰鍚嶇О */ - this.hideVectorLayer = (code) => { - let layer = this.vectorLayerMap.get(code) - this.map.removeLayer(layer) - } + this.hideVectorLayer = (code) => { + const layer = this.vectorLayerMap.get(code) + this.map.removeLayer(layer) + } } export default VectorLayerHelper diff --git a/src/components/helpers/WmsHelper.js b/src/components/helpers/WmsHelper.js index 93748f2..057a2f1 100644 --- a/src/components/helpers/WmsHelper.js +++ b/src/components/helpers/WmsHelper.js @@ -1,77 +1,77 @@ /** * 鍔犺浇WMS,鎷兼帴FILTER,LAYERS鍙傛暟绛� */ -function WmsHelper() { - this.filters = {} - this.wmsLayersMap = {} +function WmsHelper () { + this.filters = {} + this.wmsLayersMap = {} - this.initMapConfig = (mapConfig) => { - var serviceLayers = mapConfig.mapConfig.ServiceLayers - for (var i = 0; i < serviceLayers.length; i++) { - var service = serviceLayers[i] - var checked = service.checked - if (!checked) { - break - } - var filtersGroup = service.filtersGroup - if (filtersGroup) { - this.initLayer(service.code, filtersGroup) - } - } + this.initMapConfig = (mapConfig) => { + var serviceLayers = mapConfig.mapConfig.ServiceLayers + for (var i = 0; i < serviceLayers.length; i++) { + var service = serviceLayers[i] + var checked = service.checked + if (!checked) { + break + } + var filtersGroup = service.filtersGroup + if (filtersGroup) { + this.initLayer(service.code, filtersGroup) + } } - this.initLayer = (wms, layersGroup) => { - for (var i = 0; i < layersGroup.length; i++) { - var filters = layersGroup[i].filters - for (var j = 0; j < filters.length; j++) { - var layer = filters[j] - var checked = layer.checked - var code = layer.code - if (checked) { - this.addLayer(wms, code) - } - } + } + this.initLayer = (wms, layersGroup) => { + for (var i = 0; i < layersGroup.length; i++) { + var filters = layersGroup[i].filters + for (var j = 0; j < filters.length; j++) { + var layer = filters[j] + var checked = layer.checked + var code = layer.code + if (checked) { + this.addLayer(wms, code) } + } } - this.initFilter = () => { - /* for (var i = 0; i < filters.length; i++) { + } + this.initFilter = () => { + /* for (var i = 0; i < filters.length; i++) { var filter = filters[i] this.addFilter() - }*/ + } */ + } + this.addLayer = (wms, layer) => { + var wmsLayer = this.wmsLayersMap[wms] + if (wmsLayer) { + wmsLayer[wmsLayer.length] = layer + } else { + this.wmsLayersMap[wms] = [layer] } - this.addLayer = (wms, layer) => { - var wmsLayer = this.wmsLayersMap[wms] - if (wmsLayer) { - wmsLayer[wmsLayer.length] = layer - } else { - this.wmsLayersMap[wms] = [layer] + } + this.addFilter = (condition) => { + // var filter = this.filters[layer] + // if (filter) { + this.filters[this.filters.length] = condition + // } else { + // this.filters[layer] = [condition] + // } + } + this.getWmsLayersMap = () => { + return this.wmsLayersMap + } + this.getFilterURL = () => { + var filterURL = '' + var conditions = '' + for (var f in this.filters) { + var filters = this.filters[f] + for (var i = 0; i < filters.length; i++) { + conditions += filters[i] + if (i < filters.length) { + conditions += ',' } + } + filterURL += f + '.(' + conditions + ');' } - this.addFilter = (condition) => { - //var filter = this.filters[layer] - //if (filter) { - this.filters[this.filters.length] = condition - //} else { - // this.filters[layer] = [condition] - // } - } - this.getWmsLayersMap = () => { - return this.wmsLayersMap - } - this.getFilterURL = () => { - var filterURL = '' - var conditions = '' - for (var f in this.filters) { - var filters = this.filters[f] - for (var i = 0; i < filters.length; i++) { - conditions += filters[i] - if (i < filters.length) { - conditions += ',' - } - } - filterURL += f + '.(' + conditions + ');' - } - return filterURL.substr(0, filterURL.length - 1) - } + return filterURL.substr(0, filterURL.length - 1) + } } export default WmsHelper diff --git a/src/components/mapmodules/CommonLayerLoad.js b/src/components/mapmodules/CommonLayerLoad.js index f42cd55..dd970d2 100644 --- a/src/components/mapmodules/CommonLayerLoad.js +++ b/src/components/mapmodules/CommonLayerLoad.js @@ -4,71 +4,80 @@ import L from 'leaflet' import MapConfig from '@/conf/MapConfig' + const tokenStr = 'tk=' + 'f1b72b5e7cb1175acddfa485f1bc9770' + '&' + class CommonLayerLoad { - // 涓浗钃濊壊瑕嗙洊灞� - loadBlueMap() { - return L.tileLayer(MapConfig.BLUEMAP_HOST + '/server/ogcserver/whp_basemap_tile/wmts?x={x}&y={y}&z={z}', { - maxZoom: 7, - minZoom: 1, - zoomOffset: 1 + // 涓浗钃濊壊瑕嗙洊灞� + loadBlueMap () { + return L.tileLayer(MapConfig.BLUEMAP_HOST + '/server/ogcserver/whp_basemap_tile/wmts?x={x}&y={y}&z={z}', { + maxZoom: 7, + minZoom: 1, + zoomOffset: 1 - }) - } - // 閬撹矾璺� - loadNormalMap() { - return L.tileLayer('http://t0.tianditu.gov.cn/vec_c/wmts?' + tokenStr + - 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - }) - } - // 閬撹矾鏍囨敞 - loadNormalMapa() { - return L.tileLayer('http://t0.tianditu.gov.cn/cva_c/wmts?' + tokenStr + - 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 + }) + } - }) - } - // 褰卞儚鍥� - loadImgMapm() { - return L.tileLayer('http://t0.tianditu.gov.cn/img_c/wmts?' + tokenStr + + // 閬撹矾璺� + loadNormalMap () { + return L.tileLayer('http://t0.tianditu.gov.cn/vec_c/wmts?' + tokenStr + + 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + }) + } + + // 閬撹矾鏍囨敞 + loadNormalMapa () { + return L.tileLayer('http://t0.tianditu.gov.cn/cva_c/wmts?' + tokenStr + + 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + + }) + } + + // 褰卞儚鍥� + loadImgMapm () { + return L.tileLayer('http://t0.tianditu.gov.cn/img_c/wmts?' + tokenStr + 'layer=img&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - }) - } - // 褰卞儚鏍囨敞 - loadImgMapa() { - return L.tileLayer('http://t0.tianditu.gov.cn/cia_c/wmts?' + tokenStr + + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + }) + } + + // 褰卞儚鏍囨敞 + loadImgMapa () { + return L.tileLayer('http://t0.tianditu.gov.cn/cia_c/wmts?' + tokenStr + 'layer=cia&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - }) - } - // 涓煶鍖栧唴缃戝奖鍍忓浘 - loadIntranetImgMap(token) { - return L.tileLayer('http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-image-globe/WMTS?token=' + token + '&' + + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + }) + } + + // 涓煶鍖栧唴缃戝奖鍍忓浘 + loadIntranetImgMap (token) { + return L.tileLayer('http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-image-globe/WMTS?token=' + token + '&' + 'layer=img&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - }) - } - // 涓煶鍖栧唴缃戝奖鍍忓浘鏍囨敞 - loadIntranetImgMapCia(token) { - return L.tileLayer('http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-label-image/WMTS?token=' + token + '&' + + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + }) + } + + // 涓煶鍖栧唴缃戝奖鍍忓浘鏍囨敞 + loadIntranetImgMapCia (token) { + return L.tileLayer('http://10.246.132.249:8080/OneMapServer/rest/services/base-tdt-label-image/WMTS?token=' + token + '&' + 'layer=cia&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', { - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - }) - } + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + }) + } } + export default CommonLayerLoad diff --git a/src/components/mapmodules/SafetyIndexBar.js b/src/components/mapmodules/SafetyIndexBar.js index 5e306cc..ed5cdef 100644 --- a/src/components/mapmodules/SafetyIndexBar.js +++ b/src/components/mapmodules/SafetyIndexBar.js @@ -1,120 +1,122 @@ import echarts from 'echarts' -function drawSafetyBar(carDataArray, shipDataArray, plateDataArray) { - let myChart = echarts.init(document.getElementById('safetyBarIndex')) - myChart.setOption({ - color: ['#3398DB'], - tooltip: { - trigger: 'axis', - axisPointer: { // 鍧愭爣杞存寚绀哄櫒锛屽潗鏍囪酱瑙﹀彂鏈夋晥 - type: 'shadow' // 榛樿涓虹洿绾匡紝鍙�変负锛�'line' | 'shadow' - }, - textStyle: { - color: '#33FF90' - }, - extraCssText: 'background-color: rgba(73,177,231, 0.1);' +function drawSafetyBar (carDataArray, shipDataArray, plateDataArray) { + const myChart = echarts.init(document.getElementById('safetyBarIndex')) + myChart.setOption({ + color: ['#3398DB'], + tooltip: { + trigger: 'axis', + axisPointer: { // 鍧愭爣杞存寚绀哄櫒锛屽潗鏍囪酱瑙﹀彂鏈夋晥 + type: 'shadow' // 榛樿涓虹洿绾匡紝鍙�変负锛�'line' | 'shadow' + }, + textStyle: { + color: '#33FF90' + }, + extraCssText: 'background-color: rgba(73,177,231, 0.1);' + }, + legend: { + data: ['鑸硅埗', '杞﹁締'], + top: '6%', + right: '4%', + textStyle: { + color: '#33FFF8' + } + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + data: plateDataArray, + axisTick: { + alignWithLabel: true }, - legend: { - data: ['鑸硅埗', '杞﹁締'], - top: '6%', - right: '4%', - textStyle: { - color: '#33FFF8' - } + axisLabel: { + color: '#33FFF8' }, - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true + splitLine: { + show: false + } + } + ], + yAxis: [ + { + type: 'value', + axisLabel: { + color: '#33FFF8' }, - xAxis: [ - { - type: 'category', - data: plateDataArray, - axisTick: { - alignWithLabel: true - }, - axisLabel: { - color: '#33FFF8' - }, - splitLine: { - show: false - } - } - ], - yAxis: [ - { - type: 'value', - axisLabel: { - color: '#33FFF8' - }, - splitLine: { - show: true, - lineStyle: { - color: [ '#315070' ], - width: 1, - type: 'dashed' - } - } - } - ], - series: [ - { - name: '鑸硅埗', - type: 'bar', - barWidth: '12%', - color: 'rgb(88,228,239)', - itemStyle: { - normal: { - label: { - show: true, // 寮�鍚樉绀� - position: 'top', // 鍦ㄤ笂鏂规樉绀� - textStyle: { // 鏁板�兼牱寮� - color: '#ffffff', - fontSize: 12 - } - }, - barBorderRadius: [15, 15, 0, 0], - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { offset: 0, color: '#00ACFE' }, - { offset: 0.5, color: '#034B88' }, - { offset: 1, color: '#051A4C' } - ]) - } - }, - data: shipDataArray + splitLine: { + show: true, + lineStyle: { + color: ['#315070'], + width: 1, + type: 'dashed' + } + } + } + ], + series: [ + { + name: '鑸硅埗', + type: 'bar', + barWidth: '12%', + color: 'rgb(88,228,239)', + itemStyle: { + normal: { + label: { + show: true, // 寮�鍚樉绀� + position: 'top', // 鍦ㄤ笂鏂规樉绀� + textStyle: { // 鏁板�兼牱寮� + color: '#ffffff', + fontSize: 12 + } }, - { - name: '杞﹁締', - type: 'bar', - barWidth: '12%', - color: 'rgb(73,117,231)', - itemStyle: { - normal: { - label: { - show: true, // 寮�鍚樉绀� - position: 'top', // 鍦ㄤ笂鏂规樉绀� - textStyle: { // 鏁板�兼牱寮� - color: '#ffffff', - fontSize: 12 - } - }, - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { offset: 0, color: '#FED700' }, - { offset: 0.5, color: '#846B03' }, - { offset: 1, color: '#423105' } - ]), - barBorderRadius: [ 15, 15, 0, 0 ] - } - }, - data: carDataArray - } - ] - }) - window.addEventListener('resize', () => { myChart.resize() }) + barBorderRadius: [15, 15, 0, 0], + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: '#00ACFE' }, + { offset: 0.5, color: '#034B88' }, + { offset: 1, color: '#051A4C' } + ]) + } + }, + data: shipDataArray + }, + { + name: '杞﹁締', + type: 'bar', + barWidth: '12%', + color: 'rgb(73,117,231)', + itemStyle: { + normal: { + label: { + show: true, // 寮�鍚樉绀� + position: 'top', // 鍦ㄤ笂鏂规樉绀� + textStyle: { // 鏁板�兼牱寮� + color: '#ffffff', + fontSize: 12 + } + }, + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ + { offset: 0, color: '#FED700' }, + { offset: 0.5, color: '#846B03' }, + { offset: 1, color: '#423105' } + ]), + barBorderRadius: [15, 15, 0, 0] + } + }, + data: carDataArray + } + ] + }) + window.addEventListener('resize', () => { + myChart.resize() + }) } export default { - drawSafetyBar + drawSafetyBar } diff --git a/src/components/mapmodules/SafetyIndexLine.js b/src/components/mapmodules/SafetyIndexLine.js index 9706043..1c0c912 100644 --- a/src/components/mapmodules/SafetyIndexLine.js +++ b/src/components/mapmodules/SafetyIndexLine.js @@ -1,107 +1,109 @@ import echarts from 'echarts' import dayjs from 'dayjs' -function drawSafetyLine() { - let myChart = echarts.init(document.getElementById('safetyIndex')) - let yyyy = dayjs().format('YYYY') + '-' - let resDate = ['07-10', '07-11', '07-12', '07-13', '07-14', '07-15', '07-16'] - let resValue = [35, 20, 10, 20, 40, 30, 10] - let safetyStandardValue = 20 - myChart.setOption({ - tooltip: { - trigger: 'axis', - formatter: '<span style="text-align: center;display:block; color: #33FF90">' + yyyy + '{b0}</span>' + +function drawSafetyLine () { + const myChart = echarts.init(document.getElementById('safetyIndex')) + const yyyy = dayjs().format('YYYY') + '-' + const resDate = ['07-10', '07-11', '07-12', '07-13', '07-14', '07-15', '07-16'] + const resValue = [35, 20, 10, 20, 40, 30, 10] + const safetyStandardValue = 20 + myChart.setOption({ + tooltip: { + trigger: 'axis', + formatter: '<span style="text-align: center;display:block; color: #33FF90">' + yyyy + '{b0}</span>' + '<span style="color: #33FF90">{a0}锛歿c0}</span><br/>' + '<span style="color: #33FF90">瀹夊叏鏍囧噯鎸囨暟锛�' + safetyStandardValue + '</span>', // 鑷畾涔塼ip鏍煎紡 - backgroundColor: 'rgba(73,177,231, 0.1)', - axisPointer: { - lineStyle: { - color: 'rgba(73,177,231, 0.5)', - type: 'dashed' - } + backgroundColor: 'rgba(73,177,231, 0.1)', + axisPointer: { + lineStyle: { + color: 'rgba(73,177,231, 0.5)', + type: 'dashed' + } + } + }, + grid: { + left: '4%', + right: '10%', + bottom: '3%', + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: resDate, + axisLine: { + show: false, + lineStyle: { + color: '#33FFF8' + } + }, + axisTick: { // x杞村埢搴︾嚎 + show: false + } + }, + yAxis: { + type: 'value', + splitLine: { + lineStyle: { + type: 'dotted', // 璁剧疆缃戞牸绾跨被鍨� dotted:铏氱嚎 solid:瀹炵嚎 + color: 'rgb(73,177,231, 0.3)' + }, + show: true + }, + axisLine: { + show: false, + lineStyle: { + color: '#33FFF8' + } + }, + axisTick: { // y杞村埢搴︾嚎 + show: false + }, + nameTextStyle: { + lineHeight: 20 + } + }, + series: [ + { + name: '瀹夊叏鎸囨暟', + type: 'line', + data: resValue, + itemStyle: { + normal: { + lineStyle: { + color: 'rgb(233,209,74)', + width: 2 // 璁剧疆绾挎潯绮楃粏 } + } }, - grid: { - left: '4%', - right: '10%', - bottom: '3%', - containLabel: true - }, - xAxis: { - type: 'category', - boundaryGap: false, - data: resDate, - axisLine: { - show: false, - lineStyle: { - color: '#33FFF8' - } - }, - axisTick: { // x杞村埢搴︾嚎 - show: false - } - }, - yAxis: { - type: 'value', - splitLine: { - lineStyle: { - type: 'dotted', // 璁剧疆缃戞牸绾跨被鍨� dotted:铏氱嚎 solid:瀹炵嚎 - color: 'rgb(73,177,231, 0.3)' - }, - show: true - }, - axisLine: { - show: false, - lineStyle: { - color: '#33FFF8' - } - }, - axisTick: { // y杞村埢搴︾嚎 - show: false - }, - nameTextStyle: { - lineHeight: 20 - } - }, - series: [ + markLine: { + symbol: 'none', // 鍘绘帀鏍囧噯绾跨澶� + data: [ { - name: '瀹夊叏鎸囨暟', - type: 'line', - data: resValue, - itemStyle: { - normal: { - lineStyle: { - color: 'rgb(233,209,74)', - width: 2 // 璁剧疆绾挎潯绮楃粏 - } - } - }, - markLine: { - symbol: 'none', // 鍘绘帀鏍囧噯绾跨澶� - data: [ - { - label: { - normal: { - position: 'end', - formatter: '' - } - }, - name: '鏍囧噯鍊�', - yAxis: 20, - lineStyle: { - type: 'solid', - color: '#33FFF8', - width: 1 - } - } - ] + label: { + normal: { + position: 'end', + formatter: '' } + }, + name: '鏍囧噯鍊�', + yAxis: 20, + lineStyle: { + type: 'solid', + color: '#33FFF8', + width: 1 + } } - ] - }) - window.addEventListener('resize', () => { myChart.resize() }) + ] + } + } + ] + }) + window.addEventListener('resize', () => { + myChart.resize() + }) } export default { - drawSafetyLine + drawSafetyLine } diff --git a/src/components/mapmodules/SafetyIndexPie.js b/src/components/mapmodules/SafetyIndexPie.js index 44993aa..2b49d75 100644 --- a/src/components/mapmodules/SafetyIndexPie.js +++ b/src/components/mapmodules/SafetyIndexPie.js @@ -1,42 +1,45 @@ import echarts from 'echarts' -function drawSafetyPie(options) { - let id = options.id - // var title = options.title - let series = options.series - let legend = getLegend(series) - series = setSeriesLabel(series) - let myChart = echarts.init(document.getElementById(id)) - console.log(series) - console.log(legend) - // 鎸囧畾鍥捐〃鐨勯厤缃」鍜屾暟鎹� - myChart.setOption({ - series: series - }) - window.addEventListener('resize', () => { myChart.resize() }) +function drawSafetyPie (options) { + const id = options.id + // var title = options.title + let series = options.series + const legend = getLegend(series) + series = setSeriesLabel(series) + const myChart = echarts.init(document.getElementById(id)) + console.log(series) + console.log(legend) + // 鎸囧畾鍥捐〃鐨勯厤缃」鍜屾暟鎹� + myChart.setOption({ + series: series + }) + window.addEventListener('resize', () => { + myChart.resize() + }) } -function setSeriesLabel(series) { - for (var i = 0; i < series.length; i++) { - series[i]['label'] = { - position: 'inside', - formatter: '{d}%', - color: '#090607' - } +function setSeriesLabel (series) { + for (var i = 0; i < series.length; i++) { + series[i].label = { + position: 'inside', + formatter: '{d}%', + color: '#090607' } - return series + } + return series } -function getLegend(series) { - var legend = [] - for (var i = 0; i < series.length; i++) { - var datas = series[i].data - for (var j = 0; j < datas.length; j++) { - legend[legend.length] = datas[j].name - } +function getLegend (series) { + var legend = [] + for (var i = 0; i < series.length; i++) { + var datas = series[i].data + for (var j = 0; j < datas.length; j++) { + legend[legend.length] = datas[j].name } - return legend + } + return legend } + export default { - drawSafetyPie + drawSafetyPie } diff --git a/src/components/panel/MonitorHZ.vue b/src/components/panel/MonitorHZ.vue index 618b666..547a4b5 100644 --- a/src/components/panel/MonitorHZ.vue +++ b/src/components/panel/MonitorHZ.vue @@ -1,154 +1,154 @@ <template> - <div class="monitorHz"> - <el-card class="search-panel" style="background: #07325b;"> - <el-form ref="form" :model="form" label-width="80px" class="search-form"> - <el-form-item label="杞藉叿鍙凤細"> - <el-input v-model="form.name" placeholder="鍦ㄦ杈撳叆杞藉叿鍙�"></el-input> - </el-form-item> - <el-row :gutter="20"> - <el-col :span="4"> - <el-row> - <el-form-item label="鏃堕棿锛�"> - <el-date-picker - v-model="form.name" - type="date" - style="width: 118px;" - placeholder="閫夋嫨鏃ユ湡"> - </el-date-picker> - </el-form-item> - </el-row> - <el-row> - <el-form-item> - <el-date-picker - v-model="form.name" - type="date" - style="width: 118px;" - placeholder="閫夋嫨鏃ユ湡" - > - </el-date-picker> - </el-form-item> - </el-row> - </el-col> - <el-col :span="2"> - <div class="B-TMD-inp-button" @click="handleSearch"></div> - </el-col> - </el-row> - </el-form> - </el-card> - <el-card class="search-result" style="height:360px;"> - <div class="B-TMD-table-list" v-for="(item,index) in list" :key="index"> - <el-row :gutter="20"> - <el-col :span="2" style="padding-left: 15px"> - {{ index+1 }}銆� - </el-col> - <el-col :span="15" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> - {{ item.processorName }} - <br/> - {{ item.startAddress }} - </el-col> - <el-col :span="6"> - <a class="el-icon-location" style="font-size: 18px;margin-left:5px" - @click="handleLocation(item.dispatchNo,item.vno,item.eid,item.lng,item.lat)"></a> - <a class="el-icon-connection" style="font-size: 18px;margin-left:5px"></a> - </el-col> - </el-row> - </div> - </el-card> - <el-card class="footer-page" v-if="total > 10"> - <el-pagination - small - :current-page.sync="currentPage1" - @current-change="handleSearch" - :page-size="10" - layout="prev, pager, next" - :total="1000" - class="warnPagination" - > - </el-pagination> - </el-card> - </div> + <div class="monitorHz"> + <el-card class="search-panel" style="background: #07325b;"> + <el-form ref="form" :model="form" label-width="80px" class="search-form"> + <el-form-item label="杞藉叿鍙凤細"> + <el-input v-model="form.name" placeholder="鍦ㄦ杈撳叆杞藉叿鍙�"></el-input> + </el-form-item> + <el-row :gutter="20"> + <el-col :span="4"> + <el-row> + <el-form-item label="鏃堕棿锛�"> + <el-date-picker + v-model="form.name" + type="date" + style="width: 118px;" + placeholder="閫夋嫨鏃ユ湡"> + </el-date-picker> + </el-form-item> + </el-row> + <el-row> + <el-form-item> + <el-date-picker + v-model="form.name" + type="date" + style="width: 118px;" + placeholder="閫夋嫨鏃ユ湡" + > + </el-date-picker> + </el-form-item> + </el-row> + </el-col> + <el-col :span="2"> + <div class="B-TMD-inp-button" @click="handleSearch"></div> + </el-col> + </el-row> + </el-form> + </el-card> + <el-card class="search-result" style="height:360px;"> + <div class="B-TMD-table-list" v-for="(item,index) in list" :key="index"> + <el-row :gutter="20"> + <el-col :span="2" style="padding-left: 15px"> + {{ index + 1 }}銆� + </el-col> + <el-col :span="15" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"> + {{ item.processorName }} + <br/> + {{ item.startAddress }} + </el-col> + <el-col :span="6"> + <a class="el-icon-location" style="font-size: 18px;margin-left:5px" + @click="handleLocation(item.dispatchNo,item.vno,item.eid,item.lng,item.lat)"></a> + <a class="el-icon-connection" style="font-size: 18px;margin-left:5px"></a> + </el-col> + </el-row> + </div> + </el-card> + <el-card class="footer-page" v-if="total > 10"> + <el-pagination + small + :current-page.sync="currentPage1" + @current-change="handleSearch" + :page-size="10" + layout="prev, pager, next" + :total="1000" + class="warnPagination" + > + </el-pagination> + </el-card> + </div> </template> <script> - export default { - name: 'MonitorAreaTips', - components: {}, - data() { - return { - isPanelVisible: false, - total: 0, - list: [], - form: { - name: '', - region: '', - date1: '', - date2: '', - delivery: false, - type: [], - resource: '', - desc: '' - } - } - }, - methods: { - handleClose(done) { - console.log(done) - }, - handleClick(tab, event) { - console.log(tab, event) - }, - handleSearch() { - - } - }, - mounted() { - this.handleSearch() - } +export default { + name: 'MonitorAreaTips', + components: {}, + data () { + return { + isPanelVisible: false, + total: 0, + list: [], + form: { + name: '', + region: '', + date1: '', + date2: '', + delivery: false, + type: [], + resource: '', + desc: '' + } } + }, + methods: { + handleClose (done) { + console.log(done) + }, + handleClick (tab, event) { + console.log(tab, event) + }, + handleSearch () { + + } + }, + mounted () { + this.handleSearch() + } +} </script> <style lang="less"> - .monitorHz { - .el-message-box__content { - background-color: #030D2E; - } +.monitorHz { + .el-message-box__content { + background-color: #030D2E; + } - .search-form .el-form-item { - margin: 0px; - } + .search-form .el-form-item { + margin: 0px; + } - .search-form .el-icon-search { - display: grid; - line-height: 30px; - font-size: 18px; - } + .search-form .el-icon-search { + display: grid; + line-height: 30px; + font-size: 18px; + } - .search-panel { - border: #07325B; - background-color: #07325B; - } + .search-panel { + border: #07325B; + background-color: #07325B; + } - .search-result { - margin: 5px 0px 0px 0px; - padding: 0px; - border: #051842; - overflow-y: scroll; - background-color: #051842; - } + .search-result { + margin: 5px 0px 0px 0px; + padding: 0px; + border: #051842; + overflow-y: scroll; + background-color: #051842; + } - .B-TMD-table-list { - margin-top: 10px; - text-align: left; - padding-left: 10px; - color: #328EB5; - width: 100%; - line-height: 25px; - background-color: #0B3B6D; - } + .B-TMD-table-list { + margin-top: 10px; + text-align: left; + padding-left: 10px; + color: #328EB5; + width: 100%; + line-height: 25px; + background-color: #0B3B6D; + } - .footer-page { - position: absolute; - bottom: 5px; - } - } + .footer-page { + position: absolute; + bottom: 5px; + } +} </style> diff --git a/src/components/panel/MonitorPanel.vue b/src/components/panel/MonitorPanel.vue index 9eef24a..d4901e9 100644 --- a/src/components/panel/MonitorPanel.vue +++ b/src/components/panel/MonitorPanel.vue @@ -129,12 +129,12 @@ import $ from 'jquery' import MonitorHZ from './MonitorHZ' import mapApi from '@/api/mapApi' -import {mapState} from 'vuex' +import { mapState } from 'vuex' export default { name: 'MonitorPanel', - components: {MonitorHZ}, - data() { + components: { MonitorHZ }, + data () { return { isPanelVisible: false, wayBillVisible: true, @@ -153,19 +153,19 @@ attachOptions: [{ value: '1', label: '闃�闂�' - },{ + }, { value: '2', label: '绠″粖' - },{ + }, { value: '3', label: '绠℃灦' - },{ + }, { value: '4', label: '涓夐��' - },{ + }, { value: '5', label: '鍥涢��' - },{ + }, { value: '6', label: '寮ご' }], @@ -217,13 +217,13 @@ currentCorpType: state => state.currentCorpType, currentCorp: state => state.currentCorp }), - layerHelper() { + layerHelper () { return this.$store.layerHelper } }, watch: { currentCorpType: async function (val) { - let params = { + const params = { transNo: '', carrierName: '', transMode: '', @@ -235,13 +235,13 @@ size: 10, current: 1 } - let datas = await this.handleGetDatas(params) + const datas = await this.handleGetDatas(params) console.log(datas) // this.list = datas.data.records // this.total = datas.data.total }, currentCorp: async function (val) { - let params = { + const params = { transNo: '', carrierName: '', transMode: '', @@ -253,27 +253,27 @@ size: 10, current: 1 } - let datas = await this.handleGetDatas(params) + const datas = await this.handleGetDatas(params) console.log(datas) // this.list = datas.data.records // this.total = datas.data.total } }, methods: { - handleClose(done) { + handleClose (done) { console.log(done) }, - handlePipelineType(item){ + handlePipelineType (item) { console.log(item) - if(item === '2'){ + if (item === '2') { this.dataTypeOptions = this.attachOptions - }else if(item === '1'){ + } else if (item === '1') { this.dataTypeOptions = this.pipelineOptions } }, - async handlePage(page) { + async handlePage (page) { console.log(page) - let params = { + const params = { transNo: '', carrierName: '', transMode: '', @@ -285,43 +285,43 @@ size: this.pageSize, current: page } - let datas = await this.handleGetDatas(params) + const datas = await this.handleGetDatas(params) console.log(datas) // this.list = datas.data.records // this.total = datas.data.total }, - handleLocation(item) { + handleLocation (item) { window.vectorLayerHelper.vectorLayerMap.cheliang.showGeometryByXY(item.transNo, item.vehicleNo, item.lng, item.lat) }, - toggleMonitorPanel() { - let el = $('.btn-stretch') + toggleMonitorPanel () { + const el = $('.btn-stretch') // let cs = 'btn-stretch-active' var rightControl = $('#right-panel') - let right = rightControl.css('right') + const right = rightControl.css('right') if (right === '10px') { rightControl.animate({ right: '-290px' }) el.css({ - 'transform': 'rotateY(180deg)', + transform: 'rotateY(180deg)', 'transform-origin': '50% 50%', - 'transition': 'transform 1s linear' + transition: 'transform 1s linear' }) } else { rightControl.animate({ right: '10px' }) el.css({ - 'transform': 'rotateY(0deg)', + transform: 'rotateY(0deg)', 'transform-origin': '50% 50%', - 'transition': 'transform 1s linear' + transition: 'transform 1s linear' }) } }, - async handleSearch() { + async handleSearch () { // this.list = wayBillData.data // this.total = wayBillData.data.length - let params = { + const params = { transNo: this.form.transNo, carrierName: this.form.carrierName, transMode: this.form.transMode, @@ -332,15 +332,15 @@ size: this.pageSize, current: this.current } - let datas = await this.handleGetDatas(params) + const datas = await this.handleGetDatas(params) console.log(datas) // this.list = datas.data.pager.records // this.total = datas.data.pager.total }, - async handleInit() { + async handleInit () { // this.list = wayBillData.data // this.total = wayBillData.data.length - let params = { + const params = { transNo: '', carrierName: '', transMode: '', @@ -352,48 +352,48 @@ size: 10, current: 1 } - let datas = await this.handleGetDatas(params) + const datas = await this.handleGetDatas(params) console.log(datas) // this.list = datas.data.records // this.total = datas.data.total }, - async handleSetOrgCodeStrings() { - let orgCodes = await this.handleGetOrgCode() + async handleSetOrgCodeStrings () { + const orgCodes = await this.handleGetOrgCode() let orgCodesString = '' for (let i = 0; i < orgCodes.data.length; i++) { - let org = orgCodes.data[i] + const org = orgCodes.data[i] orgCodesString += org.orgCode + ',' } this.orgCodeStrings = orgCodesString.substring(0, orgCodesString.length - 1) }, - async handleGetOrgCode() { - let params = { + async handleGetOrgCode () { + const params = { orgSector: this.currentCorpType, serviceType: '' } - let datas = await mapApi.getOrganizationompanyList(params) + const datas = await mapApi.getOrganizationompanyList(params) return datas }, - async handleGetDatas(params) { + async handleGetDatas (params) { // let datas = await mapApi.getTransOrderlist(params) - let datas = params + const datas = params return datas }, - showHZ() { + showHZ () { this.wayBillVisible = true this.hzVisible = false this.isWaybillHover = true this.isRouteHover = false }, - showWayBill() { + showWayBill () { this.hzVisible = true this.wayBillVisible = false this.isWaybillHover = false this.isRouteHover = true } }, - mounted() { + mounted () { this.handleInit() } } @@ -524,12 +524,12 @@ width: 16px; height: 22px; display: block; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat 0 -90px; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat 0 -90px; cursor: pointer; } .B-TMD-table-list-title-y-car { - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -45px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -45px 0; width: 38px; height: 38px; display: block; @@ -537,7 +537,7 @@ } .B-TMD-table-list-title-y-car-offline { - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -90px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -90px 0; width: 38px; height: 38px; display: block; @@ -545,7 +545,7 @@ } .B-TMD-table-list-title-y-car-warning { - background: url('/assets/images/map-pages/icon/icon.png') no-repeat 0 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat 0 0; width: 38px; height: 38px; display: block; @@ -555,7 +555,7 @@ .btn-stretch { width: 20px; height: 28px; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -408px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -408px 0; margin-left: 10px; margin-top: 3px; cursor: pointer; @@ -566,7 +566,7 @@ } .btn-stretch-active { - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -440px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -440px 0; } .panel-tab { @@ -577,7 +577,7 @@ width: 40px; z-index: 500; background-color: #030D2E; - background: url('/assets/images/map-pages/icon/caidan.png') no-repeat; + background: url('../../assets/images/map-pages/icon/caidan.png') no-repeat; } .B-TMT-tab-div { @@ -598,7 +598,7 @@ height: 29px !important; margin-top: 0 !important; margin-left: 0 !important; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -320px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -320px 0; } .B-TMT-tab-route { @@ -606,7 +606,7 @@ height: 19px; margin-left: 5px; margin-top: 6px; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -169px 0; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -169px 0; } .B-TMT-tab-waybill-isActive, .B-TMT-tab-waybill:hover { @@ -614,7 +614,7 @@ height: 29px !important; margin-top: 0 !important; margin-left: -1px !important; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -361px 0 !important; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -361px 0 !important; } .B-TMT-tab-route-isActive, .B-TMT-tab-route:hover { @@ -622,7 +622,7 @@ height: 29px !important; margin-top: 0 !important; margin-left: -1px !important; - background: url('/assets/images/map-pages/icon/icon.png') no-repeat -197px 0 !important; + background: url('../../assets/images/map-pages/icon/icon.png') no-repeat -197px 0 !important; } .panel-tab ul { @@ -640,7 +640,7 @@ top: 0; right: 0; z-index: 999; - background: url('/assets/images/map-pages/icon/bgc.png') no-repeat; + background: url('../../assets/images/map-pages/icon/bgc.png') no-repeat; } .panel_searchTotal { @@ -726,7 +726,7 @@ color: #34e0ff; width: 100%; line-height: 25px; - background: url('/assets/images/map-pages/icon/dd.png') no-repeat; + background: url('../../assets/images/map-pages/icon/dd.png') no-repeat; } .B-TMD-inp-button { diff --git a/src/components/utils/AjaxUtils.js b/src/components/utils/AjaxUtils.js deleted file mode 100644 index 11d7517..0000000 --- a/src/components/utils/AjaxUtils.js +++ /dev/null @@ -1,101 +0,0 @@ -import $ from 'jquery' - -/** - * 瀵筳query鐨勫皝瑁卆jax鐨勪紶鏁版嵁鏂规硶 - * @param pUrl 璇锋眰鐨剈rl - * @param pData 鍙傛暟 - * @param pBackFun 鎴愬姛鍥炶皟 - */ -function post4JsonDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'post', - url: pUrl, - dataType: 'json', - data: pData, - async: true, - success: function(datas, nnn) { - pBackFun(datas) - }, - error: function(err, nnnn) { - console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) - } - }) -} - -/** - * 瀵筳query鐨勫皝瑁卆jax鐨勫彇鏁版嵁鏂规硶 - * @param pUrl 璇锋眰鐨剈rl - * @param pData 鍙傛暟 - * @param pBackFun 鎴愬姛鍥炶皟 - */ -function get4JsonDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'get', - url: pUrl, - dataType: 'json', - data: pData, - async: true, - success: function(datas, nnn) { - pBackFun(datas) - }, - error: function(err, nnnn) { - console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) - } - }) -} - -function GetDataAsynByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'GET', - url: pUrl, - data: pData, - timeout: 600000, - async: true, - success: function(datas, nnn) { - pBackFun(datas) - }, - error: function(e, nnnn) { - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) -} -function postDataAsynByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'post', - url: pUrl, - data: pData, - timeout: 600000, - async: true, - success: function(datas, nnn) { - pBackFun(datas) - }, - error: function(e, nnnn) { - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) -} - -function GetDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'GET', - url: pUrl, - data: pData, - timeout: 600000, - success: function(datas, nnn) { - pBackFun(datas) - }, - error: function(e, nnnn) { - // tmpErrJSONTextParse(e, pBackFun) // todo SGIS Server鏈変釜WFS鍥惧眰鏈嶅姟json瑙f瀽閿欒锛� 杩欓噷鏄殏鏃跺鐞嗭紝绛夎繃鍑犲ぉ榛庤��淇敼濂戒簡锛岃繖閲岄渶瑕佷慨鏀瑰洖鍘汇�� - console.log('杩斿洖鐨勯敊璇俊鎭細', e) - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) -} - -export default { - post4JsonDataByUrl, - get4JsonDataByUrl, - GetDataAsynByUrl, - postDataAsynByUrl, - GetDataByUrl -} diff --git a/src/components/utils/DateUtils.js b/src/components/utils/DateUtils.js deleted file mode 100644 index 6d6d868..0000000 --- a/src/components/utils/DateUtils.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 鏃ユ湡鏍煎紡鍖� - * @param fmt - * @param date - * @returns {*} - */ -function dateFormat(fmt, date) { - let ret - const opt = { - 'Y+': date.getFullYear().toString(), // 骞� - 'm+': (date.getMonth() + 1).toString(), // 鏈� - 'd+': date.getDate().toString(), // 鏃� - 'H+': date.getHours().toString(), // 鏃� - 'M+': date.getMinutes().toString(), // 鍒� - 'S+': date.getSeconds().toString() // 绉� - // 鏈夊叾浠栨牸寮忓寲瀛楃闇�姹傚彲浠ョ户缁坊鍔狅紝蹇呴』杞寲鎴愬瓧绗︿覆 - } - for (let k in opt) { - ret = new RegExp('(' + k + ')').exec(fmt) - if (ret) { - fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0'))) - } - } - return fmt -} - -export default { - dateFormat -} diff --git a/src/components/utils/GISUtil.js b/src/components/utils/GISUtil.js deleted file mode 100644 index c808bfd..0000000 --- a/src/components/utils/GISUtil.js +++ /dev/null @@ -1,156 +0,0 @@ -// ==============鍧愭爣绯昏浆鎹�=============== -var GSP = { - PI: 3.14159265358979324, - x_pi: 3.14159265358979324 * 3000.0 / 180.0, - delta: function(lat, lon) { - // Krasovsky 1940 - // - // a = 6378245.0, 1/f = 298.3 - // b = a * (1 - f) - // ee = (a^2 - b^2) / a^2; - var a = 6378245.0 // a: 鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛愩�� - var ee = 0.00669342162296594323 // ee: 妞悆鐨勫亸蹇冪巼銆� - var dLat = this.transformLat(lon - 105.0, lat - 35.0) - var dLon = this.transformLon(lon - 105.0, lat - 35.0) - var radLat = lat / 180.0 * this.PI - var magic = Math.sin(radLat) - magic = 1 - ee * magic * magic - var sqrtMagic = Math.sqrt(magic) - dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * this.PI) - dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * this.PI) - return { 'lat': dLat, 'lon': dLon } - }, - - // WGS-84 to GCJ-02 - gcj_encrypt: function(wgsLat, wgsLon) { - if (this.outOfChina(wgsLat, wgsLon)) { return { 'lat': wgsLat, 'lon': wgsLon } } - - var d = this.delta(wgsLat, wgsLon) - return { 'lat': wgsLat + d.lat, 'lon': wgsLon + d.lon } - }, - // GCJ-02 to WGS-84 - gcj_decrypt: function(gcjLat, gcjLon) { - if (this.outOfChina(gcjLat, gcjLon)) { return { 'lat': gcjLat, 'lon': gcjLon } } - - var d = this.delta(gcjLat, gcjLon) - return { 'lat': gcjLat - d.lat, 'lon': gcjLon - d.lon } - }, - // GCJ-02 to WGS-84 exactly - gcj_decrypt_exact: function(gcjLat, gcjLon) { - let initDelta = 0.01 - let threshold = 0.000000001 - let dLat = initDelta - let dLon = initDelta - let mLat = gcjLat - dLat - let mLon = gcjLon - dLon - let pLat = gcjLat + dLat - let pLon = gcjLon + dLon - let wgsLat - let wgsLon - let i = 0 - while (1) { - wgsLat = (mLat + pLat) / 2 - wgsLon = (mLon + pLon) / 2 - var tmp = this.gcj_encrypt(wgsLat, wgsLon) - dLat = tmp.lat - gcjLat - dLon = tmp.lon - gcjLon - if ((Math.abs(dLat) < threshold) && (Math.abs(dLon) < threshold)) { break } - - if (dLat > 0) pLat = wgsLat; else mLat = wgsLat - if (dLon > 0) pLon = wgsLon; else mLon = wgsLon - - if (++i > 10000) break - } - // console.log(i); - return { 'lat': wgsLat, 'lon': wgsLon } - }, - // GCJ-02 to BD-09 - bd_encrypt: function(gcjLat, gcjLon) { - let x = gcjLon - let y = gcjLat - let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.x_pi) - let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.x_pi) - let bdLon = z * Math.cos(theta) + 0.0065 - let bdLat = z * Math.sin(theta) + 0.006 - return { 'lat': bdLat, 'lon': bdLon } - }, - // BD-09 to GCJ-02 - bd_decrypt: function(bdLat, bdLon) { - let x = bdLon - 0.0065 - let y = bdLat - 0.006 - let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_pi) - let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_pi) - let gcjLon = z * Math.cos(theta) - let gcjLat = z * Math.sin(theta) - return { 'lat': gcjLat, 'lon': gcjLon } - }, - // WGS-84 to Web mercator - // mercatorLat -> y mercatorLon -> x - mercator_encrypt: function(wgsLat, wgsLon) { - let x = wgsLon * 20037508.34 / 180.0 - let y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0) - y = y * 20037508.34 / 180.0 - return { 'lat': y, 'lon': x } - /* - if ((Math.abs(wgsLon) > 180 || Math.abs(wgsLat) > 90)) - return null; - var x = 6378137.0 * wgsLon * 0.017453292519943295; - var a = wgsLat * 0.017453292519943295; - var y = 3189068.5 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a))); - return {'lat' : y, 'lon' : x}; - //*/ - }, - // Web mercator to WGS-84 - // mercatorLat -> y mercatorLon -> x - mercator_decrypt: function(mercatorLat, mercatorLon) { - var x = mercatorLon / 20037508.34 * 180.0 - var y = mercatorLat / 20037508.34 * 180.0 - y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2) - return { 'lat': y, 'lon': x } - /* - if (Math.abs(mercatorLon) < 180 && Math.abs(mercatorLat) < 90) - return null; - if ((Math.abs(mercatorLon) > 20037508.3427892) || (Math.abs(mercatorLat) > 20037508.3427892)) - return null; - var a = mercatorLon / 6378137.0 * 57.295779513082323; - var x = a - (Math.floor(((a + 180.0) / 360.0)) * 360.0); - var y = (1.5707963267948966 - (2.0 * Math.atan(Math.exp((-1.0 * mercatorLat) / 6378137.0)))) * 57.295779513082323; - return {'lat' : y, 'lon' : x}; - //*/ - }, - // two point's distance - distance: function(latA, lonA, latB, lonB) { - var earthR = 6371000.0 - var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180) - var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0) - var s = x + y - if (s > 1) s = 1 - if (s < -1) s = -1 - var alpha = Math.acos(s) - var distance = alpha * earthR - return distance - }, - outOfChina: function(lat, lon) { - if (lon < 72.004 || lon > 137.8347) { return true } - if (lat < 0.8293 || lat > 55.8271) { return true } - return false - }, - transformLat: function(x, y) { - var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)) - ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 - ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0 - ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0 - return ret - }, - transformLon: function(x, y) { - var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)) - ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 - ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0 - ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0 - return ret - } -} - -export default { - GSP -} diff --git a/src/components/utils/JsonUtils.js b/src/components/utils/JsonUtils.js deleted file mode 100644 index d0cfef2..0000000 --- a/src/components/utils/JsonUtils.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @param {Object} json - * @param {Object} type锛� 榛樿涓嶄紶 ==>鍏ㄩ儴灏忓啓;浼�1 ==>鍏ㄩ儴澶у啓;浼�2 ==>棣栧瓧姣嶅ぇ鍐� - * 灏唈son鐨刱ey鍊艰繘琛屽ぇ灏忓啓杞崲 - */ -function jsonKeysToCase(json, type) { - if (typeof json === 'object') { - var tempJson = JSON.parse(JSON.stringify(json)) - toCase(tempJson) - return tempJson - } else { - return json - } - - function toCase(json) { - if (typeof json === 'object') { - if (Array.isArray(json)) { - json.forEach(function(item) { - toCase(item) - }) - } else { - for (var key in json) { - var item = json[key] - if (typeof item === 'object') { - toCase(item) - } - delete (json[key]) - switch (type) { - case 1: - // key鍊煎叏閮ㄥぇ鍐� - json[key.toLocaleUpperCase()] = item - break - case 2: - // key鍊奸瀛楁瘝澶у啓锛屽叾浣欏皬鍐� - json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item - break - default: - // 榛樿key鍊煎叏閮ㄥ皬鍐� - json[key.toLocaleLowerCase()] = item - break - } - } - } - } - } -} - -export default jsonKeysToCase diff --git a/src/components/utils/MiscUtils.js b/src/components/utils/MiscUtils.js deleted file mode 100644 index 9752f95..0000000 --- a/src/components/utils/MiscUtils.js +++ /dev/null @@ -1,118 +0,0 @@ -// 鍙傛暟鍚嶇О:authCode 鍊�: 鎵�鏈�:0 鍖栧伐閿�鍞�:HXXT; 鐐兼补閿�鍞�:LXXT; 姹熻嫃鐭虫补:CPYXT; 閿�鍞崕涓�:XSHD -let SysAuthCode = '0' -/** - * Created by liangruizhe on 2019/01/14 - */ -// ==============鏃堕棿=============== -// 鑾峰彇褰撳墠鏃堕棿 -function GetCurrentTime() { - var today = new Date() - var year = today.getFullYear() - var month = today.getMonth() + 1 - var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() - var hours = today.getHours() > 9 ? today.getHours() : '0' + today.getHours() - var minutes = today.getMinutes() > 9 ? today.getMinutes() : '0' + today.getMinutes() - var seconds = today.getSeconds() > 9 ? today.getSeconds() : '0' + today.getSeconds() - return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds -} -// 鑾峰彇褰撳ぉ闆剁偣鏃堕棿 -function GetCurrentDayTime() { - var today = new Date() - var year = today.getFullYear() - var month = today.getMonth() + 1 - var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() - return year + '-' + month + '-' + day + ' 00:01:01' -} -// UtcToDateTime -function UtcToDateTime(time) { - var date = new Date(time) - var year = date.getFullYear() - var month = date.getMonth() + 1 - var day = date.getDate() - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second -} -// UtcToMonDate -function UtcToMonDate(time) { - var date = new Date(time) - var month = date.getMonth() + 1 - var day = date.getDate() - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - return month + '/' + day + ' ' + hour + ':' + minute + ':' + second -} -// yyyy-MM-dd -function convertDateFromString(dateString) { - if (dateString) { - var date = new Date(dateString.replace(/-/, '/')) - return date - } -} -// yyyy-MM-dd hh:mm:ss -function convertDateTimeFromString(dateString) { - if (dateString) { - var arr1 = dateString.split(' ') - var sdate = arr1[0].split('-') - var stime = arr1[1].split(':') - var date = new Date(sdate[0], sdate[1] - 1, sdate[2], stime[0], stime[1], stime[2]) - return date - } -} -// ==============绌洪棿璁$畻=============== -// 璁$畻鐐逛覆璺濈 -function getLength(arrPnts, isJwd) { - var dist = 0 - var length = 0 - var offset = 103133.845 - var fntPnt = null - var lastPnt = null - if (isJwd === undefined) isJwd = true - if (arrPnts.length < 2) { - return 0 - } - for (var i = 0; i < arrPnts.length - 1; i++) { - fntPnt = arrPnts[i] - lastPnt = arrPnts[i + 1] - if (lastPnt) { - var xD = Math.abs(fntPnt.x - lastPnt.x) - var yD = Math.abs(fntPnt.y - lastPnt.y) - - if (isJwd) { - if (Math.abs(fntPnt.x) > 180) { - xD = xD / 3600 - yD = yD / 3600 - } - dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) * offset - } else { - dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) - } - - length += dist - } - } - return length -} - -// 璁$畻鐐瑰埌绾挎鐨勮窛绂� -function getDistance(point, lineP1, lineP2) { - var a = Number((lineP1.y - lineP2.y) / (lineP1.x - lineP2.x)) - var b = -1 - var c = Number(lineP2.y - a * lineP2.x) - var td = Math.abs(a * point.x + b * point.y + c) / Math.sqrt(a * a + b * b) - return td -} - -export default { - SysAuthCode, - getDistance, - getLength, - GetCurrentTime, - GetCurrentDayTime, - UtcToDateTime, - UtcToMonDate, - convertDateFromString, - convertDateTimeFromString -} diff --git a/src/components/utils/wfsQueryUtils.js b/src/components/utils/wfsQueryUtils.js deleted file mode 100644 index 7901056..0000000 --- a/src/components/utils/wfsQueryUtils.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * wfs 澶氭潯浠跺睘鎬ф煡璇nd Or 绫诲瀷 - * @params params - * params={ - * Url:'', - * TypeName:'', - * Or:[{'PropertyName':'','PropertyValue',''},{}], - * And:[{'PropertyName':'PropertyValue'},{}] - * } - * @returns {string} - */ -function getPropertyNameQueryAndOrWFSUrl(params) { - var url = '' - if ((params.Or === undefined || params.Or.length === 0) && (params.And === undefined || params.And.length === 0) && (params.Not === undefined || params.Not.length === 0)) { - url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000' - } else { - url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000&Filter=<Filter>' - } - if (params.Or != null && params.Or.length !== 0) { - if (params.Or.length === 1) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Or[0].PropertyName + '</PropertyName><Literal>' + params.Or[0].PropertyValue + '</Literal></PropertyIsEqualTo>' - } else { - url += '<OR>' - for (let i = 0; i < params.Or.length; i++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Or[i].PropertyName + '</PropertyName><Literal>' + params.Or[i].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</OR>' - } - } - if (params.And != null && params.And.length !== 0) { - if (params.And.length === 1) { - url += '<PropertyIsEqualTo><PropertyName>' + params.And[0].PropertyName + '</PropertyName><Literal>' + params.And[0].PropertyValue + '</Literal></PropertyIsEqualTo>' - } else { - url += '<AND>' - for (let j = 0; j < params.And.length; j++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.And[j].PropertyName + '</PropertyName><Literal>' + params.And[j].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</AND>' - } - } - if (params.Not != null && params.Not.length !== 0) { - url += '<NOT>' - for (let k = 0; k < params.Not.length; k++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Not[k].PropertyName + '</PropertyName><Literal>' + params.Not[k].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</NOT>' - } - if ((params.Or !== undefined && params.Or.length !== 0) || (params.And !== undefined && params.And.length !== 0) || (params.Not !== undefined && params.Not.length !== 0)) { - url += '</Filter>' - } - return url -} - -export default { - getPropertyNameQueryAndOrWFSUrl -} diff --git a/src/conf/MapConfig.js b/src/conf/MapConfig.js index 98a0880..f08b037 100644 --- a/src/conf/MapConfig.js +++ b/src/conf/MapConfig.js @@ -1,12 +1,12 @@ 锘縤mport * as L from 'leaflet' -let curWwwPath = window.document.location.href -let pathname = window.document.location.pathname -let pos = curWwwPath.indexOf(pathname) -let HOST_URL = curWwwPath.substring(0, pos) +const curWwwPath = window.document.location.href +const pathname = window.document.location.pathname +const pos = curWwwPath.indexOf(pathname) +const HOST_URL = curWwwPath.substring(0, pos) // basemap涓绘満閰嶇疆 -const SINOPEC_GIS_HOST = 'http://10.246.132.249:8080' // 鍐呯綉澶╁湴鍥句富鏈哄湴鍧� +const SINOPEC_GIS_HOST = 'http://10.246.132.249:8080' // 鍐呯綉澶╁湴鍥句富鏈哄湴鍧� const TIANDITU_GIS_HOST = 'http://t0.tianditu.gov.cn' // 鍏綉澶╁湴鍥句富鏈哄湴鍧� const TIANDITU_GIS_TOKEN = '5d76218063082952d18b76da5005f490' // 澶囩敤tk: f1b72b5e7cb1175acddfa485f1bc9770 @@ -24,595 +24,595 @@ console.log(GEOM_POINT, GEOM_POLYLINE, GEOM_POLYGON) const mapOptions = { - crs: L.CRS.EPSG4326, - minZoom: 3, - maxZoom: 18, - center: [26, 104], - zoom: 3, - worldCopyJump: true, - inertia: true, - zoomControl: false, - attributionControl: false, - editable: true + crs: L.CRS.EPSG4326, + minZoom: 3, + maxZoom: 18, + center: [26, 104], + zoom: 3, + worldCopyJump: true, + inertia: true, + zoomControl: false, + attributionControl: false, + editable: true } const mapConfig = { - IsLoadMapByToken: true, // 鏄惁閫氳繃token鍔犺浇鍦板浘 - showBaseMapType: 1, // 1鏄剧ず澶╁湴鍥撅紝2鏄剧ずarcgis鍦板浘 - IntranetBaseMaps: [ - { - code: 'sinopec_img', - name: '涓煶鍖栧ぉ鍦板浘褰卞儚', - icon_actived: '/assets/images/map-pages/icon/img.png', - icon_deactived: '/assets/images/map-pages/icon/img.png', - isAddToMap: true, - map: { - layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'img_c', - isLoadMapByToken: true, - url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-image-globe/WMTS?'+ - 'layer=img&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - annotation: { - layerName: '澶╁湴鍥惧奖鍍忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cia_c', - isLoadMapByToken: true, - url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-image/WMTS?'+ - 'layer=cia&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - }, - { - code: 'sinopec_vec', - name: '涓煶鍖栧ぉ鍦板浘鐭㈤噺', - icon_actived: '/assets/images/map-pages/icon/road.png', - icon_deactived: '/assets/images/map-pages/icon/road.png', - isAddToMap: false, - map: { - layerName: '澶╁湴鍥剧煝閲忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'vec_c', - isLoadMapByToken: true, - url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-vector-globe/WMTS?'+ - 'layer=vec&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - annotation: { - layerName: '澶╁湴鍥剧煝閲忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cva_c', - isLoadMapByToken: true, - url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-vector/WMTS?'+ - 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - } + IsLoadMapByToken: true, // 鏄惁閫氳繃token鍔犺浇鍦板浘 + showBaseMapType: 1, // 1鏄剧ず澶╁湴鍥撅紝2鏄剧ずarcgis鍦板浘 + IntranetBaseMaps: [ + { + code: 'sinopec_img', + name: '涓煶鍖栧ぉ鍦板浘褰卞儚', + icon_actived: '/assets/images/map-pages/icon/img.png', + icon_deactived: '/assets/images/map-pages/icon/img.png', + isAddToMap: true, + map: { + layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'img_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-image-globe/WMTS?' + + 'layer=img&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 } - ], - InternetBaseMaps: [ - { - code: 'tianditu_img', - name: '澶╁湴鍥惧奖鍍�', - icon_actived: '/assets/images/map-pages/icon/img.png', - icon_deactived: '/assets/images/map-pages/icon/img.png', - isAddToMap: true, - map: { - layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'img_c', - isLoadMapByToken: true, - url: TIANDITU_GIS_HOST + '/img_c/wmts?layer=img&style=default&tilematrixset=c'+ - '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ - '&tk=' + TIANDITU_GIS_TOKEN, - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - annotation: { - layerName: '澶╁湴鍥惧奖鍍忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cia_c', - isLoadMapByToken: true, - url: TIANDITU_GIS_HOST + '/cia_c/wmts?layer=cia&style=default&tilematrixset=c'+ - '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ - '&tk=' + TIANDITU_GIS_TOKEN, - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - }, - { - code: 'tianditu_vec', - name: '澶╁湴鍥惧奖鍍�', - icon_actived: '/assets/images/map-pages/icon/road.png', - icon_deactived: '/assets/images/map-pages/icon/road.png', - isAddToMap: false, - map: { - layerName: '澶╁湴鍥剧煝閲忓湴鍥�', - type: 'wmts', - visible: false, - layerType: 'vec_c', - isLoadMapByToken: true, - url: TIANDITU_GIS_HOST + '/vec_c/wmts?layer=vec&style=default&tilematrixset=c'+ - '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ - '&tk=' + TIANDITU_GIS_TOKEN, - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - }, - annotation: { - layerName: '澶╁湴鍥剧煝閲忔爣娉�', - type: 'wmts', - visible: false, - layerType: 'cva_c', - isLoadMapByToken: true, - url: TIANDITU_GIS_HOST + '/cva_c/wmts?layer=cva&style=default&tilematrixset=c'+ - '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}'+ - '&tk=' + TIANDITU_GIS_TOKEN, - option:{ - maxZoom: 18, - minZoom: 1, - zoomOffset: 1 - } - } + }, + annotation: { + layerName: '澶╁湴鍥惧奖鍍忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cia_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-image/WMTS?' + + 'layer=cia&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 } - ], - ArcBaseMaps: [ - { - layerName: 'arcgis褰卞儚搴曞浘', - type: 'tile', - visible: true, - layerType: 'cia_c', - isLoadMapByToken: false, - url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-map-image-globe/MapServer' + } + }, + { + code: 'sinopec_vec', + name: '涓煶鍖栧ぉ鍦板浘鐭㈤噺', + icon_actived: '/assets/images/map-pages/icon/road.png', + icon_deactived: '/assets/images/map-pages/icon/road.png', + isAddToMap: false, + map: { + layerName: '澶╁湴鍥剧煝閲忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'vec_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-vector-globe/WMTS?' + + 'layer=vec&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 } - ], + }, + annotation: { + layerName: '澶╁湴鍥剧煝閲忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cva_c', + isLoadMapByToken: true, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-tdt-label-vector/WMTS?' + + 'layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}', + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + } + } + ], + InternetBaseMaps: [ + { + code: 'tianditu_img', + name: '澶╁湴鍥惧奖鍍�', + icon_actived: '/assets/images/map-pages/icon/img.png', + icon_deactived: '/assets/images/map-pages/icon/img.png', + isAddToMap: true, + map: { + layerName: '澶╁湴鍥惧奖鍍忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'img_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/img_c/wmts?layer=img&style=default&tilematrixset=c' + + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}' + + '&tk=' + TIANDITU_GIS_TOKEN, + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥惧奖鍍忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cia_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/cia_c/wmts?layer=cia&style=default&tilematrixset=c' + + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}' + + '&tk=' + TIANDITU_GIS_TOKEN, + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + } + }, + { + code: 'tianditu_vec', + name: '澶╁湴鍥惧奖鍍�', + icon_actived: '/assets/images/map-pages/icon/road.png', + icon_deactived: '/assets/images/map-pages/icon/road.png', + isAddToMap: false, + map: { + layerName: '澶╁湴鍥剧煝閲忓湴鍥�', + type: 'wmts', + visible: false, + layerType: 'vec_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/vec_c/wmts?layer=vec&style=default&tilematrixset=c' + + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}' + + '&tk=' + TIANDITU_GIS_TOKEN, + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + }, + annotation: { + layerName: '澶╁湴鍥剧煝閲忔爣娉�', + type: 'wmts', + visible: false, + layerType: 'cva_c', + isLoadMapByToken: true, + url: TIANDITU_GIS_HOST + '/cva_c/wmts?layer=cva&style=default&tilematrixset=c' + + '&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}' + + '&tk=' + TIANDITU_GIS_TOKEN, + option: { + maxZoom: 18, + minZoom: 1, + zoomOffset: 1 + } + } + } + ], + ArcBaseMaps: [ + { + layerName: 'arcgis褰卞儚搴曞浘', + type: 'tile', + visible: true, + layerType: 'cia_c', + isLoadMapByToken: false, + url: SINOPEC_GIS_HOST + '/OneMapServer/rest/services/base-map-image-globe/MapServer' + } + ], - ServiceLayers:[ + ServiceLayers: [ + { + code: 'guojie', + name: '鍥界晫', + icon_actived: '', + icon_deactived: '', + type: 'wmts', + url: APP_GIS_HOST + '/server/ogcserver/whp_guojie/wmts?x={x}&y={y}&z={z}', + inLegend: true, + checked: true, + option: { + zoomOffset: 1 + } + }, + { + code: 'pipeline', + name: '绠$綉鏁版嵁', + icon_actived: '', + icon_deactived: '', + type: 'wms', + url: APP_GIS_HOST_PIPELINE + '/server/ogcserver/PipeLineTest/wms?version=1.1.1', + inLegend: true, + checked: true, + option: { + layers: 'all', + styles: '', // Comma-separated list of WMS styles. + format: 'image/png', // WMS image format (use 'image/png' for layers with transparency). + transparent: true, // If true, the WMS service will return images with transparency. + version: '1.1.1', // Version of the WMS service to use + crs: L.CRS.EPSG4326, // Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. + uppercase: false + }, + layers: [ { - code:'guojie', - name:'鍥界晫', - icon_actived: '', - icon_deactived: '', - type:'wmts', - url: APP_GIS_HOST + '/server/ogcserver/whp_guojie/wmts?x={x}&y={y}&z={z}', - inLegend: true, - checked: true, - option:{ - zoomOffset: 1 - } + code: 'rainline', + name: '闆ㄦ按绾�', + sname: '闆ㄦ按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} }, { - code:'pipeline', - name:'绠$綉鏁版嵁', - icon_actived: '', - icon_deactived: '', - type:'wms', - url: APP_GIS_HOST_PIPELINE + '/server/ogcserver/PipeLineTest/wms?version=1.1.1', - inLegend: true, - checked: true, - option:{ - layers:'all', - styles:'', // Comma-separated list of WMS styles. - format:'image/png', // WMS image format (use 'image/png' for layers with transparency). - transparent:true, // If true, the WMS service will return images with transparency. - version:'1.1.1', // Version of the WMS service to use - crs:L.CRS.EPSG4326, // Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means. - uppercase:false - }, - layers:[ - { - code:'rainline', - name:'闆ㄦ按绾�', - sname:'闆ㄦ按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'oilline', - name:'鍚补姹℃按绾�', - sname:'鍚补姹℃按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'saltline', - name:'鍚洂姹℃按绾�', - sname:'鍚洂姹℃按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'alkaliline', - name:'鍚⒈姹℃按绾�', - sname:'鍚⒈姹℃按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'outlet', - name:'鎺掑彛', - sname:'鎺掑彛', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'accidentline', - name:'浜嬫晠姘寸嚎', - sname:'浜嬫晠姘�', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'loopline', - name:'寰幆姘寸嚎', - sname:'寰幆姘�', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'purifyline', - name:'鍑�鍖栨按绾�', - sname:'鍑�鍖栨按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'lifeline', - name:'鐢熸椿姹℃按', - sname:'鐢熸椿姹℃按', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - { - code:'areainfo', - name:'鍖哄煙淇℃伅', - sname:'鍖哄煙淇℃伅', - checked: true, // 榛樿閫変腑鐘舵�� - filter:{} - }, - ], - filtersGroup:[ - { - code:'fsss', - name:'闄勫睘璁炬柦', - checked: true, // 榛樿閫変腑鐘舵�� - filters:[ - { - code:'fourlink', - name:'鍥涢��', - sname:'鍥涢��', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'tee', - name:'涓夐��', - sname:'涓夐��', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'piperack', - name:'绠℃灦(澧�)', - sname:'绠℃灦', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pipegallery', - name:'绠″粖(甯�)', - sname:'绠″粖', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pipesegment', - name:'娴佸悜', - sname:'娴佸悜', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pipeline', - name:'绠$綉', - sname:'绠$綉', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'valve', - name:'闃�闂�', - sname:'闃�闂�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'elbow', - name:'寮ご', - sname:'寮ご', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - ] - }, - { - code:'hbss', - name:'鐜繚璁炬柦', - checked: true, // 榛樿閫変腑鐘舵�� - filters:[ - { - code:'manhole', - name:'绐ㄤ簳', - sname:'绐ㄤ簳', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'firedike', - name:'闃茬伀鍫�', - sname:'闃茬伀鍫�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'raingate', - name:'闆ㄧ瀛�', - sname:'闆ㄧ瀛�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'overflowweir', - name:'婧㈡祦鍫�', - sname:'婧㈡祦鍫�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'chokevalve', - name:'鎴祦闂�', - sname:'鎴祦闂�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'collectingbasin', - name:'闆嗘按姹�(缃�)', - sname:'闆嗘按姹�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'oilseparator', - name:'闅旀补姹�', - sname:'闅旀补姹�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - ] - }, - { - code:'pk', - name:'鎺掑彛', - checked: true, // 榛樿閫変腑鐘舵�� - filters:[ - { - code:'dischargeport', - name:'鎺掓斁鍙�', - sname:'鎺掓斁鍙�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - } - ] - }, - { - code:'qyxx', - name:'鍖哄煙淇℃伅', - checked: true, // 榛樿閫変腑鐘舵�� - filters:[ - { - code:'thirdpartypipe', - name:'绗笁鏂圭閬�', - sname:'绗笁鏂圭閬�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'firefightingunit', - name:'娑堥槻鍗曚綅', - sname:'娑堥槻鍗曚綅', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'emergencyesources', - name:'搴旀�ョ墿璧�', - sname:'搴旀�ョ墿璧�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'emergencyres', - name:'绀句細涓撲笟搴旀�ユ晳鎻撮槦浼�', - sname:'涓撲笟搴旀�ユ晳鎻�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'maintenanceteam', - name:'缁存姠淇槦浼�', - sname:'缁存姠淇槦浼�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'hospital', - name:'鍖婚櫌', - sname:'鍖婚櫌', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pointpreservationzone', - name:'鑷劧淇濇姢鍖�', - sname:'鑷劧淇濇姢鍖�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pointhydrology', - name:'姘翠綋', - sname:'姘翠綋', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'sensitivetarget', - name:'鏁忔劅鐩爣', - sname:'鏁忔劅鐩爣', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'envmonunit', - name:'鐜鐩戞祴鍗曚綅', - sname:'鐜鐩戞祴鍗曚綅', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pointcontaminants', - name:'鐩戞祴鐐规薄鏌撶墿鎸囨爣淇℃伅', - sname:'姹℃煋鐗╂寚鏍�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'dischargeportaround', - name:'鎺掓斁鍙e懆杈圭幆澧冩晱鎰熶俊鎭�', - sname:'鎺掓斁鍙e懆杈圭幆澧�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pump', - name:'娉�', - sname:'娉�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'liquidlevelmeter', - name:'娑蹭綅璁�', - sname:'娑蹭綅璁�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'flowmeter', - name:'娴侀噺璁�', - sname:'娴侀噺璁�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'video', - name:'瑙嗛鐩戞帶閰嶇疆', - sname:'瑙嗛鐩戞帶', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'onlinemonitoring', - name:'鍦ㄧ嚎鐩戞祴璁惧閰嶇疆', - sname:'鍦ㄧ嚎鐩戞祴', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'combustiblegas', - name:'鍙噧姘斾綋鎶ヨ璁惧閰嶇疆', - sname:'鍙噧姘斾綋鎶ヨ', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'hydrogensulfide', - name:'H2S娴撳害鎶ヨ璁惧閰嶇疆', - sname:'H2S娴撳害鎶ヨ', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'controlpoint', - name:'绠$嚎鐐�', - sname:'绠$嚎鐐�', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - }, - { - code:'pipesegment', - name:'绠℃', - sname:'绠℃', - checked: true, // 榛樿閫変腑鐘舵�� - geom: GEOM_POINT - } - ] - } - ] + code: 'oilline', + name: '鍚补姹℃按绾�', + sname: '鍚补姹℃按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'saltline', + name: '鍚洂姹℃按绾�', + sname: '鍚洂姹℃按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'alkaliline', + name: '鍚⒈姹℃按绾�', + sname: '鍚⒈姹℃按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'outlet', + name: '鎺掑彛', + sname: '鎺掑彛', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'accidentline', + name: '浜嬫晠姘寸嚎', + sname: '浜嬫晠姘�', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'loopline', + name: '寰幆姘寸嚎', + sname: '寰幆姘�', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'purifyline', + name: '鍑�鍖栨按绾�', + sname: '鍑�鍖栨按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'lifeline', + name: '鐢熸椿姹℃按', + sname: '鐢熸椿姹℃按', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} + }, + { + code: 'areainfo', + name: '鍖哄煙淇℃伅', + sname: '鍖哄煙淇℃伅', + checked: true, // 榛樿閫変腑鐘舵�� + filter: {} } - ] + ], + filtersGroup: [ + { + code: 'fsss', + name: '闄勫睘璁炬柦', + checked: true, // 榛樿閫変腑鐘舵�� + filters: [ + { + code: 'fourlink', + name: '鍥涢��', + sname: '鍥涢��', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'tee', + name: '涓夐��', + sname: '涓夐��', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'piperack', + name: '绠℃灦(澧�)', + sname: '绠℃灦', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pipegallery', + name: '绠″粖(甯�)', + sname: '绠″粖', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pipesegment', + name: '娴佸悜', + sname: '娴佸悜', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pipeline', + name: '绠$綉', + sname: '绠$綉', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'valve', + name: '闃�闂�', + sname: '闃�闂�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'elbow', + name: '寮ご', + sname: '寮ご', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + } + ] + }, + { + code: 'hbss', + name: '鐜繚璁炬柦', + checked: true, // 榛樿閫変腑鐘舵�� + filters: [ + { + code: 'manhole', + name: '绐ㄤ簳', + sname: '绐ㄤ簳', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'firedike', + name: '闃茬伀鍫�', + sname: '闃茬伀鍫�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'raingate', + name: '闆ㄧ瀛�', + sname: '闆ㄧ瀛�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'overflowweir', + name: '婧㈡祦鍫�', + sname: '婧㈡祦鍫�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'chokevalve', + name: '鎴祦闂�', + sname: '鎴祦闂�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'collectingbasin', + name: '闆嗘按姹�(缃�)', + sname: '闆嗘按姹�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'oilseparator', + name: '闅旀补姹�', + sname: '闅旀补姹�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + } + ] + }, + { + code: 'pk', + name: '鎺掑彛', + checked: true, // 榛樿閫変腑鐘舵�� + filters: [ + { + code: 'dischargeport', + name: '鎺掓斁鍙�', + sname: '鎺掓斁鍙�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + } + ] + }, + { + code: 'qyxx', + name: '鍖哄煙淇℃伅', + checked: true, // 榛樿閫変腑鐘舵�� + filters: [ + { + code: 'thirdpartypipe', + name: '绗笁鏂圭閬�', + sname: '绗笁鏂圭閬�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'firefightingunit', + name: '娑堥槻鍗曚綅', + sname: '娑堥槻鍗曚綅', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'emergencyesources', + name: '搴旀�ョ墿璧�', + sname: '搴旀�ョ墿璧�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'emergencyres', + name: '绀句細涓撲笟搴旀�ユ晳鎻撮槦浼�', + sname: '涓撲笟搴旀�ユ晳鎻�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'maintenanceteam', + name: '缁存姠淇槦浼�', + sname: '缁存姠淇槦浼�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'hospital', + name: '鍖婚櫌', + sname: '鍖婚櫌', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pointpreservationzone', + name: '鑷劧淇濇姢鍖�', + sname: '鑷劧淇濇姢鍖�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pointhydrology', + name: '姘翠綋', + sname: '姘翠綋', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'sensitivetarget', + name: '鏁忔劅鐩爣', + sname: '鏁忔劅鐩爣', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'envmonunit', + name: '鐜鐩戞祴鍗曚綅', + sname: '鐜鐩戞祴鍗曚綅', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pointcontaminants', + name: '鐩戞祴鐐规薄鏌撶墿鎸囨爣淇℃伅', + sname: '姹℃煋鐗╂寚鏍�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'dischargeportaround', + name: '鎺掓斁鍙e懆杈圭幆澧冩晱鎰熶俊鎭�', + sname: '鎺掓斁鍙e懆杈圭幆澧�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pump', + name: '娉�', + sname: '娉�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'liquidlevelmeter', + name: '娑蹭綅璁�', + sname: '娑蹭綅璁�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'flowmeter', + name: '娴侀噺璁�', + sname: '娴侀噺璁�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'video', + name: '瑙嗛鐩戞帶閰嶇疆', + sname: '瑙嗛鐩戞帶', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'onlinemonitoring', + name: '鍦ㄧ嚎鐩戞祴璁惧閰嶇疆', + sname: '鍦ㄧ嚎鐩戞祴', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'combustiblegas', + name: '鍙噧姘斾綋鎶ヨ璁惧閰嶇疆', + sname: '鍙噧姘斾綋鎶ヨ', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'hydrogensulfide', + name: 'H2S娴撳害鎶ヨ璁惧閰嶇疆', + sname: 'H2S娴撳害鎶ヨ', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'controlpoint', + name: '绠$嚎鐐�', + sname: '绠$嚎鐐�', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + }, + { + code: 'pipesegment', + name: '绠℃', + sname: '绠℃', + checked: true, // 榛樿閫変腑鐘舵�� + geom: GEOM_POINT + } + ] + } + ] + } + ] } /** * 鍐呯綉GIS锛岃幏鍙杢oken鍙傛暟 */ const TokenConfig = { - url: SINOPEC_GIS_HOST + '/RemoteTokenServer', // 鑾峰彇token鐨勬湇鍔℃帴鍙� - option: { - request: 'getToken', - username: 'sipms', // 鑾峰彇token鐨勭敤鎴峰悕 - password: 'sinopecipms', // 鑾峰彇token鐨勫瘑鐮� - expiration: 1440, - clientid: 'ref.' + HOST_URL// 鑾峰彇token鐨勫簲鐢ㄦ湇鍔″櫒鍦板潃 - } + url: SINOPEC_GIS_HOST + '/RemoteTokenServer', // 鑾峰彇token鐨勬湇鍔℃帴鍙� + option: { + request: 'getToken', + username: 'sipms', // 鑾峰彇token鐨勭敤鎴峰悕 + password: 'sinopecipms', // 鑾峰彇token鐨勫瘑鐮� + expiration: 1440, + clientid: 'ref.' + HOST_URL// 鑾峰彇token鐨勫簲鐢ㄦ湇鍔″櫒鍦板潃 + } } export default { - mapOptions, - mapConfig, - TokenConfig, + mapOptions, + mapConfig, + TokenConfig, - BLUEMAP_HOST + BLUEMAP_HOST } diff --git a/src/main.js b/src/main.js index 96479c7..4de11ed 100644 --- a/src/main.js +++ b/src/main.js @@ -18,12 +18,12 @@ echarts.registerTheme('dark', echartsDarkTheme) // 寮�鍙戠幆澧冧笅鍔犺浇鍋囨暟鎹� -if (process.env.NODE_ENV === 'development') { - console.log('褰撳墠澶勪簬寮�鍙戞ā寮忥紒') +if (process.env.VUE_APP_MOCK && process.env.NODE_ENV === 'development') { + console.warn('褰撳墠澶勪簬mock鏁版嵁璇锋眰锛�') + require('./mock') } - window.vm = new Vue({ router, store, - render: h => h(App), + render: h => h(App) }).$mount('#app') diff --git a/src/router/routes.js b/src/router/routes.js index b2c4d92..d9689c4 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -9,29 +9,29 @@ * } */ // 榛樿璺宠浆璺敱 -import App from "../App"; -import PipeLineIndex from "../views/baseInfoMgr/pipeline/PipeLineIndex"; -import MapTemplate from "../views/MapTemplate"; +import App from '../App' +import PipeLineIndex from '../views/baseInfoMgr/pipeline/PipeLineIndex' +import MapTemplate from '../views/MapTemplate' // 搴旂敤涓氬姟鐩稿叧璺敱锛屾寕杞絤enu涓婄殑page export const routes = [{ - path: '/', - name: 'Main', - component: App, - redirect: '/home', - children: [{ - path: 'home', - name: 'Home', - meta: { - title: '棣栭〉' - }, - component: MapTemplate - }, { - path: 'baseInfoMgr/pipeLine', - name: 'baseInfoMgr', - component: PipeLineIndex, - meta: { - title: '鍩虹鏁版嵁缁存姢' - } - }] + path: '/', + name: 'Main', + component: App, + redirect: '/home', + children: [{ + path: 'home', + name: 'Home', + meta: { + title: '棣栭〉' + }, + component: MapTemplate + }, { + path: 'baseInfoMgr/pipeLine', + name: 'baseInfoMgr', + component: PipeLineIndex, + meta: { + title: '鍩虹鏁版嵁缁存姢' + } + }] }] diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 9fe8eb7..6b22491 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,29 +1,27 @@ export default { - state: { + state: { - //灞炴�� + // 灞炴�� - demoValue:{} + demoValue: {} - }, + }, - getters: { + getters: { - getDemoValue: state => state.demoValue + getDemoValue: state => state.demoValue - }, + }, - mutations: { + mutations: { - //set鏂规硶 + // set鏂规硶 - setDemoValue(state,demoValue){ - - state.demoValue = demoValue - - } - + setDemoValue (state, demoValue) { + state.demoValue = demoValue } + } + } diff --git a/src/store/modules/map.js b/src/store/modules/map.js index d1e6379..d45b265 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -1,50 +1,50 @@ import mapConfig from '../../conf/MapConfig' const state = { - currentCorp: null, - currentCorpType: null, - L: null, - map: null, // 瀹炰緥鍖栫殑map - basemapHelper: {}, // 褰卞儚鍦板浘鍥惧眰鎺у埗鍣ㄥ疄鐜板姪鎵嬬▼搴� - serviceLayerHelper: {}, // 鏈嶅姟鍥惧眰鎺у埗鍣ㄥ疄鐜板姪鎵嬬▼搴� - vectoryLayerHelper: {}, // 鍔ㄦ�佸浘灞傛帶鍒跺櫒瀹炵幇鍔╂墜绋嬪簭 - layerControllerVisible: { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� - layerController: true, // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� - }, - showServiceLayerFilter: false, // Service鍥惧眰杩囨护鍣� - selectedServiceLayer: '', // 浣跨敤杩囨护鍣ㄦ椂锛岃鎵撳紑鐨刉MS鏈嶅姟鐨凜ODE - serviceLayerFilters: {}, // 鏈嶅姟鍥惧眰鎺у埗杩囨护閰嶇疆 - mapConfig: mapConfig + currentCorp: null, + currentCorpType: null, + L: null, + map: null, // 瀹炰緥鍖栫殑map + basemapHelper: {}, // 褰卞儚鍦板浘鍥惧眰鎺у埗鍣ㄥ疄鐜板姪鎵嬬▼搴� + serviceLayerHelper: {}, // 鏈嶅姟鍥惧眰鎺у埗鍣ㄥ疄鐜板姪鎵嬬▼搴� + vectoryLayerHelper: {}, // 鍔ㄦ�佸浘灞傛帶鍒跺櫒瀹炵幇鍔╂墜绋嬪簭 + layerControllerVisible: { // 鍥惧眰鎺у埗闈㈡澘鐨勬樉绀虹姸鎬佲�衡�� + layerController: true // 鐖哥埜鏍忕洰锛氭槸鍚︽樉绀哄浘灞傛帶鍒堕潰鏉� + }, + showServiceLayerFilter: false, // Service鍥惧眰杩囨护鍣� + selectedServiceLayer: '', // 浣跨敤杩囨护鍣ㄦ椂锛岃鎵撳紑鐨刉MS鏈嶅姟鐨凜ODE + serviceLayerFilters: {}, // 鏈嶅姟鍥惧眰鎺у埗杩囨护閰嶇疆 + mapConfig: mapConfig } const mutations = { - setMapObj(state, mObject) { - state.L = mObject.L - state.map = mObject.map - }, - setBasemapHelper(state, layerHelper) { - state.basemapHelper = layerHelper - }, - setServiceLayerHelper(state, layerHelper) { - state.serviceLayerHelper = layerHelper - }, - setVectorLayerHelper(state, layerHelper) { - state.vectoryLayerHelper = layerHelper - }, - updateLayerControllerVisible(state, preset) { - state.layerControllerVisible = preset - }, - setSelectedServiceLayer(state, selectedServiceLayer) { - state.selectedServiceLayer = selectedServiceLayer - }, - toggleServiceLayerFilter(state) { - state.showServiceLayerFilter = !state.showServiceLayerFilter - } + setMapObj (state, mObject) { + state.L = mObject.L + state.map = mObject.map + }, + setBasemapHelper (state, layerHelper) { + state.basemapHelper = layerHelper + }, + setServiceLayerHelper (state, layerHelper) { + state.serviceLayerHelper = layerHelper + }, + setVectorLayerHelper (state, layerHelper) { + state.vectoryLayerHelper = layerHelper + }, + updateLayerControllerVisible (state, preset) { + state.layerControllerVisible = preset + }, + setSelectedServiceLayer (state, selectedServiceLayer) { + state.selectedServiceLayer = selectedServiceLayer + }, + toggleServiceLayerFilter (state) { + state.showServiceLayerFilter = !state.showServiceLayerFilter + } } const actions = { } export default { - state, - mutations, - actions + state, + mutations, + actions } diff --git a/src/utils/AjaxUtils.js b/src/utils/AjaxUtils.js index c040419..11138b0 100644 --- a/src/utils/AjaxUtils.js +++ b/src/utils/AjaxUtils.js @@ -6,22 +6,20 @@ * @param pData 鍙傛暟 * @param pBackFun 鎴愬姛鍥炶皟 */ -function post4JsonDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'post', - url: pUrl, - dataType: 'json', - data: pData, - async: true, - success: function(datas, nnn) { - console.log(nnn) - pBackFun(datas) - }, - error: function(err, nnnn) { - console.log(nnnn) - console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) - } - }) +function post4JsonDataByUrl (pUrl, pData, pBackFun) { + $.ajax({ + type: 'post', + url: pUrl, + dataType: 'json', + data: pData, + async: true, + success: function (datas, nnn) { + pBackFun(datas) + }, + error: function (err, nnnn) { + console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) + } + }) } /** @@ -30,82 +28,74 @@ * @param pData 鍙傛暟 * @param pBackFun 鎴愬姛鍥炶皟 */ -function get4JsonDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'get', - url: pUrl, - dataType: 'json', - data: pData, - async: true, - success: function(datas, nnn) { - console.log(nnn) - pBackFun(datas) - }, - error: function(err, nnnn) { - console.log(nnnn) - console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) - } - }) +function get4JsonDataByUrl (pUrl, pData, pBackFun) { + $.ajax({ + type: 'get', + url: pUrl, + dataType: 'json', + data: pData, + async: true, + success: function (datas, nnn) { + pBackFun(datas) + }, + error: function (err, nnnn) { + console.error('鏁版嵁鑾峰彇澶辫触', err, pUrl) + } + }) } -function GetDataAsynByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'GET', - url: pUrl, - data: pData, - timeout: 600000, - async: true, - success: function(datas, nnn) { - console.log(nnn) - pBackFun(datas) - }, - error: function(e, nnnn) { - console.log(e,nnnn) - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) +function GetDataAsynByUrl (pUrl, pData, pBackFun) { + $.ajax({ + type: 'GET', + url: pUrl, + data: pData, + timeout: 600000, + async: true, + success: function (datas, nnn) { + pBackFun(datas) + }, + error: function (e, nnnn) { + console.error('鏁版嵁鑾峰彇澶辫触', pUrl) + } + }) } -function postDataAsynByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'post', - url: pUrl, - data: pData, - timeout: 600000, - async: true, - success: function(datas, nnn) { - console.log(nnn) - pBackFun(datas) - }, - error: function(e, nnnn) { - console.log(e,nnnn) - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) +function postDataAsynByUrl (pUrl, pData, pBackFun) { + $.ajax({ + type: 'post', + url: pUrl, + data: pData, + timeout: 600000, + async: true, + success: function (datas, nnn) { + pBackFun(datas) + }, + error: function (e, nnnn) { + console.error('鏁版嵁鑾峰彇澶辫触', pUrl) + } + }) } -function GetDataByUrl(pUrl, pData, pBackFun) { - $.ajax({ - type: 'GET', - url: pUrl, - data: pData, - timeout: 600000, - success: function(datas, nnn) { - console.log(nnn) - pBackFun(datas) - }, - error: function(e, nnnn) { - console.log(nnnn) - // tmpErrJSONTextParse(e, pBackFun) // todo SGIS Server鏈変釜WFS鍥惧眰鏈嶅姟json瑙f瀽閿欒锛� 杩欓噷鏄殏鏃跺鐞嗭紝绛夎繃鍑犲ぉ榛庤��淇敼濂戒簡锛岃繖閲岄渶瑕佷慨鏀瑰洖鍘汇�� - console.log('杩斿洖鐨勯敊璇俊鎭細', e) - console.error('鏁版嵁鑾峰彇澶辫触', pUrl) - } - }) +function GetDataByUrl (pUrl, pData, pBackFun) { + $.ajax({ + type: 'GET', + url: pUrl, + data: pData, + timeout: 600000, + success: function (datas, nnn) { + pBackFun(datas) + }, + error: function (e, nnnn) { + // tmpErrJSONTextParse(e, pBackFun) // todo SGIS Server鏈変釜WFS鍥惧眰鏈嶅姟json瑙f瀽閿欒锛� 杩欓噷鏄殏鏃跺鐞嗭紝绛夎繃鍑犲ぉ榛庤��淇敼濂戒簡锛岃繖閲岄渶瑕佷慨鏀瑰洖鍘汇�� + console.log('杩斿洖鐨勯敊璇俊鎭細', e) + console.error('鏁版嵁鑾峰彇澶辫触', pUrl) + } + }) } export default { - post4JsonDataByUrl, - get4JsonDataByUrl, - GetDataAsynByUrl, - postDataAsynByUrl, - GetDataByUrl + post4JsonDataByUrl, + get4JsonDataByUrl, + GetDataAsynByUrl, + postDataAsynByUrl, + GetDataByUrl } diff --git a/src/utils/DateUtils.js b/src/utils/DateUtils.js index 6d6d868..d6410b4 100644 --- a/src/utils/DateUtils.js +++ b/src/utils/DateUtils.js @@ -4,26 +4,26 @@ * @param date * @returns {*} */ -function dateFormat(fmt, date) { - let ret - const opt = { - 'Y+': date.getFullYear().toString(), // 骞� - 'm+': (date.getMonth() + 1).toString(), // 鏈� - 'd+': date.getDate().toString(), // 鏃� - 'H+': date.getHours().toString(), // 鏃� - 'M+': date.getMinutes().toString(), // 鍒� - 'S+': date.getSeconds().toString() // 绉� - // 鏈夊叾浠栨牸寮忓寲瀛楃闇�姹傚彲浠ョ户缁坊鍔狅紝蹇呴』杞寲鎴愬瓧绗︿覆 +function dateFormat (fmt, date) { + let ret + const opt = { + 'Y+': date.getFullYear().toString(), // 骞� + 'm+': (date.getMonth() + 1).toString(), // 鏈� + 'd+': date.getDate().toString(), // 鏃� + 'H+': date.getHours().toString(), // 鏃� + 'M+': date.getMinutes().toString(), // 鍒� + 'S+': date.getSeconds().toString() // 绉� + // 鏈夊叾浠栨牸寮忓寲瀛楃闇�姹傚彲浠ョ户缁坊鍔狅紝蹇呴』杞寲鎴愬瓧绗︿覆 + } + for (const k in opt) { + ret = new RegExp('(' + k + ')').exec(fmt) + if (ret) { + fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0'))) } - for (let k in opt) { - ret = new RegExp('(' + k + ')').exec(fmt) - if (ret) { - fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0'))) - } - } - return fmt + } + return fmt } export default { - dateFormat + dateFormat } diff --git a/src/utils/GISUtil.js b/src/utils/GISUtil.js index c808bfd..27e1920 100644 --- a/src/utils/GISUtil.js +++ b/src/utils/GISUtil.js @@ -1,113 +1,113 @@ // ==============鍧愭爣绯昏浆鎹�=============== var GSP = { - PI: 3.14159265358979324, - x_pi: 3.14159265358979324 * 3000.0 / 180.0, - delta: function(lat, lon) { - // Krasovsky 1940 - // - // a = 6378245.0, 1/f = 298.3 - // b = a * (1 - f) - // ee = (a^2 - b^2) / a^2; - var a = 6378245.0 // a: 鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛愩�� - var ee = 0.00669342162296594323 // ee: 妞悆鐨勫亸蹇冪巼銆� - var dLat = this.transformLat(lon - 105.0, lat - 35.0) - var dLon = this.transformLon(lon - 105.0, lat - 35.0) - var radLat = lat / 180.0 * this.PI - var magic = Math.sin(radLat) - magic = 1 - ee * magic * magic - var sqrtMagic = Math.sqrt(magic) - dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * this.PI) - dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * this.PI) - return { 'lat': dLat, 'lon': dLon } - }, + PI: 3.14159265358979324, + x_pi: 3.14159265358979324 * 3000.0 / 180.0, + delta: function (lat, lon) { + // Krasovsky 1940 + // + // a = 6378245.0, 1/f = 298.3 + // b = a * (1 - f) + // ee = (a^2 - b^2) / a^2; + var a = 6378245.0 // a: 鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛愩�� + var ee = 0.00669342162296594323 // ee: 妞悆鐨勫亸蹇冪巼銆� + var dLat = this.transformLat(lon - 105.0, lat - 35.0) + var dLon = this.transformLon(lon - 105.0, lat - 35.0) + var radLat = lat / 180.0 * this.PI + var magic = Math.sin(radLat) + magic = 1 - ee * magic * magic + var sqrtMagic = Math.sqrt(magic) + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * this.PI) + dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * this.PI) + return { lat: dLat, lon: dLon } + }, - // WGS-84 to GCJ-02 - gcj_encrypt: function(wgsLat, wgsLon) { - if (this.outOfChina(wgsLat, wgsLon)) { return { 'lat': wgsLat, 'lon': wgsLon } } + // WGS-84 to GCJ-02 + gcj_encrypt: function (wgsLat, wgsLon) { + if (this.outOfChina(wgsLat, wgsLon)) { return { lat: wgsLat, lon: wgsLon } } - var d = this.delta(wgsLat, wgsLon) - return { 'lat': wgsLat + d.lat, 'lon': wgsLon + d.lon } - }, - // GCJ-02 to WGS-84 - gcj_decrypt: function(gcjLat, gcjLon) { - if (this.outOfChina(gcjLat, gcjLon)) { return { 'lat': gcjLat, 'lon': gcjLon } } + var d = this.delta(wgsLat, wgsLon) + return { lat: wgsLat + d.lat, lon: wgsLon + d.lon } + }, + // GCJ-02 to WGS-84 + gcj_decrypt: function (gcjLat, gcjLon) { + if (this.outOfChina(gcjLat, gcjLon)) { return { lat: gcjLat, lon: gcjLon } } - var d = this.delta(gcjLat, gcjLon) - return { 'lat': gcjLat - d.lat, 'lon': gcjLon - d.lon } - }, - // GCJ-02 to WGS-84 exactly - gcj_decrypt_exact: function(gcjLat, gcjLon) { - let initDelta = 0.01 - let threshold = 0.000000001 - let dLat = initDelta - let dLon = initDelta - let mLat = gcjLat - dLat - let mLon = gcjLon - dLon - let pLat = gcjLat + dLat - let pLon = gcjLon + dLon - let wgsLat - let wgsLon - let i = 0 - while (1) { - wgsLat = (mLat + pLat) / 2 - wgsLon = (mLon + pLon) / 2 - var tmp = this.gcj_encrypt(wgsLat, wgsLon) - dLat = tmp.lat - gcjLat - dLon = tmp.lon - gcjLon - if ((Math.abs(dLat) < threshold) && (Math.abs(dLon) < threshold)) { break } + var d = this.delta(gcjLat, gcjLon) + return { lat: gcjLat - d.lat, lon: gcjLon - d.lon } + }, + // GCJ-02 to WGS-84 exactly + gcj_decrypt_exact: function (gcjLat, gcjLon) { + const initDelta = 0.01 + const threshold = 0.000000001 + let dLat = initDelta + let dLon = initDelta + let mLat = gcjLat - dLat + let mLon = gcjLon - dLon + let pLat = gcjLat + dLat + let pLon = gcjLon + dLon + let wgsLat + let wgsLon + let i = 0 + while (1) { + wgsLat = (mLat + pLat) / 2 + wgsLon = (mLon + pLon) / 2 + var tmp = this.gcj_encrypt(wgsLat, wgsLon) + dLat = tmp.lat - gcjLat + dLon = tmp.lon - gcjLon + if ((Math.abs(dLat) < threshold) && (Math.abs(dLon) < threshold)) { break } - if (dLat > 0) pLat = wgsLat; else mLat = wgsLat - if (dLon > 0) pLon = wgsLon; else mLon = wgsLon + if (dLat > 0) pLat = wgsLat; else mLat = wgsLat + if (dLon > 0) pLon = wgsLon; else mLon = wgsLon - if (++i > 10000) break - } - // console.log(i); - return { 'lat': wgsLat, 'lon': wgsLon } - }, - // GCJ-02 to BD-09 - bd_encrypt: function(gcjLat, gcjLon) { - let x = gcjLon - let y = gcjLat - let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.x_pi) - let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.x_pi) - let bdLon = z * Math.cos(theta) + 0.0065 - let bdLat = z * Math.sin(theta) + 0.006 - return { 'lat': bdLat, 'lon': bdLon } - }, - // BD-09 to GCJ-02 - bd_decrypt: function(bdLat, bdLon) { - let x = bdLon - 0.0065 - let y = bdLat - 0.006 - let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_pi) - let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_pi) - let gcjLon = z * Math.cos(theta) - let gcjLat = z * Math.sin(theta) - return { 'lat': gcjLat, 'lon': gcjLon } - }, - // WGS-84 to Web mercator - // mercatorLat -> y mercatorLon -> x - mercator_encrypt: function(wgsLat, wgsLon) { - let x = wgsLon * 20037508.34 / 180.0 - let y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0) - y = y * 20037508.34 / 180.0 - return { 'lat': y, 'lon': x } - /* + if (++i > 10000) break + } + // console.log(i); + return { lat: wgsLat, lon: wgsLon } + }, + // GCJ-02 to BD-09 + bd_encrypt: function (gcjLat, gcjLon) { + const x = gcjLon + const y = gcjLat + const z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.x_pi) + const theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.x_pi) + const bdLon = z * Math.cos(theta) + 0.0065 + const bdLat = z * Math.sin(theta) + 0.006 + return { lat: bdLat, lon: bdLon } + }, + // BD-09 to GCJ-02 + bd_decrypt: function (bdLat, bdLon) { + const x = bdLon - 0.0065 + const y = bdLat - 0.006 + const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_pi) + const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_pi) + const gcjLon = z * Math.cos(theta) + const gcjLat = z * Math.sin(theta) + return { lat: gcjLat, lon: gcjLon } + }, + // WGS-84 to Web mercator + // mercatorLat -> y mercatorLon -> x + mercator_encrypt: function (wgsLat, wgsLon) { + const x = wgsLon * 20037508.34 / 180.0 + let y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0) + y = y * 20037508.34 / 180.0 + return { lat: y, lon: x } + /* if ((Math.abs(wgsLon) > 180 || Math.abs(wgsLat) > 90)) return null; var x = 6378137.0 * wgsLon * 0.017453292519943295; var a = wgsLat * 0.017453292519943295; var y = 3189068.5 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a))); return {'lat' : y, 'lon' : x}; - //*/ - }, - // Web mercator to WGS-84 - // mercatorLat -> y mercatorLon -> x - mercator_decrypt: function(mercatorLat, mercatorLon) { - var x = mercatorLon / 20037508.34 * 180.0 - var y = mercatorLat / 20037508.34 * 180.0 - y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2) - return { 'lat': y, 'lon': x } - /* + // */ + }, + // Web mercator to WGS-84 + // mercatorLat -> y mercatorLon -> x + mercator_decrypt: function (mercatorLat, mercatorLon) { + var x = mercatorLon / 20037508.34 * 180.0 + var y = mercatorLat / 20037508.34 * 180.0 + y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2) + return { lat: y, lon: x } + /* if (Math.abs(mercatorLon) < 180 && Math.abs(mercatorLat) < 90) return null; if ((Math.abs(mercatorLon) > 20037508.3427892) || (Math.abs(mercatorLat) > 20037508.3427892)) @@ -116,41 +116,41 @@ var x = a - (Math.floor(((a + 180.0) / 360.0)) * 360.0); var y = (1.5707963267948966 - (2.0 * Math.atan(Math.exp((-1.0 * mercatorLat) / 6378137.0)))) * 57.295779513082323; return {'lat' : y, 'lon' : x}; - //*/ - }, - // two point's distance - distance: function(latA, lonA, latB, lonB) { - var earthR = 6371000.0 - var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180) - var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0) - var s = x + y - if (s > 1) s = 1 - if (s < -1) s = -1 - var alpha = Math.acos(s) - var distance = alpha * earthR - return distance - }, - outOfChina: function(lat, lon) { - if (lon < 72.004 || lon > 137.8347) { return true } - if (lat < 0.8293 || lat > 55.8271) { return true } - return false - }, - transformLat: function(x, y) { - var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)) - ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 - ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0 - ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0 - return ret - }, - transformLon: function(x, y) { - var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)) - ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 - ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0 - ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0 - return ret - } + // */ + }, + // two point's distance + distance: function (latA, lonA, latB, lonB) { + var earthR = 6371000.0 + var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180) + var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0) + var s = x + y + if (s > 1) s = 1 + if (s < -1) s = -1 + var alpha = Math.acos(s) + var distance = alpha * earthR + return distance + }, + outOfChina: function (lat, lon) { + if (lon < 72.004 || lon > 137.8347) { return true } + if (lat < 0.8293 || lat > 55.8271) { return true } + return false + }, + transformLat: function (x, y) { + var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)) + ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 + ret += (20.0 * Math.sin(y * this.PI) + 40.0 * Math.sin(y / 3.0 * this.PI)) * 2.0 / 3.0 + ret += (160.0 * Math.sin(y / 12.0 * this.PI) + 320 * Math.sin(y * this.PI / 30.0)) * 2.0 / 3.0 + return ret + }, + transformLon: function (x, y) { + var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)) + ret += (20.0 * Math.sin(6.0 * x * this.PI) + 20.0 * Math.sin(2.0 * x * this.PI)) * 2.0 / 3.0 + ret += (20.0 * Math.sin(x * this.PI) + 40.0 * Math.sin(x / 3.0 * this.PI)) * 2.0 / 3.0 + ret += (150.0 * Math.sin(x / 12.0 * this.PI) + 300.0 * Math.sin(x / 30.0 * this.PI)) * 2.0 / 3.0 + return ret + } } export default { - GSP + GSP } diff --git a/src/utils/JsonUtils.js b/src/utils/JsonUtils.js index d0cfef2..d4e6267 100644 --- a/src/utils/JsonUtils.js +++ b/src/utils/JsonUtils.js @@ -3,46 +3,46 @@ * @param {Object} type锛� 榛樿涓嶄紶 ==>鍏ㄩ儴灏忓啓;浼�1 ==>鍏ㄩ儴澶у啓;浼�2 ==>棣栧瓧姣嶅ぇ鍐� * 灏唈son鐨刱ey鍊艰繘琛屽ぇ灏忓啓杞崲 */ -function jsonKeysToCase(json, type) { - if (typeof json === 'object') { - var tempJson = JSON.parse(JSON.stringify(json)) - toCase(tempJson) - return tempJson - } else { - return json - } +function jsonKeysToCase (json, type) { + if (typeof json === 'object') { + var tempJson = JSON.parse(JSON.stringify(json)) + toCase(tempJson) + return tempJson + } else { + return json + } - function toCase(json) { - if (typeof json === 'object') { - if (Array.isArray(json)) { - json.forEach(function(item) { - toCase(item) - }) - } else { - for (var key in json) { - var item = json[key] - if (typeof item === 'object') { - toCase(item) - } - delete (json[key]) - switch (type) { - case 1: - // key鍊煎叏閮ㄥぇ鍐� - json[key.toLocaleUpperCase()] = item - break - case 2: - // key鍊奸瀛楁瘝澶у啓锛屽叾浣欏皬鍐� - json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item - break - default: - // 榛樿key鍊煎叏閮ㄥ皬鍐� - json[key.toLocaleLowerCase()] = item - break - } - } - } + function toCase (json) { + if (typeof json === 'object') { + if (Array.isArray(json)) { + json.forEach(function (item) { + toCase(item) + }) + } else { + for (var key in json) { + var item = json[key] + if (typeof item === 'object') { + toCase(item) + } + delete (json[key]) + switch (type) { + case 1: + // key鍊煎叏閮ㄥぇ鍐� + json[key.toLocaleUpperCase()] = item + break + case 2: + // key鍊奸瀛楁瘝澶у啓锛屽叾浣欏皬鍐� + json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item + break + default: + // 榛樿key鍊煎叏閮ㄥ皬鍐� + json[key.toLocaleLowerCase()] = item + break + } } + } } + } } export default jsonKeysToCase diff --git a/src/utils/MiscUtils.js b/src/utils/MiscUtils.js index 9752f95..f145ad6 100644 --- a/src/utils/MiscUtils.js +++ b/src/utils/MiscUtils.js @@ -1,118 +1,118 @@ // 鍙傛暟鍚嶇О:authCode 鍊�: 鎵�鏈�:0 鍖栧伐閿�鍞�:HXXT; 鐐兼补閿�鍞�:LXXT; 姹熻嫃鐭虫补:CPYXT; 閿�鍞崕涓�:XSHD -let SysAuthCode = '0' +const SysAuthCode = '0' /** * Created by liangruizhe on 2019/01/14 */ // ==============鏃堕棿=============== // 鑾峰彇褰撳墠鏃堕棿 -function GetCurrentTime() { - var today = new Date() - var year = today.getFullYear() - var month = today.getMonth() + 1 - var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() - var hours = today.getHours() > 9 ? today.getHours() : '0' + today.getHours() - var minutes = today.getMinutes() > 9 ? today.getMinutes() : '0' + today.getMinutes() - var seconds = today.getSeconds() > 9 ? today.getSeconds() : '0' + today.getSeconds() - return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds +function GetCurrentTime () { + var today = new Date() + var year = today.getFullYear() + var month = today.getMonth() + 1 + var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() + var hours = today.getHours() > 9 ? today.getHours() : '0' + today.getHours() + var minutes = today.getMinutes() > 9 ? today.getMinutes() : '0' + today.getMinutes() + var seconds = today.getSeconds() > 9 ? today.getSeconds() : '0' + today.getSeconds() + return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds } // 鑾峰彇褰撳ぉ闆剁偣鏃堕棿 -function GetCurrentDayTime() { - var today = new Date() - var year = today.getFullYear() - var month = today.getMonth() + 1 - var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() - return year + '-' + month + '-' + day + ' 00:01:01' +function GetCurrentDayTime () { + var today = new Date() + var year = today.getFullYear() + var month = today.getMonth() + 1 + var day = today.getDate() > 9 ? today.getDate() : '0' + today.getDate() + return year + '-' + month + '-' + day + ' 00:01:01' } // UtcToDateTime -function UtcToDateTime(time) { - var date = new Date(time) - var year = date.getFullYear() - var month = date.getMonth() + 1 - var day = date.getDate() - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second +function UtcToDateTime (time) { + var date = new Date(time) + var year = date.getFullYear() + var month = date.getMonth() + 1 + var day = date.getDate() + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second } // UtcToMonDate -function UtcToMonDate(time) { - var date = new Date(time) - var month = date.getMonth() + 1 - var day = date.getDate() - var hour = date.getHours() - var minute = date.getMinutes() - var second = date.getSeconds() - return month + '/' + day + ' ' + hour + ':' + minute + ':' + second +function UtcToMonDate (time) { + var date = new Date(time) + var month = date.getMonth() + 1 + var day = date.getDate() + var hour = date.getHours() + var minute = date.getMinutes() + var second = date.getSeconds() + return month + '/' + day + ' ' + hour + ':' + minute + ':' + second } // yyyy-MM-dd -function convertDateFromString(dateString) { - if (dateString) { - var date = new Date(dateString.replace(/-/, '/')) - return date - } +function convertDateFromString (dateString) { + if (dateString) { + var date = new Date(dateString.replace(/-/, '/')) + return date + } } // yyyy-MM-dd hh:mm:ss -function convertDateTimeFromString(dateString) { - if (dateString) { - var arr1 = dateString.split(' ') - var sdate = arr1[0].split('-') - var stime = arr1[1].split(':') - var date = new Date(sdate[0], sdate[1] - 1, sdate[2], stime[0], stime[1], stime[2]) - return date - } +function convertDateTimeFromString (dateString) { + if (dateString) { + var arr1 = dateString.split(' ') + var sdate = arr1[0].split('-') + var stime = arr1[1].split(':') + var date = new Date(sdate[0], sdate[1] - 1, sdate[2], stime[0], stime[1], stime[2]) + return date + } } // ==============绌洪棿璁$畻=============== // 璁$畻鐐逛覆璺濈 -function getLength(arrPnts, isJwd) { - var dist = 0 - var length = 0 - var offset = 103133.845 - var fntPnt = null - var lastPnt = null - if (isJwd === undefined) isJwd = true - if (arrPnts.length < 2) { - return 0 - } - for (var i = 0; i < arrPnts.length - 1; i++) { - fntPnt = arrPnts[i] - lastPnt = arrPnts[i + 1] - if (lastPnt) { - var xD = Math.abs(fntPnt.x - lastPnt.x) - var yD = Math.abs(fntPnt.y - lastPnt.y) +function getLength (arrPnts, isJwd) { + var dist = 0 + var length = 0 + var offset = 103133.845 + var fntPnt = null + var lastPnt = null + if (isJwd === undefined) isJwd = true + if (arrPnts.length < 2) { + return 0 + } + for (var i = 0; i < arrPnts.length - 1; i++) { + fntPnt = arrPnts[i] + lastPnt = arrPnts[i + 1] + if (lastPnt) { + var xD = Math.abs(fntPnt.x - lastPnt.x) + var yD = Math.abs(fntPnt.y - lastPnt.y) - if (isJwd) { - if (Math.abs(fntPnt.x) > 180) { - xD = xD / 3600 - yD = yD / 3600 - } - dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) * offset - } else { - dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) - } - - length += dist + if (isJwd) { + if (Math.abs(fntPnt.x) > 180) { + xD = xD / 3600 + yD = yD / 3600 } + dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) * offset + } else { + dist = (Math.sqrt(Math.pow(xD, 2) + Math.pow(yD, 2))) + } + + length += dist } - return length + } + return length } // 璁$畻鐐瑰埌绾挎鐨勮窛绂� -function getDistance(point, lineP1, lineP2) { - var a = Number((lineP1.y - lineP2.y) / (lineP1.x - lineP2.x)) - var b = -1 - var c = Number(lineP2.y - a * lineP2.x) - var td = Math.abs(a * point.x + b * point.y + c) / Math.sqrt(a * a + b * b) - return td +function getDistance (point, lineP1, lineP2) { + var a = Number((lineP1.y - lineP2.y) / (lineP1.x - lineP2.x)) + var b = -1 + var c = Number(lineP2.y - a * lineP2.x) + var td = Math.abs(a * point.x + b * point.y + c) / Math.sqrt(a * a + b * b) + return td } export default { - SysAuthCode, - getDistance, - getLength, - GetCurrentTime, - GetCurrentDayTime, - UtcToDateTime, - UtcToMonDate, - convertDateFromString, - convertDateTimeFromString + SysAuthCode, + getDistance, + getLength, + GetCurrentTime, + GetCurrentDayTime, + UtcToDateTime, + UtcToMonDate, + convertDateFromString, + convertDateTimeFromString } diff --git a/src/utils/MixinAuthority.js b/src/utils/MixinAuthority.js deleted file mode 100644 index 5403f9b..0000000 --- a/src/utils/MixinAuthority.js +++ /dev/null @@ -1,83 +0,0 @@ -import $API from '@/api' -import $http from '@/utils/axios' -import * as $T from '@utils/tools' - -export default { - data() { - return { - isOauthAdd: true, - isOauthEdit: true, - isOauthDelete: true, - isOauthExport: true, - isOauthImport: true, - isOauthStart: true, - isOauthStop: true, - isOnlyQuery: false - } - }, - provide: function() { - return { - oauth: this.$data - } - }, - methods: {}, - created() {}, - mounted() {}, - beforeRouteEnter(to, from, next) { - const routerName = to.name - $http.get($API.AAA_GET_PAGES_RESOURCE, { - pageCode: routerName - }).then(response => { - const str = response.data - if (!str.includes('query')) { - $T.warning('鎮ㄦ病鏈夋潈闄愭煡鐪嬮〉闈㈠唴瀹癸紝璇疯仈绯荤鐞嗗憳鍒嗛厤鏉冮檺锛�') - return - } - // 澶勭悊鏉冮檺 - next(vm => { - // 浠呮湁鏌ヨ鏉冮檺鐨勬椂鍊� - if (str === 'query') { - vm.isOnlyQuery = true - } - - // 娌℃湁娣诲姞鏉冮檺鐨勫満鏅� - if (!str.includes('add')) { - vm.isOauthAdd = false - } - - // 娌℃湁淇敼鏉冮檺鐨勫満鏅� - if (!str.includes('edit')) { - vm.isOauthEdit = false - } - - // 娌℃湁鍒犻櫎鏉冮檺鐨勫満鏅� - if (!str.includes('delete')) { - vm.isOauthDelete = false - } - - // 娌℃湁瀵煎嚭鏉冮檺鐨勫満鏅� - if (!str.includes('export')) { - vm.isOauthExport = false - } - - // 娌℃湁瀵煎叆鏉冮檺鐨勫満鏅� - if (!str.includes('import')) { - vm.isOauthImport = false - } - - // 娌℃湁鍚敤鏉冮檺鐨勫満鏅� - if (!str.includes('start')) { - vm.isOauthStart = false - } - - // 娌℃湁鍋滅敤鏉冮檺鐨勫満鏅� - if (!str.includes('stop')) { - vm.isOauthStop = false - } - }) - }).catch(() => { - $T.error('鑾峰彇椤甸潰璧勬簮鏉冮檺澶辫触锛�') - // next() - }) - } -} diff --git a/src/utils/MixinEmitter.js b/src/utils/MixinEmitter.js deleted file mode 100644 index ba41db1..0000000 --- a/src/utils/MixinEmitter.js +++ /dev/null @@ -1,57 +0,0 @@ -function broadcast(componentName, eventName, params) { - this.$children.forEach(child => { - const name = child.$options.name - - if (name === componentName) { - child.$emit.apply(child, [eventName].concat(params)) - } else { - // todo 濡傛灉 params 鏄┖鏁扮粍锛屾帴鏀跺埌鐨勪細鏄� undefined - broadcast.apply(child, [componentName, eventName].concat([params])) - } - }) -} - -export default { - methods: { - dispatch(componentName, eventName, params) { - let parent = this.$parent || this.$root - let name = parent.$options.name - - while (parent && (!name || name !== componentName)) { - parent = parent.$parent - - if (parent) { - name = parent.$options.name - } - } - if (parent) { - parent.$emit.apply(parent, [eventName].concat(params)) - } - }, - broadcast(componentName, eventName, params) { - broadcast.call(this, componentName, eventName, params) - }, - findComponentHandler(targetComponentName) { - let finedComponent = null - - function find(componentSubs) { - for (let i = 0, len = componentSubs.length; i < len; i++) { - let component = componentSubs[i] - let name = component.$options.name - if (name === targetComponentName) { - finedComponent = component - break - } - if (targetComponentName !== name) { - find(component.$children) - } else { - return true - } - } - } - - find(this.$children) - return finedComponent - } - } -} diff --git a/src/utils/authorityAPI.js b/src/utils/authorityAPI.js deleted file mode 100644 index f847195..0000000 --- a/src/utils/authorityAPI.js +++ /dev/null @@ -1,11 +0,0 @@ -// 杩愯鍒嗘瀽 -export const EOOA_OAUTH_API = [ - 'eowc/equipmentConfig/notConfigEquipment' -] - -// 鐩戞帶棰勮 -export const EMEW_OAUTH_API = [ - 'eowc/equipmentConfig/notConfigEquipment' -] - -export const OAUTH_API_GROUP = [...EOOA_OAUTH_API, ...EMEW_OAUTH_API] diff --git a/src/utils/axios.js b/src/utils/axios.js deleted file mode 100644 index e759790..0000000 --- a/src/utils/axios.js +++ /dev/null @@ -1,214 +0,0 @@ -import Vue from 'vue' -import axios from 'axios' -import * as $CONST from '@/utils/constant' -import * as $T from '@/utils/tools' -import $store from '@/store' - -/** - * 瀹氫箟浼犲叆鍙傛暟鏁版嵁鏍煎紡 - * - * === 鍒犻櫎鏁版嵁 === - * { - * key:['dataId1','dataId2'] - * } - * - */ - -/** - * 瀹氫箟杩斿洖鐨刯son鏁版嵁鏍煎紡 - * - * === 鍒嗛〉鏁版嵁 === - * { - * code:200, --- 鐩墠妗嗘灦璁や负0鍜�200閮芥槸鎴愬姛鐘舵�� - * message:'鎸変笟鍔¤嚜瀹氫箟', - * data:{ - * records:[{...},{...}], --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴�� - * total:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴�� - * size:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴�� - * current:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴�� - * pages:xx --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴�� - * }, - * } - * - * === 鍒楄〃鏁版嵁 === - * - * { - * code:200, - * message:'鎸変笟鍔¤嚜瀹氫箟', - * data:[{..},{..}...] - * } - * - * === 涓�鏉℃暟鎹� === - * - * { - * code:200, - * message:'鎸変笟鍔¤嚜瀹氫箟', - * data:{...} - * } - * - * === 鏃犺繑鍥炴暟鎹� === - * - * { - * code:200, - * message:'鎸変笟鍔¤嚜瀹氫箟', - * data: null - * } - * - * === 鏍戝舰缁撴瀯 === - * - * { - * code:200, - * message:'鎸変笟鍔¤嚜瀹氫箟' - * data:[{ - * prop:xx, - * ... - * children: [ - * prop:xx, - * ... - * children:[...] - * ] - * }, - * { - * prop:xx, - * ... - * children: [ - * prop:xx, - * ... - * children:[...] - * ] - * }] - * } - * - */ - -// 鍒涘缓axios瀹炰緥 -const Service = axios.create({ - timeout: 1000 -}) - -const CancelToken = axios.CancelToken - -/* - function showDebugInfo(config) { - console.group('%cMethod::' + config.method + '::Url::' + config.url, 'color:red;font-size:12px;') - console.log('%c淇濆瓨/鏇存柊/鏌ョ湅鍦哄悎锛屼紶鍏ョ殑鍙傛暟::', 'font-size:12px;') - console.log(config.hasOwnProperty('params') ? JSON.stringify(config.params) : JSON.stringify(config.data)) - console.groupEnd() - } - - function filterOauthData(config) { - let url = config.url - if (config.method === 'post' && $t.isExistOauthApi(url)) { - // post璇锋眰鐨勫満鍚堜笅锛岃拷鍔犺鑹插悕绉� - } - - if (config.method === 'get' && $t.isExistOauthApi(url)) { - // get璇锋眰鐨勫満鍚堜笅锛岃拷鍔犺鑹插悕绉� - if (config.hasOwnProperty('params')) { - config.params['userCode'] = '' - } else { - config['params'] = {} - config.params['userCode'] = '' - } - } - return config - }*/ - -// request鎷︽埅鍣� -Service.interceptors.request.use( - config => { - // 涓存椂杩藉姞 - if ($store.state.user.account) { - config.headers.account = $store.state.user.account - } - let copyConfig = Object.assign({}, config) - // copyConfig = filterOauthData(copyConfig) - // showDebugInfo(copyConfig) - copyConfig.cancelToken = new CancelToken((c) => { - // 椤甸潰澶辨晥鍦烘櫙锛屽彇娑坧adding涓姹� - Vue.prototype.$cancels.push(c) - // todo 蹇�熷弻鍑诲彇娑堥噸澶嶈姹� - // 閲嶅璇锋眰鍦烘櫙锛屽彇娑堟帀涓婁竴涓湭padding涓姹� - }) - return copyConfig - }, - error => { - Promise.reject(error) - }) - -// respone鎷︽埅鍣� -Service.interceptors.response.use( - response => { - const res = response.data - if (Number(res.code) !== 200 && Number(res.code) !== 0) { - $T.warning(res.message) - return res - } else { - return res - } - }, - error => { - if (error.message && error.message.includes('timeout')) { - $T.fail($CONST.MSG_SYS_TIME_OUT) - return Promise.reject(error) - } - - if (!error.response) { - $T.fail($CONST.MSG_SYS_ERR) - return Promise.reject(error) - } - - switch (error.response.status) { - // http status handler - case 404: - $T.fail($CONST.MSG_SYS_404) - break - case 500: - $T.fail($CONST.MSG_SYS_ERR) - break - case 503: - $T.fail($CONST.MSG_SYS_503) - break - } - - return Promise.reject(error) - } -) - -const $http = {} -$http.$service = Service -$http.$axios = axios -$http.get = function(url, params = {}) { - if ($T.isInlineParams(url)) { - // 涓ユ牸閬靛惊restful鏍囧噯鐨剈rl鐨勫満鏅� - url = $T.replaceUrlParams(url, params) - params = {} - } - return Service({ - url: url, - method: 'get', - params: $T.filterParams(params) - }) -} -$http.post = function(url, data = {}) { - return Service({ - url: url, - method: 'post', - data: data - }) -} -$http.put = function(url, data = {}) { - return Service({ - url: url, - method: 'put', - data: data - }) -} -$http.delete = function(url, data = {}) { - return Service({ - url: url, - method: 'delete', - data: data - }) -} -export default $http diff --git a/src/utils/constant.js b/src/utils/constant.js deleted file mode 100644 index 877ff0d..0000000 --- a/src/utils/constant.js +++ /dev/null @@ -1,65 +0,0 @@ -/* 鏃ユ湡璁剧疆 - -------------------------- */ -export const PICKER_OPTIONS_SHORTCUTS = [ - { - text: '浠婂ぉ', - onClick(picker) { - const end = new Date() - const start = new Date(new Date().toDateString()) - end.setTime(start.getTime()) - picker.$emit('pick', [start, end]) - } - }, { - text: '鏈�杩戜竴鍛�', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(end.getTime() - 3600 * 1000 * 24 * 7) - picker.$emit('pick', [start, end]) - } - }, { - text: '鏈�杩戜竴涓湀', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) - picker.$emit('pick', [start, end]) - } - }, { - text: '鏈�杩戜笁涓湀', - onClick(picker) { - const end = new Date(new Date().toDateString()) - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 90) - picker.$emit('pick', [start, end]) - } - }] - -/* 绯荤粺閿欒娑堟伅 - -------------------------- */ -export const MSG_SYS_ERR = '鏈嶅姟鍣ㄥ唴閮ㄨ繍琛岄敊璇紝璇风◢鍚庨噸璇曪紒' -export const MSG_SYS_TIME_OUT = '褰撳墠缃戠粶鐜杈冨樊锛岃闂秴鏃讹紝璇峰埛鏂伴噸璇曪紒' -export const MSG_SYS_404 = '璇锋眰鐨勮祫婧愪笉瀛樺湪锛�' -export const MSG_SYS_503 = '鏈嶅姟鍣ㄦ鍦ㄧ淮鎶わ紝璇风◢绛夛紒' -export const MSG_SYS_SUCCESS = '鎿嶄綔鎴愬姛锛�' -export const MSG_SYS_FAIL = '鎿嶄綔澶辫触锛�' -export const MSG_SYS_CANCELED = '鎿嶄綔宸插彇娑堬紒' -export const MSG_SYS_WARNING = '璀﹀憡锛屾湭鎸夎鍒欐搷浣滐紒' - -export const MSG_RULES_NUMBER = '蹇呴』涓烘暟瀛楀�硷紒' -export const MSG_RULES_REQUIRED = '涓嶈兘涓虹┖锛�' - -export const MSG_BUSINESS_DELETE = '鍒犻櫎璇ユ暟鎹�, 鏄惁缁х画锛�' -export const MSG_BUSINESS_SUBMIT = '鎻愪氦璇ユ暟鎹�, 鏄惁缁х画锛�' -export const MSG_BUSINESS_SELECTED = '璇烽�夋嫨瑕佹搷浣滅殑鏁版嵁锛�' -export const MSG_BUSINESS_START = '鍚敤璇ユ暟鎹�, 鏄惁缁х画锛�' -export const MSG_BUSINESS_STOP = '鍋滅敤璇ユ暟鎹�, 鏄惁缁х画锛�' -export const MSG_BUSINESS_IMPORT = '璇疯�愬績绛夊緟锛屾暟鎹鍏ヤ腑...' -export const MSG_BUSINESS_EXPORT = '璇疯�愬績绛夊緟锛屾暟鎹鍑轰腑...' -export const MSG_BUSINESS_EXPORT_ALL = '瀵煎嚭鏉′欢绛涢�夊嚭鐨勫叏閮ㄦ暟鎹�' -export const MSG_BUSINESS_UPLOAD = '璇疯�愬績绛夊緟锛屾枃浠朵笂浼犱腑...' -export const MSG_BUSINESS_UPLOAD_SUCCESS = '涓婁紶鎴愬姛锛�' -export const MSG_BUSINESS_UPLOAD_FAIL = '涓婁紶澶辫触锛�' -export const MSG_BUSINESS_UPLOAD_IMG = '涓婁紶鍥剧墖鍙兘鏄� JPG/PNG 鏍煎紡锛�' -export const MSG_BUSINESS_UPLOAD_SIZE_2M = '涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 2MB锛�' -export const MSG_BUSINESS_UPLOAD_SIZE_10M = '涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 10MB锛�' diff --git a/src/utils/dictionary.js b/src/utils/dictionary.js deleted file mode 100644 index 76b3c46..0000000 --- a/src/utils/dictionary.js +++ /dev/null @@ -1,782 +0,0 @@ -/* 涓氬姟瀛楀吀 - -------------------------- */ -// 杞﹁締璇佷欢绫诲瀷 -export const DICT_CAR_CERTIFICATE_TYPE = [ - { - typeName: '钀ヤ笟鎵х収', - type: '120001' - }, - { - typeName: '鍗遍櫓璐х墿閬撹矾杩愯緭缁忚惀璁稿彲璇�', - type: '120002' - }, - { - typeName: '鍗遍櫓璐х墿姘磋矾杩愯緭璁稿彲璇�', - type: '120003' - }, - { - typeName: '鍥哄簾澶勭疆缁忚惀璁稿彲璇�', - type: '120004' - }, - { - typeName: '閬撹矾杩愯緭璇�', - type: '120005' - }, - { - typeName: '杞﹁締琛岄┒璇�', - type: '120006' - }, - { - typeName: '缃愭鎶ュ憡', - type: '120007' - }, - { - typeName: '瀹夊叏绠$悊璇�', - type: '120008' - }, - { - typeName: '鍗遍櫓璐х墿閫傝璇�', - type: '120009' - }, - { - typeName: '鏈哄姩杞﹂┚椹惰瘉', - type: '120010' - }, - { - typeName: '鍗遍櫓鍝佷粠涓氳祫鏍艰瘉', - type: '120011' - }, - { - typeName: '鍗遍櫓搴熺墿缁煎悎缁忚惀璁稿彲璇�', - type: '120012' - }, - { - typeName: '鍗遍櫓搴熺墿鏀堕泦缁忚惀璁稿彲璇�', - type: '120013' - } -] - -// 璧勬簮搴撶被鍨� -export const DICT_RESOURCE_TYPE = [ - { - resourceTypeName: '鎵胯繍鍟�', - resourceType: '400001' - }, - { - resourceTypeName: '杞﹁締', - resourceType: '400002' - }, - { - resourceTypeName: '鑸硅埗', - resourceType: '400003' - }, - { - resourceTypeName: '閾佽矾鑷杞�', - resourceType: '400004' - }, - { - resourceTypeName: '椹炬娂浜哄憳', - resourceType: '400005' - }, - { - resourceTypeName: '鍗卞簾鍚嶅綍', - resourceType: '400006' - }, - { - resourceTypeName: '鍗卞簾澶勭疆鍟�', - resourceType: '400007' - }, - { - resourceTypeName: '鍗卞簾杞Щ搴�', - resourceType: '400008' - } -] - -// 榛戝悕鍗曠骇鍒� -export const DICT_BLACK_LIST_TYPE = [ - { - blacklistTypeName: '璀﹀憡', - blacklistType: '490001' - }, - { - blacklistTypeName: '绂佺敤', - blacklistType: '490002' - }, - { - blacklistTypeName: '鏃�', - blacklistType: '490000' - } -] - -// 榛戝悕鍗曡繘鍏ュ師鍥� -export const DICT_BLACK_LIST_REASON = [ - { - enterReasonName: '杩濊', - enterReason: '491001' - }, - { - enterReasonName: '璧勮川杩囨湡', - enterReason: '491002' - }, - { - enterReasonName: '鍏朵粬', - enterReason: '491009' - } -] - -// 娣诲姞榛戝悕鍗� -export const DICT_BLACKLIST_OPERATION = [ - { - optTypeName: '娣诲姞榛戝悕鍗�', - optType: '492001' - }, - { - optTypeName: '绉婚櫎榛戝悕鍗�', - optType: '492002' - } -] - -// 鍚敤 鍋滅敤 -export const DICT_IS_ENABLED_RADIO = [ - { - label: '鍚敤', - value: '110001' - }, - { - label: '鍋滅敤', - value: '110002' - } -] -export const DICT_IS_ENABLED_COMPANY = [ - { - isEnabledName: '浣跨敤涓�', - isEnabled: '110001' - }, - { - isEnabledName: '宸插仠鐢�', - isEnabled: '110002' - } -] -export const DICT_IS_YES_NO = [ - { - label: '鏄�', - value: '110001' - }, - { - label: '鍚�', - value: '110002' - } -] - -// 鐏伨绫诲埆 -export const DICT_FIRE_HAZARD_TYPE = [ - { - fireHazardTypeName: '鐢茬被', - fireHazardType: '770001' - }, - { - fireHazardTypeName: '涔欑被', - fireHazardType: '770002' - }, - { - fireHazardTypeName: '涓欑被', - fireHazardType: '770003' - } -] - -// 鏈嶅姟绫诲瀷 -export const DICT_SERVICE_TYPE_HCS = [ - { - serviceTypeName: '鍗卞寲鍝�', - serviceType: '1' - }, - { - serviceTypeName: '鍗卞簾', - serviceType: '2' - }, - { - serviceTypeName: '鍗卞寲鍝�&鍗卞簾', - serviceType: '0' - } -] - -// 閫旂粡鐐规暟閲� -export const DICT_HWS_WAYPOINT_AMOUNT = [ - { - hwsWayPointAmountName: '0', - hwsWayPointCount: 0 - }, - { - hwsWayPointAmountName: '1', - hwsWayPointCount: 1 - }, - { - hwsWayPointAmountName: '2', - hwsWayPointCount: 2 - }, - { - hwsWayPointAmountName: '3', - hwsWayPointCount: 3 - }, - { - hwsWayPointAmountName: '4', - hwsWayPointCount: 4 - }, - { - hwsWayPointAmountName: '5', - hwsWayPointCount: 5 - }, - { - hwsWayPointAmountName: '6', - hwsWayPointCount: 6 - }, - { - hwsWayPointAmountName: '7', - hwsWayPointCount: 7 - }, - { - hwsWayPointAmountName: '8', - hwsWayPointCount: 8 - }, - { - hwsWayPointAmountName: '9', - hwsWayPointCount: 9 - }, - { - hwsWayPointAmountName: '10', - hwsWayPointCount: 10 - } -] - -// 杞﹁締鐜繚绛夌骇 -export const DICT_LEVEL = [ - { - envProtLevelName: '鍥解厾', - envProtLevel: '420001' - }, - { - envProtLevelName: '鍥解叀', - envProtLevel: '420002' - }, - { - envProtLevelName: '鍥解參', - envProtLevel: '420003' - }, - { - envProtLevelName: '鍥解叄', - envProtLevel: '420004' - }, - { - envProtLevelName: '鍥解叅', - envProtLevel: '420005' - }, - { - envProtLevelName: '鍥解叆', - envProtLevel: '420006' - }, - { - envProtLevelName: '鍏朵粬', - envProtLevel: '420009' - } -] - -// 椹炬娂浜哄憳绫诲瀷 -export const DICT_DRIVERS_TYPE = [ - { - driverTypeName: '椹鹃┒鍛�', - driverType: '450001' - }, - { - driverTypeName: '鎶艰繍鍛�', - driverType: '450002' - }, - { - driverTypeName: '椹鹃┒鍛�/鎶艰繍鍛�', - driverType: '450003' - } -] - -// 缁勭粐鏈烘瀯绫诲埆 -export const DICT_ORG_LEVEL = [{ - orgLevelName: '闆嗗洟鍏徃绾�', - orgLevel: '510001' -}, { - orgLevelName: '浜嬩笟閮�/绠$悊閮�/涓撲笟鍏徃', - orgLevel: '510002' -}, { - orgLevelName: '浼佷笟绾�', - orgLevel: '510003' -}, { - orgLevelName: '浜岀骇鍗曚綅', - orgLevel: '510004' -}, { - orgLevelName: '鍩哄眰鍗曚綅', - orgLevel: '510005' -}, { - orgLevelName: '鍏跺畠', - orgLevel: '510006' -}] - -// 缁勭粐鏈烘瀯鎬ц川 -export const DICT_ORG_CHARACTER = [ - { - orgCharacterName: '鑲′唤', - orgCharacter: '520001' - }, - { - orgCharacterName: '瀛樼画', - orgCharacter: '520002' - } -] - -// 缁勭粐鏈烘瀯鏉垮潡 -export const DICT_ORG_SECTOR = [ - { - sectorName: '閿�鍞澘鍧�', - orgSector: '10010088' - }, - { - sectorName: '鐐兼补鏉垮潡', - orgSector: '30070000' - }, - { - sectorName: '鍖栧伐鏉垮潡', - orgSector: '30090000' - }, - { - sectorName: '娌圭敯鏉垮潡', - orgSector: '30050000' - } -] - -// 杩愯緭鐘舵�� -export const DICT_TRANS_STATE = [ - { - statusName: '寰呭彂杩�', - status: '590002' - }, - { - statusName: '杩愯緭涓�', - status: '590006' - }, - { - statusName: '宸插畬鎴�', - status: '590007' - }, - { - statusName: '宸蹭綔搴�', - status: '590009' - } -] - -// 涓氬姟鑼冨洿 -export const DICT_TRANS_METHOD = [ - { - businessScopeName: '鍏矾', - businessScope: 'RD' - }, - { - businessScopeName: '姘磋矾 ', - businessScope: 'RL' - }, - { - businessScopeName: '鍏矾&姘磋矾', - businessScope: 'AL' - } -] - -// 閫氱煡閰嶇疆 -export const NOTICE_CONFIG_TYPE = [ - { - noticeTypeName: '绂佽鍖哄煙閫氱煡', - noticeType: '620001' - }, - { - noticeTypeName: '鎻愰啋鍖哄煙閫氱煡', - noticeType: '620002' - }, - { - noticeTypeName: '琛岄┒璺緞鍋忕Щ閫氱煡 ', - noticeType: '620003' - }, - { - noticeTypeName: '杞﹁締鎶ヨ閫氱煡 ', - noticeType: '620004' - }, - { - noticeTypeName: '杞﹁締鎶ヨ閫氱煡', - noticeType: '620005' - } -] - -// 閫氱煡閰嶇疆 -export const DICT_NOTICE_CONFIG_REMIND_TYPE = [ - { - remindTypeName: '瀹炴椂鎻愰啋', - remindType: '630001' - }, - { - remindTypeName: '鏃ユ眹鎬绘彁閱�', - remindType: '630002' - }, - { - remindTypeName: '鍛ㄦ眹鎬绘彁閱� ', - remindType: '630003' - } -] - -// 绯荤粺鏁版嵁鏉ユ簮 -export const DICT_SOURCE_STATE = [ - { - sourceSysName: '鑷湁', - sourceSys: '640001' - } -] - -// 鍗卞寲鍝佺被鍨� -export const DICT_HCS_TYPE = [ - { - hcsTypeName: '鍖栧伐鍝�', - hcsType: '122001' - }, - { - hcsTypeName: '鎴愬搧娌�', - hcsType: '122002' - }, - { - hcsTypeName: '娑︽粦娌�', - hcsType: '122003' - }, - { - hcsTypeName: '澶╃劧姘�', - hcsType: '122004' - }, - { - hcsTypeName: '娑插寲鐭虫补姘�', - hcsType: '122005' - } -] - -// 鐩戞帶绫诲瀷 -export const DICT_MONITOR_TYPE = [ - { - monitorTypeName: '涓�鑸洃鎺�', - monitorType: '130001' - }, - { - monitorTypeName: '閲嶇偣鐩戞帶', - monitorType: '130002' - } -] - -// 琛屾斂绾у埆 -export const DICT_ADMINISTRATIVE_LEVEL = [ - { - adminLevelName: '姝i儴绾�', - adminLevel: '650001' - }, - { - adminLevelName: '鍓儴绾�', - adminLevel: '650002' - }, - { - adminLevelName: '姝e眬绾�', - adminLevel: '650003' - }, - { - adminLevelName: '鍓眬绾�', - adminLevel: '650004' - }, - { - adminLevelName: '姝e绾�', - adminLevel: '650005' - }, - { - adminLevelName: '鍓绾�', - adminLevel: '650006' - }, - { - adminLevelName: '姝g绾�', - adminLevel: '650007' - }, - { - adminLevelName: '鍓绾�', - adminLevel: '650008' - }, - { - adminLevelName: '涓�鑸鐞嗕汉鍛�', - adminLevel: '650009' - }, - { - adminLevelName: '鎿嶄綔浜哄憳', - adminLevel: '6500010' - } -] - -// 鑱岀О -export const DICT_POSITIONAL_TITLES = [ - { - PositionalTitlesName: '鍔╃悊宸ョ▼甯�', - jobTitle: '710001' - }, - { - PositionalTitlesName: '宸ョ▼甯�', - jobTitle: '710002' - }, - { - PositionalTitlesName: '楂樼骇宸ョ▼甯�', - jobTitle: '710003' - }, - { - PositionalTitlesName: '鏁欐巿绾ч珮绾у伐绋嬪笀', - jobTitle: '710004' - }, - { - PositionalTitlesName: '涓讳换鍖诲笀', - jobTitle: '710005' - }, - { - PositionalTitlesName: '鍓富浠诲尰甯�', - jobTitle: '710006' - }, - { - PositionalTitlesName: '楂樼骇缁忔祹甯�', - jobTitle: '710007' - }, - { - PositionalTitlesName: '缁忔祹甯�', - jobTitle: '710008' - }, - { - PositionalTitlesName: '楂樼骇鏀垮伐甯�', - jobTitle: '710009' - }, - { - PositionalTitlesName: '闄㈠+', - jobTitle: '710010' - }, - { - PositionalTitlesName: '鏀垮伐甯�', - jobTitle: '710011' - } -] - -// 瀛﹀巻 -export const DICT_EDUCATION = [ - { - educationName: '鍒濅腑', - education: '660001' - }, - { - educationName: '楂樹腑', - education: '660002' - }, - { - educationName: '澶т笓', - education: '660003' - }, - { - educationName: '澶ф湰', - education: '660004' - }, - { - educationName: '纭曞+鐮旂┒鐢�', - education: '660005' - }, - { - educationName: '鍗氬+鐮旂┒鐢�', - education: '660006' - }, - { - educationName: '鍏朵粬', - education: '660007' - } -] - -// 鎬у埆 -export const DICT_USER_SEX = [ - { - value: '110011', - label: '鐢�' - }, - { - value: '110012', - label: '濂�' - } -] - -// 杞︾墝棰滆壊 -export const DICT_VEHICLE_COLOR = [ - { - vehicleColorName: '钃濊壊', - vehicleColor: '750001' - }, - { - vehicleColorName: '榛勮壊', - vehicleColor: '750002' - }, - { - vehicleColorName: '缁胯壊', - vehicleColor: '750003' - } -] - -// 涓氬姟绫诲瀷 -export const DICT_SERVICE_TYPE = [ - { - value: '1', - label: '鍗卞寲鍝�' - }, - { - value: '2', - label: '鍗卞簾' - } -] - -// 杞﹁締绫诲瀷 -export const DICT_VEHILCE_TYPE = [ - { - value: '730001', - label: '绛剧害杞﹁締' - }, - { - value: '730002', - label: '鑷湁杞﹁締' - } -] - -// 鍩硅缁撴灉 -export const DICT_TRAIN_RESULT = [ - { - value: '110011', - label: '鍚堟牸' - }, - { - value: '110012', - label: '涓嶅悎鏍�' - } -] - -// 杩愯緭绫诲瀷 -export const DICT_TRANSFER_TYPE = [ - { - transferTypeName: '鍐呴儴杞Щ', - transferType: '780001' - }, - { - transferTypeName: '澶栭儴閰嶉��', - transferType: '780002' - } -] - -// 杩愯緭鏂瑰紡(杩愬崟绠$悊) -export const DICT_TRANS_MODE = [ - { - transModeName: '鍏矾', - transMode: 'RD' - }, - { - transModeName: '姘磋矾 ', - transMode: 'RL' - } -] - -// 鍖呰鏂瑰紡 -export const DICT_PACKAGE_TYPE = [ - { - value: '820001', - label: '妗惰' - }, - { - value: '820002', - label: '鍌ㄧ綈' - } -] - -// 琛ㄨ褰㈡�� -export const DICT_APPARENT_TYPE = [ - { - apparentTypeName: '鍥烘��', - apparentType: '810001' - }, - { - apparentTypeName: '娑叉��', - apparentType: '810002' - }, - { - apparentTypeName: '鍗婂浐鎬�', - apparentType: '810003' - }, - { - apparentTypeName: '姘旀��', - apparentType: '810004' - } -] - -// 杩愬崟绠$悊杩愬崟鐘舵�� -export const DICT_ORDER_STATE = [ - { - orderStateName: '寰呭彂杩�', - orderState: '2' - }, - { - orderStateName: '杩愯緭涓�', - orderState: '3' - }, - { - orderStateName: '宸插畬鎴�', - orderState: '7' - }, - { - orderStateName: '宸蹭綔搴�', - orderState: '4' - } -] - -// 杩愬崟鏁版嵁鏉ユ簮 -export const DICT_ORDER_SOURCE = [ - { - dictionaryName: '鑷缓', - dictionaryCode: 'ZJXT' - }, - { - dictionaryName: '鐐奸攢绯荤粺', - dictionaryCode: 'LXXT' - }, - { - dictionaryName: '鍖栭攢绯荤粺', - dictionaryCode: 'HXXT' - }, - { - dictionaryName: '鎴愬搧娌圭郴缁�', - dictionaryCode: 'CPYXT' - } -] - -// 鐭冲寲鍐呭 -export const DICT_PETRIFACTION = [ - { - dictionaryName: '鐭冲寲鍐�', - dictionaryCode: 'A' - }, - { - dictionaryName: '鐭冲寲澶�', - dictionaryCode: 'B' - } -] - -// 杩愯緭鏂瑰紡(杩愬崟鍒楄〃) -export const DICT_WAYBILL_LIST = [ - { - transModeName: '鍏矾', - transMode: 'RD' - }, - { - transModeName: '姘磋矾 ', - transMode: 'RL' - }, - { - transModeName: '閾佽矾 ', - transMode: 'WT' - } -] diff --git a/src/utils/navigation.js b/src/utils/navigation.js deleted file mode 100644 index be520db..0000000 --- a/src/utils/navigation.js +++ /dev/null @@ -1,324 +0,0 @@ -import Cookies from 'js-cookie' -import { hasOneOf, objEqual, _ } from '@/utils/tools' -const appConfig = require('@/app.config') -const { title, cookieExpires, useI18n } = appConfig - -export const TOKEN_KEY = 'token' -export const ACCOUNT_KEY = 'account' -export const setToken = (token) => { - Cookies.set(TOKEN_KEY, token, { expires: cookieExpires || 1 }) -} - -export const getToken = () => { - const token = Cookies.get(TOKEN_KEY) - if (token) return token - else return false -} - -export const setAccount = (account) => { - Cookies.set(ACCOUNT_KEY, account, { expires: cookieExpires || 1 }) -} - -export const getAccount = () => { - const account = Cookies.get(ACCOUNT_KEY) - if (account) return account - else return false -} - -export const hasChild = (item) => { - return item.children && item.children.length !== 0 -} - -/** - * @param {Array} routeMetched 褰撳墠璺敱metched - * @returns {Array} - */ -export const getBreadCrumbList = (route, homeRoute) => { - let homeItem = { ...homeRoute, icon: homeRoute.meta.icon } - let routeMetched = route.matched - if (routeMetched.some(item => item.name === homeRoute.name)) return [homeItem] - let res = routeMetched.filter(item => { - return item.meta === undefined || !item.meta.hideInBread - }).map(item => { - let meta = { ...item.meta } - if (meta.title && typeof meta.title === 'function') { - meta.__titleIsFunction__ = true - meta.title = meta.title(route) - } - let obj = { - icon: (item.meta && item.meta.icon) || '', - name: item.name, - meta: meta - } - return obj - }) - res = res.filter(item => { - return !item.meta.hideInMenu - }) - return [{ ...homeItem, to: homeRoute.path }, ...res] -} - -export const getRouteTitleHandled = (route) => { - let router = { ...route } - let meta = { ...route.meta } - let title = '' - if (meta.title) { - if (typeof meta.title === 'function') { - meta.__titleIsFunction__ = true - title = meta.title(router) - } else title = meta.title - } - meta.title = title - router.meta = meta - return router -} - -export const showTitle = (item, vm) => { - let { title, __titleIsFunction__ } = item.meta - if (!title) return - if (useI18n) { - if (title.includes('{{') && title.includes('}}') && useI18n) title = title.replace(/({{[\s\S]+?}})/, (m, str) => str.replace(/{{([\s\S]*)}}/, (m, _) => vm.$t(_.trim()))) - else if (__titleIsFunction__) title = item.meta.title - else title = vm.$t(item.name) - } else title = (item.meta && item.meta.title) || item.name - return title -} - -/** - * @description 鏈湴瀛樺偍鍜岃幏鍙栨爣绛惧鑸垪琛� - */ -export const setTagNavListToLocalstorage = list => { - localStorage.tagNaveList = JSON.stringify(list) -} - -/** - * @returns {Array} 鍏朵腑鐨勬瘡涓厓绱犲彧鍖呭惈璺敱鍘熶俊鎭腑鐨刵ame, path, meta涓夐」 - */ -export const getTagNavListFromLocalstorage = () => { - const list = localStorage.tagNaveList - return list ? JSON.parse(list) : [] -} - -/** - * @param {Array} routers 璺敱鍒楄〃鏁扮粍 - * @description 鐢ㄤ簬鎵惧埌璺敱鍒楄〃涓璶ame涓篽ome鐨勫璞� - */ -export const getHomeRouter = (routers, homeName = 'Home') => { - let i = -1 - let len = routers.length - let homeRoute = {} - while (++i < len) { - let item = routers[i] - if (item.children && item.children.length) { - let res = getHomeRouter(item.children, homeName) - if (res.name) return res - } else { - if (item.name === homeName) homeRoute = item - } - } - return homeRoute -} - -/** - * @param {*} list 鐜版湁鏍囩瀵艰埅鍒楄〃 - * @param {*} newRoute 鏂版坊鍔犵殑璺敱鍘熶俊鎭璞� - * @description 濡傛灉璇ewRoute宸茬粡瀛樺湪鍒欎笉鍐嶆坊鍔� - */ -export const getNewTagList = (list, newRoute) => { - const { name, path, meta } = newRoute - let newList = [...list] - if (newList.findIndex(item => item.name === name) >= 0) return newList - else newList.push({ name, path, meta }) - return newList -} - -/** - * @param {*} access 鐢ㄦ埛鏉冮檺鏁扮粍锛屽 ['super_admin', 'admin'] - * @param {*} route 璺敱鍒楄〃 - */ -const hasAccess = (access, route) => { - if (route.meta && route.meta.access) return hasOneOf(access, route.meta.access) - else return true -} - -/** - * 鑿滃崟鏉冮壌 - * @param {*} name 鍗冲皢璺宠浆鐨勮矾鐢眓ame - * @param {*} access 鐢ㄦ埛鏉冮檺鏁扮粍 - * @param {*} routes 璺敱鍒楄〃 - * @description 鐢ㄦ埛鏄惁鍙烦杞埌璇ラ〉 - */ -export const canTurnTo = (name, access, routes) => { - const routePermissionJudge = (list) => { - return list.some(item => { - if (item.children && item.children.length) { - return routePermissionJudge(item.children) - } else if (item.name === name) { - return hasAccess(access, item) - } - }) - } - - return routePermissionJudge(routes) -} - -/** - * @param {String} url - * @description 浠嶶RL涓В鏋愬弬鏁� - */ -export const getParams = url => { - const keyValueArr = url.split('?')[1].split('&') - let paramObj = {} - _.forEach(keyValueArr, item => { - const keyValue = item.split('=') - paramObj[keyValue[0]] = keyValue[1] - }) - return paramObj -} - -/** - * @param {Array} list 鏍囩鍒楄〃 - * @param {String} name 褰撳墠鍏抽棴鐨勬爣绛剧殑name - */ -export const getNextRouter = (list, route) => { - let res = {} - if (list.length === 2) { - res = getHomeRouter(list) - } else { - const index = list.findIndex(item => routeEqual(item, route)) - if (index === list.length - 1) res = list[list.length - 2] - else res = list[index + 1] - } - return res -} - -/** - * @param {Number} times 鍥炶皟鍑芥暟闇�瑕佹墽琛岀殑娆℃暟 - * @param {Function} callback 鍥炶皟鍑芥暟 - */ -export const doCustomTimes = (times, callback) => { - let i = -1 - while (++i < times) { - callback(i) - } -} - -export const findNodeUpper = (ele, tag) => { - if (ele.parentNode) { - if (ele.parentNode.tagName === tag.toUpperCase()) { - return ele.parentNode - } else { - return findNodeUpper(ele.parentNode, tag) - } - } -} - -export const findNodeUpperByClasses = (ele, classes) => { - let parentNode = ele.parentNode - if (parentNode) { - let classList = parentNode.classList - if (classList && classes.every(className => classList.contains(className))) { - return parentNode - } else { - return findNodeUpperByClasses(parentNode, classes) - } - } -} - -export const findNodeDownward = (ele, tag) => { - const tagName = tag.toUpperCase() - if (ele.childNodes.length) { - let i = -1 - let len = ele.childNodes.length - while (++i < len) { - let child = ele.childNodes[i] - if (child.tagName === tagName) return child - else return findNodeDownward(child, tag) - } - } -} - -export const showByAccess = (access, canViewAccess) => { - return hasOneOf(canViewAccess, access) -} - -/** - * @description 鏍规嵁name/params/query鍒ゆ柇涓や釜璺敱瀵硅薄鏄惁鐩哥瓑 - * @param {*} route1 璺敱瀵硅薄 - * @param {*} route2 璺敱瀵硅薄 - */ -export const routeEqual = (route1, route2) => { - const params1 = route1.params || {} - const params2 = route2.params || {} - const query1 = route1.query || {} - const query2 = route2.query || {} - return (route1.name === route2.name) && objEqual(params1, params2) && objEqual(query1, query2) -} - -/** - * 鍒ゆ柇鎵撳紑鐨勬爣绛惧垪琛ㄩ噷鏄惁宸插瓨鍦ㄨ繖涓柊娣诲姞鐨勮矾鐢卞璞� - */ -export const routeHasExist = (tagNavList, routeItem) => { - let len = tagNavList.length - let res = false - doCustomTimes(len, (index) => { - if (routeEqual(tagNavList[index], routeItem)) res = true - }) - return res -} - -export const localSave = (key, value) => { - localStorage.setItem(key, value) -} - -export const localRead = (key) => { - return localStorage.getItem(key) || '' -} - -// scrollTop animation -export const scrollTop = (el, from = 0, to, duration = 500, endCallback) => { - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = ( - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60) - } - ) - } - const difference = Math.abs(from - to) - const step = Math.ceil(difference / duration * 50) - - const scroll = (start, end, step) => { - if (start === end) { - endCallback && endCallback() - return - } - - let d = (start + step > end) ? end : start + step - if (start > end) { - d = (start - step < end) ? end : start - step - } - - if (el === window) { - window.scrollTo(d, d) - } else { - el.scrollTop = d - } - window.requestAnimationFrame(() => scroll(d, end, step)) - } - scroll(from, to, step) -} - -/** - * @description 鏍规嵁褰撳墠璺宠浆鐨勮矾鐢辫缃樉绀哄湪娴忚鍣ㄦ爣绛剧殑title - * @param {Object} routeItem 璺敱瀵硅薄 - * @param {Object} vm Vue瀹炰緥 - */ -export const setTitle = (routeItem, vm) => { - const handledRoute = getRouteTitleHandled(routeItem) - const pageTitle = showTitle(handledRoute, vm) - const resTitle = pageTitle ? `${title} - ${pageTitle}` : title - window.document.title = resTitle -} diff --git a/src/utils/tools.js b/src/utils/tools.js deleted file mode 100644 index 45ce110..0000000 --- a/src/utils/tools.js +++ /dev/null @@ -1,1154 +0,0 @@ -/* eslint-disable no-prototype-builtins */ -import { OAUTH_API_GROUP } from '@/utils/authorityAPI' -import * as $CONST from './constant' -import { Message } from 'element-ui' - -export const _ = require('lodash') - -/** - * 闆嗗悎杞崲涓篔SON - * @param obj collection鏁版嵁 - * @author TJ 2019/03/11 - * @example 鐣� - */ -export function collectionToJson(collection) { - if (!_.isArray(collection)) return [] - let arr = [] - // 鏁版嵁浣� - _.forEach(collection, function(item) { - let tempObj = {} - if (item.hasOwnProperty('data') && _.isArray(item.data)) { - _.forEach(item.data, function(obj) { - tempObj[_.trim(obj.name)] = _.trim(obj.value) - }) - } - arr.push(tempObj) - }) - return arr -} - -/** - * collection鏁版嵁杞崲涓烘爣鍑咼SON - * @param obj collection鏁版嵁 - * @author TJ 2019/03/11 - * @example 鐣� - */ -export function transformStandardJson(obj) { - let body = {} - let data = null - let pages = null - let collection = obj.collection - if (_.isObject(collection)) { - // 閿欒鐨勫満鏅� - if (collection.hasOwnProperty('error')) { - return { - code: 300, - body: null, - msg: collection.error - } - } - // 鏁版嵁浣� - if (collection.hasOwnProperty('items') && _.isArray(collection.items)) { - data = collectionToJson(collection.items) - } - // 鍒嗛〉淇℃伅 - if (collection.hasOwnProperty('page') && _.isArray(collection.data)) { - pages = collectionToJson([collection.page]) - } - // 缁勮body鏁版嵁 - body = { - data: data - } - - if (pages) { - _.extend(body, { - total: pages[0].totalElements, - pageIndex: 0, - pageSize: pages[0].size, - pages: pages[0].totalPages - }) - } - - return { - code: 200, - body: body, - msg: '鎿嶄綔鎴愬姛' - } - } -} - -/** - * POST PUT绛夎姹傚弬鏁拌浆鎹㈡垚闆嗗悎 - * @param json object - * @returns collection - * @author TJ 2019/03/11 - * @example 鐣� - */ -export function transformParams(obj) { - let collection = { - version: '1.0', - href: '', - items: [], - templates: [] - } - if (_.isObject(obj)) { - let arr = [] - _.each(obj, function(val, key) { - let newVal = val - if (_.isArray(val)) { - newVal = val.join(',') - } - arr.push({ - name: key, - value: newVal - }) - }) - - let o = { - data: arr - } - collection.templates.push(o) - } - return { - collection: collection - } -} - -/** - * 灏嗗唴瀹瑰瓨鍌ㄥ埌sessionStorage - * @param key {string} key - * @param content {Object} 瀛樺偍json瀵硅薄 - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function setSessionStorage(key, content) { - if (!key) return false - let jsonContent = JSON.stringify(content) - jsonContent ? sessionStorage.setItem(key, jsonContent) : sessionStorage.setItem(key, content) -} - -/** - * 鑾峰彇瀛樺偍鍒皊essionStorage鐨勫唴瀹� - * @param key {string} key - * @return {object} 杩斿洖json瀵硅薄 - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function getSessionStorage(key) { - let item = sessionStorage.getItem(key) - if (!item) return false - let result = JSON.parse(sessionStorage.getItem(key)) - return result ? result : item -} - -/** - * 鍒犻櫎瀛樺偍鍒皊essionStorage鐨勫唴瀹� - * @param key {string} key - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function removeSessionStorage(key) { - sessionStorage.removeItem(key) -} - -/** - * 灏嗗唴瀹瑰瓨鍌ㄥ埌localStorage - * @param key {string} key - * @param content {Object} 瀛樺偍json瀵硅薄 - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function setLocalStorage(key, content) { - if (!key) return false - let jsonContent = JSON.stringify(content) - jsonContent ? localStorage.setItem(key, jsonContent) : localStorage.setItem(key, content) -} - -/** - * 鑾峰彇瀛樺偍鍒發ocalStorage鐨勫唴瀹� - * @param key {string} key - * @return {object} 杩斿洖json瀵硅薄 - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function getLocalStorage(key) { - let item = localStorage.getItem(key) - if (!item) return false - let result = JSON.parse(localStorage.getItem(key)) - return result ? result : item -} - -/** - * localStorage - * @param key {string} key - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function removeLocalStorage(key) { - localStorage.removeItem(key) -} - -/** - * 鍒ゆ柇json瀵硅薄鏄惁涓虹┖瀵硅薄 - * @param obj {object} json瀵硅薄 - * @return {boolean} 绌哄璞¤繑鍥� true 鍚﹀垯杩斿洖 false - * @author TJ 2018/05/28 - * @example 鐣� - */ -export function isEmptyObject(obj) { - if (obj === null) return true - return Object.keys(obj).length === 0 -} - -/** - * 杩囨护鍙傛暟 - * @param params {object} 闇�瑕佹牸寮忓寲鐨勬椂闂� - * @return {object} 鏍煎紡鍖栧悗鐨勬椂闂� - * @author TJ 2017/05/28 - * @example 鐣� - */ -export function filterParams(params) { - if (!_.isObject(params)) { - return params - } - let newParams = {} - _.each(params, function(v, k) { - // 杩囨护鎺夋潯浠舵槸绌虹殑椤� - if (typeof v === 'string' && (v.length === 0 || v === '*鍏�*閮�*')) { - console.log() - } else { - newParams[k] = v - } - }) - return newParams -} - -/** - * 灏唍ull杞崲涓虹┖瀵硅薄 - * @param params {obj} - * @author TJ 2018/05/31 - */ -export function emptyObjectWrapper(obj) { - return obj === null ? {} : obj -} - -/** - * 鏍煎紡鍖栨椂闂� - * @param time {string} 闇�瑕佹牸寮忓寲鐨勬椂闂� - * @param cFormat {string} 鏃堕棿鏍煎紡 - * @return {string} 鏍煎紡鍖栧悗鐨勬椂闂� - * @author TJ 2017/07/21 - * @example 鐣� - */ -export function parseTime(time, cFormat) { - if (!time) return false - if (arguments.length === 0) { - return false - } - const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' - let date - if (typeof time === 'object') { - date = time - } else { - if (('' + time).length === 10) time = parseInt(time) * 1000 - if (('' + time).length === 8 && ('' + time).indexOf('-') === -1 && ('' + time).indexOf('/') === -1) { - time = time.substring(0, 4) + '-' + time.substring(4, 6) + '-' + time.substring(6, 8) - } - - date = new Date(time) - } - const formatObj = { - y: date.getFullYear(), - m: date.getMonth() + 1, - d: date.getDate(), - h: date.getHours(), - i: date.getMinutes(), - s: date.getSeconds(), - a: date.getDay() - } - const timeStr = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { - let value = formatObj[key] - if (key === 'a') return ['涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�', '鏃�'][value - 1] - if (result.length > 0 && value < 10) { - value = '0' + value - } - return value || 0 - }) - return timeStr -} - -/** - * 灏嗘椂闂存暟缁勫垎鍓叉垚寮�濮嬫椂闂村拰缁撴潫鏃堕棿 - * @param time {array} - * @return {object} - * @author TJ 2017/08/01 - * @example 鐣� - */ -export function formatTime(time) { - if (Array.isArray(time)) { - if (!time[0] || !time[1]) return false - var start = parseTime(time[0], '{y}-{m}-{d}') - var end = parseTime(time[1], '{y}-{m}-{d}') - return { - start: start, - end: end - } - } - - return false -} - -/** - * 鍒ゆ柇璇锋眰鐨刟pi鏄惁鏄杩藉姞鏉冮檺鐨� - * @param api {String} - * @return {boolean} - * @author TJ 2017/08/01 - * @example 鐣� - */ -export function isExistOauthApi(api) { - let isExist = false - for (let item of OAUTH_API_GROUP) { - if (api && api.includes(item)) { - isExist = true - break - } - } - return isExist -} - -/** - * 鏉冮檺API鎷兼帴鐢ㄦ埛鍚� - * @param api {String} - * @return {boolean} - * @author TJ 2017/08/01 - * @example 鐣� - */ -export function getJoinOauthApi(url) { - let name = window._loginName ? window._loginName : '' - if (url.includes('?')) { - url += '&createId=' + name - } else { - url += 'createId=' + name - } - return url -} - -/** - * 鎷兼帴鏌ヨURL - * @param url {String} - * @param obj {obj} - * @return {String} - * @author TJ 2017/08/01 - * @example 鐣� - */ -export function joinQueryUrl(url, obj) { - let str = '' - let fullUrl = '' - for (let key in obj) { - if (key) { - if (!obj.hasOwnProperty(key)) return - if (str) { - str += '&' - } - str += key + '=' + obj[key] - } - } - if (url.includes('?')) { - fullUrl = url + '&' + str - } else { - fullUrl = url + '?' + str - } - return fullUrl -} - -/** - * 鍒ゆ柇鍙傛暟鏄惁宓屽叆鍦╱rl涓� - * @param url {String} - * @return {Boolean} - * @author TJ 2018/08/27 - */ -export function isInlineParams(url) { - const splitChar = '{$' - if (url && url.indexOf(splitChar) > -1) { - return true - } else { - return false - } -} - -/** - * 鏇挎崲url閲岀殑鍙傛暟 - * @param url {String} - * @param params {obj} - * @author TJ 2018/05/31 - */ -export function replaceUrlParams(url, params) { - if (url) { - if (!isInlineParams(url)) { - return url - } - // 姝e垯鍖归厤{}锛岀敓鎴愭暟缁� - let patt = /\{.*?\}/g - let arr = url.match(patt) ? url.match(patt) : [] - arr.forEach(function(item) { - let key = item.replace('{', '').replace('}', '').replace('$', '') - url = url.replace(item, params[key]) - }) - } - return url -} - -/** - * 鑾峰彇浼犲叆灏忔椂涔嬪墠鐨勬棩鏈� - * @param pastHour {Number} - * @param format {String} - * @author ZC 2020/11/03 - */ -export function zcGetDate(pastHour, format) { - if (!format) { - format = 'yyyy-MM-dd' - } - // eslint-disable-next-line no-extend-native - Date.prototype.Format = function(fmt) { - let o = { - 'M+': this.getMonth() + 1, // 鏈堜唤 - 'd+': this.getDate(), // 鏃� - 'h+': this.getHours(), // 灏忔椂 - 'm+': this.getMinutes(), // 鍒� - 's+': this.getSeconds(), // 绉� - 'q+': Math.floor((this.getMonth() + 3) / 3), // 瀛e害 - 'S': this.getMilliseconds() // 姣 - } - if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) - for (let k in o) { - // eslint-disable-next-line eqeqeq - if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) - } - return fmt - } - if (pastHour) { - // 鑾峰彇涔嬪墠鐨勬椂闂� - return new Date(new Date().getTime() - pastHour * 60 * 60 * 1000).Format(format) - } else { - return new Date(new Date().getTime()).Format(format) - } -} - -/** - * 鑾峰彇浼犲叆灏忔椂涔嬪墠鐨勬棩鏈� - * @param url {String} - * @author ZC 2020/12/09 - */ -export function zcDownload(url) { - let downloadElement = document.createElement('a') - downloadElement.href = url // 鍒涘缓 - downloadElement.download = '瀵煎嚭.zip' // 涓嬭浇鍚庢枃浠跺悕 - document.body.appendChild(downloadElement) - downloadElement.click() // 鐐瑰嚮涓嬭浇 - document.body.removeChild(downloadElement) // 涓嬭浇瀹屾垚绉婚櫎鍏冪礌 -} - -/** - * 閰嶇疆Echart涓婚棰滆壊 - * @param {obj} echart 瀹炰緥 - * @author TJ 2017/10/17 - * @return 鏃犺繑鍥炵粨鏋� - */ -export function resgisterTheme(echart) { - /* eslint-disable */ - let theme = { - 'color': [ - '#29d0b0', - '#2d99ed', - '#fd8667', - '#72ccff', - '#f7c5a0', - '#d4a4eb', - '#fdc547', - '#76f2f2', - '#da4d00', - '#b0419e' - ], - 'backgroundColor': 'transparents', - 'textStyle': { - 'itemStyle': { - 'normal': { - 'color': '#fff' - } - } - }, - 'title': { - 'textStyle': { - 'color': '#ffffff' - }, - 'subtextStyle': { - 'color': '#dddddd' - } - }, - 'line': { - 'itemStyle': { - 'normal': { - 'borderWidth': '1' - } - }, - 'lineStyle': { - 'normal': { - 'width': '1' - } - }, - 'symbolSize': '4', - 'symbol': 'circle', - 'smooth': false - }, - 'radar': { - 'itemStyle': { - 'normal': { - 'borderWidth': '4' - } - }, - 'lineStyle': { - 'normal': { - 'width': '3' - } - }, - 'symbolSize': '1', - 'symbol': 'circle', - 'smooth': true - }, - 'bar': { - 'itemStyle': { - 'normal': { - 'barBorderWidth': 0, - 'barBorderColor': '#ccc' - }, - 'emphasis': { - 'barBorderWidth': 0, - 'barBorderColor': '#ccc' - } - } - }, - 'pie': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'scatter': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'boxplot': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'parallel': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'sankey': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'funnel': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - }, - 'emphasis': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - } - }, - 'gauge': { - 'itemStyle': { - 'normal': { - 'borderWidth': 1, - 'borderColor': '#fff' - }, - 'emphasis': { - 'borderWidth': 1, - 'borderColor': '#fff' - } - } - }, - 'candlestick': { - 'itemStyle': { - 'normal': { - 'color': '#fc97af', - 'color0': 'transparent', - 'borderColor': '#fc97af', - 'borderColor0': '#87f7cf', - 'borderWidth': '2' - } - } - }, - 'graph': { - 'itemStyle': { - 'normal': { - 'borderWidth': 0, - 'borderColor': '#ccc' - } - }, - 'lineStyle': { - 'normal': { - 'width': '1', - 'color': '#ffffff' - } - }, - 'symbolSize': '5', - 'symbol': 'circle', - 'smooth': true, - 'color': [ - '#29d0b0', - '#2d99ed', - '#fd8667', - '#72ccff', - '#f7c5a0', - '#d4a4eb', - '#fdc547', - '#76f2f2', - '#da4d00', - '#b0419e' - ], - 'label': { - 'normal': { - 'textStyle': { - 'color': '#293441' - } - } - } - }, - 'map': { - 'itemStyle': { - 'normal': { - 'areaColor': '#f3f3f3', - 'borderColor': '#999999', - 'borderWidth': 0.5 - }, - 'emphasis': { - 'areaColor': 'rgba(255,178,72,1)', - 'borderColor': '#eb8146', - 'borderWidth': 1 - } - }, - 'label': { - 'normal': { - 'textStyle': { - 'color': '#893448' - } - }, - 'emphasis': { - 'textStyle': { - 'color': 'rgb(137,52,72)' - } - } - } - }, - 'geo': { - 'itemStyle': { - 'normal': { - 'areaColor': '#f3f3f3', - 'borderColor': '#999999', - 'borderWidth': 0.5 - }, - 'emphasis': { - 'areaColor': 'rgba(255,178,72,1)', - 'borderColor': '#eb8146', - 'borderWidth': 1 - } - }, - 'label': { - 'normal': { - 'textStyle': { - 'color': '#893448' - } - }, - 'emphasis': { - 'textStyle': { - 'color': 'rgb(137,52,72)' - } - } - } - }, - 'categoryAxis': { - 'axisLine': { - 'show': true, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisTick': { - 'show': false, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisLabel': { - 'show': true, - 'textStyle': { - 'color': '#fff' - } - }, - 'splitLine': { - 'show': false, - 'lineStyle': { - 'color': [ - '#e6e6e6' - ] - } - }, - 'splitArea': { - 'show': false, - 'areaStyle': { - 'color': [ - 'rgba(250,250,250,0.05)', - 'rgba(200,200,200,0.02)' - ] - } - } - }, - 'valueAxis': { - 'axisLine': { - 'show': true, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisTick': { - 'show': false, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisLabel': { - 'show': true, - 'textStyle': { - 'color': '#fff' - } - }, - 'splitLine': { - 'show': false, - 'lineStyle': { - 'color': [ - '#e6e6e6' - ] - } - }, - 'splitArea': { - 'show': false, - 'areaStyle': { - 'color': [ - 'rgba(250,250,250,0.05)', - 'rgba(200,200,200,0.02)' - ] - } - } - }, - 'logAxis': { - 'axisLine': { - 'show': true, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisTick': { - 'show': false, - 'lineStyle': { - 'color': '#333' - } - }, - 'axisLabel': { - 'show': true, - 'textStyle': { - 'color': '#fff' - } - }, - 'splitLine': { - 'show': false, - 'lineStyle': { - 'color': [ - '#e6e6e6' - ] - } - }, - 'splitArea': { - 'show': false, - 'areaStyle': { - 'color': [ - 'rgba(250,250,250,0.05)', - 'rgba(200,200,200,0.02)' - ] - } - } - }, - 'timeAxis': { - 'axisLine': { - 'show': true, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisTick': { - 'show': false, - 'lineStyle': { - 'color': '#fff' - } - }, - 'axisLabel': { - 'show': true, - 'textStyle': { - 'color': '#fff' - } - }, - 'splitLine': { - 'show': false, - 'lineStyle': { - 'color': [ - '#fff' - ] - } - }, - 'splitArea': { - 'show': false, - 'areaStyle': { - 'color': [ - 'rgba(250,250,250,0.05)', - 'rgba(200,200,200,0.02)' - ] - } - } - }, - 'toolbox': { - 'iconStyle': { - 'normal': { - 'borderColor': '#999999' - }, - 'emphasis': { - 'borderColor': '#666666' - } - } - }, - 'legend': { - 'textStyle': { - 'color': '#e0e0e0' - } - }, - 'tooltip': { - 'axisPointer': { - 'lineStyle': { - 'color': '#cccccc', - 'width': 1 - }, - 'crossStyle': { - 'color': '#cccccc', - 'width': 1 - } - } - }, - 'timeline': { - 'lineStyle': { - 'color': '#87f7cf', - 'width': 1 - }, - 'itemStyle': { - 'normal': { - 'color': '#87f7cf', - 'borderWidth': 1 - }, - 'emphasis': { - 'color': '#f7f494' - } - }, - 'controlStyle': { - 'normal': { - 'color': '#87f7cf', - 'borderColor': '#87f7cf', - 'borderWidth': 0.5 - }, - 'emphasis': { - 'color': '#87f7cf', - 'borderColor': '#87f7cf', - 'borderWidth': 0.5 - } - }, - 'checkpointStyle': { - 'color': '#fc97af', - 'borderColor': 'rgba(252,151,175,0.3)' - }, - 'label': { - 'normal': { - 'textStyle': { - 'color': '#87f7cf' - } - }, - 'emphasis': { - 'textStyle': { - 'color': '#87f7cf' - } - } - } - }, - 'visualMap': { - 'color': [ - '#fc97af', - '#87f7cf' - ] - }, - 'dataZoom': { - 'backgroundColor': 'rgba(255,255,255,0)', - 'dataBackgroundColor': 'rgba(114,204,255,1)', - 'fillerColor': 'rgba(114,204,255,0.2)', - 'handleColor': '#72ccff', - 'handleSize': '100%', - 'textStyle': { - 'color': '#fff' - } - }, - 'markPoint': { - 'label': { - 'normal': { - 'textStyle': { - 'color': '#293441' - } - }, - 'emphasis': { - 'textStyle': { - 'color': '#293441' - } - } - } - } - } - echart.registerTheme('dark', theme) - /* eslint-enable */ -} - -/** - * 鏍规嵁璺敱鍒囨崲鐨偆鏍囪瘑锛岄粯璁ょ毊鑲ゆ湭钃濊壊 - * @author TJ 2019/05/29 - */ -export function changeThemeClass(toRouterName) { - const darkSkinRouterName = [] - - if (darkSkinRouterName.includes(toRouterName)) { - document.body.className = 'dark' - } else { - document.body.className = 'blue' - } -} - -/** - * 鍒ゆ柇瑕佹煡璇㈢殑鏁扮粍鏄惁鑷冲皯鏈変竴涓厓绱犲寘鍚湪鐩爣鏁扮粍涓� - * @param {Array} target 鐩爣鏁扮粍 - * @param {Array} arr 闇�瑕佹煡璇㈢殑鏁扮粍 - */ -export const hasOneOf = (targetarr, arr) => { - return targetarr.some(_ => arr.indexOf(_) > -1) -} - -/** - * 鍒ゆ柇涓や釜瀵硅薄鏄惁鐩哥瓑锛岃繖涓や釜瀵硅薄鐨勫�煎彧鑳芥槸鏁板瓧鎴栧瓧绗︿覆 - * @param {Object} obj1 瀵硅薄 - * @param {Object} obj2 瀵硅薄 - */ -export const objEqual = (obj1, obj2) => { - const keysArr1 = Object.keys(obj1) - const keysArr2 = Object.keys(obj2) - if (keysArr1.length !== keysArr2.length) return false - else if (keysArr1.length === 0 && keysArr2.length === 0) return true - /* eslint-disable-next-line */ - else return !keysArr1.some(key => obj1[key] != obj2[key]) -} - -/** - * 鍒ゆ柇鍊兼槸鍚︿负鐪�,涓嶅寘鎷0鐨勫垽鏂� - * @param {String} val 瀛楃 - */ -export function isTrue(val) { - return !_.isNull(val) && !_.isUndefined(val) && val !== '' -} - -/** - * 瑙f瀽URL鍙傛暟 - * - * @param {String} url - * @return {object} - */ -export function getQueryObject(url = window.location.href) { - if (!url) return - let search = url.substring(url.lastIndexOf('?') + 1) - let obj = {} - let reg = /([^?&=]+)=([^?&=]*)/g - search.replace(reg, function(rs, $1, $2) { - let name = decodeURIComponent($1) - let val = decodeURIComponent($2) - val = String(val) - obj[name] = val - // return rs - }) - return obj -} - -/** - * 閫掑綊鏌ヨ鏍戣妭鐐� - * - * @param {object} treeData 鏍戠粨鏋勬暟鎹泦鍚� - * @param {string} prop 灞炴�у瓧娈� - * @param {string} propValue 灞炴�у搴旂殑鍊� - * @return {object} 鑺傜偣瀵硅薄 - */ -export function recursion(tree, prop, propValue) { - if (!tree || !Array.isArray(tree)) return false - let result = {} - - function handelTree(tree) { - for (let o of tree) { - if (o.children && Array.isArray(o.children) && o.children.length) { - if (o[prop] !== propValue) { - // 閫掑綊 - handelTree(o.children) - } else { - result = o - break - } - } else { - if (o[prop] === propValue) { - result = o - } - } - } - return result - } - - return handelTree(tree) -} - -export function success(msg = $CONST.MSG_SYS_SUCCESS) { - Message({ - message: msg, - type: 'success' - }) -} - -export function fail(msg = $CONST.MSG_SYS_FAIL) { - Message({ - message: msg, - type: 'error' - }) -} - -export function error(msg = $CONST.MSG_SYS_ERR) { - Message({ - message: msg, - type: 'error' - }) -} - -export function warning(msg = $CONST.MSG_SYS_WARNING) { - Message({ - message: msg, - type: 'warning' - }) -} - -export function info(msg = $CONST.MSG_SYS_CANCELED) { - Message({ - message: msg, - type: 'info' - }) -} - -export function alertError(msg = $CONST.MSG_SYS_ERR, options) { - options = Object.assign({ - dangerouslyUseHTMLString: true, - title: '鎻愮ず', - type: 'error', - 'show-icon': true - }, options) - window.vm.$alert(msg, options) -} - -export function alertWarning(msg = $CONST.MSG_SYS_WARNING, options) { - options = Object.assign({ - dangerouslyUseHTMLString: true, - title: '鎻愮ず', - type: 'warning', - 'show-icon': true - }, options) - window.vm.$alert(msg, options) -} - -export function todo() { - warning('寮�鍙戜腑銆傘�傘��') -} - -/** - * 寮傛鍔犺浇缁勪欢 - * @author TJ 2019/05/30 - */ - -/* eslint-disable */ -export function lazyLoadView(AsyncView) { - const AsyncComponent = () => ({ - // 闇�瑕佸姞杞界殑缁勪欢 (搴旇鏄竴涓� `Promise` 瀵硅薄) - component: AsyncView, - // 寮傛缁勪欢鍔犺浇鏃朵娇鐢ㄧ殑缁勪欢 - loading: '', - // 鍔犺浇澶辫触鏃朵娇鐢ㄧ殑缁勪欢 - error: '', - // 灞曠ず鍔犺浇鏃剁粍浠剁殑寤舵椂鏃堕棿銆傞粯璁ゅ�兼槸 200 (姣) - delay: 200, - // 濡傛灉鎻愪緵浜嗚秴鏃舵椂闂翠笖缁勪欢鍔犺浇涔熻秴鏃朵簡锛� - // 鍒欎娇鐢ㄥ姞杞藉け璐ユ椂浣跨敤鐨勭粍浠躲�傞粯璁ゅ�兼槸锛歚Infinity` - timeout: 3000 - }) - - return Promise.resolve({ - functional: true, - render(h, { data, children }) { - // Transparently pass any props or children - // to the view component. - return h(AsyncComponent, data, children) - } - }) -} diff --git a/src/utils/wfsQueryUtils.js b/src/utils/wfsQueryUtils.js index 7901056..cec720f 100644 --- a/src/utils/wfsQueryUtils.js +++ b/src/utils/wfsQueryUtils.js @@ -9,48 +9,48 @@ * } * @returns {string} */ -function getPropertyNameQueryAndOrWFSUrl(params) { - var url = '' - if ((params.Or === undefined || params.Or.length === 0) && (params.And === undefined || params.And.length === 0) && (params.Not === undefined || params.Not.length === 0)) { - url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000' - } else { - url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000&Filter=<Filter>' - } - if (params.Or != null && params.Or.length !== 0) { - if (params.Or.length === 1) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Or[0].PropertyName + '</PropertyName><Literal>' + params.Or[0].PropertyValue + '</Literal></PropertyIsEqualTo>' - } else { - url += '<OR>' - for (let i = 0; i < params.Or.length; i++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Or[i].PropertyName + '</PropertyName><Literal>' + params.Or[i].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</OR>' - } - } - if (params.And != null && params.And.length !== 0) { - if (params.And.length === 1) { - url += '<PropertyIsEqualTo><PropertyName>' + params.And[0].PropertyName + '</PropertyName><Literal>' + params.And[0].PropertyValue + '</Literal></PropertyIsEqualTo>' - } else { - url += '<AND>' - for (let j = 0; j < params.And.length; j++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.And[j].PropertyName + '</PropertyName><Literal>' + params.And[j].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</AND>' +function getPropertyNameQueryAndOrWFSUrl (params) { + var url = '' + if ((params.Or === undefined || params.Or.length === 0) && (params.And === undefined || params.And.length === 0) && (params.Not === undefined || params.Not.length === 0)) { + url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000' + } else { + url = params.Url + '?VERSION=1.0.0&SERVICE=WFS&REQUEST=getfeature&TYPENAME=' + params.TypeName + '&outputformat=json&maxfeature=20000&Filter=<Filter>' + } + if (params.Or != null && params.Or.length !== 0) { + if (params.Or.length === 1) { + url += '<PropertyIsEqualTo><PropertyName>' + params.Or[0].PropertyName + '</PropertyName><Literal>' + params.Or[0].PropertyValue + '</Literal></PropertyIsEqualTo>' + } else { + url += '<OR>' + for (let i = 0; i < params.Or.length; i++) { + url += '<PropertyIsEqualTo><PropertyName>' + params.Or[i].PropertyName + '</PropertyName><Literal>' + params.Or[i].PropertyValue + '</Literal></PropertyIsEqualTo>' } - } - if (params.Not != null && params.Not.length !== 0) { - url += '<NOT>' - for (let k = 0; k < params.Not.length; k++) { - url += '<PropertyIsEqualTo><PropertyName>' + params.Not[k].PropertyName + '</PropertyName><Literal>' + params.Not[k].PropertyValue + '</Literal></PropertyIsEqualTo>' - } - url += '</NOT>' - } - if ((params.Or !== undefined && params.Or.length !== 0) || (params.And !== undefined && params.And.length !== 0) || (params.Not !== undefined && params.Not.length !== 0)) { - url += '</Filter>' + url += '</OR>' } - return url + } + if (params.And != null && params.And.length !== 0) { + if (params.And.length === 1) { + url += '<PropertyIsEqualTo><PropertyName>' + params.And[0].PropertyName + '</PropertyName><Literal>' + params.And[0].PropertyValue + '</Literal></PropertyIsEqualTo>' + } else { + url += '<AND>' + for (let j = 0; j < params.And.length; j++) { + url += '<PropertyIsEqualTo><PropertyName>' + params.And[j].PropertyName + '</PropertyName><Literal>' + params.And[j].PropertyValue + '</Literal></PropertyIsEqualTo>' + } + url += '</AND>' + } + } + if (params.Not != null && params.Not.length !== 0) { + url += '<NOT>' + for (let k = 0; k < params.Not.length; k++) { + url += '<PropertyIsEqualTo><PropertyName>' + params.Not[k].PropertyName + '</PropertyName><Literal>' + params.Not[k].PropertyValue + '</Literal></PropertyIsEqualTo>' + } + url += '</NOT>' + } + if ((params.Or !== undefined && params.Or.length !== 0) || (params.And !== undefined && params.And.length !== 0) || (params.Not !== undefined && params.Not.length !== 0)) { + url += '</Filter>' + } + return url } export default { - getPropertyNameQueryAndOrWFSUrl + getPropertyNameQueryAndOrWFSUrl } diff --git a/src/views/MapTemplate.vue b/src/views/MapTemplate.vue index 0356636..126b29f 100644 --- a/src/views/MapTemplate.vue +++ b/src/views/MapTemplate.vue @@ -1,13 +1,13 @@ <template> <div class="full-screen"> - <div id="map" ref="rootmap"></div> - <sgis-layer-controller :preset="'warningPreset'"> - <lc-basemap></lc-basemap> - <div class="barline"></div> - <lc-service-layer></lc-service-layer> - </sgis-layer-controller> - <lc-service-layer-filter v-show="showServiceLayerFilter" ref="serviceLayerFilter"></lc-service-layer-filter> - <monitor-panel></monitor-panel> + <div id="map" ref="rootmap"></div> + <sgis-layer-controller :preset="'warningPreset'"> + <lc-basemap></lc-basemap> + <div class="bar-line"></div> + <lc-service-layer></lc-service-layer> + </sgis-layer-controller> + <lc-service-layer-filter v-show="showServiceLayerFilter" ref="serviceLayerFilter"></lc-service-layer-filter> + <monitor-panel></monitor-panel> </div> </template> @@ -24,71 +24,72 @@ export default { name: 'MapTemplate', - components: {SgisLayerController, MonitorPanel, LcBasemap, LcServiceLayer, LcServiceLayerFilter}, - data(){ + components: { SgisLayerController, MonitorPanel, LcBasemap, LcServiceLayer, LcServiceLayerFilter }, + data () { return { basemapHelper: {}, serviceLayerHelper: {}, vectorLayerHelper: {} } }, - computed:{ - showServiceLayerFilter(){ + computed: { + showServiceLayerFilter () { return this.$store.state.map.showServiceLayerFilter }, - mapConfig(){ + mapConfig () { return this.$store.state.map.mapConfig } }, - beforeMount(){ - this.$nextTick(() => { - this.init() - }) + beforeMount () { + this.$nextTick(() => { + this.init() + }) }, - methods:{ - saveMapStatus(){ - this.$store.commit('setMapObj', this.mapObj); - this.$store.commit('setBasemapHelper', this.basemapHelper); - this.$store.commit('setServiceLayerHelper', this.serviceLayerHelper); - this.$store.commit('setVectorLayerHelper', this.vectorLayerHelper); + methods: { + saveMapStatus () { + this.$store.commit('setMapObj', this.mapObj) + this.$store.commit('setBasemapHelper', this.basemapHelper) + this.$store.commit('setServiceLayerHelper', this.serviceLayerHelper) + this.$store.commit('setVectorLayerHelper', this.vectorLayerHelper) }, - init() { - const mapcontainer = this.$refs.rootmap - this.mapObj = Sgis.initMap(mapcontainer) + init () { + const mapcontainer = this.$refs.rootmap + this.mapObj = Sgis.initMap(mapcontainer) - this.basemapHelper = Sgis.initBasemapsHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栧熀纭�搴曞浘鍔╂墜 - this.basemapHelper.initBasemap(this.mapConfig, false) // 绗簩涓弬鏁帮紝琛ㄧず鏄惁鍐呯綉搴曞浘 + this.basemapHelper = Sgis.initBasemapsHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栧熀纭�搴曞浘鍔╂墜 + this.basemapHelper.initBasemap(this.mapConfig, false) // 绗簩涓弬鏁帮紝琛ㄧず鏄惁鍐呯綉搴曞浘 - this.serviceLayerHelper = Sgis.initTileLayersHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栦笟鍔″簳鍥惧姪鎵� - this.serviceLayerHelper.initServiceLayers(this.mapConfig) + this.serviceLayerHelper = Sgis.initTileLayersHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栦笟鍔″簳鍥惧姪鎵� + this.serviceLayerHelper.initServiceLayers(this.mapConfig) - this.vectorLayerHelper = Sgis.initVectorLayersHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栧姩鎬佽绱犲浘灞傚姪鎵� - this.vectorLayerHelper.initVectorLayers(this.mapConfig) + this.vectorLayerHelper = Sgis.initVectorLayersHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栧姩鎬佽绱犲浘灞傚姪鎵� + this.vectorLayerHelper.initVectorLayers(this.mapConfig) - - this.saveMapStatus() - // this.setMapObj(this.mapObj) - // this.setBasemapHelper(this.basemapHelper) - // this.setServiceLayerHelper(this.serviceLayerHelper) - // this.setVectorLayerHelper(this.vectorLayerHelper) - } + this.saveMapStatus() + // this.setMapObj(this.mapObj) + // this.setBasemapHelper(this.basemapHelper) + // this.setServiceLayerHelper(this.serviceLayerHelper) + // this.setVectorLayerHelper(this.vectorLayerHelper) + } } } </script> <style lang="less"> -.full-screen{ - width: 100%; - height: 100%; - margin: 0; - padding: 0; - position: absolute; - #map{ +.full-screen { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + position: absolute; + + #map { height: 100%; width: 100%; } - .barline{ + + .bar-line { width: 100%; height: 1px; background-color: #0661AE; -- Gitblit v1.8.0