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:
parent
924885e038
commit
acb86e4fe1
@ -90,6 +90,8 @@ async def get_permission_tree(
|
||||
"code": perm.code,
|
||||
"parentid": perm.parentid,
|
||||
"description": perm.description,
|
||||
"createtime": perm.createtime,
|
||||
"updatetime": perm.updatetime,
|
||||
"children": []
|
||||
} for perm in permissions}
|
||||
|
||||
@ -154,6 +156,8 @@ async def get_menu(
|
||||
"parentid": perm.parentid,
|
||||
"route": perm.route,
|
||||
"description": perm.description,
|
||||
"createtime": perm.createtime,
|
||||
"updatetime": perm.updatetime,
|
||||
"children": []
|
||||
} for perm in user_menu_permissions}
|
||||
|
||||
@ -351,6 +355,8 @@ async def get_current_user_permissions(
|
||||
"parentid": perm.parentid,
|
||||
"route": perm.route,
|
||||
"description": perm.description,
|
||||
"createtime": perm.createtime,
|
||||
"updatetime": perm.updatetime,
|
||||
"children": []
|
||||
} for perm in user_menu_permissions}
|
||||
|
||||
|
||||
@ -167,6 +167,8 @@ class PermissionTreeResponse(BaseModel):
|
||||
code: str = Field(..., description="权限编码")
|
||||
parentid: int = Field(..., description="父权限ID")
|
||||
route: Optional[str] = Field(None, description="前端路由路径")
|
||||
createtime: Optional[datetime] = Field(None, description="创建时间")
|
||||
updatetime: Optional[datetime] = Field(None, description="更新时间")
|
||||
description: Optional[str] = Field(None, description="权限描述")
|
||||
children: list = Field([], description="子权限列表")
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
<th>设置键名</th>
|
||||
<th>设置值</th>
|
||||
<th>描述</th>
|
||||
<th>更新时间</th>
|
||||
<th>创建时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@ -22,10 +23,11 @@
|
||||
<td>{{ item.key }}</td>
|
||||
<td class="value-cell">{{ item.value }}</td>
|
||||
<td>{{ item.description || '-' }}</td>
|
||||
<td>{{ item.createtime }}</td>
|
||||
<td>{{ formatDateTime(item.updatetime) }}</td>
|
||||
<td>{{ formatDateTime(item.createtime) }}</td>
|
||||
<td class="actions">
|
||||
<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>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -62,7 +64,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
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";
|
||||
|
||||
interface SettingItem {
|
||||
@ -71,8 +74,23 @@ interface SettingItem {
|
||||
value: string;
|
||||
description: 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 showModal = ref(false);
|
||||
const isEdit = ref(false);
|
||||
@ -119,7 +137,7 @@ const closeModal = () => {
|
||||
showModal.value = false;
|
||||
};
|
||||
|
||||
const handleDelete = async (item: SettingItem) => {
|
||||
/* const handleDelete = async (item: SettingItem) => {
|
||||
try {
|
||||
await ElMessageBox.confirm("确定要删除吗?");
|
||||
await http.delete(`/settings/${item.id}`);
|
||||
@ -128,7 +146,7 @@ const handleDelete = async (item: SettingItem) => {
|
||||
} catch (error) {
|
||||
ElMessage.error("删除失败");
|
||||
}
|
||||
};
|
||||
}; */
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.value.key) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user