diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 213f5e6..5cbe390 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,6 +2,7 @@ const TokenKey = 'token' const PublicKey = 'public_key' +const CurrentSystem = 'current_system' export function getToken() { return Cookies.get(TokenKey) @@ -27,3 +28,23 @@ return window.localStorage.removeItem(PublicKey) } +export function getCurrentSys() { + let currentSystem = window.localStorage.getItem(CurrentSystem) + if (typeof (currentSystem) === 'undefined') { + return undefined + } else { + currentSystem = JSON.parse(currentSystem) + return currentSystem + } +} + +export function setCurrentSys(currentSystem) { + console.log('in auth setCurrentSys') + const currentSys = JSON.stringify(currentSystem) + return window.localStorage.setItem(CurrentSystem, currentSys) +} + +export function removeCurrentSys() { + return window.localStorage.removeItem(CurrentSystem) +} + diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 213f5e6..5cbe390 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,6 +2,7 @@ const TokenKey = 'token' const PublicKey = 'public_key' +const CurrentSystem = 'current_system' export function getToken() { return Cookies.get(TokenKey) @@ -27,3 +28,23 @@ return window.localStorage.removeItem(PublicKey) } +export function getCurrentSys() { + let currentSystem = window.localStorage.getItem(CurrentSystem) + if (typeof (currentSystem) === 'undefined') { + return undefined + } else { + currentSystem = JSON.parse(currentSystem) + return currentSystem + } +} + +export function setCurrentSys(currentSystem) { + console.log('in auth setCurrentSys') + const currentSys = JSON.stringify(currentSystem) + return window.localStorage.setItem(CurrentSystem, currentSys) +} + +export function removeCurrentSys() { + return window.localStorage.removeItem(CurrentSystem) +} + diff --git a/src/views/overview/components/layerChoose.vue b/src/views/overview/components/layerChoose.vue new file mode 100644 index 0000000..486d65a --- /dev/null +++ b/src/views/overview/components/layerChoose.vue @@ -0,0 +1,106 @@ + + + + + + diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 213f5e6..5cbe390 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,6 +2,7 @@ const TokenKey = 'token' const PublicKey = 'public_key' +const CurrentSystem = 'current_system' export function getToken() { return Cookies.get(TokenKey) @@ -27,3 +28,23 @@ return window.localStorage.removeItem(PublicKey) } +export function getCurrentSys() { + let currentSystem = window.localStorage.getItem(CurrentSystem) + if (typeof (currentSystem) === 'undefined') { + return undefined + } else { + currentSystem = JSON.parse(currentSystem) + return currentSystem + } +} + +export function setCurrentSys(currentSystem) { + console.log('in auth setCurrentSys') + const currentSys = JSON.stringify(currentSystem) + return window.localStorage.setItem(CurrentSystem, currentSys) +} + +export function removeCurrentSys() { + return window.localStorage.removeItem(CurrentSystem) +} + diff --git a/src/views/overview/components/layerChoose.vue b/src/views/overview/components/layerChoose.vue new file mode 100644 index 0000000..486d65a --- /dev/null +++ b/src/views/overview/components/layerChoose.vue @@ -0,0 +1,106 @@ + + + + + + diff --git a/src/views/overview/components/searchItem.vue b/src/views/overview/components/searchItem.vue new file mode 100644 index 0000000..d1b804a --- /dev/null +++ b/src/views/overview/components/searchItem.vue @@ -0,0 +1,90 @@ + + + + + + diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 213f5e6..5cbe390 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,6 +2,7 @@ const TokenKey = 'token' const PublicKey = 'public_key' +const CurrentSystem = 'current_system' export function getToken() { return Cookies.get(TokenKey) @@ -27,3 +28,23 @@ return window.localStorage.removeItem(PublicKey) } +export function getCurrentSys() { + let currentSystem = window.localStorage.getItem(CurrentSystem) + if (typeof (currentSystem) === 'undefined') { + return undefined + } else { + currentSystem = JSON.parse(currentSystem) + return currentSystem + } +} + +export function setCurrentSys(currentSystem) { + console.log('in auth setCurrentSys') + const currentSys = JSON.stringify(currentSystem) + return window.localStorage.setItem(CurrentSystem, currentSys) +} + +export function removeCurrentSys() { + return window.localStorage.removeItem(CurrentSystem) +} + diff --git a/src/views/overview/components/layerChoose.vue b/src/views/overview/components/layerChoose.vue new file mode 100644 index 0000000..486d65a --- /dev/null +++ b/src/views/overview/components/layerChoose.vue @@ -0,0 +1,106 @@ + + + + + + diff --git a/src/views/overview/components/searchItem.vue b/src/views/overview/components/searchItem.vue new file mode 100644 index 0000000..d1b804a --- /dev/null +++ b/src/views/overview/components/searchItem.vue @@ -0,0 +1,90 @@ + + + + + + diff --git a/src/views/overview/components/searchList.vue b/src/views/overview/components/searchList.vue new file mode 100644 index 0000000..62cb72b --- /dev/null +++ b/src/views/overview/components/searchList.vue @@ -0,0 +1,135 @@ + + + + + + diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index b515f61..4ed6b5f 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,8 @@ if (icon) { vnodes.push() + } else { + vnodes.push() } if (title) { diff --git a/src/permission.js b/src/permission.js index 5965c45..b702a95 100644 --- a/src/permission.js +++ b/src/permission.js @@ -40,8 +40,11 @@ // 远程访问获取权限列表(菜单&按钮) store.dispatch('GetMenus', currentSys).then(() => { store.commit('SET_CHANGEFLAG', '0') - router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + // 获取所有地址列表 + store.dispatch('GetUrls').then(() => { + router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record + }) }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { diff --git a/src/store/getters.js b/src/store/getters.js index 80b80fb..526de90 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -22,6 +22,12 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + urls: state => state.map.urls, // 地图服务地址列表 + baseUrl: state => state.map.baseUrl, // 地图服务地址 + partsUrl: state => state.map.partsUrl, // 部件分层地址 + partsAllUrl: state => state.map.partsAllUrl, // 部件不分层地址 + mapUrl: state => state.map.mapUrl, // 底图地址 + editUrl: state => state.map.editUrl // 编辑地图地址 } export default getters diff --git a/src/store/modules/app.js b/src/store/modules/app.js index f65d58f..073c22b 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,6 +1,7 @@ import Cookies from 'js-cookie' import { getConfig } from '@/api/login' import { getPublicKey, setPublicKey } from '../../utils/auth' +import { getCurrentSys, setCurrentSys } from '@/utils/auth' const state = { sidebar: { @@ -10,7 +11,9 @@ device: 'desktop', kaptcha: '', // 验证码 publicKey: getPublicKey(), // 公钥 - sid: '' // sid + sid: '', // sid + currentSystem: getCurrentSys(), // 当前子系统 + changeFlag: '0' // 更换子系统标志,1为更换 0为未更换 } const mutations = { TOGGLE_SIDEBAR: state => { @@ -35,6 +38,13 @@ state.publicKey = config.publicKey state.sid = config.sid setPublicKey(config.publicKey) + }, + SET_SYSTEM: (state, system) => { + state.currentSystem = system + setCurrentSys(system) + }, + SET_CHANGEFLAG: (state, changeFlag) => { + state.changeFlag = changeFlag } } diff --git a/src/store/modules/map.js b/src/store/modules/map.js new file mode 100644 index 0000000..49e6167 --- /dev/null +++ b/src/store/modules/map.js @@ -0,0 +1,72 @@ +import { getServerList } from '@/api/server' + +const state = { + urls: '', // 所有图层信息 + baseUrl: '', // 服务基础地址 + partsUrl: '', // 部件分层地址 + partsAllUrl: '', // 部件不分层地址 + mapUrl: '', // 二维底图地址 + editUrl: '' // 编辑地图URL +} +const mutations = { + SET_URLS: (state, urls) => { + state.urls = JSON.stringify(urls) + }, + SET_BASE_URL: (state, url) => { + state.baseUrl = url + }, + SET_PARTS_URL: (state, url) => { + state.partsUrl = url + }, + SET_PARTS_ALL_URL: (state, url) => { + state.partsAllUrl = url + }, + SET_MAP_URL: (state, url) => { + state.mapUrl = url + }, + SET_EDIT_URL: (state, url) => { + state.editUrl = url + } +} + +const actions = { + // 获取地图图层,并存在cookie中,避免重复取数据耗费时间 + GetUrls({ commit }) { + return new Promise((resolve, reject) => { + const listQuery = { offset: 1, limit: 100 } + getServerList(listQuery).then(response => { + if (response.code === 200) { + const data = response.data.rows + commit('SET_URLS', data) + const urls = data + // 遍历所以有地址获取 + for (const item of urls) { + if (item.name === 'GIS地图') { + commit('SET_BASE_URL', item.url) + } else if (item.name === '部件分层URL') { + commit('SET_PARTS_URL', item.url) + } else if (item.name === '部件地图URL') { + commit('SET_PARTS_ALL_URL', item.url) + } else if (item.name === '二维地图URL') { + commit('SET_MAP_URL', item.url) + } else if (item.name === '编辑地图URL') { + commit('SET_EDIT_URL', item.url) + } + } + resolve() + } else { + reject(response) + } + }).catch(error => { + reject(error) + }) + }) + } +} + +export default { + namespace: true, + state, + mutations, + actions +} diff --git a/src/utils/auth.js b/src/utils/auth.js index 213f5e6..5cbe390 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -2,6 +2,7 @@ const TokenKey = 'token' const PublicKey = 'public_key' +const CurrentSystem = 'current_system' export function getToken() { return Cookies.get(TokenKey) @@ -27,3 +28,23 @@ return window.localStorage.removeItem(PublicKey) } +export function getCurrentSys() { + let currentSystem = window.localStorage.getItem(CurrentSystem) + if (typeof (currentSystem) === 'undefined') { + return undefined + } else { + currentSystem = JSON.parse(currentSystem) + return currentSystem + } +} + +export function setCurrentSys(currentSystem) { + console.log('in auth setCurrentSys') + const currentSys = JSON.stringify(currentSystem) + return window.localStorage.setItem(CurrentSystem, currentSys) +} + +export function removeCurrentSys() { + return window.localStorage.removeItem(CurrentSystem) +} + diff --git a/src/views/overview/components/layerChoose.vue b/src/views/overview/components/layerChoose.vue new file mode 100644 index 0000000..486d65a --- /dev/null +++ b/src/views/overview/components/layerChoose.vue @@ -0,0 +1,106 @@ + + + + + + diff --git a/src/views/overview/components/searchItem.vue b/src/views/overview/components/searchItem.vue new file mode 100644 index 0000000..d1b804a --- /dev/null +++ b/src/views/overview/components/searchItem.vue @@ -0,0 +1,90 @@ + + + + + + diff --git a/src/views/overview/components/searchList.vue b/src/views/overview/components/searchList.vue new file mode 100644 index 0000000..62cb72b --- /dev/null +++ b/src/views/overview/components/searchList.vue @@ -0,0 +1,135 @@ + + + + + + diff --git a/static/project.config.json b/static/project.config.json index 8d25c63..a2cede2 100644 --- a/static/project.config.json +++ b/static/project.config.json @@ -6,6 +6,6 @@ "city":"崇仁县", "mapUrl":"https://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=216ee92889e17ab1b083fae665d522b8", "labelUrl":"https://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=216ee92889e17ab1b083fae665d522b8", - "center":[27.75962, 116.06021], - "zoom":13 + "center":[27.755, 116.08], + "zoom":15 }