Browse Source

Merge branch 'sit' of http://120.46.155.214:3000/xiaodai2022/accout-vue3-ui into sit

xiaodai2017 2 years ago
parent
commit
dd39cff71d

+ 4 - 5
src/components/PageContent/src/page-content.tsx

@@ -10,6 +10,9 @@ import { useRenderIcon } from "../../ReIcon/src/hooks";
 import { useColumns } from "./hooks/use-columns";
 import { useActions } from "./hooks/use-actions";
 import { onBeforeRouteLeave } from "vue-router";
+
+import { useAppStoreHook } from "/@/store/modules/app";
+import { useUserInfo } from "/@/hooks/core/useUser";
 import { Operation } from "./actions";
 import "./styles/index.scss";
 
@@ -21,8 +24,6 @@ import {
   ElScrollbar,
   ElTooltip
 } from "element-plus";
-import { useAppStoreHook } from "/@/store/modules/app";
-import { useUserInfo } from "/@/hooks/core/useUser";
 
 const PageConent = defineComponent({
   name: "PageContent",
@@ -208,9 +209,7 @@ const PageConent = defineComponent({
       setSearchParams(basicParams, pagination);
     });
 
-    function renderExpand(row) {
-      return slots.expand && slots.expand(row);
-    }
+    const renderExpand = (row) => slots.expand && slots.expand(row)
 
     function renderFilterColumnns() {
       return (

+ 3 - 0
src/components/ReIcon/src/iconifyIconOffline.ts

@@ -44,6 +44,9 @@ import Excel from "@iconify-icons/fa-solid/file-excel";
 import Promotion from "@iconify-icons/ep/promotion";
 import BellFilled from "@iconify-icons/ep/bell-filled";
 import downloadLine from "@iconify-icons/ep/download";
+import SwitchArrow from "@iconify-icons/ep/switch";
+
+addIcon("switch-arrow", SwitchArrow);
 addIcon("download-line", downloadLine);
 addIcon("bell-filled", BellFilled);
 addIcon("success", Select);

+ 4 - 0
src/hooks/core/useUser.ts

@@ -6,9 +6,13 @@ export function useUserInfo() {
 
   const isSuperUser = computed(() => userStore.isSuperUser);
   const userInfo = computed(() => userStore.info);
+  const userLevel = computed(() => userStore.level);
+  const setUserLevel = (level: string) => userStore.SET_LEVEL(level);
 
   return {
+    setUserLevel,
     isSuperUser,
+    userLevel,
     userInfo
   };
 }

+ 34 - 6
src/layout/components/navbar.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { computed, ref } from "vue";
+import { computed, ref, watch } from "vue";
 import { useNav } from "../hooks/nav";
 import mixNav from "./sidebar/mixNav.vue";
 import avatars from "/@/assets/avatars.jpg";
@@ -8,7 +8,6 @@ import Breadcrumb from "./sidebar/breadCrumb.vue";
 import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
 import { useRouter, useRoute } from "vue-router";
 import { deviceDetection } from "@pureadmin/utils";
-import screenfull from "../components/screenfull/index.vue";
 import Company from "../components/company/index.vue";
 import Super from "../components/company/super.vue";
 import { useUserInfo } from "/@/hooks/core/useUser";
@@ -16,17 +15,23 @@ import { getToken, SECRET_KEY } from "/@/utils/auth";
 import SystemNotify from "./system-notify.vue";
 import HelpModal from "./help-modal.vue";
 import CryptoJS from "crypto-js";
+import { initRouter } from "/@/router/utils";
 
 const route = useRoute();
-const { push } = useRouter();
-const { isSuperUser, userInfo } = useUserInfo();
+const { push, replace } = useRouter();
 const showBackButton = computed(() => route.path.indexOf("Detail") >= 0);
 const helpModalRef = ref<InstanceType<typeof HelpModal> | null>(null);
 const systemNotifyRef = ref<InstanceType<typeof SystemNotify>>(null);
+const { logout, toggleSideBar, pureApp, avatarsStyle } = useNav();
+
+const { isSuperUser, userInfo, userLevel, setUserLevel } = useUserInfo();
+
+const switchAccountModeText = computed(() =>
+  userLevel.value === "3" ? "切换至业务公司" : "切换至供应商"
+);
 
 function routeToList() {
   const { path, query } = route;
-
   push(
     (query?.back as string) ? (query.back as string) : path.split("Detail")[0]
   );
@@ -45,7 +50,17 @@ function openPurchaseSystem() {
   window.open("http://localhost:8080/#/accept?t=" + encData);
 }
 
-const { logout, toggleSideBar, pureApp, avatarsStyle } = useNav();
+//超管切换供应商、业务公司视角
+async function onSwitchAccountMode() {
+  const isSupplier = userLevel.value === "3";
+
+  setUserLevel(isSupplier ? "1" : "3");
+  await initRouter({ level: isSupplier ? "1" : "3" });
+  console.log(route.path);
+  await replace(
+    route.path + "?reload=" + (isSupplier ? "supplier" : "business")
+  );
+}
 </script>
 
 <template>
@@ -79,6 +94,7 @@ const { logout, toggleSideBar, pureApp, avatarsStyle } = useNav();
       <!-- 采销系统入口 -->
       <el-tooltip placement="left" content="登录采销平台">
         <el-button
+          v-if="isSuperUser"
           size="large"
           class="fixed"
           style="bottom: 100px; right: 60px"
@@ -88,6 +104,18 @@ const { logout, toggleSideBar, pureApp, avatarsStyle } = useNav();
         />
       </el-tooltip>
 
+      <!--  超管切换至供应商和业务公司    -->
+      <el-tooltip placement="left" :content="switchAccountModeText">
+        <el-button
+          size="large"
+          class="fixed"
+          style="bottom: 160px; right: 60px"
+          circle
+          @click="onSwitchAccountMode"
+          :icon="useRenderIcon('switch-arrow')"
+        />
+      </el-tooltip>
+
       <!-- 公司名称筛选 -->
       <Super v-if="isSuperUser" />
       <Company v-else />

+ 5 - 3
src/router/utils.ts

@@ -113,10 +113,10 @@ function resetRouter(): void {
 }
 
 // 初始化路由
-function initRouter() {
+function initRouter(data = {}) {
   return new Promise((resolve, reject) => {
     useUserStoreHook()
-      .postMenuList({})
+      .postMenuList(data)
       .then(({ code, data }) => {
         if (code === 0) {
           const arrag: Array<any> = [];
@@ -176,11 +176,13 @@ function initRouter() {
                   const flattenRouters = router
                     .getRoutes()
                     .find(n => n.path === "/");
+
                   router.addRoute(flattenRouters);
                 }
                 resolve(router);
               }
             );
+
             usePermissionStoreHook().changeSetting(arrag);
           }
 
@@ -282,7 +284,7 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
       // 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会根path保持一致)
       const index = v?.component
         ? // @ts-expect-error
-          modulesRoutesKeys.findIndex(ev => ev.includes(v.component))
+        modulesRoutesKeys.findIndex(ev => ev.includes(v.component))
         : modulesRoutesKeys.findIndex(ev => ev.includes(v.path));
       v.component = modulesRoutes[modulesRoutesKeys[index]];
     }

+ 1 - 0
src/store/modules/types.ts

@@ -53,6 +53,7 @@ export type userType = {
   info: null | Record<string, string>;
   disabledCompany: boolean;
   systemInfo: Record<string, string>;
+  level: string;
 };
 
 export type resType = {

+ 12 - 4
src/store/modules/user.ts

@@ -33,6 +33,7 @@ export const useUserStore = defineStore({
   id: "pure-user",
   state: (): userType => ({
     token: getToken(),
+    level: "0",
     name: "admin",
     // 前端生成的验证码(按实际需求替换)
     verifyCode: "",
@@ -54,6 +55,11 @@ export const useUserStore = defineStore({
     SET_NAME(name) {
       this.name = name;
     },
+
+    SET_LEVEL(level) {
+      this.level = level;
+    },
+
     SET_VERIFYCODE(verifyCode) {
       this.verifyCode = verifyCode;
     },
@@ -119,9 +125,9 @@ export const useUserStore = defineStore({
 
       this.info = data;
       if (Number(code) === 0) {
-        const { role_level } = data;
-
+        const { role_level, level } = data;
         this.isSuperUser = role_level === "1";
+        this.level = level;
         const code = getRelaComNo();
         const companyName = getRelaComName();
         if (!this.isSuperUser && this.companyList.length === 0) {
@@ -155,8 +161,10 @@ export const useUserStore = defineStore({
     // 获取当前账号菜单数据
     async postMenuList(form) {
       try {
-        await this.requesetUserInfo();
-        await this.requsetSystemInfo();
+        if (this.level === "0") {
+          await this.requesetUserInfo();
+          await this.requsetSystemInfo();
+        }
 
         return new Promise((resolve, reject) => {
           getAsyncRoutes(form)

+ 1 - 1
src/views/InvoiceSaleSettings/commodityCost/index.vue

@@ -64,7 +64,7 @@ function onDownloadTemplate() {
 <template>
   <div class="main role">
     <PagePower :is-show="hasPermissionWithCode('001')">
-      <div w-full>
+      <div>
         <PageSearch
           :form-config="searchFormConfig"
           @search-btn-click="handleSearchClick"

+ 1 - 2
src/views/interest/companyAccount/addEdit.vue

@@ -247,8 +247,6 @@ function handleDelete(index) {
     defaultCompanyNo = ruleForm.companyArr[index - 1].companyCode;
     defaultCompany.value[index - 1] = true;
   }
-
-  console.log(defaultCompanyNo, defaultCompany.value);
 }
 
 function handleChoose(companys) {
@@ -265,6 +263,7 @@ function handleChoose(companys) {
   });
 
   defaultCompany.value = ruleForm.companyArr.map(() => false);
+
   const index = ruleForm.companyArr.findIndex(
     ({ companyCode }) => companyCode === defaultCompanyNo
   );

+ 1 - 1
src/views/interest/companyAccount/components/company-modal.vue

@@ -106,7 +106,7 @@ defineExpose({
       <el-table-column type="selection" width="55" />
       <el-table-column label="公司编号" prop="companyNo" show-overflow-tooltip />
       <el-table-column label="公司名称" prop="name" show-overflow-tooltip />
-      <el-table-column label="公司类型" prop="nature" show-overflow-tooltip />
+      <!--<el-table-column label="公司类型" prop="nature" show-overflow-tooltip />-->
     </el-table>
     <div flex justify-between mt-2>
       <el-pagination

+ 1 - 1
src/views/supplierManage/supplierAccoutManage/index.vue

@@ -20,7 +20,7 @@ import resetPassword from "./resetPassword.vue";
 const { logout } = useNav();
 
 defineOptions({
-  name: "supplierAccoutManage"
+  name: "supplierAccountManage"
 });
 
 const powers = ref([]);

+ 1 - 0
src/views/system/menuOperator/components/edit-dialog.vue

@@ -290,6 +290,7 @@ defineExpose({
           <el-col :span="12">
             <el-form-item label-width="120px" label="菜单权限等级" prop="level">
               <el-select v-model="ruleForm.level">
+                <el-option label="公共" value="0" />
                 <el-option label="超管" value="1" />
                 <el-option label="平台端" value="2" />
                 <el-option label="供应商端" value="3" />