From db70664f18c0a55da866923b9404681a2aa97362 Mon Sep 17 00:00:00 2001 From: lzq <2495532633@qq.com> Date: Mon, 2 Mar 2026 18:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/app/app-user-store.ts | 205 +++++++------------------------ src/common/app/index.ts | 19 ++- src/pages/a-frame/AFrame.vue | 58 ++++++++- src/pages/login/login.d.ts | 165 ++++++++++++++++++++++++- 4 files changed, 277 insertions(+), 170 deletions(-) diff --git a/src/common/app/app-user-store.ts b/src/common/app/app-user-store.ts index 0848372..ebe3874 100644 --- a/src/common/app/app-user-store.ts +++ b/src/common/app/app-user-store.ts @@ -6,176 +6,29 @@ import { import Strings from '@/common/utils/strings.ts' import Evt from '@/common/utils/evt.ts' -interface IdentityInfo { - identityCategory: string - - customerId: string - - /** - * 组织信息 Id;cst_org.id - */ - orgId: string - - /** - * 客户姓名 - */ - customerName: string - - /** - * 客户联系电话 - */ - phone: string - - /** - * 结算方式,YueJie-->月结、YuE-->余额、XianFu-->现付 - */ - settlementWay: string - - settlementWayTxt: string - - /** - * 是否管理员;是否为当前的组织管理员,0-->否、1-->是 - */ - manager: boolean - - - /** - * 主体类型,GeTiHu-->个体户、QiYe-->企业 - */ - orgCategory: string - orgCategoryTxt: string - - /** - * 统一社会信用代码 - */ - uscc: string - - /** - * 组织名称 - */ - orgName: string - - /** - * 营业执照 - */ - businessLicense: string - - /** - * 营业执照有效期 - */ - licenseStartTime: string - - /** - * 营业执照有效期 - */ - licenseEndTime: string - - /** - * 法人名称 - */ - legalRepresentative: string - - /** - * 法人身份证号 - */ - idcard: string - - /** - * 法人身份证有效期 - */ - idcardStartTime: string - - /** - * 法人身份证有效期 - */ - idcardEndTime: string - - /** - * 法人身份证正面 - */ - idcardFront: string - - /** - * 法人身份证反面 - */ - idcardBack: string - - /** - * 省;代码 - */ - province: string - - /** - * 市;代码 - */ - city: string - - /** - * 区县;代码 - */ - area: string - - /** - * 乡镇街道;代码 - */ - town: string - - /** - * 省;名称 - */ - provinceName: string - - /** - * 市;名称 - */ - cityName: string - - /** - * 区县;名称 - */ - areaName: string - - /** - * 乡镇街道;名称 - */ - townName: string - - /** - * 详细地址 - */ - address: string - - /** - * 经度 - */ - lng: string - - /** - * 纬度 - */ - lat: string -} - export const useAppUserStore = defineStore('AppUser', () => { const userId = ref(null) const roles = ref([]) - const bizObj = ref(null) const nickname = ref(null) const avatar = ref(null) const token = ref(null) const tenantId = ref(null) const tenantName = ref(null) - const currentIdentity = ref(null) - const identities = ref([]) + const currentCustomerId = ref(null) + const identities = ref([]) + const currentIdentity = ref(null) const isAuthenticated = computed(() => !Strings.isEmpty(token.value)) - - const isXiaoNa = computed(() => { - return roles.value.includes('ROLE_XiaoNa') - }) - - const isAdmin = computed(() => { - return roles.value.includes('ROLE_ADMIN') - }) + const hasCaiGou = ref(false) + const isCaiGou = ref(false) + const hasChanFei = ref(false) + const isChanFei = ref(false) + const hasSiJi = ref(false) + const isSiJi = ref(false) + const hasXiaoNa = ref(false) + const isXiaoNa = ref(false) + const hasYunShu = ref(false) + const isYunShu = ref(false) + const isAdmin = ref(false) function $reset() { userId.value = null @@ -184,8 +37,23 @@ export const useAppUserStore = defineStore('AppUser', () => { token.value = null tenantId.value = null tenantName.value = null - bizObj.value = null roles.value = [] + currentCustomerId.value = null + currentIdentity.value = null + identities.value = [] + tenantId.value = null + tenantName.value = null + hasCaiGou.value = false + isCaiGou.value = false + hasChanFei.value = false + isChanFei.value = false + hasSiJi.value = false + isSiJi.value = false + hasXiaoNa.value = false + isXiaoNa.value = false + hasYunShu.value = false + isYunShu.value = false + isAdmin.value = false } Evt.on('logout', $reset) @@ -197,18 +65,27 @@ export const useAppUserStore = defineStore('AppUser', () => { token, tenantId, tenantName, - bizObj, isAuthenticated, roles, + hasCaiGou, + isCaiGou, + hasChanFei, + isChanFei, + hasSiJi, + isSiJi, + hasXiaoNa, isXiaoNa, + hasYunShu, + isYunShu, isAdmin, identities, currentIdentity, + currentCustomerId, $reset, } }, { persist: { - pick: [ 'userId', 'avatar', 'nickname', 'token', 'tenantId', 'tenantName', 'bizObj' ], + pick: [ 'userId', 'avatar', 'nickname', 'token', 'tenantId', 'tenantName' ], }, }) diff --git a/src/common/app/index.ts b/src/common/app/index.ts index 71d658a..7edb2c2 100644 --- a/src/common/app/index.ts +++ b/src/common/app/index.ts @@ -45,8 +45,21 @@ export function reloadUserInfo() { avatar: data.avatar, tenantId: data.tenantId, tenantName: data.tenantName, - bizObj: data.bizObj, roles: data.roles, + currentCustomerId: data.currentCustomerId, + identities: data.identities, + currentIdentity: data.currentIdentity, + hasCaiGou: data.hasCaiGou, + isCaiGou: data.isCaiGou, + hasChanFei: data.hasChanFei, + isChanFei: data.isChanFei, + hasSiJi: data.hasSiJi, + isSiJi: data.isSiJi, + hasXiaoNa: data.hasXiaoNa, + isXiaoNa: data.isXiaoNa, + hasYunShu: data.hasYunShu, + isYunShu: data.isYunShu, + isAdmin: data.isAdmin, }) }) } @@ -59,9 +72,7 @@ export function hasPermission(resSn?: string) { export function changeIdentity(id: string) { return AppApi.changeIdentity(id) - .then(() => { - return reloadUserInfo() - }) + .then(reloadUserInfo) } export function saveFile(r: Promise>, defaultName: string = '下载的文件') { diff --git a/src/pages/a-frame/AFrame.vue b/src/pages/a-frame/AFrame.vue index c581284..45d977b 100644 --- a/src/pages/a-frame/AFrame.vue +++ b/src/pages/a-frame/AFrame.vue @@ -6,10 +6,22 @@ import AIcon from '@/components/a-icon/AIcon.vue' import { useAppPageStore } from '@/common/app/app-page-store.ts' import { elIcons } from '@/common/element/element.ts' import ATabbar from '@/pages/a-frame/ATabbar.vue' +import { useAppUserStore } from '@/common/app/app-user-store.ts' +import { changeIdentity } from '@/common/app' +import Colls from '@/common/utils/colls.ts' const appPageStore = useAppPageStore() const isCollapse = ref(false) +const changingIdentity = ref(false) +const appUserStore = useAppUserStore() +function changeIdentityHandle(val: string) { + changingIdentity.value = true + changeIdentity(val) + .finally(() => { + changingIdentity.value = false + }) +} onMounted(() => { Evt.emit('connect_ws') @@ -42,6 +54,19 @@ onUnmounted(() => { + + + @@ -62,6 +87,15 @@ onUnmounted(() => {