This commit is contained in:
gr
2026-11-06 13:37:12 +08:00
parent d43cb8da36
commit 20884d8b1a
843 changed files with 5555 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<template>
<el-button v-if="enabled" text :loading="busy" @click="launch">进入甄美 ERP ↗</el-button>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { iamGet, iamPost, identityError } from '@/api/iam-v2'
const enabled = ref(false),
busy = ref(false)
onMounted(async () => {
try {
const status = await iamGet('/status')
enabled.value = !!status.enabled && status.launch_enabled === true
} catch {
enabled.value = false
}
})
async function launch() {
const tab = window.open('about:blank', '_blank')
if (tab) tab.opener = null
busy.value = true
try {
const r = await iamPost('/launch/start')
if (tab) tab.location.href = r.url
else ElMessage.warning('请允许新标签页后再试。')
} catch (e) {
tab?.close()
ElMessage.warning(identityError(e))
} finally {
busy.value = false
}
}
</script>
+137
View File
@@ -0,0 +1,137 @@
<template>
<el-card v-if="status?.enabled || error" class="mt-4" shadow="never">
<template #header
><strong>统一身份 IAM</strong
><el-button class="float-right" text @click="refresh">刷新状态</el-button></template
>
<el-alert v-if="error" :title="error" type="warning" :closable="false" class="mb-4" />
<p>
关联状态:<el-tag :type="linked ? 'success' : 'info'">{{
linked ? '已关联' : status.binding?.state === 'revoked' ? '关联已撤销' : '未关联'
}}</el-tag>
</p>
<p v-if="status.employee" class="my-3">
IAM 员工:{{ status.employee.displayName }}({{ status.employee.username }})
</p>
<p class="my-3 text-gray-500">
关联只确认同一人的身份,不会复制业务角色或自动授予其他平台权限。
</p>
<el-alert
v-if="!linked && status.protected_account"
class="mb-4"
type="warning"
:closable="false"
title="此账号属于敏感账号,请由本地管理员在 IAM 关联管理发起单人中央复核,不使用个人自助绑定。"
/>
<div class="flex flex-wrap gap-3">
<el-button @click="reauthVisible = true">验证当前身份</el-button>
<el-button @click="wecomRelogin">企业微信重新登录</el-button>
<el-button
v-if="!linked && !status.protected_account && status.management_enabled"
type="primary"
:loading="busy"
@click="navigate('/self-link/start')"
>关联已有 IAM 账号</el-button
>
<el-button
v-if="linked && status.management_enabled && status.employee?.passwordSetupPending"
type="primary"
:loading="busy"
@click="navigate('/password-setup')"
>设置 IAM 登录密码</el-button
>
<el-button v-if="linked && status.launch_enabled" :loading="busy" @click="launch">进入甄美 ERP ↗</el-button>
</div>
<el-dialog
v-model="reauthVisible"
title="验证当前 ZYT 身份"
width="420px"
:close-on-click-modal="false"
>
<el-form @submit.prevent="reauth"
><el-form-item label="当前密码"
><el-input
v-model="password"
type="password"
show-password
autocomplete="current-password"
@keyup.enter="reauth" /></el-form-item
></el-form>
<p class="text-gray-500">
仅验证当前账号,验证有效期 5 分钟。密码不会被保存或传给 IAM。
</p>
<template #footer
><el-button @click="cancelReauth">取消</el-button
><el-button type="primary" :loading="busy" @click="reauth"
>验证</el-button
></template
>
</el-dialog>
</el-card>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { iamGet, iamPost, identityError } from '@/api/iam-v2'
import useUserStore from '@/stores/modules/user'
const status = ref<any>({ enabled: false }),
error = ref(''),
busy = ref(false),
reauthVisible = ref(false),
password = ref('')
const linked = computed(() => status.value?.binding?.state === 'verified')
async function refresh() {
try {
status.value = await iamGet('/status')
error.value = ''
} catch (e) {
error.value = identityError(e)
}
}
function cancelReauth() {
reauthVisible.value = false
password.value = ''
}
async function reauth() {
busy.value = true
try {
await iamPost('/reauth', { password: password.value })
reauthVisible.value = false
await refresh()
} catch (e) {
error.value = identityError(e)
} finally {
password.value = ''
busy.value = false
}
}
async function navigate(path: string) {
busy.value = true
try {
const r = await iamPost(path)
window.location.assign(r.url)
} catch (e) {
error.value = identityError(e)
} finally {
busy.value = false
}
}
async function launch() {
const tab = window.open('about:blank', '_blank')
if (tab) tab.opener = null
busy.value = true
try {
const r = await iamPost('/launch/start')
if (tab) tab.location.href = r.url
else error.value = '请允许浏览器打开新标签页后再试。'
} catch (e) {
tab?.close()
error.value = identityError(e)
} finally {
busy.value = false
}
}
async function wecomRelogin() {
await useUserStore().logout()
}
onMounted(refresh)
</script>