diff --git a/src/common/app/app-api.ts b/src/common/app/app-api.ts index ffc123c..4b23856 100644 --- a/src/common/app/app-api.ts +++ b/src/common/app/app-api.ts @@ -66,4 +66,7 @@ export default { return getFileUrl('/oss/download/' + filename) } }, + changeIdentity(id: string) { + return get('/customer/change_identity', {targetCustomerId: id}) + }, } diff --git a/src/common/app/app-user-store.ts b/src/common/app/app-user-store.ts index dedb4d0..0848372 100644 --- a/src/common/app/app-user-store.ts +++ b/src/common/app/app-user-store.ts @@ -6,6 +6,156 @@ 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([]) @@ -15,12 +165,16 @@ export const useAppUserStore = defineStore('AppUser', () => { const token = ref(null) const tenantId = ref(null) const tenantName = ref(null) + const currentIdentity = ref(null) + const identities = ref([]) const isAuthenticated = computed(() => !Strings.isEmpty(token.value)) + const isXiaoNa = computed(() => { - return false + return roles.value.includes('ROLE_XiaoNa') }) + const isAdmin = computed(() => { - return true + return roles.value.includes('ROLE_ADMIN') }) function $reset() { @@ -48,6 +202,8 @@ export const useAppUserStore = defineStore('AppUser', () => { roles, isXiaoNa, isAdmin, + identities, + currentIdentity, $reset, } }, { diff --git a/src/common/app/index.ts b/src/common/app/index.ts index 9746762..71d658a 100644 --- a/src/common/app/index.ts +++ b/src/common/app/index.ts @@ -5,6 +5,7 @@ import { useAppUserStore } from '@/common/app/app-user-store.ts' import Utils from '@/common/utils' import type { R } from '@/common/utils/http-util.ts' import { MenuCategory } from '@/common/app/constants.ts' +import AppApi from '@/common/app/app-api.ts' const home = { 'id': '-1', @@ -56,9 +57,11 @@ export function hasPermission(resSn?: string) { return res != null } -export function isAdmin() { - const appUserStore = useAppUserStore() - return appUserStore.roles != null && appUserStore.roles.includes('ROLE_ADMIN') +export function changeIdentity(id: string) { + return AppApi.changeIdentity(id) + .then(() => { + return reloadUserInfo() + }) } export function saveFile(r: Promise>, defaultName: string = '下载的文件') { diff --git a/src/dts/components.d.ts b/src/dts/components.d.ts index 578a46e..a2bf8af 100644 --- a/src/dts/components.d.ts +++ b/src/dts/components.d.ts @@ -5,6 +5,7 @@ // ------ // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +import { GlobalComponents } from 'vue' export {} @@ -121,4 +122,4 @@ declare global { const ElUpload: typeof import('element-plus/es')['ElUpload'] const RouterLink: typeof import('vue-router')['RouterLink'] const RouterView: typeof import('vue-router')['RouterView'] -} +} \ No newline at end of file diff --git a/src/pages/login/login.d.ts b/src/pages/login/login.d.ts index a031416..d66beb9 100644 --- a/src/pages/login/login.d.ts +++ b/src/pages/login/login.d.ts @@ -25,6 +25,8 @@ declare global { menus: AppTypes.Menu[] token: string setting: UserSetting + currentCustomerId: string + currentOrgId: string } diff --git a/src/pages/wh/warehouse/Warehouse.vue b/src/pages/wh/warehouse/Warehouse.vue index 7ee373a..057a715 100644 --- a/src/pages/wh/warehouse/Warehouse.vue +++ b/src/pages/wh/warehouse/Warehouse.vue @@ -1,51 +1,18 @@