feat: 关系配置组件
This commit is contained in:
parent
8ffb079c62
commit
700aa9a5d5
|
@ -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)
|
|
@ -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>
|
|
@ -319,7 +319,7 @@
|
|||
</j-button>
|
||||
</div>
|
||||
</FullPage>
|
||||
<!-- <Relation></Relation> -->
|
||||
<Relation></Relation>
|
||||
</page-container>
|
||||
</template>
|
||||
|
||||
|
|
Loading…
Reference in New Issue