shuishen
2023-07-12 e99fe0d12125c0c5dd80d90b445b308c13ecaec2
运维管理按钮显示权限,电子沙盘权限调整
9 files modified
423 ■■■■ changed files
src/api/user/index.js 41 ●●●●● patch | view | raw | blame | history
src/store/getters.js 4 ●●● patch | view | raw | blame | history
src/store/modules/user.js 266 ●●●●● patch | view | raw | blame | history
src/views/activity/components/polygonPlot.vue 4 ●●●● patch | view | raw | blame | history
src/views/activity/components/publicIndex.vue 7 ●●●● patch | view | raw | blame | history
src/views/activity/index.vue 10 ●●●● patch | view | raw | blame | history
src/views/home/index.vue 56 ●●●● patch | view | raw | blame | history
src/views/layout/index.vue 16 ●●●● patch | view | raw | blame | history
src/views/login/index.vue 19 ●●●●● patch | view | raw | blame | history
src/api/user/index.js
@@ -2,26 +2,33 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-02-20 14:16:37
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-02-20 14:23:06
 * @LastEditTime: 2023-07-12 09:23:27
 * @FilePath: \srs-police-affairs\src\api\user\index.js
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import request from "@/router/axios.js"
import request from "@/router/axios.js";
export const refreshToken = (refresh_token, tenantId) => request({
    url: '/api/blade-auth/oauth/token',
    method: 'post',
export const refreshToken = (refresh_token, tenantId) =>
  request({
    url: "/api/blade-auth/oauth/token",
    method: "post",
    headers: {
        'Tenant-Id': tenantId,
        'Dept-Id': '',
        'Role-Id': ''
      "Tenant-Id": tenantId,
      "Dept-Id": "",
      "Role-Id": "",
    },
    params: {
        tenantId,
        refresh_token,
        grant_type: "refresh_token",
        scope: "all",
    }
})
      tenantId,
      refresh_token,
      grant_type: "refresh_token",
      scope: "all",
    },
  });
export const getButtons = () =>
  request({
    url: "/api/blade-system/menu/buttons",
    method: "get",
  });
src/store/getters.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-02 16:36:47
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-04-04 10:54:12
 * @LastEditTime: 2023-07-12 09:58:42
 * @FilePath: \srs-police-affairs\src\store\getters.js
 * @Description: 
 * 
