|
|
@@ -19,11 +19,12 @@ const tabbar = useTabbar()
|
|
|
interface TreeNode {
|
|
|
label: string
|
|
|
isLeaf: boolean
|
|
|
- modId: number
|
|
|
+ moduleId: number
|
|
|
children?: TreeNode[]
|
|
|
}
|
|
|
|
|
|
interface Api {
|
|
|
+ moduleId: number
|
|
|
apiId: number
|
|
|
apiType: number
|
|
|
apiTitle: string
|
|
|
@@ -51,7 +52,7 @@ const getApiData = async () => {
|
|
|
const curModuleId = state.curModuleId
|
|
|
if (curModuleId > 0) {
|
|
|
state.loading = true
|
|
|
- const { data } = await getApiByList({ modId: curModuleId })
|
|
|
+ const { data } = await getApiByList({ moduleId: curModuleId })
|
|
|
state.apiList = data
|
|
|
state.loading = false
|
|
|
}
|
|
|
@@ -62,8 +63,8 @@ const getModuleData = async () => {
|
|
|
const children: TreeNode[] = []
|
|
|
data.forEach((item: any) => {
|
|
|
return children.push({
|
|
|
- label: item.modTitle,
|
|
|
- modId: item.modId,
|
|
|
+ label: item.moduleTitle,
|
|
|
+ moduleId: item.moduleId,
|
|
|
isLeaf: true,
|
|
|
})
|
|
|
})
|
|
|
@@ -71,15 +72,15 @@ const getModuleData = async () => {
|
|
|
{
|
|
|
label: '功能模块',
|
|
|
isLeaf: false,
|
|
|
- modId: -1,
|
|
|
+ moduleId: -1,
|
|
|
children,
|
|
|
},
|
|
|
]
|
|
|
|
|
|
if (data && data.length > 0) {
|
|
|
- state.curModuleId = data[0].modId
|
|
|
+ state.curModuleId = data[0].moduleId
|
|
|
nextTick(() => {
|
|
|
- leftTreeRef.value.setCurrentKey(data[0].modId)
|
|
|
+ leftTreeRef.value.setCurrentKey(data[0].moduleId)
|
|
|
})
|
|
|
await getApiData()
|
|
|
}
|
|
|
@@ -90,15 +91,15 @@ const onModuleAdd = () => {
|
|
|
}
|
|
|
|
|
|
// 模块编辑
|
|
|
-const onModuleEdit = (data: { ModId: number }) => {
|
|
|
- const modId = data.ModId
|
|
|
- ModuleRef.value.showEditModule(modId)
|
|
|
+const onModuleEdit = (data: { moduleId: number }) => {
|
|
|
+ const moduleId = data.moduleId
|
|
|
+ ModuleRef.value.showEditModule(moduleId)
|
|
|
}
|
|
|
|
|
|
// 模块删除
|
|
|
const onModuleDelete = (data: any) => {
|
|
|
ElMessageBox.confirm(`确认删除「${data.modTitle}」吗?`, '确认信息').then(async () => {
|
|
|
- await deleteModuleById(data.modId)
|
|
|
+ await deleteModuleById(data.moduleId)
|
|
|
await getModuleData()
|
|
|
ElMessage.success({
|
|
|
message: '删除成功',
|
|
|
@@ -114,7 +115,7 @@ onMounted(() => {
|
|
|
// 模块选择
|
|
|
const onTreeNodeClick = (node: TreeNode) => {
|
|
|
if (node.isLeaf) {
|
|
|
- state.curModuleId = node.modId
|
|
|
+ state.curModuleId = node.moduleId
|
|
|
getApiData()
|
|
|
}
|
|
|
}
|
|
|
@@ -133,17 +134,17 @@ const onApiAdd = () => {
|
|
|
}
|
|
|
|
|
|
// 编辑API
|
|
|
-const onApiEdit = (data: { apiId: number; modId: number }) => {
|
|
|
+const onApiEdit = (data: { moduleId: number; apiId: number }) => {
|
|
|
+ const moduleId = data.moduleId
|
|
|
const apiId = data.apiId
|
|
|
- const modId = data.modId
|
|
|
- apiRef.value.showEditApi(modId, apiId)
|
|
|
+ apiRef.value.showEditApi(moduleId, apiId)
|
|
|
}
|
|
|
|
|
|
// 删除API
|
|
|
const onApiDelete = (row: any) => {
|
|
|
- const { apiId, apiTitle } = row
|
|
|
+ const { moduleId, apiId, apiTitle } = row
|
|
|
ElMessageBox.confirm(`确认删除「${apiTitle}」吗?`, '确认信息').then(async () => {
|
|
|
- await deleteApiById(apiId)
|
|
|
+ await deleteApiById(moduleId, apiId)
|
|
|
await getApiData()
|
|
|
ElMessage.success({
|
|
|
message: '删除成功',
|
|
|
@@ -153,12 +154,12 @@ const onApiDelete = (row: any) => {
|
|
|
}
|
|
|
|
|
|
// 编辑对象
|
|
|
-const onApiTrans = (row: { modId: number; apiId: number }) => {
|
|
|
+const onApiTrans = (row: { moduleId: number; apiId: number }) => {
|
|
|
if (settingsStore.settings.tabbar.enable && settingsStore.settings.tabbar.mergeTabsBy !== 'activeMenu') {
|
|
|
tabbar.open({
|
|
|
name: 'apiTrans',
|
|
|
params: {
|
|
|
- modId: row.modId,
|
|
|
+ moduleId: row.moduleId,
|
|
|
apiId: row.apiId,
|
|
|
},
|
|
|
})
|
|
|
@@ -167,15 +168,15 @@ const onApiTrans = (row: { modId: number; apiId: number }) => {
|
|
|
router.push({
|
|
|
name: 'apiTrans',
|
|
|
params: {
|
|
|
- modId: row.modId,
|
|
|
+ moduleId: row.moduleId,
|
|
|
apiId: row.apiId,
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function onChangeStatus(row: { modId: number;apiId: number; status: number }) {
|
|
|
- const res = await updateApiStatus(row.modId, row.apiId, row.status)
|
|
|
+async function onChangeStatus(row: { moduleId: number; apiId: number; status: number }) {
|
|
|
+ const res = await updateApiStatus(row.moduleId, row.apiId, row.status)
|
|
|
ElMessage.success({
|
|
|
message: res.msg,
|
|
|
center: true,
|
|
|
@@ -202,7 +203,7 @@ async function onChangeStatus(row: { modId: number;apiId: number; status: number
|
|
|
<LayoutContainer left-side-width="300px" hide-left-side-toggle>
|
|
|
<template #leftSide>
|
|
|
<el-scrollbar class="tree">
|
|
|
- <ElTree ref="leftTreeRef" :data="state.modules" default-expand-all node-key="modId" @node-click="onTreeNodeClick">
|
|
|
+ <ElTree ref="leftTreeRef" :data="state.modules" default-expand-all node-key="moduleId" @node-click="onTreeNodeClick">
|
|
|
<template #default="{ node, data }">
|
|
|
<div class="custom-tree-node">
|
|
|
<div class="label" :title="node.label">
|