refactor(auth,settings): add and display time fields for permissions and settings

1. 为权限相关响应schema新增createtime和updatetime字段
2. 在权限接口返回中补充返回创建和更新时间
3. 在设置管理页面新增更新时间列并调整创建时间展示顺序
4. 添加日期时间格式化工具函数
5. 注释删除设置的按钮暂时禁用删除功能
This commit is contained in:
jayhgq 2026-06-10 17:42:20 +08:00
parent 924885e038
commit acb86e4fe1
3 changed files with 31 additions and 5 deletions

View File

@ -90,6 +90,8 @@ async def get_permission_tree(
"code": perm.code, "code": perm.code,
"parentid": perm.parentid, "parentid": perm.parentid,
"description": perm.description, "description": perm.description,
"createtime": perm.createtime,
"updatetime": perm.updatetime,
"children": [] "children": []
} for perm in permissions} } for perm in permissions}
@ -154,6 +156,8 @@ async def get_menu(
"parentid": perm.parentid, "parentid": perm.parentid,
"route": perm.route, "route": perm.route,
"description": perm.description, "description": perm.description,
"createtime": perm.createtime,
"updatetime": perm.updatetime,
"children": [] "children": []
} for perm in user_menu_permissions} } for perm in user_menu_permissions}
@ -351,6 +355,8 @@ async def get_current_user_permissions(
"parentid": perm.parentid, "parentid": perm.parentid,
"route": perm.route, "route": perm.route,
"description": perm.description, "description": perm.description,
"createtime": perm.createtime,
"updatetime": perm.updatetime,
"children": [] "children": []
} for perm in user_menu_permissions} } for perm in user_menu_permissions}

View File

@ -167,6 +167,8 @@ class PermissionTreeResponse(BaseModel):
code: str = Field(..., description="权限编码") code: str = Field(..., description="权限编码")
parentid: int = Field(..., description="父权限ID") parentid: int = Field(..., description="父权限ID")
route: Optional[str] = Field(None, description="前端路由路径") route: Optional[str] = Field(None, description="前端路由路径")
createtime: Optional[datetime] = Field(None, description="创建时间")
updatetime: Optional[datetime] = Field(None, description="更新时间")
description: Optional[str] = Field(None, description="权限描述") description: Optional[str] = Field(None, description="权限描述")
children: list = Field([], description="子权限列表") children: list = Field([], description="子权限列表")

View File

@ -12,6 +12,7 @@
<th>设置键名</th> <th>设置键名</th>
<th>设置值</th> <th>设置值</th>
<th>描述</th> <th>描述</th>
<th>更新时间</th>
<th>创建时间</th> <th>创建时间</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
@ -22,10 +23,11 @@
<td>{{ item.key }}</td> <td>{{ item.key }}</td>
<td class="value-cell">{{ item.value }}</td> <td class="value-cell">{{ item.value }}</td>
<td>{{ item.description || '-' }}</td> <td>{{ item.description || '-' }}</td>
<td>{{ item.createtime }}</td> <td>{{ formatDateTime(item.updatetime) }}</td>
<td>{{ formatDateTime(item.createtime) }}</td>
<td class="actions"> <td class="actions">
<button class="edit-btn" @click="openEditModal(item)">编辑</button> <button class="edit-btn" @click="openEditModal(item)">编辑</button>
<button class="delete-btn" @click="handleDelete(item)">删除</button> <!-- <button class="delete-btn" @click="handleDelete(item)">删除</button> -->
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -62,7 +64,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage } from "element-plus";
// import { ElMessageBox } from "element-plus";
import { http } from "@/modules/admin/api/http"; import { http } from "@/modules/admin/api/http";
interface SettingItem { interface SettingItem {
@ -71,8 +74,23 @@ interface SettingItem {
value: string; value: string;
description: string; description: string;
createtime: string; createtime: string;
updatetime: string;
} }
const formatDateTime = (dateStr: string): string => {
const date = new Date(dateStr);
if (isNaN(date.getTime())) {
return "-";
}
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
const settings = ref<SettingItem[]>([]); const settings = ref<SettingItem[]>([]);
const showModal = ref(false); const showModal = ref(false);
const isEdit = ref(false); const isEdit = ref(false);
@ -119,7 +137,7 @@ const closeModal = () => {
showModal.value = false; showModal.value = false;
}; };
const handleDelete = async (item: SettingItem) => { /* const handleDelete = async (item: SettingItem) => {
try { try {
await ElMessageBox.confirm("确定要删除吗?"); await ElMessageBox.confirm("确定要删除吗?");
await http.delete(`/settings/${item.id}`); await http.delete(`/settings/${item.id}`);
@ -128,7 +146,7 @@ const handleDelete = async (item: SettingItem) => {
} catch (error) { } catch (error) {
ElMessage.error("删除失败"); ElMessage.error("删除失败");
} }
}; }; */
const handleSubmit = async () => { const handleSubmit = async () => {
if (!formData.value.key) { if (!formData.value.key) {