diff --git a/src/components/MapBox.vue b/src/components/MapBox.vue index 791fd19..38d5cdc 100644 --- a/src/components/MapBox.vue +++ b/src/components/MapBox.vue @@ -123,7 +123,9 @@ export default { }, async mounted () { // 等待 异步 加载 后端地图源 地址 - await this.$store.dispatch('fetchMapStyleList', this.$store.state.settings.host) + if (this.$store.state.mapStyleList.length === 0) { + await this.$store.dispatch('fetchMapStyleList', this.$store.state.settings.host) + } // 等待 异步 地图初始化 await this.init() diff --git a/src/router/index.js b/src/router/index.js index 8e5a81e..f5edccd 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -16,6 +16,51 @@ const routes = [ hidden: true } }, + { + path: '/mapstyle', + component: Layout, + redirect: '/mapstyle/index', + meta: { + title: '地图类型', + icon: 'el-icon-map-location', + roles: ['master'], + hidden: true + }, + children: [ + { + path: '/mapstyle/index', + component: () => import('@/views/layout/components/main/mapstyle/index'), + meta: { + title: '地图列表', + icon: 'el-icon-tickets', + roles: ['master'], + hidden: true + } + }, + { + path: '/mapstyle/add', + component: () => import('@/views/layout/components/main/mapstyle/add'), + meta: { + title: '地图添加', + icon: 'el-icon-plus', + roles: ['master'], + tapName: 'plane', + hidden: true + } + }, + { + path: '/mapstyle/edit/:id', + component: () => import('@/views/layout/components/main/mapstyle/add'), + meta: { + title: '地图更新', + icon: 'el-icon-edit', + roles: ['master'], + tapName: 'plane', + hidden: true + } + } + ] + }, { path: '/home', component: Layout, diff --git a/src/store/index.js b/src/store/index.js index 7eea0c6..89cd1b1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1217,6 +1217,11 @@ const store = new Vuex.Store({ const sourceKey = style.source_key || 'default' return { + // 附带原始字段,便于管理端展示和操作 + id: style.id, + is_active: Number(style.is_active ?? 1), + sort_order: Number(style.sort_order ?? 0), + source_key: sourceKey, name: style.name, sprite: `${host}/Public/map/sprite`, glyphs: 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf', @@ -1241,6 +1246,23 @@ const store = new Vuex.Store({ commit('setMapStyleList', []) Message.error(res.data.msg || '地图样式获取失败') } + }, + /** + * @description: 地图样式排序 + * @param {*} form { id, sort_order } + */ + async fetchOrderMapStyle ({ dispatch }, form) { + const params = new URLSearchParams() + params.append('id', form.id) + params.append('sort_order', form.sort_order) + const res = await api.post('orderMapStyle', params, 'Plane') + if (res.data.status === 1) { + await dispatch('fetchMapStyleList') // 刷新样式列表 + Message.success(res.data.msg || '排序已更新') + } else { + Message.error(res.data.msg || '排序更新失败') + } + return res } }, modules: { diff --git a/src/styles/index.scss b/src/styles/index.scss index 6189df9..10986d1 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -137,6 +137,10 @@ label { color: #606266 !important; } +.el-form-item__content { + padding-left: 25px !important; +} + /* 当屏幕宽度小于等于480px时 */ @media (max-width: 480px) { .el-dialog { diff --git a/src/views/layout/components/main/home/set.vue b/src/views/layout/components/main/home/set.vue index 2f8b206..e1dbfde 100644 --- a/src/views/layout/components/main/home/set.vue +++ b/src/views/layout/components/main/home/set.vue @@ -40,6 +40,16 @@ + +