Files
GERP/src/components/AdminBadge.vue
T
TermiNexus 2d989d5af1 fix(components): 修正 Boolean prop 缺默认值导致表格退化为只读
Vue 会把未传的 Boolean prop 强制转成 false,而代码按未传=undefined 判定:CrudTable 的 editable 未声明默认值,使 canEdit 恒为 false,所有未传 :editable 的表格操作栏只剩查看,新增/批量删除/行内编辑/删除全部消失(部门详情页部门员工子表即此现象);AdminBadge 的 visible 同样缺默认值,导致特权模式横幅从未显示。

两处均改用 withDefaults 显式声明默认 true,并同步部署产物(entry assets/index-Chv4xcO_.js)。
2026-09-29 13:20:53 +08:00

49 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/**
* AdminBadge 管理员特权模式横幅
*
* 对齐原生 CompanyCommon 的 adminBadge 横幅,在管理员特权模式下显眼提示
* 跨租户/公司隔离已关闭,避免误操作。
*
* 显示条件:
* - visible 不为 false(外部可控)
* - 且(非默认服务器 或 携带 admin_verify=1 标记)
*/
import { computed } from 'vue'
import { isDefaultServer, hasAdminVerifyArg } from '@/utils/serverScope'
const props = withDefaults(defineProps<{
/** 是否显示,默认 true。设为 false 可强制隐藏 */
visible?: boolean
}>(), {
// visible 必须显式给默认值 true:Vue 会把「未传的 Boolean prop」强制转成 false,
// 不给默认值时 props.visible 恒为 false,`visible !== false` 判定失败 → 横幅永不显示
visible: true,
})
// 综合判断:外部未隐藏,且满足特权模式触发条件之一
const show = computed(
() => props.visible !== false && (!isDefaultServer() || hasAdminVerifyArg())
)
</script>
<template>
<!-- 警告色横幅,居中展示,不可关闭 -->
<el-alert
v-if="show"
type="warning"
center
:closable="false"
class="admin-badge"
>
管理员特权模式 - 跨租户/公司隔离已关闭
</el-alert>
</template>
<style scoped lang="scss">
// 横幅底部留白,与下方内容分隔
.admin-badge {
margin-bottom: 12px;
}
</style>