mes-vue/src/api/permissionConfig.ts
2026-08-07 14:54:04 +08:00

73 lines
2.1 KiB
TypeScript

import { request } from '@/utils/request'
// 数据权限配置 类型定义
export interface PermissionConfig {
id?: number
mapperKey?: string
controlMethod?: string
permissionControl?: string
}
// 数据权限配置 API
export const permissionConfigApi = {
// 分页查询
page(params: { page: number; pageSize: number; mapperKey?: string; controlMethod?: string }) {
return request({ url: '/biz/permissionConfig/page', method: 'get', params })
},
// 新增
options() {
return request({ url: '/biz/permissionConfig/options', method: 'get' })
},
// 获取详情
detail(id: string) {
return request({ url: `/biz/permissionConfig/${id}`, method: 'get' })
},
// 新增
create(data: PermissionConfig) {
return request({ url: '/biz/permissionConfig', method: 'post', data })
},
// 修改
update(data: PermissionConfig) {
return request({ url: '/biz/permissionConfig', method: 'put', data })
},
// 删除
delete(ids: string[]) {
return request({ url: `/biz/permissionConfig/${ids.join(',')}`, method: 'delete' })
},
// 导出
export(params?: { ids?: string[]; mapperKey?: string; controlMethod?: string }) {
const p: Record<string, any> = {}
if (params?.ids?.length) p.ids = params.ids.join(',')
if (params?.mapperKey !== undefined && params?.mapperKey !== null) p.mapperKey = params.mapperKey
if (params?.controlMethod !== undefined && params?.controlMethod !== null) p.controlMethod = params.controlMethod
return request({ url: `/biz/permissionConfig/export`, method: 'get', params: p, responseType: 'blob' })
},
// 导入
importData(file: File) {
const formData = new FormData()
formData.append('file', file)
return request<{ success: number; fail: number; errors: string[] }>({
url: `/biz/permissionConfig/import`,
method: 'post',
data: formData,
headers: { 'Content-Type': 'multipart/form-data' }
})
},
// 下载导入模板
downloadTemplate() {
return request({ url: `/biz/permissionConfig/template`, method: 'get', responseType: 'blob' })
}
}