Commit 08c772fede28b35afbb53e4014fcc53f6606d31e

Authored by YunaiV
1 parent 89bd2f6d

1. 将 BasePage 重命名为 PageParam

2. 增加代码注释
3. 调整 menu 重置表单的逻辑,避免写 2 遍 null 的数据
yudao-ui-admin-vue3/src/api/system/errorCode/index.ts
@@ -9,7 +9,7 @@ export interface ErrorCodeVO { @@ -9,7 +9,7 @@ export interface ErrorCodeVO {
9 createTime: string 9 createTime: string
10 } 10 }
11 11
12 -export interface ErrorCodePageReqVO extends BasePage { 12 +export interface ErrorCodePageReqVO extends PageParam {
13 type?: number 13 type?: number
14 applicationName?: string 14 applicationName?: string
15 code?: number 15 code?: number
yudao-ui-admin-vue3/src/api/system/loginLog/index.ts
@@ -12,7 +12,7 @@ export interface LoginLogVO { @@ -12,7 +12,7 @@ export interface LoginLogVO {
12 createTime: string 12 createTime: string
13 } 13 }
14 14
15 -export interface LoginLogReqVO extends BasePage { 15 +export interface LoginLogReqVO extends PageParam {
16 userIp?: string 16 userIp?: string
17 username?: string 17 username?: string
18 status?: boolean 18 status?: boolean
yudao-ui-admin-vue3/src/api/system/menu/index.ts
@@ -20,6 +20,7 @@ export interface MenuPageReqVO { @@ -20,6 +20,7 @@ export interface MenuPageReqVO {
20 name?: string 20 name?: string
21 status?: number 21 status?: number
22 } 22 }
  23 +
23 // 查询菜单(精简)列表 24 // 查询菜单(精简)列表
24 export const listSimpleMenusApi = () => { 25 export const listSimpleMenusApi = () => {
25 return request.get({ url: '/system/menu/list-all-simple' }) 26 return request.get({ url: '/system/menu/list-all-simple' })
yudao-ui-admin-vue3/src/api/system/notice/index.ts
@@ -12,7 +12,7 @@ export interface NoticeVO { @@ -12,7 +12,7 @@ export interface NoticeVO {
12 updateTime: string 12 updateTime: string
13 } 13 }
14 14
15 -export interface NoticePageReqVO extends BasePage { 15 +export interface NoticePageReqVO extends PageParam {
16 title?: string 16 title?: string
17 status?: number 17 status?: number
18 } 18 }
yudao-ui-admin-vue3/src/api/system/oauth2/token.ts
@@ -11,7 +11,7 @@ export interface OAuth2TokenVO { @@ -11,7 +11,7 @@ export interface OAuth2TokenVO {
11 expiresTime: string 11 expiresTime: string
12 } 12 }
13 13
14 -export interface OAuth2TokenPageReqVO extends BasePage { 14 +export interface OAuth2TokenPageReqVO extends PageParam {
15 code?: string 15 code?: string
16 name?: string 16 name?: string
17 status?: number 17 status?: number
yudao-ui-admin-vue3/src/api/system/operatelog/index.ts
@@ -22,7 +22,7 @@ export type OperateLogVO = { @@ -22,7 +22,7 @@ export type OperateLogVO = {
22 resultMsg: string 22 resultMsg: string
23 resultData: string 23 resultData: string
24 } 24 }
25 -export interface OperateLogPageReqVO extends BasePage { 25 +export interface OperateLogPageReqVO extends PageParam {
26 module?: string 26 module?: string
27 userNickname?: string 27 userNickname?: string
28 type?: number 28 type?: number
yudao-ui-admin-vue3/src/api/system/post/index.ts
@@ -10,7 +10,7 @@ export interface PostVO { @@ -10,7 +10,7 @@ export interface PostVO {
10 createTime?: string 10 createTime?: string
11 } 11 }
12 12
13 -export interface PostPageReqVO extends BasePage { 13 +export interface PostPageReqVO extends PageParam {
14 code?: string 14 code?: string
15 name?: string 15 name?: string
16 status?: number 16 status?: number
@@ -31,6 +31,7 @@ export const getPostPageApi = async (params: PostPageReqVO) => { @@ -31,6 +31,7 @@ export const getPostPageApi = async (params: PostPageReqVO) => {
31 export const listSimplePostsApi = async () => { 31 export const listSimplePostsApi = async () => {
32 return await request.get({ url: '/system/post/list-all-simple' }) 32 return await request.get({ url: '/system/post/list-all-simple' })
33 } 33 }
  34 +
34 // 查询岗位详情 35 // 查询岗位详情
35 export const getPostApi = async (id: number) => { 36 export const getPostApi = async (id: number) => {
36 return await request.get({ url: '/system/post/get?id=' + id }) 37 return await request.get({ url: '/system/post/get?id=' + id })
yudao-ui-admin-vue3/src/views/system/menu/index.vue
@@ -277,6 +277,7 @@ import { required } from '@/utils/formRules.js' @@ -277,6 +277,7 @@ import { required } from '@/utils/formRules.js'
277 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' 277 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
278 import { SystemMenuTypeEnum, CommonStatusEnum } from '@/utils/constants' 278 import { SystemMenuTypeEnum, CommonStatusEnum } from '@/utils/constants'
279 import { handleTree } from '@/utils/tree' 279 import { handleTree } from '@/utils/tree'
  280 +import { deepCopy } from 'windicss/utils'
280 281
281 const { t } = useI18n() // 国际化 282 const { t } = useI18n() // 国际化
282 const message = useMessage() // 消息弹窗 283 const message = useMessage() // 消息弹窗
@@ -291,7 +292,7 @@ const actionType = ref('') // 操作按钮的类型 @@ -291,7 +292,7 @@ const actionType = ref('') // 操作按钮的类型
291 const actionLoading = ref(false) // 遮罩层 292 const actionLoading = ref(false) // 遮罩层
292 // 新增和修改的表单值 293 // 新增和修改的表单值
293 const formRef = ref<FormInstance>() 294 const formRef = ref<FormInstance>()
294 -const menuForm = ref<MenuApi.MenuVO>({ 295 +const menuFormNull = {
295 id: 0, 296 id: 0,
296 name: '', 297 name: '',
297 permission: '', 298 permission: '',
@@ -305,7 +306,8 @@ const menuForm = ref&lt;MenuApi.MenuVO&gt;({ @@ -305,7 +306,8 @@ const menuForm = ref&lt;MenuApi.MenuVO&gt;({
305 visible: true, 306 visible: true,
306 keepAlive: true, 307 keepAlive: true,
307 createTime: '' 308 createTime: ''
308 -}) 309 +}
  310 +const menuForm = ref<MenuApi.MenuVO>(menuFormNull)
309 // 新增和修改的表单校验 311 // 新增和修改的表单校验
310 const rules = reactive({ 312 const rules = reactive({
311 name: [required], 313 name: [required],
@@ -323,6 +325,7 @@ const menuProps = { @@ -323,6 +325,7 @@ const menuProps = {
323 value: 'id' 325 value: 'id'
324 } 326 }
325 const menuOptions = ref<any[]>([]) // 树形结构 327 const menuOptions = ref<any[]>([]) // 树形结构
  328 +// 获取下拉框[上级菜单]的数据
326 const getTree = async () => { 329 const getTree = async () => {
327 menuOptions.value = [] 330 menuOptions.value = []
328 const res = await MenuApi.listSimpleMenusApi() 331 const res = await MenuApi.listSimpleMenusApi()
@@ -336,6 +339,7 @@ const queryParams = reactive&lt;MenuApi.MenuPageReqVO&gt;({ @@ -336,6 +339,7 @@ const queryParams = reactive&lt;MenuApi.MenuPageReqVO&gt;({
336 name: undefined, 339 name: undefined,
337 status: undefined 340 status: undefined
338 }) 341 })
  342 +// 执行查询
339 const getList = async () => { 343 const getList = async () => {
340 tableLoading.value = true 344 tableLoading.value = true
341 const res = await MenuApi.getMenuListApi(queryParams) 345 const res = await MenuApi.getMenuListApi(queryParams)
@@ -368,27 +372,14 @@ const setDialogTile = async (type: string) =&gt; { @@ -368,27 +372,14 @@ const setDialogTile = async (type: string) =&gt; {
368 // 新增操作 372 // 新增操作
369 const handleCreate = () => { 373 const handleCreate = () => {
370 setDialogTile('create') 374 setDialogTile('create')
  375 + // 重置表单
371 formRef.value?.resetFields() 376 formRef.value?.resetFields()
372 - menuForm.value = {  
373 - id: 0,  
374 - name: '',  
375 - permission: '',  
376 - type: SystemMenuTypeEnum.DIR,  
377 - sort: 1,  
378 - parentId: 0,  
379 - path: '',  
380 - icon: '',  
381 - component: '',  
382 - status: CommonStatusEnum.ENABLE,  
383 - visible: true,  
384 - keepAlive: true,  
385 - createTime: ''  
386 - } 377 + menuForm.value = deepCopy(menuFormNull)
387 } 378 }
388 379
389 // 修改操作 380 // 修改操作
390 const handleUpdate = async (rowId: number) => { 381 const handleUpdate = async (rowId: number) => {
391 - setDialogTile('update') 382 + await setDialogTile('update')
392 // 设置数据 383 // 设置数据
393 const res = await MenuApi.getMenuApi(rowId) 384 const res = await MenuApi.getMenuApi(rowId)
394 menuForm.value = res 385 menuForm.value = res
yudao-ui-admin-vue3/types/global.d.ts
@@ -37,10 +37,11 @@ declare global { @@ -37,10 +37,11 @@ declare global {
37 data: T extends any ? T : T & any 37 data: T extends any ? T : T & any
38 } 38 }
39 39
40 - declare interface BasePage { 40 + declare interface PageParam {
41 pageSize?: number 41 pageSize?: number
42 pageNo?: number 42 pageNo?: number
43 } 43 }
  44 +
44 declare interface Tree { 45 declare interface Tree {
45 id: number 46 id: number
46 name: string 47 name: string