fix(前端): 后台摘掉公司这一维度——列表列/筛选/建号选择/顶栏旁白全部去掉
用户定案:隔离该由数据和后端自己做,不该把"公司"摆到操作员眼前多一个选错的机会。 于是原计划里给品牌库/去重库两页加公司列(Task 9)反向执行,顺带把一期已上线的展示也收掉。 建号归属改为请求体不带 company_id,由后端 resolveTargetCompanyId 落操作者自己的公司。 这条前端删下拉的安全依据完全靠后端那两条分支撑着,所以用跨仓读 Java 源码的方式钉成可执行断言: 谁把那边改成"必填公司"或删掉任一分支,这边立刻红。 副作用要说清——超管建的号一律归公司 1,给第 2 家建号得用那家公司自己的管理员登录。 「公司管理」页的引导语原写"建号时选哪家公司",下拉没了就成了错的承诺; "停用后不能再用于新建账号"也不再成立(requireActive 两个调用点都要求显式传 company_id, 而页面现在一律不传)。文案改成真实口径,并断言这三句失效说法不得回流。 1683 例 / 0 红,vue-tsc 干净,变异 6/6 被杀。
This commit is contained in:
@@ -15,8 +15,6 @@ export interface UserListParams {
|
||||
adminId?: number | null
|
||||
/** 角色过滤(''=全部)。 */
|
||||
role?: string
|
||||
/** 按所属公司过滤(V143);仅超管用得到——公司内 admin 后端本来就只返回本公司账号。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
|
||||
@@ -28,7 +26,6 @@ export interface UserListQuery {
|
||||
created_by_id?: number
|
||||
admin_id?: number
|
||||
role?: string
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
|
||||
@@ -49,12 +46,6 @@ function finiteInt(value: unknown): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
||||
}
|
||||
|
||||
/** 公司 id 只认正整数:0/负数/NaN 一律当"没筛选",否则会下发一个必然查不到账号的过滤。 */
|
||||
function positiveId(value: unknown): number | null {
|
||||
const id = finiteInt(value)
|
||||
return id !== null && id > 0 ? id : null
|
||||
}
|
||||
|
||||
/** 归一化分页/筛选参数:页码下限 1、页大小 1..上限,空关键字视为无过滤。 */
|
||||
export function normalizeUserPageParams(raw: Partial<UserListParams>): UserListParams {
|
||||
const page = Math.max(finiteInt(raw.page) ?? USER_PAGE_MIN_PAGE, USER_PAGE_MIN_PAGE)
|
||||
@@ -70,7 +61,6 @@ export function normalizeUserPageParams(raw: Partial<UserListParams>): UserListP
|
||||
keyword,
|
||||
createdById: typeof raw.createdById === 'number' ? raw.createdById : null,
|
||||
adminId: typeof raw.adminId === 'number' ? raw.adminId : null,
|
||||
companyId: positiveId(raw.companyId),
|
||||
role: typeof raw.role === 'string' ? raw.role.trim() || undefined : undefined,
|
||||
}
|
||||
}
|
||||
@@ -82,8 +72,6 @@ export function toUserListQuery(params: UserListParams): UserListQuery {
|
||||
if (params.createdById != null) query.created_by_id = params.createdById
|
||||
if (params.adminId != null) query.admin_id = params.adminId
|
||||
if (params.role) query.role = params.role
|
||||
const companyId = positiveId(params.companyId)
|
||||
if (companyId !== null) query.company_id = companyId
|
||||
return query
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@ export function toAdminUserItem(raw: unknown): AdminUser | null {
|
||||
if (updatedAt) item.updatedAt = updatedAt
|
||||
const creator = text(r.creator_username)
|
||||
if (creator) item.creatorUsername = creator
|
||||
// 公司维度只在后端带上时才写键:留 undefined 而不是 null,好让"这版后端没带公司"
|
||||
// 与"账号确实没归属公司"在页面上是两种可读的状态。
|
||||
const companyId = numberOrNull(r.company_id)
|
||||
if (companyId !== null) item.companyId = companyId
|
||||
const companyName = text(r.company_name).trim()
|
||||
if (companyName) item.companyName = companyName
|
||||
const abbr = text(r.pinyin_abbr)
|
||||
if (abbr) item.pinyinAbbr = abbr
|
||||
return item
|
||||
|
||||
@@ -104,9 +104,6 @@ async function signOut() {
|
||||
<NotificationBell />
|
||||
<div class="admin-user-meta">
|
||||
<strong>{{ userVm.username }}</strong>
|
||||
<span v-if="userVm.company" class="admin-user-company" :title="`所属公司:${userVm.company}`">
|
||||
{{ userVm.company }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="userVm.role" class="admin-user-role">{{ userVm.role }}</span>
|
||||
<el-button class="admin-user-logout" @click="signOut">退出登录</el-button>
|
||||
|
||||
@@ -30,7 +30,7 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
steps: ['筛选用户或状态', '立即检测连通性', '必要时清空'],
|
||||
},
|
||||
admin_companies: {
|
||||
text: '公司决定账号归属:建号时选哪家公司,该账号名下的数据就归哪家公司。公司只做启用/停用,不提供删除——停用后不能再用于新建账号。',
|
||||
text: '公司决定账号归属:新建账号自动落在操作者自己所在的公司,页面上不出现公司选项——要给别的公司建号,请用那个公司自己的管理员登录。公司只做启用/停用,不提供删除。',
|
||||
steps: ['查看公司列表', '新建公司', '改名或启停'],
|
||||
},
|
||||
admin_dedupe_total_data: {
|
||||
|
||||
@@ -13,18 +13,15 @@ export function pageTitleOf(title: string | null | undefined): string {
|
||||
export interface TopbarUserViewModel {
|
||||
username: string
|
||||
role: string
|
||||
/** 所属公司名(V143);后端没带就是空串,模板据此整段不显示,不能渲染出 undefined。 */
|
||||
company: string
|
||||
hasUser: boolean
|
||||
}
|
||||
|
||||
/** 顶部栏用户模型:用户信息或未登录空态统一为可渲染视图模型。 */
|
||||
export function topbarUserOf(user: AdminUser | null | undefined): TopbarUserViewModel {
|
||||
if (!user) return { username: '当前用户', role: '', company: '', hasUser: false }
|
||||
if (!user) return { username: '当前用户', role: '', hasUser: false }
|
||||
return {
|
||||
username: user.username || '当前用户',
|
||||
role: roleLabel(user.role) || user.role || '',
|
||||
company: (user.companyName || '').trim(),
|
||||
hasUser: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { submitCreateUser } from './user-create-adapter'
|
||||
import {
|
||||
createEmptyCreateUserForm,
|
||||
initialCompanyId,
|
||||
selectableCompanies,
|
||||
type CreateOperatorScope,
|
||||
type CreateUserForm,
|
||||
type CreateUserFormErrors,
|
||||
validateCreateUserForm,
|
||||
} from './user-create-model'
|
||||
import type { CompanyItem } from '@/api/companies-dto'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||
@@ -20,10 +16,6 @@ const props = defineProps<{
|
||||
operatorSuper?: boolean
|
||||
/** 所属管理员候选(列表响应 admins;仅超管创建普通账号时展示)。 */
|
||||
adminOptions?: Array<{ id: number; username: string }>
|
||||
/** 整份公司目录(GET /api/admin/companies,后端已按操作者收窄)。 */
|
||||
companies?: CompanyItem[]
|
||||
/** 操作者角色与归属:决定公司下拉是否必选。 */
|
||||
operator?: CreateOperatorScope
|
||||
}>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'created'): void }>()
|
||||
|
||||
@@ -31,9 +23,6 @@ const form = reactive<CreateUserForm>(createEmptyCreateUserForm())
|
||||
const errors = reactive<CreateUserFormErrors>({})
|
||||
const busy = ref(false)
|
||||
|
||||
/** 可选项收窄规则与后端 resolveTargetCompanyId 同源,写在这里而不是父页模板里。 */
|
||||
const companyOptions = computed(() => selectableCompanies(props.companies || [], props.operator || {}))
|
||||
|
||||
/** 角色下拉(对齐 admin.html:普通账号/管理员;超管才显示可改)。 */
|
||||
const ROLE_CHOICES: Array<{ value: 'admin' | 'normal'; label: string }> = [
|
||||
{ value: 'normal', label: '普通账号' },
|
||||
@@ -49,10 +38,8 @@ watch(
|
||||
form.role = 'normal'
|
||||
form.columnIds = []
|
||||
form.createdBy = null
|
||||
form.companyId = initialCompanyId(props.operator || {}, props.companies || [])
|
||||
errors.username = undefined
|
||||
errors.password = undefined
|
||||
errors.company = undefined
|
||||
},
|
||||
)
|
||||
|
||||
@@ -61,7 +48,7 @@ function close(): void {
|
||||
}
|
||||
|
||||
async function create(): Promise<void> {
|
||||
const { valid, errors: errs } = validateCreateUserForm(form, props.operator)
|
||||
const { valid, errors: errs } = validateCreateUserForm(form)
|
||||
Object.assign(errors, errs)
|
||||
if (!valid) return
|
||||
busy.value = true
|
||||
@@ -120,22 +107,6 @@ async function create(): Promise<void> {
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="companyOptions.length" label="所属公司" :error="errors.company">
|
||||
<el-select
|
||||
v-model="form.companyId"
|
||||
filterable
|
||||
:placeholder="operatorSuper ? '请选择所属公司' : '所属公司'"
|
||||
style="width: 200px"
|
||||
@change="errors.company = undefined"
|
||||
>
|
||||
<el-option
|
||||
v-for="company in companyOptions"
|
||||
:key="company.id"
|
||||
:label="company.companyName"
|
||||
:value="company.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
|
||||
@@ -8,9 +8,6 @@ import type { AdminUser } from '@/types/admin'
|
||||
import { roleLabel } from '@/types/admin'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { deleteUser, fetchUserList } from '@/api/users'
|
||||
import { fetchCompanies } from '@/api/companies'
|
||||
import type { CompanyItem } from '@/api/companies-dto'
|
||||
import type { CreateOperatorScope } from './user-create-model'
|
||||
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
|
||||
import { totalPageCount } from './user-pagination'
|
||||
import { deleteBlockReason, deleteConfirmMessage } from './user-delete-model'
|
||||
@@ -27,12 +24,6 @@ const rows = ref<AdminUser[]>([])
|
||||
const total = ref(0)
|
||||
/** 所属管理员候选(来自列表响应的 admins),供超管筛选下拉使用。 */
|
||||
const admins = ref<Array<{ id: number; username: string }>>([])
|
||||
/** 公司目录(GET /api/admin/companies):后端已按操作者收窄,前端不再自己判权限。 */
|
||||
const companies = ref<CompanyItem[]>([])
|
||||
const operatorScope = computed<CreateOperatorScope>(() => ({
|
||||
role: session.user?.role,
|
||||
companyId: session.user?.companyId ?? null,
|
||||
}))
|
||||
const filters = reactive<UserFilterState>(createUserFilterState())
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
const currentUserId = computed(() => session.user?.id ?? null)
|
||||
@@ -87,18 +78,6 @@ function retry() {
|
||||
void loadUsers()
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司目录只服务下拉,不参与表格状态机:拉失败时列表照常显示,
|
||||
* 但超管建号会卡在"请选择所属公司"——所以要把原因说出来,别让人对着空下拉猜。
|
||||
*/
|
||||
async function loadCompanies() {
|
||||
try {
|
||||
companies.value = await fetchCompanies()
|
||||
} catch (error) {
|
||||
ElMessage.warning(error instanceof Error ? error.message : '公司目录加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交新筛选条件:重置回第一页再查询。 */
|
||||
function search() {
|
||||
filters.page = 1
|
||||
@@ -143,7 +122,6 @@ function goJump() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadCompanies()
|
||||
void loadUsers()
|
||||
})
|
||||
</script>
|
||||
@@ -162,12 +140,6 @@ onMounted(() => {
|
||||
<label>用户名(模糊搜索)</label>
|
||||
<input v-model="filters.keyword" type="text" placeholder="输入用户名关键字" @keyup.enter="search" />
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="form-group" style="min-width: 160px">
|
||||
<label>所属公司</label>
|
||||
<el-select v-model="filters.companyId" class="admin-filter" filterable clearable placeholder="全部公司" @change="search">
|
||||
<el-option v-for="company in companies" :key="company.id" :label="company.companyName" :value="company.id" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="form-group" style="min-width: 160px">
|
||||
<label>所属管理员</label>
|
||||
<el-select v-model="filters.createdByAdminId" class="admin-filter" filterable clearable placeholder="全部" @change="search">
|
||||
@@ -197,7 +169,6 @@ onMounted(() => {
|
||||
<th style="width: 70px">ID</th>
|
||||
<th style="width: 180px">用户名</th>
|
||||
<th style="width: 140px">角色</th>
|
||||
<th style="width: 140px">所属公司</th>
|
||||
<th style="width: 160px">所属管理员</th>
|
||||
<th style="width: 180px">创建时间</th>
|
||||
<th style="width: 180px">更新时间</th>
|
||||
@@ -210,7 +181,6 @@ onMounted(() => {
|
||||
<td>{{ row.id }}</td>
|
||||
<td>{{ row.username }}</td>
|
||||
<td>{{ roleLabel(row.role) }}</td>
|
||||
<td>{{ row.companyName || '-' }}</td>
|
||||
<td>{{ row.creatorUsername || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
@@ -237,10 +207,10 @@ onMounted(() => {
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="8" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
<td colspan="7" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -253,8 +223,6 @@ onMounted(() => {
|
||||
v-model="createVisible"
|
||||
:operator-super="isSuperAdmin"
|
||||
:admin-options="admins"
|
||||
:companies="companies"
|
||||
:operator="operatorScope"
|
||||
@created="loadUsers"
|
||||
/>
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" @updated="loadUsers" />
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
/** 新建用户表单模型(任务 45):纯逻辑,镜像 Java AdminUserCreateRequest 字段与后端校验。 */
|
||||
|
||||
// 相对路径而非 @/ 别名:本文件被 node --test 直接 import,别名只有 vite 认。
|
||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '../../api/companies-dto.ts'
|
||||
|
||||
export const CREATE_USERNAME_MIN_LEN = 2
|
||||
export const CREATE_PASSWORD_MIN_LEN = 6
|
||||
|
||||
/** 新建用户可选角色:super_admin 不可由表单创建(后端只收 admin|normal)。 */
|
||||
export type CreatableUserRole = 'normal' | 'admin'
|
||||
|
||||
/** 当前操作者的公司归属(来自 /api/admin/current-user)。 */
|
||||
export interface CreateOperatorScope {
|
||||
role?: string | null
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
export interface CreateUserForm {
|
||||
username: string
|
||||
password: string
|
||||
@@ -23,14 +14,11 @@ export interface CreateUserForm {
|
||||
columnIds: number[]
|
||||
/** 所属管理员 id(超管创建普通账号时可指定,对齐 admin 的 created_by_id)。 */
|
||||
createdBy?: number | null
|
||||
/** 所属公司 id(V143)。超管必选;公司内 admin 由后端强制落自己公司。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
export interface CreateUserFormErrors {
|
||||
username?: string
|
||||
password?: string
|
||||
company?: string
|
||||
}
|
||||
|
||||
/** 发送 POST /api/admin/user 的请求体(与 Java AdminUserCreateRequest camelCase 对齐)。 */
|
||||
@@ -41,11 +29,10 @@ export interface CreateUserPayload {
|
||||
columnIds: number[]
|
||||
/** 仅 role=normal 且选了所属管理员时发送,与参考 admin.js 的 created_by_id 语义一致。 */
|
||||
createdById?: number
|
||||
companyId?: number
|
||||
}
|
||||
|
||||
export function createEmptyCreateUserForm(): CreateUserForm {
|
||||
return { username: '', password: '', role: 'normal', columnIds: [], createdBy: null, companyId: null }
|
||||
return { username: '', password: '', role: 'normal', columnIds: [], createdBy: null }
|
||||
}
|
||||
|
||||
/** 未知/空白/超管角色一律归一到 normal,与后端 "admin"/"normal" 白名单一致。 */
|
||||
@@ -53,40 +40,11 @@ export function normalizeCreateRole(role: string | null | undefined): CreatableU
|
||||
return (role || '').trim().toLowerCase() === 'admin' ? 'admin' : 'normal'
|
||||
}
|
||||
|
||||
function positiveInt(value: unknown): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.floor(value) : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 建号能选哪家公司,口径与后端 AdminUserService#resolveTargetCompanyId 一致:
|
||||
* 超管 = 全部启用中的公司(后端 requireActive 会拒停用公司);
|
||||
* 其余角色 = 只有自己也那一家,且不看启停——后端对非超管直接落 operator.companyId、
|
||||
* 不校验状态,前端若跟着过滤就会出现「下拉没得选、提交却能建号」的自相矛盾。
|
||||
*/
|
||||
export function selectableCompanies(companies: CompanyItem[], operator: CreateOperatorScope): CompanyItem[] {
|
||||
const rows = Array.isArray(companies) ? companies : []
|
||||
if (operator?.role === 'super_admin') {
|
||||
return rows.filter((company) => company.status === COMPANY_STATUS_ACTIVE)
|
||||
}
|
||||
const own = positiveInt(operator?.companyId)
|
||||
if (own === null) return []
|
||||
return rows.filter((company) => company.id === own)
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹窗打开时预选哪家公司:候选只有一个(公司内 admin 的本公司)就落它;
|
||||
* 多个(超管)返回 null——给超管填默认值等于替他决定账号挂在哪家,这是会写进库的判断。
|
||||
*/
|
||||
export function initialCompanyId(operator: CreateOperatorScope, companies: CompanyItem[]): number | null {
|
||||
const options = selectableCompanies(companies, operator)
|
||||
return options.length === 1 ? options[0].id : null
|
||||
}
|
||||
|
||||
/** 表单校验(镜像后端:用户名≥2、密码≥6、均必填;超管必须显式选公司);返回逐字段错误。 */
|
||||
export function validateCreateUserForm(
|
||||
form: CreateUserForm,
|
||||
operator?: CreateOperatorScope,
|
||||
): { valid: boolean; errors: CreateUserFormErrors } {
|
||||
/** 表单校验(镜像后端:用户名≥2、密码≥6、均必填);返回逐字段错误。 */
|
||||
export function validateCreateUserForm(form: CreateUserForm): {
|
||||
valid: boolean
|
||||
errors: CreateUserFormErrors
|
||||
} {
|
||||
const errors: CreateUserFormErrors = {}
|
||||
const username = (form.username || '').trim()
|
||||
if (!username) {
|
||||
@@ -100,15 +58,17 @@ export function validateCreateUserForm(
|
||||
} else if (password.length < CREATE_PASSWORD_MIN_LEN) {
|
||||
errors.password = `密码至少${CREATE_PASSWORD_MIN_LEN}个字符`
|
||||
}
|
||||
if (operator?.role === 'super_admin' && positiveInt(form.companyId) === null) {
|
||||
errors.company = '请选择所属公司'
|
||||
}
|
||||
return { valid: Object.keys(errors).length === 0, errors }
|
||||
}
|
||||
|
||||
/** 表单 → 创建请求体:用户名去空格、角色归一、菜单 id 拷贝不共享引用;
|
||||
* createdById 仅在 role=normal 且选了所属管理员时携带(对齐 admin.js 的 created_by_id 语义);
|
||||
* companyId 选了才带,未选时由后端落操作者自己公司。 */
|
||||
/**
|
||||
* 表单 → 创建请求体:用户名去空格、角色归一、菜单 id 拷贝不共享引用;
|
||||
* createdById 仅在 role=normal 且选了所属管理员时携带(对齐 admin.js 的 created_by_id 语义)。
|
||||
*
|
||||
* <p>故意不带 company_id:归属由后端 `AdminUserService#resolveTargetCompanyId` 落操作者自己的公司。
|
||||
* 页面上没有公司可选项(2026-10-04 定案),所以这条是"新账号归哪家公司"的唯一口径 ——
|
||||
* 想给别的公司建号,得用那个公司自己的 admin 登录,不是在这里改请求体。</p>
|
||||
*/
|
||||
export function toCreateUserRequest(form: CreateUserForm): CreateUserPayload {
|
||||
const payload: CreateUserPayload = {
|
||||
username: (form.username || '').trim(),
|
||||
@@ -119,7 +79,5 @@ export function toCreateUserRequest(form: CreateUserForm): CreateUserPayload {
|
||||
if (payload.role === 'normal' && form.createdBy != null) {
|
||||
payload.createdById = form.createdBy
|
||||
}
|
||||
const companyId = positiveInt(form.companyId)
|
||||
if (companyId !== null) payload.companyId = companyId
|
||||
return payload
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ export interface UserFilterState {
|
||||
createdByAdminId: number | null
|
||||
/** 角色过滤(''=全部;super_admin/admin/normal)。 */
|
||||
role: string
|
||||
/** 按所属公司过滤(null=全部);只有超管能用,公司内 admin 看到的本来就是本公司。 */
|
||||
companyId: number | null
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
@@ -20,7 +18,6 @@ export function createUserFilterState(): UserFilterState {
|
||||
keyword: '',
|
||||
createdByAdminId: null,
|
||||
role: '',
|
||||
companyId: null,
|
||||
page: USER_PAGE_MIN_PAGE,
|
||||
pageSize: USER_PAGE_DEFAULT_SIZE,
|
||||
}
|
||||
@@ -29,7 +26,7 @@ export function createUserFilterState(): UserFilterState {
|
||||
/** 修改筛选条件时重置回第一页(避免停在可能越界的旧页)。 */
|
||||
export function withFilterReset(
|
||||
state: UserFilterState,
|
||||
next: Partial<Pick<UserFilterState, 'keyword' | 'createdByAdminId' | 'role' | 'companyId'>>,
|
||||
next: Partial<Pick<UserFilterState, 'keyword' | 'createdByAdminId' | 'role'>>,
|
||||
): UserFilterState {
|
||||
return { ...state, ...next, page: USER_PAGE_MIN_PAGE }
|
||||
}
|
||||
@@ -41,11 +38,7 @@ export function withPage(state: UserFilterState, page: number): UserFilterState
|
||||
|
||||
/** 是否存在生效筛选(仅空白关键字不算)。 */
|
||||
export function isFilterActive(state: UserFilterState): boolean {
|
||||
return (
|
||||
Boolean(state.keyword && state.keyword.trim()) ||
|
||||
state.createdByAdminId != null ||
|
||||
state.companyId != null
|
||||
)
|
||||
return Boolean(state.keyword && state.keyword.trim()) || state.createdByAdminId != null
|
||||
}
|
||||
|
||||
/** 页面状态 → 查询适配层参数(空关键字不下发)。 */
|
||||
@@ -56,7 +49,6 @@ export function toUserListParams(state: UserFilterState): UserListParams {
|
||||
pageSize: state.pageSize,
|
||||
keyword: keyword || undefined,
|
||||
createdById: state.createdByAdminId,
|
||||
companyId: state.companyId,
|
||||
}
|
||||
const role = (state.role || '').trim()
|
||||
if (role) params.role = role
|
||||
|
||||
@@ -106,11 +106,6 @@ button, input, textarea, select { font: inherit; }
|
||||
.admin-user { display: flex; align-items: center; gap: 14px; }
|
||||
.admin-user-meta { display: flex; align-items: flex-end; flex-direction: column; }
|
||||
.admin-user-meta strong { font-size: 13px; font-weight: 600; color: var(--admin-text); }
|
||||
.admin-user-company {
|
||||
max-width: 200px; margin-top: 3px;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
color: #6b8096; font-size: 11.5px;
|
||||
}
|
||||
.admin-user-role {
|
||||
display: inline-flex; align-items: center;
|
||||
padding: 2px 10px; border-radius: 999px; font-size: 12px; line-height: 1.7;
|
||||
|
||||
@@ -11,10 +11,6 @@ export interface AdminUser {
|
||||
isAdmin?: boolean
|
||||
createdById?: number | null
|
||||
creatorUsername?: string
|
||||
/** 所属公司(V143):列表来自 AdminUserItemVo 的 company_id/company_name,
|
||||
* current-user 来自 AdminConsoleController 的 camelCase 摘要。 */
|
||||
companyId?: number | null
|
||||
companyName?: string
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
pinyinAbbr?: string
|
||||
|
||||
Reference in New Issue
Block a user