|
@@ -5,10 +5,9 @@ meta:
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
-import PSModule from './components/Module.vue'
|
|
|
|
|
import PSApi from './components/Api.vue'
|
|
import PSApi from './components/Api.vue'
|
|
|
|
|
+import { getBizData } from '@/api/biz/bizApi'
|
|
|
import { deleteApiById, getApiByList, updateApiStatus } from '@/api/api/apiApi'
|
|
import { deleteApiById, getApiByList, updateApiStatus } from '@/api/api/apiApi'
|
|
|
-import { deleteModuleById, getModuleByList } from '@/api/api/apiModuleApi'
|
|
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
import { apiType } from '@/utils/tool'
|
|
import { apiType } from '@/utils/tool'
|
|
|
|
|
|
|
@@ -19,12 +18,16 @@ const tabbar = useTabbar()
|
|
|
interface TreeNode {
|
|
interface TreeNode {
|
|
|
label: string
|
|
label: string
|
|
|
isLeaf: boolean
|
|
isLeaf: boolean
|
|
|
- moduleId: number
|
|
|
|
|
|
|
+ value: number
|
|
|
|
|
+ bizId: number
|
|
|
|
|
+ objectId: number
|
|
|
children?: TreeNode[]
|
|
children?: TreeNode[]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface Api {
|
|
interface Api {
|
|
|
- moduleId: number
|
|
|
|
|
|
|
+ bizId: number
|
|
|
|
|
+ objectId: number
|
|
|
|
|
+ oamId: number
|
|
|
apiId: number
|
|
apiId: number
|
|
|
apiType: number
|
|
apiType: number
|
|
|
apiTitle: string
|
|
apiTitle: string
|
|
@@ -37,8 +40,9 @@ interface Api {
|
|
|
const state = reactive({
|
|
const state = reactive({
|
|
|
loading: false,
|
|
loading: false,
|
|
|
keywords: '',
|
|
keywords: '',
|
|
|
- modules: [] as TreeNode[],
|
|
|
|
|
- curModuleId: 0,
|
|
|
|
|
|
|
+ treeData: [] as TreeNode[],
|
|
|
|
|
+ curBizId: 0,
|
|
|
|
|
+ curObjectId: 0,
|
|
|
apiList: [] as Api[],
|
|
apiList: [] as Api[],
|
|
|
dialogState: 1,
|
|
dialogState: 1,
|
|
|
search: {
|
|
search: {
|
|
@@ -49,74 +53,49 @@ const state = reactive({
|
|
|
const leftTreeRef = ref()
|
|
const leftTreeRef = ref()
|
|
|
const ModuleRef = ref()
|
|
const ModuleRef = ref()
|
|
|
const getApiData = async () => {
|
|
const getApiData = async () => {
|
|
|
- const curModuleId = state.curModuleId
|
|
|
|
|
- if (curModuleId > 0) {
|
|
|
|
|
|
|
+ const curBizId = state.curBizId
|
|
|
|
|
+ const curObjectId = state.curObjectId
|
|
|
|
|
+ if (curBizId > 0 && curObjectId > 0) {
|
|
|
state.loading = true
|
|
state.loading = true
|
|
|
- const { data } = await getApiByList({ moduleId: curModuleId })
|
|
|
|
|
|
|
+ const { data } = await getApiByList({ bizId: curBizId, objectId: curObjectId })
|
|
|
state.apiList = data
|
|
state.apiList = data
|
|
|
state.loading = false
|
|
state.loading = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const getModuleData = async () => {
|
|
|
|
|
- const { data } = await getModuleByList('')
|
|
|
|
|
- const children: TreeNode[] = []
|
|
|
|
|
- data.forEach((item: any) => {
|
|
|
|
|
- return children.push({
|
|
|
|
|
- label: item.moduleTitle,
|
|
|
|
|
- moduleId: item.moduleId,
|
|
|
|
|
- isLeaf: true,
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- state.modules = [
|
|
|
|
|
- {
|
|
|
|
|
- label: '功能模块',
|
|
|
|
|
- isLeaf: false,
|
|
|
|
|
- moduleId: -1,
|
|
|
|
|
- children,
|
|
|
|
|
- },
|
|
|
|
|
- ]
|
|
|
|
|
|
|
+const getData = async () => {
|
|
|
|
|
+ const { data } = await getBizData()
|
|
|
|
|
+ state.treeData = data
|
|
|
|
|
|
|
|
if (data && data.length > 0) {
|
|
if (data && data.length > 0) {
|
|
|
- state.curModuleId = data[0].moduleId
|
|
|
|
|
|
|
+ state.curBizId = data[0].bizId
|
|
|
|
|
+
|
|
|
|
|
+ data.forEach((biz: { label: string; bizTitle: string; objects: any; children: any; isLeaf: boolean }) => {
|
|
|
|
|
+ biz.label = biz.bizTitle
|
|
|
|
|
+ biz.isLeaf = false
|
|
|
|
|
+ const objects = biz.objects
|
|
|
|
|
+ objects.forEach((object: { label: string; objectTitle: string; isLeaf: boolean }) => {
|
|
|
|
|
+ object.label = object.objectTitle
|
|
|
|
|
+ object.isLeaf = true
|
|
|
|
|
+ })
|
|
|
|
|
+ biz.children = objects
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
await getApiData()
|
|
await getApiData()
|
|
|
await nextTick(() => {
|
|
await nextTick(() => {
|
|
|
- leftTreeRef.value.setCurrentKey(data[0].moduleId)
|
|
|
|
|
|
|
+ leftTreeRef.value.setCurrentKey(data[0].bizId)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-// 模块新增
|
|
|
|
|
-const onModuleAdd = () => {
|
|
|
|
|
- ModuleRef.value.showAddModule()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 模块编辑
|
|
|
|
|
-const onModuleEdit = (data: { moduleId: number }) => {
|
|
|
|
|
- const moduleId = data.moduleId
|
|
|
|
|
- ModuleRef.value.showEditModule(moduleId)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 模块删除
|
|
|
|
|
-const onModuleDelete = (data: any) => {
|
|
|
|
|
- ElMessageBox.confirm(`确认删除「${data.moduleTitle}」吗?`, '确认信息').then(async () => {
|
|
|
|
|
- await deleteModuleById(data.moduleId)
|
|
|
|
|
- await getModuleData()
|
|
|
|
|
- ElMessage.success({
|
|
|
|
|
- message: '删除成功',
|
|
|
|
|
- center: true,
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- getModuleData()
|
|
|
|
|
|
|
+ getData()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 模块选择
|
|
// 模块选择
|
|
|
const onTreeNodeClick = (node: TreeNode) => {
|
|
const onTreeNodeClick = (node: TreeNode) => {
|
|
|
if (node.isLeaf) {
|
|
if (node.isLeaf) {
|
|
|
- state.curModuleId = node.moduleId
|
|
|
|
|
|
|
+ state.curObjectId = node.objectId
|
|
|
getApiData()
|
|
getApiData()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -131,7 +110,7 @@ const onSearch = () => {
|
|
|
|
|
|
|
|
// 新增API
|
|
// 新增API
|
|
|
const onApiAdd = () => {
|
|
const onApiAdd = () => {
|
|
|
- apiRef.value.showAddApi(state.curModuleId)
|
|
|
|
|
|
|
+ apiRef.value.showAddApi(state.curBizId, state.curObjectId)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 编辑API
|
|
// 编辑API
|
|
@@ -155,12 +134,11 @@ const onApiDelete = (row: any) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 编辑对象
|
|
// 编辑对象
|
|
|
-const onApiTrans = (row: { moduleId: number; apiId: number }) => {
|
|
|
|
|
|
|
+const onApiTrans = (row: { apiId: number }) => {
|
|
|
if (settingsStore.settings.tabbar.enable && settingsStore.settings.tabbar.mergeTabsBy !== 'activeMenu') {
|
|
if (settingsStore.settings.tabbar.enable && settingsStore.settings.tabbar.mergeTabsBy !== 'activeMenu') {
|
|
|
tabbar.open({
|
|
tabbar.open({
|
|
|
name: 'apiTrans',
|
|
name: 'apiTrans',
|
|
|
params: {
|
|
params: {
|
|
|
- moduleId: row.moduleId,
|
|
|
|
|
apiId: row.apiId,
|
|
apiId: row.apiId,
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
@@ -169,15 +147,14 @@ const onApiTrans = (row: { moduleId: number; apiId: number }) => {
|
|
|
router.push({
|
|
router.push({
|
|
|
name: 'apiTrans',
|
|
name: 'apiTrans',
|
|
|
params: {
|
|
params: {
|
|
|
- moduleId: row.moduleId,
|
|
|
|
|
apiId: row.apiId,
|
|
apiId: row.apiId,
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function onChangeStatus(row: { moduleId: number; apiId: number; status: number }) {
|
|
|
|
|
- const res = await updateApiStatus(row.moduleId, row.apiId, row.status)
|
|
|
|
|
|
|
+async function onChangeStatus(row: { apiId: number; status: number }) {
|
|
|
|
|
+ const res = await updateApiStatus(row.apiId, row.status)
|
|
|
ElMessage.success({
|
|
ElMessage.success({
|
|
|
message: res.msg,
|
|
message: res.msg,
|
|
|
center: true,
|
|
center: true,
|
|
@@ -189,14 +166,6 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
<div class="absolute-container">
|
|
<div class="absolute-container">
|
|
|
<tool-header title="API管理">
|
|
<tool-header title="API管理">
|
|
|
<template #right>
|
|
<template #right>
|
|
|
- <el-button type="primary" plain @click="onModuleAdd">
|
|
|
|
|
- <template #icon>
|
|
|
|
|
- <el-icon>
|
|
|
|
|
- <svg-icon name="i-ep:plus" />
|
|
|
|
|
- </el-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- 新增模块
|
|
|
|
|
- </el-button>
|
|
|
|
|
</template>
|
|
</template>
|
|
|
</tool-header>
|
|
</tool-header>
|
|
|
|
|
|
|
@@ -204,7 +173,7 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
<LayoutContainer left-side-width="250px" hide-left-side-toggle>
|
|
<LayoutContainer left-side-width="250px" hide-left-side-toggle>
|
|
|
<template #leftSide>
|
|
<template #leftSide>
|
|
|
<el-scrollbar class="tree">
|
|
<el-scrollbar class="tree">
|
|
|
- <ElTree ref="leftTreeRef" :data="state.modules" default-expand-all node-key="moduleId" @node-click="onTreeNodeClick">
|
|
|
|
|
|
|
+ <ElTree ref="leftTreeRef" :data="state.treeData" default-expand-all node-key="moduleId" @node-click="onTreeNodeClick">
|
|
|
<template #default="{ node, data }">
|
|
<template #default="{ node, data }">
|
|
|
<div class="custom-tree-node">
|
|
<div class="custom-tree-node">
|
|
|
<div class="label" :title="node.label">
|
|
<div class="label" :title="node.label">
|
|
@@ -215,24 +184,6 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
{{ data.label }}
|
|
{{ data.label }}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div v-if="data.isLeaf" class="actions">
|
|
|
|
|
- <el-button-group>
|
|
|
|
|
- <el-button type="info" plain size="small" @click.stop="onModuleEdit(data)">
|
|
|
|
|
- <template #icon>
|
|
|
|
|
- <el-icon>
|
|
|
|
|
- <svg-icon name="i-ep:edit" />
|
|
|
|
|
- </el-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </el-button>
|
|
|
|
|
- <el-button type="danger" plain size="small" @click.stop="onModuleDelete(data)">
|
|
|
|
|
- <template #icon>
|
|
|
|
|
- <el-icon>
|
|
|
|
|
- <svg-icon name="i-ep:delete" />
|
|
|
|
|
- </el-icon>
|
|
|
|
|
- </template>
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </el-button-group>
|
|
|
|
|
- </div>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</ElTree>
|
|
</ElTree>
|
|
@@ -265,7 +216,7 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
<el-table ref="apiTableRef" v-loading="state.loading" class="list-table" :data="state.apiList" border stripe highlight-current-row height="100%">
|
|
<el-table ref="apiTableRef" v-loading="state.loading" class="list-table" :data="state.apiList" border stripe highlight-current-row height="100%">
|
|
|
<el-table-column type="index" label="序号" header-align="center" align="center" width="70" />
|
|
<el-table-column type="index" label="序号" header-align="center" align="center" width="70" />
|
|
|
|
|
|
|
|
- <el-table-column prop="apiTitle" label="名称" header-align="center" align="center" width="200">
|
|
|
|
|
|
|
+ <el-table-column prop="apiTitle" label="名称" header-align="center" align="center" width="150">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
<span> {{ scope.row.apiTitle }} </span>
|
|
<span> {{ scope.row.apiTitle }} </span>
|
|
|
</template>
|
|
</template>
|
|
@@ -277,7 +228,7 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
|
|
|
|
- <el-table-column prop="apiCode" label="代码" header-align="left" align="left" width="200">
|
|
|
|
|
|
|
+ <el-table-column prop="apiCode" label="代码" header-align="left" align="left" width="120">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
<span> {{ scope.row.apiCode }} </span>
|
|
<span> {{ scope.row.apiCode }} </span>
|
|
|
</template>
|
|
</template>
|
|
@@ -315,7 +266,6 @@ async function onChangeStatus(row: { moduleId: number; apiId: number; status: nu
|
|
|
</div>
|
|
</div>
|
|
|
</LayoutContainer>
|
|
</LayoutContainer>
|
|
|
</div>
|
|
</div>
|
|
|
- <PSModule ref="ModuleRef" @success="getModuleData" />
|
|
|
|
|
<PSApi ref="apiRef" @success="getApiData" />
|
|
<PSApi ref="apiRef" @success="getApiData" />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|