mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-23 11:04:32 +08:00
refactor(components): 移除废弃的Description组件并改用原生antd组件
移除已废弃的Description组件及其相关类型定义和hook,替换为直接使用antd原生Descriptions组件 更新user-reset-pwd-modal和user-info-modal使用新的实现方式
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="tsx">
|
||||
import type { DescriptionsProps } from 'antdv-next';
|
||||
|
||||
import type { User } from '#/api/system/user/model';
|
||||
|
||||
import { computed, shallowRef } from 'vue';
|
||||
@@ -12,7 +14,8 @@ import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
import { findUserInfo } from '#/api/system/user';
|
||||
import { renderDict } from '#/utils/render';
|
||||
import { DictTag } from '#/components/dict';
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(relativeTime);
|
||||
@@ -83,70 +86,74 @@ const diffLoginTime = computed(() => {
|
||||
const diffText = dayjs.duration(diffSeconds, 'seconds').humanize();
|
||||
return diffText;
|
||||
});
|
||||
|
||||
const statusOptions = getDictOptions(DictEnum.SYS_NORMAL_DISABLE);
|
||||
const items = computed<DescriptionsProps['items']>(() => {
|
||||
if (!currentUser.value) {
|
||||
return [];
|
||||
}
|
||||
const { userId, status } = currentUser.value;
|
||||
return [
|
||||
{ label: 'userId', content: userId },
|
||||
{
|
||||
label: '用户状态',
|
||||
content: <DictTag dicts={statusOptions} value={status} />,
|
||||
},
|
||||
{ label: '用户信息', content: mixInfo.value },
|
||||
{ label: '手机号', content: currentUser.value.phonenumber || '-' },
|
||||
{ label: '邮箱', content: currentUser.value.email || '-' },
|
||||
{
|
||||
label: '岗位',
|
||||
content: (
|
||||
<div class="flex flex-wrap gap-0.5">
|
||||
{currentUser.value.postNames.map((item) => (
|
||||
<Tag key={item}>{item}</Tag>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
label: '权限',
|
||||
content: (
|
||||
<div class="flex flex-wrap gap-0.5">
|
||||
{currentUser.value.roleNames.map((item) => (
|
||||
<Tag key={item}>{item}</Tag>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{ label: '创建时间', content: currentUser.value.createTime },
|
||||
{ label: '上次登录IP', content: currentUser.value.loginIp || '-' },
|
||||
{ label: '上次登录时间', content: currentUser.value.loginDate || '-' },
|
||||
{
|
||||
label: '上次登录时间',
|
||||
content: (
|
||||
<>
|
||||
<span>{currentUser.value.loginDate ?? '-'}</span>
|
||||
<Tag
|
||||
bordered={false}
|
||||
class="ml-2"
|
||||
color="processing"
|
||||
v-if="diffLoginTime"
|
||||
>
|
||||
{diffLoginTime}前
|
||||
</Tag>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{ label: '备注', content: currentUser.value.remark || '-' },
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :footer="false" :fullscreen-button="false" title="用户信息">
|
||||
<Descriptions v-if="currentUser" size="small" :column="1" bordered>
|
||||
<Descriptions.Item label="userId">
|
||||
{{ currentUser.userId }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="用户状态">
|
||||
<component
|
||||
:is="renderDict(currentUser.status, DictEnum.SYS_NORMAL_DISABLE)"
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="用户信息">
|
||||
{{ mixInfo }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="手机号">
|
||||
{{ currentUser.phonenumber || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="邮箱">
|
||||
{{ currentUser.email || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="岗位">
|
||||
<div
|
||||
v-if="currentUser.postNames.length > 0"
|
||||
class="flex flex-wrap gap-0.5"
|
||||
>
|
||||
<Tag v-for="item in currentUser.postNames" :key="item">
|
||||
{{ item }}
|
||||
</Tag>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="权限">
|
||||
<div
|
||||
v-if="currentUser.roleNames.length > 0"
|
||||
class="flex flex-wrap gap-0.5"
|
||||
>
|
||||
<Tag v-for="item in currentUser.roleNames" :key="item">
|
||||
{{ item }}
|
||||
</Tag>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
{{ currentUser.createTime }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="上次登录IP">
|
||||
{{ currentUser.loginIp ?? '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="上次登录时间">
|
||||
<span>{{ currentUser.loginDate ?? '-' }}</span>
|
||||
<Tag
|
||||
class="ml-2"
|
||||
v-if="diffLoginTime"
|
||||
:bordered="false"
|
||||
color="processing"
|
||||
>
|
||||
{{ diffLoginTime }}前
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="备注">
|
||||
{{ currentUser.remark ?? '-' }}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Descriptions
|
||||
v-if="currentUser"
|
||||
size="small"
|
||||
:column="1"
|
||||
bordered
|
||||
:items="items"
|
||||
/>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import type { DescriptionsProps } from 'antdv-next';
|
||||
|
||||
import type { ResetPwdParam, User } from '#/api/system/user/model';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal, z } from '@vben/common-ui';
|
||||
|
||||
import { Descriptions, DescriptionsItem } from 'antdv-next';
|
||||
import { Descriptions } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { userResetPassword } from '#/api/system/user';
|
||||
@@ -86,6 +88,17 @@ async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
currentUser.value = null;
|
||||
}
|
||||
|
||||
const items = computed<DescriptionsProps['items']>(() => {
|
||||
if (!currentUser.value) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
{ label: '用户ID', content: currentUser.value.userId },
|
||||
{ label: '用户名', content: currentUser.value.userName },
|
||||
{ label: '昵称', content: currentUser.value.nickName },
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -95,17 +108,7 @@ async function handleClosed() {
|
||||
title="重置密码"
|
||||
>
|
||||
<div class="flex flex-col gap-[12px]">
|
||||
<Descriptions v-if="currentUser" size="small" :column="1" bordered>
|
||||
<DescriptionsItem label="用户ID">
|
||||
{{ currentUser.userId }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="用户名">
|
||||
{{ currentUser.userName }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="昵称">
|
||||
{{ currentUser.nickName }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
<Descriptions size="small" :column="1" bordered :items="items" />
|
||||
<BasicForm />
|
||||
</div>
|
||||
</BasicModal>
|
||||
|
||||
Reference in New Issue
Block a user