添加数据格式化
This commit is contained in:
parent
ef048efac5
commit
702fc4ba0d
@ -17,7 +17,7 @@
|
||||
"ant-design-vue": "^4.2.6",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"axios": "^1.7.9",
|
||||
"dayjs": "^1.11.10",
|
||||
"dayjs": "^1.11.13",
|
||||
"js-md5": "^0.8.3",
|
||||
"pinia": "^2.3.0",
|
||||
"postcss": "^8.4.49",
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { md5 } from "js-md5";
|
||||
import {md5} from "js-md5";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export function getMd5(str: string) {
|
||||
return md5(str);
|
||||
return md5(str);
|
||||
}
|
||||
|
||||
export function formatDatetime(date: Date | string | number, format = 'YYYY-MM-DD HH:mm:ss') {
|
||||
if (!date) return date;
|
||||
return dayjs(date).format(format);
|
||||
}
|
@ -10,8 +10,10 @@ import { RoleEnum, AllRoleList } from '@/core/enums.ts'
|
||||
import { columns, getList, deleteUser } from "@/service/api/user";
|
||||
import PageHeader from '@/components/page-header.vue'
|
||||
import useRequest from "@/service/useRequest";
|
||||
import {useUserStore} from "@/service/user-store.ts";
|
||||
|
||||
import EditModal from './modal.vue'
|
||||
import {formatDatetime} from "@/core/string.ts";
|
||||
|
||||
const editUser = ref<Partial<UserInfo>>()
|
||||
const searchParams = ref<UserSearchParam>({
|
||||
@ -19,6 +21,7 @@ const searchParams = ref<UserSearchParam>({
|
||||
limit: 10,
|
||||
role: ''
|
||||
})
|
||||
const {userInfo} = useUserStore();
|
||||
|
||||
const { data: allDataList, loading, run, refresh } = useRequest(() => getList(searchParams.value))
|
||||
|
||||
@ -75,7 +78,7 @@ function handleSearch() {
|
||||
</Space>
|
||||
<Space class="form-item" :size="15">
|
||||
<Button :icon="h(SearchOutlined)" type="primary" @click="handleSearch">查询</Button>
|
||||
<Button :icon="h(PlusOutlined)" class="btn-info" @click="editUser = { id: 0 }">新增</Button>
|
||||
<Button v-if="userInfo?.role == 'root'" :icon="h(PlusOutlined)" class="btn-info" @click="editUser = { id: 0 }">新增</Button>
|
||||
</Space>
|
||||
</Space>
|
||||
</div>
|
||||
@ -86,7 +89,7 @@ function handleSearch() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-for="th in columns">{{ th.title }}</th>
|
||||
<th width="150">操作</th>
|
||||
<th width="150" v-if="userInfo?.role == 'root'">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -94,7 +97,9 @@ function handleSearch() {
|
||||
<td>{{ user.nickname }}</td>
|
||||
<td>{{ user.account }}</td>
|
||||
<td>{{ user.role == RoleEnum.ROOT ? '超级管理员' : '管理员' }}</td>
|
||||
<td>
|
||||
<td>{{ formatDatetime(user.created_at) }}</td>
|
||||
<td>{{ user.last_login ?formatDatetime(user.last_login): '-' }}</td>
|
||||
<td v-if="userInfo?.role == 'root'">
|
||||
<Space :size="20">
|
||||
<a @click="editUser = { ...user, password: '' }">编辑</a>
|
||||
<a @click="handleDelete(user.id)">删除</a>
|
||||
|
@ -32,4 +32,6 @@ export const columns = [
|
||||
{ title: '姓名', dataIndex: 'nickname' },
|
||||
{ title: '账号', dataIndex: 'account' },
|
||||
{ title: '角色', dataIndex: 'role' },
|
||||
{ title: '创建时间', dataIndex: 'create_at' },
|
||||
{ title: '最后登录时间', dataIndex: 'last_login' },
|
||||
]
|
@ -923,11 +923,16 @@ csstype@^3.1.1, csstype@^3.1.3:
|
||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz"
|
||||
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
|
||||
|
||||
dayjs@^1.10.5, dayjs@^1.11.10:
|
||||
dayjs@^1.10.5:
|
||||
version "1.11.10"
|
||||
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0"
|
||||
integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==
|
||||
|
||||
dayjs@^1.11.13:
|
||||
version "1.11.13"
|
||||
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c"
|
||||
integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==
|
||||
|
||||
de-indent@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user