@@ -27,6 +27,8 @@
    videoRowClickPopupData: (state) => state.popupParams.videoRowClickPopupData,
    isShowHomeContent: (state) => state.popupParams.isShowHomeContent,
    isShowHomeContentBtn: (state) => state.popupParams.isShowHomeContentBtn,
    permission: state => state.user.permission,
}
export default getters
src/store/modules/user.js
@@ -2,125 +2,167 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-12-27 09:33:01
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-06-07 09:40:52
 * @LastEditTime: 2023-07-12 09:40:00
 * @FilePath: \srs-police-affairs\src\store\modules\user.js
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { loginByUsername, logout } from "@/api/login/login"
import { Message } from 'element-ui'
import md5 from "js-md5"
import * as auth from '@/utils/auth'
import { setStore, getStore } from '@/utils/store'
import { refreshToken } from '@/api/user'
import { validatenull } from '@/utils/validate'
import { loginByUsername, logout } from "@/api/login/login";
import { Message } from "element-ui";
import md5 from "js-md5";
import * as auth from "@/utils/auth";
import { setStore, getStore } from "@/utils/store";
import { refreshToken, getButtons } from "@/api/user";
import { validatenull } from "@/utils/validate";
const user = {
    state: {
        tenantId: getStore({ name: 'tenantId' }) || '',
        userInfo: getStore({ name: 'userInfo' }) || [],
        token: getStore({ name: 'token' }) || '',
        refreshToken: getStore({ name: 'refreshToken' }) || '',
  state: {
    tenantId: getStore({ name: "tenantId" }) || "",
    userInfo: getStore({ name: "userInfo" }) || [],
    permission: getStore({ name: 'permission' }) || {},
    token: getStore({ name: "token" }) || "",
    refreshToken: getStore({ name: "refreshToken" }) || "",
  },
  actions: {
    //根据用户名登录
    LoginByUsername({ commit }, loginForm) {
      return new Promise((resolve, reject) => {
        loginByUsername(
          loginForm.tenantId,
          loginForm.username,
          md5(loginForm.password),
          loginForm.type,
          loginForm.key,
          loginForm.code
        )
          .then((res) => {
            const data = res.data;
            if (res.status != 200) {
              Message({
                message: "系统异常,请联系管理员",
                type: "error",
              });
              reject(res);
            } else {
              if (data.error_description) {
                Message({
                  message: data.error_description,
                  type: "error",
                });
                reject(res);
              } else {
                commit("SET_TOKEN", data.access_token);
                commit("SET_USER_INFO", data);
                commit("SET_REFRESH_TOKEN", data.refresh_token);
                commit("SET_TENANT_ID", data.tenant_id);
                resolve();
              }
            }
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
    actions: {
        //根据用户名登录
        LoginByUsername ({ commit }, loginForm) {
            return new Promise((resolve, reject) => {
                loginByUsername(
                    loginForm.tenantId,
                    loginForm.username,
                    md5(loginForm.password),
                    loginForm.type,
                    loginForm.key,
                    loginForm.code
                )
                    .then((res) => {
                        const data = res.data
                        if (res.status != 200) {
                            Message({
                                message: '系统异常,请联系管理员',
                                type: "error",
                            })
                            reject(res)
                        }
                        else {
                            if (data.error_description) {
                                Message({
                                    message: data.error_description,
                                    type: "error",
                                })
                                reject(res)
                            } else {
                                commit("SET_TOKEN", data.access_token)
                                commit('SET_USER_INFO', data)
                                commit('SET_REFRESH_TOKEN', data.refresh_token)
                                commit('SET_TENANT_ID', data.tenant_id)
                                resolve()
                            }
                        }
                    })
                    .catch((error) => {
                        reject(error)
                    })
            })
        },
        //登出
        LogOut ({ commit }) {
            return new Promise((resolve, reject) => {
                logout().then(() => {
                    commit('SET_TOKEN', '')
                    auth.removeToken()
                    auth.removeUserInfo()
                    auth.removeRefreshToken()
                    resolve()
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //刷新token
        refreshToken ({ state, commit }, userInfo) {
            return new Promise((resolve, reject) => {
                refreshToken(state.refreshToken, state.tenantId,
                    !validatenull(userInfo) ? userInfo.deptId : state.userInfo.dept_id,
                    !validatenull(userInfo) ? userInfo.roleId : state.userInfo.role_id
                ).then(res => {
                    const data = res.data
                    commit('SET_TOKEN', data.access_token)
                    commit('SET_REFRESH_TOKEN', data.refresh_token)
                    commit('SET_USER_INFO', data)
                    resolve()
                }).catch(error => {
                    reject(error)
                })
            })
        },
    //登出
    LogOut({ commit }) {
      return new Promise((resolve, reject) => {
        logout()
          .then(() => {
            commit("SET_TOKEN", "");
            auth.removeToken();
            auth.removeUserInfo();
            auth.removeRefreshToken();
            resolve();
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
    mutations: {
        SET_TOKEN: (state, token) => {
            auth.setToken(token)
            state.token = token
            setStore({ name: 'store-token', content: state.token })
        },
        SET_USER_INFO: (state, userInfo) => {
            state.userInfo = userInfo
            auth.setUserInfo(state.userInfo)
            setStore({ name: 'userInfo', content: state.userInfo })
        },
    //刷新token
    refreshToken({ state, commit }, userInfo) {
      return new Promise((resolve, reject) => {
        refreshToken(
          state.refreshToken,
          state.tenantId,
          !validatenull(userInfo) ? userInfo.deptId : state.userInfo.dept_id,
          !validatenull(userInfo) ? userInfo.roleId : state.userInfo.role_id
        )
          .then((res) => {
            const data = res.data;
            commit("SET_TOKEN", data.access_token);
            commit("SET_REFRESH_TOKEN", data.refresh_token);
            commit("SET_USER_INFO", data);
            resolve();
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
        SET_REFRESH_TOKEN: (state, refreshToken) => {
            auth.setRefreshToken(refreshToken)
            state.refreshToken = refreshToken
            setStore({ name: 'refreshToken', content: state.refreshToken })
        },
    //获取系统按钮
    GetButtons({ commit }) {
      return new Promise((resolve) => {
        getButtons().then((res) => {
          const data = res.data.data;
          commit("SET_PERMISSION", data);
          resolve();
        });
      });
    },
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      auth.setToken(token);
      state.token = token;
      setStore({ name: "store-token", content: state.token });
    },
    SET_USER_INFO: (state, userInfo) => {
      state.userInfo = userInfo;
      auth.setUserInfo(state.userInfo);
      setStore({ name: "userInfo", content: state.userInfo });
    },
        SET_TENANT_ID: (state, tenantId) => {
            state.tenantId = tenantId
            setStore({ name: 'tenantId', content: state.tenantId })
        },
    }
}
    SET_REFRESH_TOKEN: (state, refreshToken) => {
      auth.setRefreshToken(refreshToken);
      state.refreshToken = refreshToken;
      setStore({ name: "refreshToken", content: state.refreshToken });
    },
export default user
    SET_TENANT_ID: (state, tenantId) => {
      state.tenantId = tenantId;
      setStore({ name: "tenantId", content: state.tenantId });
    },
    SET_PERMISSION: (state, permission) => {
      let result = [];
      function getCode(list) {
        list.forEach((ele) => {
          if (typeof ele === "object") {
            const chiildren = ele.children;
            const code = ele.code;
            if (chiildren) {
              getCode(chiildren);
            } else {
              result.push(code);
            }
          }
        });
      }
      getCode(permission);
      state.permission = {};
      result.forEach((ele) => {
        state.permission[ele] = true;
      });
      setStore({ name: "permission", content: state.permission });
    },
  },
};
export default user;
src/views/activity/components/polygonPlot.vue
@@ -151,9 +151,9 @@
import { deleteSecurityPlot, addSecurityPlot } from '@/api/activity/index.js'
export default {
    inject: ['userInfo', 'activityDeptId'],
    inject: ['userInfo'],
    props: ['showingSecurityId'],
    props: ['showingSecurityId', 'activityDeptId'],
    data () {
        return {
src/views/activity/components/publicIndex.vue
@@ -14,7 +14,8 @@
            :policeSwitch="policeSwitch" :polylineBtnSwitch="polylineBtnSwitch" :arrowBtnSwitch="arrowBtnSwitch"
            :policeIconId="policeIconId" :lineWidth="lineWidth" @setPoliceOption="setPoliceOption"></two-draw-btn-box>
        <polygon-plot ref="PolygonPlotPage" :showingSecurityId="showingSecurityId"></polygon-plot>
        <polygon-plot ref="PolygonPlotPage" :showingSecurityId="showingSecurityId"
            :activityDeptId="activityDeptId"></polygon-plot>
        <polyline-plot ref="PolylinePlotPage" :showingSecurityId="showingSecurityId"></polyline-plot>
@@ -61,7 +62,9 @@
let policecarOption = []
export default {
    inject: ['userInfo', 'activityDeptId'],
    inject: ['userInfo'],
    props: ['activityDeptId'],
    data () {
        return {
src/views/activity/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-24 16:36:55
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-06-21 09:58:58
 * @LastEditTime: 2023-07-12 10:12:11
 * @FilePath: \srs-police-affairs\src\views\activity\index.vue
 * @Description: 
 * 
@@ -184,7 +184,7 @@
        <map-search-box></map-search-box>
        <public-index ref="PublicIndexPage"></public-index>
        <public-index ref="PublicIndexPage" :activityDeptId="activityDeptId"></public-index>
    </div>
</template>
@@ -218,12 +218,6 @@
export default {
    inject: ['userInfo'],
    provide () {
        return {
            activityDeptId: this.activityDeptId
        }
    },
    data () {
        return {
src/views/home/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:17
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-07-11 15:13:20
 * @LastEditTime: 2023-07-11 16:24:57
 * @FilePath: \srs-police-affairs\src\views\home\index.vue
 * @Description: 小区-栋-层-房屋
 *
@@ -581,33 +581,33 @@
            }],
    }]
let positionColor = [
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 97, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 142, 97, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 192, 97, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 242, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(0, 185, 209, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(208, 167, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(221, 255, 97, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(51, 255, 0, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 255, 181, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 181, 252, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 129, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 252, 236, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 184, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 113, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(81, 252, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(126, 97, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(168, 252, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(171, 97, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 249, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(210, 97, 255, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 174, 58, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 226, 97, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 176, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 252, 155, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 155, 90),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 97, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 142, 97, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 192, 97, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 242, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(0, 185, 209, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(208, 167, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(221, 255, 97, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(51, 255, 0, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 255, 181, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 181, 252, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 129, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 252, 236, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 184, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(97, 113, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(81, 252, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(126, 97, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(168, 252, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(171, 97, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 249, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(210, 97, 255, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 174, 58, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 226, 97, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(255, 97, 176, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(58, 252, 155, 50),
    global.DC.Namespace.Cesium.Color.fromBytes(252, 58, 155, 50),
]
let timer = []
src/views/layout/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:24
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-04-21 16:40:03
 * @LastEditTime: 2023-07-12 09:56:09
 * @FilePath: \srs-police-affairs\src\views\layout\index.vue
 * @Description: 
 * 
@@ -57,7 +57,7 @@
                    <div class="triangle"></div>
                    <div class="userName">用户名:{{ currentUserInfo.user_name }}</div>
                    <div class="userBtn">
                        <div class="back-system" v-if="userBackSystem" @click="goToBack">
                        <div class="back-system" v-if="permission.operation_manager" @click="goToBack">
                            <i class="el-icon-user-back"></i>
                            运维管理
                        </div>
@@ -118,6 +118,8 @@
import { getStore } from "@/utils/store.js"
import { getUserInfo, getToken } from '@/utils/auth'
import { mapGetters } from "vuex"
export default {
    provide () {
        return {
@@ -186,18 +188,16 @@
            refreshLock: false,
            //刷新token的时间
            refreshTime: "",
            userBackSystem: false,
        }
    },
    computed: {
        ...mapGetters(['permission'])
    },
    created () {
        this.currentUrl = this.$route.path
        this.init()
        if (JSON.parse(getUserInfo()).dept_id == '1123598813738675201') {
            this.userBackSystem = true
        }
        //实时检测刷新token
        this.refreshToken()
src/views/login/index.vue
@@ -35,21 +35,12 @@
            <p>用户登录</p>
            <el-form :model="loginForm" ref="formName" status-icon :rules="rules">
                <el-form-item prop="username">
                    <el-input
                        v-model="loginForm.username"
                        prefix-icon="el-icon-user"
                        placeholder="请输入您的用户名"
                        autocomplete="off"
                    ></el-input>
                    <el-input v-model="loginForm.username" prefix-icon="el-icon-user" placeholder="请输入您的用户名"
                        autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input
                        type="password"
                        v-model="loginForm.password"
                        prefix-icon="el-icon-lock"
                        placeholder="请输入您密码"
                        autocomplete="off"
                    ></el-input>
                    <el-input type="password" v-model="loginForm.password" prefix-icon="el-icon-lock" placeholder="请输入您密码"
                        autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item>
                    <!-- <el-button type="primary" @click.enter="onLogin()">登&nbsp;录</el-button> -->
@@ -138,6 +129,8 @@
                        background: 'rgba(0, 0, 0, 0.5)'
                    })
                    this.$store.dispatch("LoginByUsername", this.loginForm).then((res) => {
                        this.$store.dispatch("GetButtons")
                        //跳转首页
                        this.$router.push({ path: "/layout/home" })
                        loading.close()