身份切换
parent
aec179db0d
commit
db70664f18
|
|
@ -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<string | null>(null)
|
||||
const roles = ref<string[]>([])
|
||||
const bizObj = ref<string | null>(null)
|
||||
const nickname = ref<string | null>(null)
|
||||
const avatar = ref<string | null>(null)
|
||||
const token = ref<string | null>(null)
|
||||
const tenantId = ref<string | null>(null)
|
||||
const tenantName = ref<string | null>(null)
|
||||
const currentIdentity = ref<IdentityInfo | null>(null)
|
||||
const identities = ref<IdentityInfo[]>([])
|
||||
const currentCustomerId = ref<string | null>(null)
|
||||
const identities = ref<LoginTypes.IdentityInfo[]>([])
|
||||
const currentIdentity = ref<LoginTypes.IdentityInfo | null>(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<boolean>(false)
|
||||
const isCaiGou = ref<boolean>(false)
|
||||
const hasChanFei = ref<boolean>(false)
|
||||
const isChanFei = ref<boolean>(false)
|
||||
const hasSiJi = ref<boolean>(false)
|
||||
const isSiJi = ref<boolean>(false)
|
||||
const hasXiaoNa = ref<boolean>(false)
|
||||
const isXiaoNa = ref<boolean>(false)
|
||||
const hasYunShu = ref<boolean>(false)
|
||||
const isYunShu = ref<boolean>(false)
|
||||
const isAdmin = ref<boolean>(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' ],
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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<R<{ content: Blob, filename: string }>>, defaultName: string = '下载的文件') {
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
|||
<ElButton text>
|
||||
<AIcon name="settings"/>
|
||||
</ElButton>
|
||||
<ElSelect
|
||||
v-if="!Colls.isEmpty(appUserStore.identities)"
|
||||
:class="{'change-identity-changing':changingIdentity}"
|
||||
:disabled="changingIdentity"
|
||||
:model-value="appUserStore.currentCustomerId"
|
||||
:show-arrow="changingIdentity"
|
||||
:suffix-icon="changingIdentity?elIcons.Loading:elIcons.ArrowDown"
|
||||
class="change-identity" @change="changeIdentityHandle">
|
||||
<ElOption v-for="item in appUserStore.identities"
|
||||
:key="item.identityCategory"
|
||||
:label="item.identityCategoryTxt"
|
||||
:value="item.customerId"/>
|
||||
</ElSelect>
|
||||
</div>
|
||||
<AAvatar/>
|
||||
</div>
|
||||
|
|
@ -62,6 +87,15 @@ onUnmounted(() => {
|
|||
</template>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@keyframes el-select__icon-rotate {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.a-frame {
|
||||
height 100%
|
||||
width 100%;
|
||||
|
|
@ -81,13 +115,35 @@ onUnmounted(() => {
|
|||
|
||||
& > section {
|
||||
height 100%
|
||||
//padding-right 20px
|
||||
|
||||
.a-frame-header {
|
||||
height 110px
|
||||
padding 0 10px 0 0
|
||||
background-color: #FAFBFC;
|
||||
|
||||
.change-identity {
|
||||
width: 120px
|
||||
|
||||
:deep(.el-select__wrapper) {
|
||||
box-shadow: unset !important
|
||||
}
|
||||
|
||||
:deep(.el-select__wrapper.is-disabled) {
|
||||
background-color unset !important
|
||||
}
|
||||
|
||||
|
||||
:deep(.el-select__icon) {
|
||||
color var(--el-color-primary)
|
||||
}
|
||||
}
|
||||
|
||||
.change-identity-changing {
|
||||
:deep(.el-select__icon) {
|
||||
animation: el-select__icon-rotate 1s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
& > div:nth-child(1) {
|
||||
height 60px
|
||||
width 100%
|
||||
|
|
|
|||
|
|
@ -14,10 +14,160 @@ declare global {
|
|||
logo: string | null
|
||||
}
|
||||
|
||||
interface IdentityInfo {
|
||||
identityCategory: string
|
||||
identityCategoryTxt: 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
|
||||
}
|
||||
|
||||
interface UserDetail {
|
||||
id: string
|
||||
nickname: string
|
||||
bizObj?: string
|
||||
avatar?: string
|
||||
tenantId?: string
|
||||
tenantName?: string
|
||||
|
|
@ -27,6 +177,19 @@ declare global {
|
|||
setting: UserSetting
|
||||
currentCustomerId: string
|
||||
currentOrgId: string
|
||||
hasCaiGou: boolean
|
||||
isCaiGou: boolean
|
||||
hasChanFei: boolean
|
||||
isChanFei: boolean
|
||||
hasSiJi: boolean
|
||||
isSiJi: boolean
|
||||
hasXiaoNa: boolean
|
||||
isXiaoNa: boolean
|
||||
hasYunShu: boolean
|
||||
isYunShu: boolean
|
||||
isAdmin: boolean
|
||||
identities: IdentityInfo[]
|
||||
currentIdentity: IdentityInfo
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue