From 603cdf328532baed52992c5176fe7c6c49f7c4af Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Mon, 28 Apr 2025 18:40:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8json=E6=88=96excel?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/data.js | 85 ------------------- src/api/v1/system/power.ts | 7 +- src/enums/baseConstant.ts | 2 +- src/store/system/power.ts | 10 +++ src/views/scheduler/schedulers/utils/auth.ts | 4 +- .../permission/components/power-dialog.vue | 74 +++++++++++++++- src/views/system/permission/utils/auth.ts | 2 +- src/views/system/permission/utils/columns.ts | 8 +- src/views/system/permission/utils/hooks.tsx | 3 +- 9 files changed, 98 insertions(+), 97 deletions(-) delete mode 100644 build/data.js diff --git a/build/data.js b/build/data.js deleted file mode 100644 index 335dfb6..0000000 --- a/build/data.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * * 自动创建权限内容 - */ -(async function requestPath() { - // 获取基础paths对象 - const response = await fetch('http://localhost:7070/v3/api-docs/%E9%BB%98%E8%AE%A4%E8%AF%B7%E6%B1%82%E6%8E%A5%E5%8F%A3', { method: 'GET' }); - const json = await response.json(); - const paths = json.paths; - - // 设置父级id顺序 - let id = 1; - - // 最后整理的数据内容 - const data = {}; - - // 获取所有键 - Object.keys(paths) - .filter(item => !item.includes('noAuth') && !item.includes('noManage')) - .forEach(key => { - const pathKey = paths[key]; - const { tags, description } = pathKey[Object.keys(pathKey)[0]]; - const tag = tags[0]; - - // 父级内容为info信息 - const path = key.match(/\w+\/\w+/, key)[0]; - const info = { - id: 1, - parentId: 0, - powerCode: path.replaceAll('/', '::'), - powerName: tag, - requestUrl: undefined, - }; - - // 整理子级内容信息 - const powerCode = key.replace('/api/', '').replace(/\/\{.*?\}/g, ''); - const item = { - parentId: info.id, - powerCode: powerCode.replaceAll('/', '::'), - powerName: description, - requestUrl: key.replace(/\/{.*/, '/.*'), - }; - - // 向父级内容添加子级Children内容 - if (!data[tag]) { - data[tag] = { - info, - children: [item], - }; - } - data[tag].children.push(item); - }); - - // 便利整理好的参数data - for (const item in data) { - // 先添加父级内容 - const info = data[item].info; - info.id = id; - await add(info); - - // 遍历子级内容向服务器添加 - const children = data[item].children; - for (const item1 of children) { - item1.parentId = id; - await add(item1); - } - - // 父级添加后id增加 - id++; - } -})(); - -// 向服务器添加的内容 -async function add(data) { - const response = await fetch('http://localhost:7070/admin/power/addPower', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - token: - 'eyJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_yWLywqFIBQA_-WsE_RknWxXuz5DU8EgCx9QXO6_X-HuhmHmA7kamGGtMb7QgXtumAX1KEekQXVQs0ubbe6PUZ-u5Ys9Qwy5JF2u1LajhGaNFoZGLxlKS0xavjPjkbPBKS8Uql3TBN8fHTtSk3MAAAA.u-rDR1a46DoV0X-iQEz0Y9lfUGPm0Nsr2MuD4fvtVMg', - }, - body: JSON.stringify(data), - }); - const json = await response.json(); - console.log(json); -} diff --git a/src/api/v1/system/power.ts b/src/api/v1/system/power.ts index 6b59e12..f12cc77 100644 --- a/src/api/v1/system/power.ts +++ b/src/api/v1/system/power.ts @@ -35,7 +35,12 @@ export const importPermission = (data: any) => { /** 权限---获取所有权限 */ export const getPermissionList = () => { - return http.request>('get', `permission/getPermissionList`); + return http.request>('get', `permission/private/getPermissionList`); +}; + +/* 权限---获取系统API信息 */ +export const getSystemApiInfoList = () => { + return http.request>('get', 'permission/private/getSystemApiInfoList'); }; /** 权限---更新权限 */ diff --git a/src/enums/baseConstant.ts b/src/enums/baseConstant.ts index c9160f2..cf583b0 100644 --- a/src/enums/baseConstant.ts +++ b/src/enums/baseConstant.ts @@ -45,4 +45,4 @@ export const tableSelectButtonClass = computed(() => ['!h-[20px]', 'reset-margin export const UserAvatar = 'https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eoj0hHXhgJNOTSOFsS4uZs8x1ConecaVOB8eIl115xmJZcT4oCicvia7wMEufibKtTLqiaJeanU2Lpg3w/132'; -export const RequestMethod = ['', 'GET', 'PUT', 'POST', 'DELETE', 'HEAD', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH']; +export const RequestMethod = ['', 'GET', 'PUT', 'POST', 'DELETE', /* 'HEAD', 'CONNECT', 'OPTIONS', 'TRACE', */ 'PATCH']; diff --git a/src/store/system/power.ts b/src/store/system/power.ts index bae7922..5441adf 100644 --- a/src/store/system/power.ts +++ b/src/store/system/power.ts @@ -5,6 +5,7 @@ import { exportPermission, getPermissionList, getPermissionPage, + getSystemApiInfoList, importPermission, updatePermission, updatePermissionListByParentId, @@ -24,6 +25,8 @@ export const usePermissionStore = defineStore('PermissionStore', { datalist: [], // 权限树形结构 allPowerList: [], + // 系统api列表 + systemApiInfoList: [], // 查询表单 form: { // 权限编码 @@ -102,6 +105,13 @@ export const usePermissionStore = defineStore('PermissionStore', { this.allPowerList = result.data; }, + /* 获取系统API信息 */ + async loadSystemApiInfoList() { + const result = await getSystemApiInfoList(); + if (result.code !== 200) return; + this.systemApiInfoList = result.data; + }, + /** 批量修改权限父级 */ async updatePermissionListByParentId(data: any) { const result = await updatePermissionListByParentId(data); diff --git a/src/views/scheduler/schedulers/utils/auth.ts b/src/views/scheduler/schedulers/utils/auth.ts index af4f93c..98b1f11 100644 --- a/src/views/scheduler/schedulers/utils/auth.ts +++ b/src/views/scheduler/schedulers/utils/auth.ts @@ -4,9 +4,9 @@ export const auth = { // 添加操作 add: ['schedulers::add'], // 暂停 - pause: ['schedulers::pause'], + pause: ['schedulers::update'], // 恢复 - resume: ['schedulers::resume'], + resume: ['schedulers::update'], // 删除操作 delete: ['schedulers::delete'], }; diff --git a/src/views/system/permission/components/power-dialog.vue b/src/views/system/permission/components/power-dialog.vue index fa475c9..73977ef 100644 --- a/src/views/system/permission/components/power-dialog.vue +++ b/src/views/system/permission/components/power-dialog.vue @@ -1,11 +1,17 @@ + diff --git a/src/views/system/permission/utils/auth.ts b/src/views/system/permission/utils/auth.ts index 649dbbd..2f1fa99 100644 --- a/src/views/system/permission/utils/auth.ts +++ b/src/views/system/permission/utils/auth.ts @@ -1,7 +1,7 @@ export const auth = { // 分页查询 query: ['power::query', 'power::queryPage'], - // 添加操作 + // // 添加操作 add: ['power::addPower'], // 更新操作 update: ['power::updatePower'], diff --git a/src/views/system/permission/utils/columns.ts b/src/views/system/permission/utils/columns.ts index 9732ee1..5af4727 100644 --- a/src/views/system/permission/utils/columns.ts +++ b/src/views/system/permission/utils/columns.ts @@ -7,12 +7,12 @@ export const columns: TableColumnList = [ { type: 'selection', align: 'left' }, { type: 'index', index: (index: number) => index + 1, label: $t('index'), minWidth: 60 }, // 权限编码 - { label: $t('power_powerCode'), prop: 'powerCode', minWidth: 350 }, + { label: $t('power_powerCode'), prop: 'powerCode', minWidth: 240, align: 'left' }, // 权限名称 - { label: $t('power_powerName'), prop: 'powerName', minWidth: 320 }, + { label: $t('power_powerName'), prop: 'powerName', minWidth: 220 }, // 请求路径 - { label: $t('power_requestUrl'), prop: 'requestUrl', minWidth: 360 }, - { label: $t('requestMethod'), prop: 'requestMethod', minWidth: 360 }, + { label: $t('power_requestUrl'), prop: 'requestUrl', minWidth: 360, align: 'left' }, + { label: $t('requestMethod'), prop: 'requestMethod', minWidth: 80 }, { label: $t('table.updateTime'), prop: 'updateTime', sortable: true, minWidth: 160 }, { label: $t('table.createTime'), prop: 'createTime', sortable: true, minWidth: 160 }, { label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', minWidth: 130 }, diff --git a/src/views/system/permission/utils/hooks.tsx b/src/views/system/permission/utils/hooks.tsx index f75a169..e7f3910 100644 --- a/src/views/system/permission/utils/hooks.tsx +++ b/src/views/system/permission/utils/hooks.tsx @@ -75,7 +75,8 @@ export function onUpdate(row: any) { const form = options.props.formInline as FormItemProps; formRef.value.formRef.validate(async (valid: any) => { if (!valid) return; - + // 请求方法是否存在,不存在就为空 + form.requestMethod = form.requestMethod ? form.requestMethod : ''; const result = await powerStore.editPermission({ ...form, id: row.id }); if (!result) return; done();