feat: 关系配置组件

This commit is contained in:
leiqiaochu 2023-10-11 15:45:38 +08:00
parent 8ffb079c62
commit 700aa9a5d5
3 changed files with 67 additions and 23 deletions

10
src/api/relation.ts Normal file
View File

@ -0,0 +1,10 @@
import server from '@/utils/request';
/**
*
*/
export const queryTypes = () => server.get('/relation/types')
/**
*
*/
export const queryRelation = (data:any) => server.post('/relation/_query',data)

View File

@ -1,34 +1,68 @@
<template>
<j-drawer :visible="true" title="关系绑定" placement="right" @close="closeDrawer" :width="500">
<j-tabs v-model:activeKey="activeKey" type="card">
<j-tab-pane v-for="(item,index) in relationOptions" :key="item.value" :tab="item.text">
<j-tabs v-model:activeKey="activeKey" type="card" @change="getRelation">
<j-tab-pane v-for="(item, index) in relationOptions" :key="item.id" :tab="item.name">
</j-tab-pane>
</j-tabs>
</j-drawer>
</template>
<script lang="ts" setup>
import { queryTypes, queryRelation } from '@/api/relation'
const props = defineProps({
type: {
type: String,
default: 'device'
}
})
const activeKey = ref('user')
const relationOptions = [{
text:'用户',
value:'user'
},{
text:'产品',
value:'product'
},{
text:'设备',
value:'device'
},{
text: '组织',
value:'organization'
},{
text:'角色',
value:'role'
}]
const closeDrawer = () =>{
const relationOptions = ref()
const closeDrawer = () => {
}
const queryRelationOptions = () => {
queryTypes().then((resp: any) => {
if (resp.status === 200) {
relationOptions.value = resp.result
}
})
}
const getRelation = (activeKey: string) => {
queryRelation({
paging: false,
terms: [
{
terms: [{
value: props.type,
termType: "eq",
column: "objectType",
type: "and"
},
{
value: activeKey,
termType: "eq",
column: "targetType",
}]
},
{
terms: [{
value: activeKey,
termType: "eq",
column: "objectType",
type: "and"
},
{
value: props.type,
termType: "eq",
column: "targetType",
}]
}
]
}).then((resq: any) => {
})
}
queryRelationOptions()
</script>
<style lang="less" scoped>
</style>
<style lang="less" scoped></style>

View File

@ -319,7 +319,7 @@
</j-button>
</div>
</FullPage>
<!-- <Relation></Relation> -->
<Relation></Relation>
</page-container>
</template>