diff --git a/README.md b/README.md index a9b100d89..f514c732a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ - [react 版 coding](https://github.com/buqiyuan/react-antd-admin) - [vite 版](https://github.com/buqiyuan/vite-vue3-admin) - [gitee 地址](https://gitee.com/buqiyuan/vue3-antd-admin) +- 根据 JSON 生成 typescript 的工具:[http://json2ts.com/](http://json2ts.com/) ## vscode 配置 @@ -30,7 +31,7 @@ - [ ] 纯前端导出 PDF 自动分页 - [ ] 其他... -## Project setup +### Project setup ```shell yarn install @@ -38,7 +39,7 @@ yarn install yarn --frozen-lockfile ``` -## 赞赏 +### 赞赏 如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持! @@ -46,7 +47,11 @@ yarn --frozen-lockfile | :-: | :-: | | ![donate](http://buqiyuan.gitee.io/images/weixin.jpg) | ![donate](http://buqiyuan.gitee.io/images/zhifubao.jpg) | -## 感谢 JetBrains 免费的开源授权 +### 致谢 + +- [sf-vue-admin](https://github.com/hackycy/sf-vue-admin) + +### 感谢 JetBrains 免费的开源授权 diff --git a/src/api/system/dept/model.d.ts b/src/api/system/dept/model.d.ts index 33a369cc8..5730ba338 100644 --- a/src/api/system/dept/model.d.ts +++ b/src/api/system/dept/model.d.ts @@ -7,7 +7,7 @@ declare namespace API { parentId: number; name: string; orderNum: number; - pIds?: number[]; + keyPath?: number[]; }; /** 部门 */ type MovedDeptItem = { diff --git a/src/api/system/menu/model.d.ts b/src/api/system/menu/model.d.ts index 34566fb1f..504ca9077 100644 --- a/src/api/system/menu/model.d.ts +++ b/src/api/system/menu/model.d.ts @@ -13,7 +13,7 @@ declare namespace API { viewPath: string; keepalive: boolean; isShow: boolean; - pIds?: number[]; + keyPath?: number[]; }; /** 获取菜单列表参数 */ diff --git a/src/api/system/serve/index.ts b/src/api/system/serve/index.ts new file mode 100644 index 000000000..75d9f77c2 --- /dev/null +++ b/src/api/system/serve/index.ts @@ -0,0 +1,9 @@ +import { request } from '@/utils/request'; +import ServeApi from '@/core/permission/modules/sys/serve'; + +export function getServeStat() { + return request({ + url: ServeApi.stat, + method: 'get', + }); +} diff --git a/src/api/system/serve/model.d.ts b/src/api/system/serve/model.d.ts new file mode 100644 index 000000000..05bee05cd --- /dev/null +++ b/src/api/system/serve/model.d.ts @@ -0,0 +1,42 @@ +declare namespace API { + export interface Runtime { + os: string; + arch: string; + nodeVersion: string; + npmVersion: string; + } + + export interface CoresLoad { + rawLoad: number; + rawLoadIdle: number; + } + + export interface Cpu { + manufacturer: string; + brand: string; + physicalCores: number; + model: string; + speed: number; + rawCurrentLoad: number; + rawCurrentLoadIdle: number; + coresLoad: CoresLoad[]; + } + + export interface Disk { + size: number; + used: number; + available: number; + } + + export interface Memory { + total: number; + available: number; + } + + export interface SysServeStat { + runtime: Runtime; + cpu: Cpu; + disk: Disk; + memory: Memory; + } +} diff --git a/src/api/system/user/model.d.ts b/src/api/system/user/model.d.ts index 0c17847c2..16fd20290 100644 --- a/src/api/system/user/model.d.ts +++ b/src/api/system/user/model.d.ts @@ -14,6 +14,7 @@ declare namespace API { username: string; departmentName: string; roleNames: string[]; + keyPath?: number[]; }; /** 获取用户列表结果 */ diff --git a/src/api/typings.d.ts b/src/api/typings.d.ts index 39e2abe49..da95764be 100644 --- a/src/api/typings.d.ts +++ b/src/api/typings.d.ts @@ -3,102 +3,102 @@ declare namespace API { type CurrentUser = { - name?: string - avatar?: string - userid?: string - email?: string - signature?: string - title?: string - group?: string - tags?: { key?: string; label?: string }[] - notifyCount?: number - unreadCount?: number - country?: string - access?: string + name?: string; + avatar?: string; + userid?: string; + email?: string; + signature?: string; + title?: string; + group?: string; + tags?: { key?: string; label?: string }[]; + notifyCount?: number; + unreadCount?: number; + country?: string; + access?: string; geographic?: { - province?: { label?: string; key?: string } - city?: { label?: string; key?: string } - } - address?: string - phone?: string - } + province?: { label?: string; key?: string }; + city?: { label?: string; key?: string }; + }; + address?: string; + phone?: string; + }; /** 全局通过表格查询返回结果 */ type TableListResult = { - list: T - pagination: PaginationResult - } + list: T; + pagination?: PaginationResult; + }; /** 全局通用表格分页返回数据结构 */ type PaginationResult = { - page: number - size: number - total: number - } + page: number; + size: number; + total: number; + }; /** 全局通用表格分页请求参数 */ type PageParams = { - limit?: number - page?: number + limit?: number; + page?: number; } & { - [P in keyof T]?: T[P] - } + [P in keyof T]?: T[P]; + }; type RuleListItem = { - key?: number - disabled?: boolean - href?: string - avatar?: string - name?: string - owner?: string - desc?: string - callNo?: number - status?: number - updatedAt?: string - createdAt?: string - progress?: number - } + key?: number; + disabled?: boolean; + href?: string; + avatar?: string; + name?: string; + owner?: string; + desc?: string; + callNo?: number; + status?: number; + updatedAt?: string; + createdAt?: string; + progress?: number; + }; type RuleList = { - data?: RuleListItem[] + data?: RuleListItem[]; /** 列表的内容总数 */ - total?: number - success?: boolean - } + total?: number; + success?: boolean; + }; type FakeCaptcha = { - code?: number - status?: string - } + code?: number; + status?: string; + }; type ErrorResponse = { /** 业务约定的错误码 */ - errorCode: string + errorCode: string; /** 业务上的错误信息 */ - errorMessage?: string + errorMessage?: string; /** 业务上的请求是否成功 */ - success?: boolean - } + success?: boolean; + }; type NoticeIconList = { - data?: NoticeIconItem[] + data?: NoticeIconItem[]; /** 列表的内容总数 */ - total?: number - success?: boolean - } + total?: number; + success?: boolean; + }; - type NoticeIconItemType = 'notification' | 'message' | 'event' + type NoticeIconItemType = 'notification' | 'message' | 'event'; type NoticeIconItem = { - id?: string - extra?: string - key?: string - read?: boolean - avatar?: string - title?: string - status?: string - datetime?: string - description?: string - type?: NoticeIconItemType - } + id?: string; + extra?: string; + key?: string; + read?: boolean; + avatar?: string; + title?: string; + status?: string; + datetime?: string; + description?: string; + type?: NoticeIconItemType; + }; } diff --git a/src/components/JSON-schema-form/schema-form-item.vue b/src/components/JSON-schema-form/schema-form-item.vue index cd9085f80..e20ec80d8 100644 --- a/src/components/JSON-schema-form/schema-form-item.vue +++ b/src/components/JSON-schema-form/schema-form-item.vue @@ -14,9 +14,9 @@ :is="getComponent" :ref="setItemRef" :key="schemaItem.field" - v-model:[modelValueType]="modelValue[schemaItem.field]" v-bind="getComponentProps" v-on="componentEvents" + v-model:[modelValueType]="modelValue[schemaItem.field]" /> @@ -29,7 +29,7 @@ import type { ValidationRule } from 'ant-design-vue/lib/form/Form'; import { componentMap, ComponentMapType } from './componentMap'; import { FormItemSchema, FormSchema } from './types/form'; - import { isFunction, isNull, isString, isObject } from '@/utils/is'; + import { isFunction, isNull, isString } from '@/utils/is'; import { useVModel } from '@vueuse/core'; import { useItemLabelWidth } from './hooks/useLabelWidth'; import cloneDeep from 'lodash/cloneDeep'; @@ -61,9 +61,11 @@ }, }); + const emit = defineEmits(['update:formModel']); + // const currentInstance = getCurrentInstance(); - const modelValue = useVModel(props, 'formModel'); + const modelValue = useVModel(props, 'formModel', emit); const { schemaItem, schema } = toRefs(props) as { schemaItem: Ref; @@ -79,8 +81,8 @@ const modelValueType = computed(() => { const { component, componentProps } = schemaItem.value; - if (isObject(componentProps) && isString(componentProps?.vModelKey)) { - return componentProps?.vModelKey; + if (typeof componentProps !== 'function' && componentProps?.vModelKey) { + return componentProps.vModelKey; } const isCheck = isString(component) && ['Switch', 'Checkbox'].includes(component); return isCheck ? 'checked' : 'value'; @@ -170,10 +172,10 @@ }); const getComponentsProps = computed(() => { - const { schemaItem, tableAction, formModel, formActionType } = props; + const { schemaItem, formModel } = props; let { componentProps = {} } = schemaItem; if (isFunction(componentProps)) { - componentProps = componentProps({ schemaItem, tableAction, formModel, formActionType }) ?? {}; + componentProps = componentProps({ schemaItem, formModel }) ?? {}; } return componentProps as Recordable; }); diff --git a/src/components/dynamic-table/components/query-form/index.vue b/src/components/dynamic-table/components/query-form/index.vue index 916ab4fbb..0fd1c9520 100644 --- a/src/components/dynamic-table/components/query-form/index.vue +++ b/src/components/dynamic-table/components/query-form/index.vue @@ -112,8 +112,9 @@ return 24 - remainder; }; - const reset = () => { + const reset = async () => { dynamicFormRef.value?.resetFields(); + await query(); }; const query = async () => { const formModel = await dynamicFormRef.value?.validate(); diff --git a/src/components/dynamic-table/components/table-settings/column-setting.vue b/src/components/dynamic-table/components/table-settings/column-setting.vue index f357f568e..256c74ab8 100644 --- a/src/components/dynamic-table/components/table-settings/column-setting.vue +++ b/src/components/dynamic-table/components/table-settings/column-setting.vue @@ -85,7 +85,7 @@ const defaultShowIndex = !!table.showIndex; const defaultBordered = table.bordered; - const tableColumns = ref([]); + const tableColumns = ref[]>([]); const checkAll = computed({ get() { @@ -129,7 +129,7 @@ table.setProps({ bordered: e.target.checked }); }; - const handleColumnFixed = (columItem: TableColumn, direction: 'left' | 'right') => { + const handleColumnFixed = (columItem: TableColumn, direction: 'left' | 'right') => { columItem.fixed = columItem.fixed === direction ? false : direction; }; diff --git a/src/components/dynamic-table/hooks/usePagination.ts b/src/components/dynamic-table/hooks/usePagination.ts index 2590c3b6b..1c88bfeba 100644 --- a/src/components/dynamic-table/hooks/usePagination.ts +++ b/src/components/dynamic-table/hooks/usePagination.ts @@ -13,7 +13,7 @@ export function usePagination(pageOption: Pagination) { current: 1, pageSize: 10, total: 0, - pageSizeOptions: ['10', '20', '30', '40', '50'], + pageSizeOptions: ['10', '20', '50', '100'], showQuickJumper: true, showSizeChanger: true, // 显示可改变每页数量 showTotal: (total) => `共 ${total} 条`, // 显示总数 diff --git a/src/components/dynamic-table/hooks/useTableContext.ts b/src/components/dynamic-table/hooks/useTableContext.ts index c636ccd95..f3b75a8be 100644 --- a/src/components/dynamic-table/hooks/useTableContext.ts +++ b/src/components/dynamic-table/hooks/useTableContext.ts @@ -6,6 +6,7 @@ type DynamicTableInstance = { } & { setProps(props: Partial): () => any; getProps: TableProps; + refreshTable: (...rest: any[]) => any; }; const key = Symbol('dynamic-table'); diff --git a/src/components/progress/index.vue b/src/components/progress/index.vue new file mode 100644 index 000000000..794ce3992 --- /dev/null +++ b/src/components/progress/index.vue @@ -0,0 +1,33 @@ + + + diff --git a/src/core/permission/modules/sys/index.ts b/src/core/permission/modules/sys/index.ts index e1b086fe6..1ac244f89 100644 --- a/src/core/permission/modules/sys/index.ts +++ b/src/core/permission/modules/sys/index.ts @@ -5,6 +5,7 @@ import { SysOnlinePerms } from './online'; import { SysRolePerms } from './role'; import { SysTaskPerms } from './task'; import { SysUserPerms } from './user'; +import { SysServePerms } from './serve'; export type SysPermissionType = | SysLogPerms @@ -13,4 +14,5 @@ export type SysPermissionType = | SysOnlinePerms | SysRolePerms | SysTaskPerms + | SysServePerms | SysUserPerms; diff --git a/src/core/permission/modules/sys/serve.ts b/src/core/permission/modules/sys/serve.ts new file mode 100644 index 000000000..8b2008ad3 --- /dev/null +++ b/src/core/permission/modules/sys/serve.ts @@ -0,0 +1,9 @@ +export const sysServe = { + stat: 'sys/serve/stat', +} as const; + +export const values = Object.values(sysServe); + +export type SysServePerms = typeof values[number]; + +export default sysServe; diff --git a/src/core/permission/utils.ts b/src/core/permission/utils.ts index 55aa32476..6f2155d8b 100644 --- a/src/core/permission/utils.ts +++ b/src/core/permission/utils.ts @@ -8,16 +8,20 @@ export interface TreeDataItem extends ATreeDataItem { * 渲染部门至树形控件 * @param {Array} depts 所有部门 * @param {Number | null} parentId 父级部门ID + * @param {number[]|string[]} keyPath ID路径 */ export const formatDept2Tree = ( depts: API.SysDeptListResult[], parentId: number | null = null, + keyPath: (string | number)[] = [], ): TreeDataItem[] => { return depts .filter((item) => item.parentId === parentId) .map((item) => { - const arr = formatDept2Tree(depts, item.id); + const _keyPath = keyPath.concat(parentId || []); + const arr = formatDept2Tree(depts, item.id, _keyPath); return Object.assign(item, { + keyPath: _keyPath, title: item.name, key: item.id, value: item.id, @@ -31,16 +35,20 @@ export const formatDept2Tree = ( * 渲染菜单至树形控件 * @param {Array} menus 所有菜单 * @param {Number | null} parentId 父级菜单ID + * @param {number[]|string[]} keyPath ID路径 */ export const formatMenu2Tree = ( menus: API.MenuListResult, parentId: number | null = null, + keyPath: (string | number)[] = [], ): TreeDataItem[] => { return menus .filter((item) => item.parentId === parentId) .map((item) => { - const arr = formatMenu2Tree(menus, item.id); + const _keyPath = keyPath.concat(parentId || []); + const arr = formatMenu2Tree(menus, item.id, _keyPath); return Object.assign(item, { + keyPath: _keyPath, title: item.name, key: item.id, value: item.id, @@ -49,3 +57,29 @@ export const formatMenu2Tree = ( }); }); }; + +/** + * 在树中根据ID找child + * @param {string|number} id + * @param {any[]} treeData 树形数据 + * @param {string} keyName 指定ID的属性名,默认是id + * @param {string} children 指定children的属性名,默认是children + */ +export const findChildById = ( + id, + treeData: T[] = [], + keyName = 'id', + children = 'children', +) => { + return treeData.reduce((prev, curr) => { + if (curr[keyName] === id) { + return curr; + } + if (prev) { + return prev; + } + if (curr[children]?.length) { + return findChildById(id, curr[children], keyName, children); + } + }, undefined); +}; diff --git a/src/mock/hero/index.js b/src/mock/hero/index.js index 4ec595faa..2f6a143b0 100644 --- a/src/mock/hero/index.js +++ b/src/mock/hero/index.js @@ -9,7 +9,8 @@ module.exports = [ timeout: 700, response: ({ query }) => { const { page = 1, limit = 10 } = query; - return resultPageSuccess(page, limit, heroListJson); + const filterResult = heroListJson.filter((n) => n.cname.includes(query.cname || '')); + return resultPageSuccess(page, limit, filterResult); }, }, ]; diff --git a/src/mock/log/index.js b/src/mock/log/index.js index 31c0d4c01..d1731f554 100644 --- a/src/mock/log/index.js +++ b/src/mock/log/index.js @@ -1,4 +1,5 @@ -const reqLogJson = require('./reqLog'); +const data = require('./reqLog'); +const { resultPageSuccess } = require('../utils'); module.exports = [ // 获取请求日志 @@ -8,14 +9,7 @@ module.exports = [ timeout: 1000, response: ({ query }) => { const { page = 1, limit = 10 } = query; - const list = reqLogJson.data.list; - return { - ...reqLogJson, - data: { - list: list.slice((page - 1) * limit, limit * page), - pagination: { total: list.length, size: limit, page: page }, - }, - }; + return resultPageSuccess(page, limit, data); }, }, ]; diff --git a/src/mock/log/reqLog.js b/src/mock/log/reqLog.js index 500a9cd62..7aa08452b 100644 --- a/src/mock/log/reqLog.js +++ b/src/mock/log/reqLog.js @@ -1,609 +1,602 @@ -module.exports = { - code: 200, - data: { - list: [ - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1488, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 13, - }, - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1487, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 3, - }, - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1486, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 16, - }, - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1485, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1484, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 21, - }, - { - createTime: '2021-09-20 15:09:20', - updateTime: '2021-09-20 15:09:20', - id: 1483, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-20 15:09:10', - updateTime: '2021-09-20 15:09:10', - id: 1482, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-20 08:13:26', - updateTime: '2021-09-20 08:13:26', - id: 1481, - ip: '127.0.0.1', - userId: 1, - params: '{"page":1,"limit":20,"departmentIds":[4]}', - action: '/admin/sys/user/page', - method: 'POST', - status: 200, - consumeTime: 12, - }, - { - createTime: '2021-09-20 08:13:24', - updateTime: '2021-09-20 08:13:24', - id: 1480, - ip: '127.0.0.1', - userId: 1, - params: '{"page":1,"limit":20}', - action: '/admin/sys/user/page', - method: 'POST', - status: 200, - consumeTime: 8, - }, - { - createTime: '2021-09-20 08:13:24', - updateTime: '2021-09-20 08:13:24', - id: 1479, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/dept/list', - method: 'GET', - status: 200, - consumeTime: 3, - }, - { - createTime: '2021-09-20 08:13:20', - updateTime: '2021-09-20 08:13:20', - id: 1478, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/dept/list', - method: 'GET', - status: 200, - consumeTime: 5, - }, - { - createTime: '2021-09-20 08:13:20', - updateTime: '2021-09-20 08:13:20', - id: 1477, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/menu/list', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-20 08:13:19', - updateTime: '2021-09-20 08:13:19', - id: 1476, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/role/list', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-20 08:12:25', - updateTime: '2021-09-20 08:12:25', - id: 1475, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/menu/list', - method: 'GET', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-20 08:12:25', - updateTime: '2021-09-20 08:12:25', - id: 1474, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/dept/list', - method: 'GET', - status: 200, - consumeTime: 5, - }, - { - createTime: '2021-09-20 08:12:23', - updateTime: '2021-09-20 08:12:23', - id: 1473, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/role/list', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-20 08:12:20', - updateTime: '2021-09-20 08:12:20', - id: 1472, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/menu/list', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1471, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1470, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 5, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1469, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1468, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1467, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 1, - }, - { - createTime: '2021-09-20 08:12:12', - updateTime: '2021-09-20 08:12:12', - id: 1466, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-20 08:12:06', - updateTime: '2021-09-20 08:12:06', - id: 1465, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-20 08:12:05', - updateTime: '2021-09-20 08:12:05', - id: 1464, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 3, - }, - { - createTime: '2021-09-20 08:12:02', - updateTime: '2021-09-20 08:12:02', - id: 1463, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-20 08:11:59', - updateTime: '2021-09-20 08:11:59', - id: 1462, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-20 08:11:51', - updateTime: '2021-09-20 08:11:51', - id: 1461, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 5, - }, - { - createTime: '2021-09-20 02:45:12', - updateTime: '2021-09-20 02:45:12', - id: 1460, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-19 08:13:37', - updateTime: '2021-09-19 08:13:37', - id: 1459, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 5, - }, - { - createTime: '2021-09-18 12:33:17', - updateTime: '2021-09-18 12:33:17', - id: 1458, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 9, - }, - { - createTime: '2021-09-17 19:48:12', - updateTime: '2021-09-17 19:48:12', - id: 1457, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-17 02:26:14', - updateTime: '2021-09-17 02:26:14', - id: 1456, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/menu/list', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-17 02:26:11', - updateTime: '2021-09-17 02:26:11', - id: 1455, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/role/list', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:26:10', - updateTime: '2021-09-17 02:26:10', - id: 1454, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/menu/list', - method: 'GET', - status: 200, - consumeTime: 3, - }, - { - createTime: '2021-09-17 02:26:07', - updateTime: '2021-09-17 02:26:07', - id: 1453, - ip: '127.0.0.1', - userId: 1, - params: '{"page":1,"limit":20}', - action: '/admin/sys/user/page', - method: 'POST', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-17 02:26:07', - updateTime: '2021-09-17 02:26:07', - id: 1452, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/sys/dept/list', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:26:07', - updateTime: '2021-09-17 02:26:07', - id: 1451, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 8, - }, - { - createTime: '2021-09-17 02:26:07', - updateTime: '2021-09-17 02:26:07', - id: 1450, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1449, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1448, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1447, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 8, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1446, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1445, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 6, - }, - { - createTime: '2021-09-17 02:25:58', - updateTime: '2021-09-17 02:25:58', - id: 1444, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - { - createTime: '2021-09-17 02:25:52', - updateTime: '2021-09-17 02:25:52', - id: 1443, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-17 00:56:59', - updateTime: '2021-09-17 00:56:59', - id: 1442, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 3, - }, - { - createTime: '2021-09-17 00:56:46', - updateTime: '2021-09-17 00:56:46', - id: 1441, - ip: '127.0.0.1', - userId: null, - params: '{}', - action: '/admin/captcha/img', - method: 'GET', - status: 200, - consumeTime: 4, - }, - { - createTime: '2021-09-16 18:05:25', - updateTime: '2021-09-16 18:05:25', - id: 1440, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/permmenu', - method: 'GET', - status: 200, - consumeTime: 7, - }, - { - createTime: '2021-09-16 18:05:25', - updateTime: '2021-09-16 18:05:25', - id: 1439, - ip: '127.0.0.1', - userId: 1, - params: '{}', - action: '/admin/account/info', - method: 'GET', - status: 200, - consumeTime: 2, - }, - ], - pagination: { total: 1488, size: 50, page: 1 }, - }, - message: 'success', -}; +module.exports = [ + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1488, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 13, + }, + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1487, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 3, + }, + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1486, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 16, + }, + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1485, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1484, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 21, + }, + { + createTime: '2021-09-20 15:09:20', + updateTime: '2021-09-20 15:09:20', + id: 1483, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-20 15:09:10', + updateTime: '2021-09-20 15:09:10', + id: 1482, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-20 08:13:26', + updateTime: '2021-09-20 08:13:26', + id: 1481, + ip: '127.0.0.1', + userId: 1, + params: '{"page":1,"limit":20,"departmentIds":[4]}', + action: '/admin/sys/user/page', + method: 'POST', + status: 200, + consumeTime: 12, + }, + { + createTime: '2021-09-20 08:13:24', + updateTime: '2021-09-20 08:13:24', + id: 1480, + ip: '127.0.0.1', + userId: 1, + params: '{"page":1,"limit":20}', + action: '/admin/sys/user/page', + method: 'POST', + status: 200, + consumeTime: 8, + }, + { + createTime: '2021-09-20 08:13:24', + updateTime: '2021-09-20 08:13:24', + id: 1479, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/dept/list', + method: 'GET', + status: 200, + consumeTime: 3, + }, + { + createTime: '2021-09-20 08:13:20', + updateTime: '2021-09-20 08:13:20', + id: 1478, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/dept/list', + method: 'GET', + status: 200, + consumeTime: 5, + }, + { + createTime: '2021-09-20 08:13:20', + updateTime: '2021-09-20 08:13:20', + id: 1477, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/menu/list', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-20 08:13:19', + updateTime: '2021-09-20 08:13:19', + id: 1476, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/role/list', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-20 08:12:25', + updateTime: '2021-09-20 08:12:25', + id: 1475, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/menu/list', + method: 'GET', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-20 08:12:25', + updateTime: '2021-09-20 08:12:25', + id: 1474, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/dept/list', + method: 'GET', + status: 200, + consumeTime: 5, + }, + { + createTime: '2021-09-20 08:12:23', + updateTime: '2021-09-20 08:12:23', + id: 1473, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/role/list', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-20 08:12:20', + updateTime: '2021-09-20 08:12:20', + id: 1472, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/menu/list', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1471, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1470, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 5, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1469, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1468, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1467, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 1, + }, + { + createTime: '2021-09-20 08:12:12', + updateTime: '2021-09-20 08:12:12', + id: 1466, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-20 08:12:06', + updateTime: '2021-09-20 08:12:06', + id: 1465, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-20 08:12:05', + updateTime: '2021-09-20 08:12:05', + id: 1464, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 3, + }, + { + createTime: '2021-09-20 08:12:02', + updateTime: '2021-09-20 08:12:02', + id: 1463, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-20 08:11:59', + updateTime: '2021-09-20 08:11:59', + id: 1462, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-20 08:11:51', + updateTime: '2021-09-20 08:11:51', + id: 1461, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 5, + }, + { + createTime: '2021-09-20 02:45:12', + updateTime: '2021-09-20 02:45:12', + id: 1460, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-19 08:13:37', + updateTime: '2021-09-19 08:13:37', + id: 1459, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 5, + }, + { + createTime: '2021-09-18 12:33:17', + updateTime: '2021-09-18 12:33:17', + id: 1458, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 9, + }, + { + createTime: '2021-09-17 19:48:12', + updateTime: '2021-09-17 19:48:12', + id: 1457, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-17 02:26:14', + updateTime: '2021-09-17 02:26:14', + id: 1456, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/menu/list', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-17 02:26:11', + updateTime: '2021-09-17 02:26:11', + id: 1455, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/role/list', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:26:10', + updateTime: '2021-09-17 02:26:10', + id: 1454, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/menu/list', + method: 'GET', + status: 200, + consumeTime: 3, + }, + { + createTime: '2021-09-17 02:26:07', + updateTime: '2021-09-17 02:26:07', + id: 1453, + ip: '127.0.0.1', + userId: 1, + params: '{"page":1,"limit":20}', + action: '/admin/sys/user/page', + method: 'POST', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-17 02:26:07', + updateTime: '2021-09-17 02:26:07', + id: 1452, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/sys/dept/list', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:26:07', + updateTime: '2021-09-17 02:26:07', + id: 1451, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 8, + }, + { + createTime: '2021-09-17 02:26:07', + updateTime: '2021-09-17 02:26:07', + id: 1450, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1449, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1448, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1447, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 8, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1446, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1445, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 6, + }, + { + createTime: '2021-09-17 02:25:58', + updateTime: '2021-09-17 02:25:58', + id: 1444, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, + { + createTime: '2021-09-17 02:25:52', + updateTime: '2021-09-17 02:25:52', + id: 1443, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-17 00:56:59', + updateTime: '2021-09-17 00:56:59', + id: 1442, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 3, + }, + { + createTime: '2021-09-17 00:56:46', + updateTime: '2021-09-17 00:56:46', + id: 1441, + ip: '127.0.0.1', + userId: null, + params: '{}', + action: '/admin/captcha/img', + method: 'GET', + status: 200, + consumeTime: 4, + }, + { + createTime: '2021-09-16 18:05:25', + updateTime: '2021-09-16 18:05:25', + id: 1440, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/permmenu', + method: 'GET', + status: 200, + consumeTime: 7, + }, + { + createTime: '2021-09-16 18:05:25', + updateTime: '2021-09-16 18:05:25', + id: 1439, + ip: '127.0.0.1', + userId: 1, + params: '{}', + action: '/admin/account/info', + method: 'GET', + status: 200, + consumeTime: 2, + }, +]; diff --git a/src/router/asyncModules/system.ts b/src/router/asyncModules/system.ts index f4e0891d1..76778dc84 100644 --- a/src/router/asyncModules/system.ts +++ b/src/router/asyncModules/system.ts @@ -10,6 +10,7 @@ export default { 'views/system/monitor/req-log': getAsyncPage('system/monitor/req-log'), 'views/system/monitor/online': getAsyncPage('system/monitor/online'), 'views/system/monitor/login-log': getAsyncPage('system/monitor/login-log'), + 'views/system/monitor/serve': getAsyncPage('system/monitor/serve'), 'views/system/schedule/task': getAsyncPage('system/schedule/task'), 'views/system/schedule/log': getAsyncPage('system/schedule/log'), }; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 000000000..300128ef5 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,20 @@ +/** + * + * byte to size + * formatBytes(1024); // 1 KB + * formatBytes('1024'); // 1 KB + * formatBytes(1234); // 1.21 KB + * formatBytes(1234, 3); // 1.205 KB + * @param {number} bytes file size + */ +export function formatSizeUnits(bytes, decimals = 2) { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; +} diff --git a/src/views/shared/demos/tables/wzry-table/columns.tsx b/src/views/shared/demos/tables/wzry-table/columns.tsx index 5eca18a3c..93600e891 100644 --- a/src/views/shared/demos/tables/wzry-table/columns.tsx +++ b/src/views/shared/demos/tables/wzry-table/columns.tsx @@ -6,6 +6,7 @@ export const columns: TableColumn[] = [ title: '头像', align: 'center', width: 100, + hideInSearch: true, dataIndex: 'faceimg', bodyCell: ({ record }) => , }, diff --git a/src/views/system/monitor/serve/index.vue b/src/views/system/monitor/serve/index.vue new file mode 100644 index 000000000..aa5d017a7 --- /dev/null +++ b/src/views/system/monitor/serve/index.vue @@ -0,0 +1,208 @@ + + + + + + diff --git a/src/views/system/permission/menu/index.vue b/src/views/system/permission/menu/index.vue index 4d1eb25a3..37b018b6d 100644 --- a/src/views/system/permission/menu/index.vue +++ b/src/views/system/permission/menu/index.vue @@ -36,6 +36,7 @@ import { getColumns, TableListItem } from './columns'; import { menuSchemas } from './formSchemas'; import { formatMenu2Tree } from '@/core/permission/utils'; + import { cloneDeep } from 'lodash'; const menuTree = ref([]); const dynamicTableRef = ref>(); @@ -45,11 +46,11 @@ const loadTableData = async () => { const data = await getMenuList(); menuTree.value = formatMenu2Tree( - data.filter((n) => n.type !== 2), + cloneDeep(data).filter((n) => n.type !== 2), null, ); - return { list: formatMenu2Tree(data, null) }; + return { list: formatMenu2Tree(cloneDeep(data), null) }; }; const openMenuModal = async (record: Partial) => { @@ -75,7 +76,10 @@ formRef.value?.updateSchema([ { field: 'parentId', - componentProps: { treeData: [{ key: -1, name: '一级菜单', children: menuTree.value }] }, + componentProps: { + treeDefaultExpandedKeys: [-1].concat(record?.keyPath || []), + treeData: [{ key: -1, name: '一级菜单', children: menuTree.value }], + }, }, ]); diff --git a/src/views/system/permission/user/index.vue b/src/views/system/permission/user/index.vue index 2a410e102..be83516f5 100644 --- a/src/views/system/permission/user/index.vue +++ b/src/views/system/permission/user/index.vue @@ -101,7 +101,6 @@ } from '@ant-design/icons-vue'; import { SplitPanel } from '@/components/split-panel'; import { DynamicTable, LoadDataParams, DynamicTableInstance } from '@/components/dynamic-table'; - import { getColumns, TableListItem } from './columns'; import { deleteUsers, getUserListPage, @@ -114,7 +113,8 @@ import { getDeptList, transferDept } from '@/api/system/dept'; import { useFormModal } from '@/hooks/useModal/index'; import { userSchemas, deptSchemas, updatePswSchemas, transferUserSchemas } from './formSchemas'; - import { TreeDataItem, formatDept2Tree } from '@/core/permission/utils'; + import { getColumns, TableListItem } from './columns'; + import { TreeDataItem, formatDept2Tree, findChildById } from '@/core/permission/utils'; interface State { expandedKeys: number[]; @@ -171,7 +171,16 @@ formRef.value?.updateSchema([ { field: 'parentId', - componentProps: { treeData: [{ key: -1, title: '#', children: state.deptTree }] }, + componentProps: { + treeDefaultExpandedKeys: [-1].concat(record?.keyPath || []), + treeData: [ + { + key: -1, + title: '#', + children: state.deptTree, + }, + ], + }, }, ]); formRef.value?.setFieldsValue({ @@ -231,10 +240,15 @@ schemas: userSchemas, }, }); + formRef.value?.updateSchema([ { field: 'departmentId', - componentProps: { treeData: state.deptTree }, + componentProps: { + treeDefaultExpandedKeys: + findChildById(record?.departmentId, state.deptTree)?.keyPath || [], + treeData: state.deptTree, + }, }, ]);