Compare commits

...

2 Commits

Author SHA1 Message Date
702fc4ba0d 添加数据格式化 2025-01-09 21:09:19 +08:00
ef048efac5 💄 update style 2025-01-09 20:53:06 +08:00
9 changed files with 39 additions and 15 deletions

View File

@ -17,7 +17,7 @@
"ant-design-vue": "^4.2.6", "ant-design-vue": "^4.2.6",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"axios": "^1.7.9", "axios": "^1.7.9",
"dayjs": "^1.11.10", "dayjs": "^1.11.13",
"js-md5": "^0.8.3", "js-md5": "^0.8.3",
"pinia": "^2.3.0", "pinia": "^2.3.0",
"postcss": "^8.4.49", "postcss": "^8.4.49",

View File

@ -1,5 +1,11 @@
import { md5 } from "js-md5"; import {md5} from "js-md5";
import dayjs from "dayjs";
export function getMd5(str: string) { 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);
} }

View File

@ -1,10 +1,8 @@
import { createApp } from 'vue' import { createApp } from 'vue'
// import 'view-ui-plus/dist/styles/viewuiplus.css'
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import './style.scss' import './style.scss'
// import 'ant-design-vue/dist/reset.css';
import {ClickOutsideDirective} from "./service/click-outside.ts"; import {ClickOutsideDirective} from "./service/click-outside.ts";
createApp(App) createApp(App)

View File

@ -144,6 +144,7 @@ function handleHideModal() {
.app-name { .app-name {
font-size: 16px; font-size: 16px;
font-weight: bold;
padding: 30px 10px 0; padding: 30px 10px 0;
} }
@ -199,7 +200,7 @@ function handleHideModal() {
.app-main-container { .app-main-container {
min-width: 500px; min-width: 500px;
padding: 30px; padding: 20px 30px 30px;
overflow: auto; overflow: auto;
background: #f0f2f0; background: #f0f2f0;
flex: 1; flex: 1;
@ -209,6 +210,11 @@ function handleHideModal() {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 30px; margin-bottom: 30px;
.app-name{
font-size: 24px;
font-weight: bold;
color:#3f3f3f;
}
} }
} }

View File

@ -83,18 +83,20 @@ function handleSearch(){
<div> <div>
<Spin :spinning="loading"> <Spin :spinning="loading">
<table class="table"> <table class="table border">
<thead> <thead>
<tr> <tr>
<th>营养制剂</th> <th>营养制剂</th>
<th>Key</th>
<th v-for="th in ProductCols">{{ th.name }}</th> <th v-for="th in ProductCols">{{ th.name }}</th>
<th width="150">计量单位</th> <th width="100" class="text-center">计量单位</th>
<th width="150">操作</th> <th width="150" class="text-center">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(tr, rowIndex) in allDataList?.list" :key="rowIndex"> <tr v-for="(tr, rowIndex) in allDataList?.list" :key="rowIndex">
<td>{{ tr.name }}</td> <td>{{ tr.name }}</td>
<td>{{ tr.alias }}</td>
<td v-for="th in ProductCols">{{ (tr as any)[th.alias] || 'NULL' }}</td> <td v-for="th in ProductCols">{{ (tr as any)[th.alias] || 'NULL' }}</td>
<td>{{ tr.unit }}</td> <td>{{ tr.unit }}</td>

View File

@ -10,8 +10,10 @@ import { RoleEnum, AllRoleList } from '@/core/enums.ts'
import { columns, getList, deleteUser } from "@/service/api/user"; import { columns, getList, deleteUser } from "@/service/api/user";
import PageHeader from '@/components/page-header.vue' import PageHeader from '@/components/page-header.vue'
import useRequest from "@/service/useRequest"; import useRequest from "@/service/useRequest";
import {useUserStore} from "@/service/user-store.ts";
import EditModal from './modal.vue' import EditModal from './modal.vue'
import {formatDatetime} from "@/core/string.ts";
const editUser = ref<Partial<UserInfo>>() const editUser = ref<Partial<UserInfo>>()
const searchParams = ref<UserSearchParam>({ const searchParams = ref<UserSearchParam>({
@ -19,6 +21,7 @@ const searchParams = ref<UserSearchParam>({
limit: 10, limit: 10,
role: '' role: ''
}) })
const {userInfo} = useUserStore();
const { data: allDataList, loading, run, refresh } = useRequest(() => getList(searchParams.value)) const { data: allDataList, loading, run, refresh } = useRequest(() => getList(searchParams.value))
@ -75,18 +78,18 @@ function handleSearch() {
</Space> </Space>
<Space class="form-item" :size="15"> <Space class="form-item" :size="15">
<Button :icon="h(SearchOutlined)" type="primary" @click="handleSearch">查询</Button> <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>
</Space> </Space>
</div> </div>
<div class="search-result-table"> <div class="search-result-table">
<div> <div>
<Spin :spinning="loading"> <Spin :spinning="loading">
<table class="table"> <table class="table border">
<thead> <thead>
<tr> <tr>
<th v-for="th in columns">{{ th.title }}</th> <th v-for="th in columns">{{ th.title }}</th>
<th>操作</th> <th width="150" v-if="userInfo?.role == 'root'">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -94,7 +97,9 @@ function handleSearch() {
<td>{{ user.nickname }}</td> <td>{{ user.nickname }}</td>
<td>{{ user.account }}</td> <td>{{ user.account }}</td>
<td>{{ user.role == RoleEnum.ROOT ? '超级管理员' : '管理员' }}</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"> <Space :size="20">
<a @click="editUser = { ...user, password: '' }">编辑</a> <a @click="editUser = { ...user, password: '' }">编辑</a>
<a @click="handleDelete(user.id)">删除</a> <a @click="handleDelete(user.id)">删除</a>

View File

@ -32,4 +32,6 @@ export const columns = [
{ title: '姓名', dataIndex: 'nickname' }, { title: '姓名', dataIndex: 'nickname' },
{ title: '账号', dataIndex: 'account' }, { title: '账号', dataIndex: 'account' },
{ title: '角色', dataIndex: 'role' }, { title: '角色', dataIndex: 'role' },
{ title: '创建时间', dataIndex: 'create_at' },
{ title: '最后登录时间', dataIndex: 'last_login' },
] ]

View File

@ -205,7 +205,7 @@ img {
.layout{ .layout{
.menu{ .menu{
min-width: 100px; min-width: 120px;
} }
} }
.menu-text{ .menu-text{

View File

@ -923,11 +923,16 @@ csstype@^3.1.1, csstype@^3.1.3:
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz" resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
dayjs@^1.10.5, dayjs@^1.11.10: dayjs@^1.10.5:
version "1.11.10" version "1.11.10"
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0"
integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== 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: de-indent@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz" resolved "https://registry.npmmirror.com/de-indent/-/de-indent-1.0.2.tgz"