|
|
@@ -0,0 +1,500 @@
|
|
|
+import axios from "axios";
|
|
|
+import router from "@/router";
|
|
|
+import { genFileId, ElMessage, ElMessageBox } from "element-plus";
|
|
|
+
|
|
|
+// 声明变量
|
|
|
+const state = {
|
|
|
+ collapse: false,
|
|
|
+ activeIndex: "", // 记录当前路由
|
|
|
+ messageNum: "", // 未读信息条数
|
|
|
+ username: "",
|
|
|
+ password: "",
|
|
|
+ // api: "/alumnus/gxy/houtai/drone/auto", // 线上
|
|
|
+ api: "/lowFly/houtai/drone/auto", // 线上
|
|
|
+ // api: "/drone/auto", // 测试
|
|
|
+ roleList: [
|
|
|
+ // {
|
|
|
+ // path: "distribution",
|
|
|
+ // name: "distribution",
|
|
|
+ // component: () => import("@/views/distribution/distribution.vue"),
|
|
|
+ // meta: { title: "配送中心", icon: "distribution" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "drone",
|
|
|
+ // name: "drone",
|
|
|
+ // component: () => import("@/views/drone/drone.vue"),
|
|
|
+ // meta: { title: "飞行器管理", icon: "drone" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "station",
|
|
|
+ // name: "station",
|
|
|
+ // component: () => import("@/views/station/station.vue"),
|
|
|
+ // meta: { title: "站点管理", icon: "station" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "parking",
|
|
|
+ // name: "parking",
|
|
|
+ // component: () => import("@/views/parking/parking.vue"),
|
|
|
+ // meta: { title: "停机坪管理", icon: "parking" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "container",
|
|
|
+ // name: "container",
|
|
|
+ // component: () => import("@/views/container/container.vue"),
|
|
|
+ // meta: { title: "货柜管理", icon: "container" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "account",
|
|
|
+ // name: "account",
|
|
|
+ // component: () => import("@/views/account/account.vue"),
|
|
|
+ // meta: { title: "账号管理", icon: "account" },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // path: "system",
|
|
|
+ // name: "system",
|
|
|
+ // component: () => import("@/views/system/system.vue"),
|
|
|
+ // meta: { title: "系统管理", icon: "system" },
|
|
|
+ // },
|
|
|
+ ],
|
|
|
+ roles: [],
|
|
|
+ hasRoutes: false,
|
|
|
+};
|
|
|
+
|
|
|
+// 修改变量(state不能直接赋值修改,只能通过mutations)
|
|
|
+const mutations = {
|
|
|
+ menuClose: (state, value) => {
|
|
|
+ state.collapse = value;
|
|
|
+ },
|
|
|
+ indexUp: (state, value) => {
|
|
|
+ sessionStorage.setItem("sidevarItem", value);
|
|
|
+ state.activeIndex = value;
|
|
|
+ // if (!value) {
|
|
|
+ // let roleId = sessionStorage.getItem("roleId");
|
|
|
+ // state.user.roles.forEach((item) => {
|
|
|
+ // if (item.roles == roleId) {
|
|
|
+ // state.activeIndex = `/jianguanCloud/${item.list[0]}`;
|
|
|
+ // sessionStorage.setItem(
|
|
|
+ // "sidevarItem",
|
|
|
+ // `/jianguanCloud/${item.list[0]}`
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // sessionStorage.setItem("sidevarItem", value);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ SET_ROUTES_STATE: (state, value) => {
|
|
|
+ state.hasRoutes = value;
|
|
|
+ },
|
|
|
+ userName: (state, value) => {
|
|
|
+ state.username = value;
|
|
|
+ },
|
|
|
+ passWord: (state, value) => {
|
|
|
+ state.password = value;
|
|
|
+ },
|
|
|
+ ROLELIST: async (state, value) => {
|
|
|
+ let roleList = JSON.parse(sessionStorage.getItem("roleList"));
|
|
|
+ console.log(roleList, "role");
|
|
|
+ },
|
|
|
+};
|
|
|
+// mutations的值由actions传入(异步)
|
|
|
+const actions = {
|
|
|
+ newsAsync: async ({ commit, state }) => {
|
|
|
+ let data = new FormData();
|
|
|
+ let res = await axios({
|
|
|
+ method: "post",
|
|
|
+ url: state.api + "/carBook/usermesUnRead.action",
|
|
|
+ headers: {
|
|
|
+ token: sessionStorage.getItem("token"),
|
|
|
+ },
|
|
|
+ data: data,
|
|
|
+ });
|
|
|
+ console.log(res, "系统消息");
|
|
|
+
|
|
|
+ commit("newsUp", res.data.u_count);
|
|
|
+ sessionStorage.setItem("newsNum", res.data.u_count);
|
|
|
+ console.log("vuex", res.data.u_count);
|
|
|
+ },
|
|
|
+ // 系统扫码时间
|
|
|
+ login: async ({ commit, state }, data) => {
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ let res = await axios({
|
|
|
+ method: "post",
|
|
|
+ url: state.api + "/login/Login",
|
|
|
+ data: data,
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(res, "登录账号");
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ sessionStorage.setItem("userName", res.data.data.userName);
|
|
|
+ sessionStorage.setItem("token", res.data.data.token);
|
|
|
+ let droneManagement = res.data.data.droneManagement;
|
|
|
+ let btnRoles = {
|
|
|
+ peisongzhongxin: {}, // 配送中心
|
|
|
+ peisongshenqing: {}, // 配送申请
|
|
|
+ feixingqiguanli: {}, // 飞行器管理
|
|
|
+ zhandianguanli: {}, // 站点管理
|
|
|
+ tingjipingguanli: {}, // 停机坪管理
|
|
|
+ huoguiguanli: {}, // 货柜管理
|
|
|
+ jueseguanli: {}, // 角色管理
|
|
|
+ guanliduanguanli: {}, // 管理端管理
|
|
|
+ yidongduanguanli: {}, // 移动端管理
|
|
|
+ xinxi: {}, // 信息
|
|
|
+ jiancezhongxin: {}, // 检测中心
|
|
|
+ xitongguanli: {}, // 检测中心
|
|
|
+ };
|
|
|
+ let roleList = [];
|
|
|
+ // 配送中心
|
|
|
+ if (droneManagement.distributionCenter) {
|
|
|
+ let list = droneManagement.distributionCenter.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 3;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "配送中心",
|
|
|
+ path: "distribution",
|
|
|
+ route: "/delivery/distribution",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.peisongzhongxin.chakan = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.peisongzhongxin.fanhui = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.peisongzhongxin.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 配送申请
|
|
|
+ if (droneManagement.distributionApplication) {
|
|
|
+ let list = droneManagement.distributionApplication.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "配送中心",
|
|
|
+ path: "distribution",
|
|
|
+ route: "/delivery/distribution",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.peisongshenqing.chakan = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.peisongshenqing.tongyi = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.peisongshenqing.jujue = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.peisongshenqing.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 飞行器管理
|
|
|
+ if (droneManagement.aircraftManagement) {
|
|
|
+ let list = droneManagement.aircraftManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 1;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "飞行器管理",
|
|
|
+ path: "drone",
|
|
|
+ route: "/delivery/drone",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.feixingqiguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.feixingqiguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.feixingqiguanli.qiyong = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.feixingqiguanli.jinyong = 1;
|
|
|
+ }
|
|
|
+ if (i == 5) {
|
|
|
+ btnRoles.feixingqiguanli.xiazaierweima = 1;
|
|
|
+ }
|
|
|
+ if (i == 6) {
|
|
|
+ btnRoles.feixingqiguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 7) {
|
|
|
+ btnRoles.feixingqiguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 站点管理
|
|
|
+ if (droneManagement.stationManagement) {
|
|
|
+ let list = droneManagement.stationManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "站点管理",
|
|
|
+ path: "station",
|
|
|
+ route: "/delivery/station",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.zhandianguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.zhandianguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.zhandianguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.zhandianguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 停机坪管理
|
|
|
+ if (droneManagement.parkingManagement) {
|
|
|
+ let list = droneManagement.parkingManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "停机坪管理",
|
|
|
+ path: "parking",
|
|
|
+ route: "/delivery/parking",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.tingjipingguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.tingjipingguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.tingjipingguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.tingjipingguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 货柜管理
|
|
|
+ if (droneManagement.containerManagement) {
|
|
|
+ let list = droneManagement.containerManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "货柜管理",
|
|
|
+ path: "container",
|
|
|
+ route: "/delivery/container",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.huoguiguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.huoguiguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.huoguiguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.huoguiguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 角色管理
|
|
|
+ if (droneManagement.menuManagement) {
|
|
|
+ let list = droneManagement.menuManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "账号管理",
|
|
|
+ path: "account",
|
|
|
+ route: "/delivery/account",
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.jueseguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.jueseguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.jueseguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.jueseguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 管理端管理
|
|
|
+ if (droneManagement.adminManagement) {
|
|
|
+ let list = droneManagement.adminManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "账号管理",
|
|
|
+ path: "account",
|
|
|
+ route: "/delivery/account",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.guanliduanguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.guanliduanguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.guanliduanguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.guanliduanguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 移动端管理
|
|
|
+ if (droneManagement.appManagement) {
|
|
|
+ let list = droneManagement.appManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 4;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "账号管理",
|
|
|
+ path: "account",
|
|
|
+ route: "/delivery/account",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.yidongduanguanli.bianji = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.yidongduanguanli.xinzeng = 1;
|
|
|
+ }
|
|
|
+ if (i == 3) {
|
|
|
+ btnRoles.yidongduanguanli.shanchu = 1;
|
|
|
+ }
|
|
|
+ if (i == 4) {
|
|
|
+ btnRoles.yidongduanguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 信息
|
|
|
+ if (droneManagement.messageManagement) {
|
|
|
+ let list = droneManagement.messageManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 1;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "信息",
|
|
|
+ path: "message",
|
|
|
+ route: "/delivery/message",
|
|
|
+ flag: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.xinxi.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 检测中心
|
|
|
+ if (droneManagement.monitoringCenterManagement) {
|
|
|
+ let list = droneManagement.monitoringCenterManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 1;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "检测中心",
|
|
|
+ path: "monitoring",
|
|
|
+ route: "/delivery/monitoring",
|
|
|
+ flag: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.jiancezhongxin.chaxun = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 系统管理
|
|
|
+ if (droneManagement.systemManagement) {
|
|
|
+ let list = droneManagement.systemManagement.split(",");
|
|
|
+ let a = list.some((i) => {
|
|
|
+ return i == 1;
|
|
|
+ });
|
|
|
+ if (a) {
|
|
|
+ roleList.push({
|
|
|
+ name: "系统管理",
|
|
|
+ path: "system",
|
|
|
+ route: "/delivery/system",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ list.forEach((i) => {
|
|
|
+ if (i == 1) {
|
|
|
+ btnRoles.xitongguanli.chaxun = 1;
|
|
|
+ }
|
|
|
+ if (i == 2) {
|
|
|
+ btnRoles.xitongguanli.xiugai = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let jrr = [];
|
|
|
+ roleList.forEach((i) => {
|
|
|
+ let flag = jrr.some((j) => {
|
|
|
+ return j.path == i.path;
|
|
|
+ });
|
|
|
+ if (!flag) {
|
|
|
+ jrr.push(i);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ sessionStorage.setItem("roleList", JSON.stringify(jrr));
|
|
|
+ sessionStorage.setItem("btnRoles", JSON.stringify(btnRoles));
|
|
|
+ commit("userName", res.data.data.userName);
|
|
|
+ commit("ROLELIST", "");
|
|
|
+ // if (res.data.data.roleId == 1) {
|
|
|
+ // router.push({ path: "/jianguanCloud/project" });
|
|
|
+ // commit("indexUp", "/jianguanCloud/project");
|
|
|
+ // } else {
|
|
|
+ // router.push({ path: "/jianguanCloud/home" });
|
|
|
+ // commit("indexUp", "/jianguanCloud/home");
|
|
|
+ // }
|
|
|
+ resolve("success");
|
|
|
+ } else {
|
|
|
+ resolve({ name: "reject", data: res });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+export default {
|
|
|
+ state,
|
|
|
+ mutations,
|
|
|
+ actions,
|
|
|
+};
|