Forráskód Böngészése

子账号接单方式修改,logo去除

zouzs 13 órája
szülő
commit
4f66269b5b

+ 27 - 0
src/api/childAccount.ts

@@ -8,6 +8,10 @@ type Result = {
   msg: string;
 };
 
+/**
+ * 获取子账户列表
+ * @param data
+ */
 export const getChildAccountList = data => {
   return http.request<Result>(
     "post",
@@ -18,6 +22,9 @@ export const getChildAccountList = data => {
   );
 };
 
+/**
+ * 获取当前登录用户的子账户
+ */
 export const getChildAccount = () => {
   return http.request<Result>(
     "post",
@@ -25,6 +32,10 @@ export const getChildAccount = () => {
   );
 };
 
+/**
+ * 新增
+ * @param data
+ */
 export const createChildAccount = data => {
   return http.request<Result>(
     "post",
@@ -35,12 +46,20 @@ export const createChildAccount = data => {
   );
 };
 
+/**
+ * 修改
+ * @param data
+ */
 export const updateChildAccount = data => {
   return http.request<Result>("post", baseUrlApi("merchantUserInfo/update"), {
     data
   });
 };
 
+/**
+ * 详情
+ * @param id
+ */
 export const merchantUserInfoDetail = (id: string) => {
   return http.request<Result>(
     "get",
@@ -48,6 +67,10 @@ export const merchantUserInfoDetail = (id: string) => {
   );
 };
 
+/**
+ * 修改状态
+ * @param data
+ */
 export const merchantUserInfoupdateStatus = data => {
   return http.request<Result>(
     "post",
@@ -58,6 +81,10 @@ export const merchantUserInfoupdateStatus = data => {
   );
 };
 
+/**
+ * 修改接单状态
+ * @param data
+ */
 export const merchantUserInfoupdateAllocationStatus = data => {
   return http.request<Result>(
     "post",

+ 1 - 4
src/api/user.ts

@@ -62,10 +62,7 @@ export const getVerifySmsApi = (data?: object) => {
 export type UserResult = {
   code: number;
   msg: string;
-  data: {
-    access_token: string;
-    expires_in: number;
-  };
+  data: any;
 };
 
 /** 登录 */

+ 6 - 0
src/layout/components/lay-navbar/index.vue

@@ -3,12 +3,15 @@ import { useNav } from "@/layout/hooks/useNav";
 import LaySearch from "../lay-search/index.vue";
 import LayNotice from "../lay-notice/index.vue";
 import LayNavMix from "../lay-sidebar/NavMix.vue";
+import LaySwitch from "../lay-switch/index.vue";
 import LaySidebarFullScreen from "../lay-sidebar/components/SidebarFullScreen.vue";
 import LaySidebarBreadCrumb from "../lay-sidebar/components/SidebarBreadCrumb.vue";
 import LaySidebarTopCollapse from "../lay-sidebar/components/SidebarTopCollapse.vue";
 
 import LogoutCircleRLine from "~icons/ri/logout-circle-r-line";
 import Setting from "~icons/ri/settings-3-line";
+import { hasAuth } from "@/router/utils";
+import { useUserStoreHook } from "@/store/modules/user";
 
 const {
   layout,
@@ -40,6 +43,9 @@ const {
     <LayNavMix v-if="layout === 'mix'" />
 
     <div v-if="layout === 'vertical'" class="vertical-header-right">
+      <div v-if="useUserStoreHook().isChild">
+        <LaySwitch id="header-switch" />
+      </div>
       <!-- 菜单搜索 -->
       <LaySearch id="header-search" />
       <!-- 全屏 -->

+ 2 - 2
src/layout/components/lay-sidebar/components/SidebarLogo.vue

@@ -19,7 +19,7 @@ const { title, getLogo } = useNav();
         class="sidebar-logo-link"
         :to="getTopMenu()?.path ?? '/'"
       >
-        <img :src="getLogo()" alt="logo" />
+        <!--        <img :src="getLogo()" alt="logo" />-->
         <span class="sidebar-title">{{ title }}</span>
       </router-link>
       <router-link
@@ -29,7 +29,7 @@ const { title, getLogo } = useNav();
         class="sidebar-logo-link"
         :to="getTopMenu()?.path ?? '/'"
       >
-        <img :src="getLogo()" alt="logo" />
+        <!--        <img :src="getLogo()" alt="logo" />-->
         <span class="sidebar-title">{{ title }}</span>
       </router-link>
     </transition>

+ 66 - 0
src/layout/components/lay-switch/index.vue

@@ -0,0 +1,66 @@
+<script setup lang="ts">
+import { onMounted, ref } from "vue";
+import {
+  merchantUserInfoDetail,
+  merchantUserInfoupdateAllocationStatus
+} from "@/api/childAccount";
+import { useUserStoreHook } from "@/store/modules/user";
+import { ElMessage, ElMessageBox } from "element-plus";
+
+const allocationStatus = ref();
+const loading = ref(false);
+
+onMounted(async () => {
+  getStatus();
+});
+
+const getStatus = () => {
+  loading.value = true;
+  merchantUserInfoDetail(useUserStoreHook().admUserId)
+    .then(res => {
+      allocationStatus.value = res.data.receiveStatus;
+    })
+    .finally(() => {
+      loading.value = false;
+    });
+};
+
+const handleChangeStatus = () => {
+  ElMessageBox.confirm("确定要修改接单状态吗?", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning"
+  })
+    .then(async () => {
+      loading.value = true;
+      let params = {
+        allocationStatus: allocationStatus.value,
+        ids: [useUserStoreHook().admUserId]
+      };
+      let res = await merchantUserInfoupdateAllocationStatus(params);
+      if (res.code === 0) {
+        ElMessage.success("操作成功");
+      } else {
+        ElMessage.error(res.msg);
+        allocationStatus.value = !allocationStatus.value;
+      }
+      loading.value = false;
+    })
+    .catch(() => {
+      allocationStatus.value = !allocationStatus.value;
+    });
+};
+</script>
+
+<template>
+  <el-switch
+    v-model="allocationStatus"
+    :loading="loading"
+    inline-prompt
+    active-text="接单中"
+    inactive-text="已停止接单"
+    @change="handleChangeStatus"
+  />
+</template>
+
+<style scoped lang="scss"></style>

+ 9 - 1
src/store/modules/user.ts

@@ -42,7 +42,11 @@ export const useUserStore = defineStore("pure-user", {
     // 登录页的免登录存储几天,默认7天
     loginDay: 7,
     // 是否子账号
-    isChild: storageLocal().getItem<DataInfo<number>>(userKey)?.isChild ?? false
+    isChild:
+      storageLocal().getItem<DataInfo<number>>(userKey)?.isChild ?? false,
+    // 账户id
+    admUserId:
+      storageLocal().getItem<DataInfo<string>>(userKey)?.admUserId ?? ""
   }),
   actions: {
     /** 存储头像 */
@@ -77,6 +81,10 @@ export const useUserStore = defineStore("pure-user", {
     SET_ISCHILD(bool: boolean) {
       this.isChild = bool;
     },
+    /** 存储账户id */
+    SET_ADMUSERID(value: string) {
+      this.admUserId = value;
+    },
     /** 登入 */
     async loginByUsername(data: object, submitType: number) {
       return new Promise<UserResult>((resolve, reject) => {

+ 1 - 0
src/store/types.ts

@@ -45,4 +45,5 @@ export type userType = {
   isRemembered?: boolean;
   loginDay?: number;
   isChild?: boolean;
+  admUserId?: string;
 };

+ 12 - 33
src/utils/auth.ts

@@ -24,7 +24,7 @@ export interface DataInfo<T> {
   /** 是否子账号 */
   isChild?: boolean;
 
-  admUserId: number;
+  admUserId: string;
   admUserName: string;
   id: number;
   loginName: string;
@@ -97,66 +97,45 @@ export function setToken(data: DataInfo<number>) {
 }
 
 export function setUserInfo(data: DataInfo<number>) {
-  function setUserKey({
-    avatar,
-    username,
-    nickname,
-    roles,
-    permissions,
-    isChild
-  }) {
-    useUserStoreHook().SET_AVATAR(avatar);
+  function setUserKey({ username, roles, isChild, admUserId }) {
     useUserStoreHook().SET_USERNAME(username);
-    useUserStoreHook().SET_NICKNAME(nickname);
     useUserStoreHook().SET_ROLES(roles);
-    useUserStoreHook().SET_PERMS(permissions);
     useUserStoreHook().SET_ISCHILD(isChild);
+    useUserStoreHook().SET_ADMUSERID(admUserId);
     storageLocal().setItem(userKey, {
       // refreshToken,
-      avatar,
       username,
-      nickname,
       roles,
-      permissions,
-      isChild
+      isChild,
+      admUserId
     });
   }
 
   if (data.admUserName && data.loginName) {
     console.log("走的这里");
-    let { permissions, roles, main } = data;
-    console.log(main);
-    if (main) {
+    let roles = [];
+    if (data.main) {
       roles = ["admin"];
     }
-    const user = data.user;
     setUserKey({
-      avatar: user?.avatar ?? "",
-      username: user?.loginName ?? "",
-      nickname: user?.admUserName ?? "",
+      username: data?.loginName ?? "",
       roles,
-      permissions,
-      isChild: !main
+      isChild: !data.main,
+      admUserId: data.admUserId
     });
   } else {
     console.log("走这里");
-    const avatar =
-      storageLocal().getItem<DataInfo<number>>(userKey)?.avatar ?? "";
     const username =
       storageLocal().getItem<DataInfo<number>>(userKey)?.username ?? "";
     const nickname =
       storageLocal().getItem<DataInfo<number>>(userKey)?.nickname ?? "";
     const roles =
       storageLocal().getItem<DataInfo<number>>(userKey)?.roles ?? [];
-    const permissions =
-      storageLocal().getItem<DataInfo<number>>(userKey)?.permissions ?? [];
     setUserKey({
-      avatar,
       username,
-      nickname,
       roles,
-      permissions,
-      isChild: !main
+      isChild: !data.main,
+      admUserId: data.admUserId
     });
   }
 }

+ 8 - 8
src/views/login/index.vue

@@ -54,8 +54,8 @@ dataThemeChange(overallStyle.value);
 const { title } = useNav();
 
 const ruleForm = reactive({
-  loginName: "tushanjing9805",
-  loginPwd: "Aa123456!!",
+  loginName: "undef1ned",
+  loginPwd: "zZs19970821/",
   code: "",
   uuid: ""
 });
@@ -352,15 +352,15 @@ onMounted(() => {
               </el-form-item>
             </Motion>-->
 
-            <Motion :delay="250">
+            <!--            <Motion :delay="250">
               <el-form-item>
                 <el-checkbox v-model="ruleForm.agree">
                   下次登录记住我的身份
                 </el-checkbox>
               </el-form-item>
-            </Motion>
+            </Motion>-->
 
-            <Motion :delay="300">
+            <Motion :delay="250">
               <el-button
                 class="w-full"
                 size="default"
@@ -413,15 +413,15 @@ onMounted(() => {
               </el-form-item>
             </Motion>
 
-            <Motion :delay="150">
+            <!--            <Motion :delay="150">
               <el-form-item class="default-color">
                 <el-checkbox v-model="ruleForm.agree">
                   下次登录记住我的身份
                 </el-checkbox>
               </el-form-item>
-            </Motion>
+            </Motion>-->
 
-            <Motion :delay="200">
+            <Motion :delay="150">
               <el-button
                 class="w-full"
                 size="default"