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