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,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<j-drawer :visible="true" title="关系绑定" placement="right" @close="closeDrawer" :width="500">
|
<j-drawer :visible="true" title="关系绑定" placement="right" @close="closeDrawer" :width="500">
|
||||||
<j-tabs v-model:activeKey="activeKey" type="card">
|
<j-tabs v-model:activeKey="activeKey" type="card" @change="getRelation">
|
||||||
<j-tab-pane v-for="(item,index) in relationOptions" :key="item.value" :tab="item.text">
|
<j-tab-pane v-for="(item, index) in relationOptions" :key="item.id" :tab="item.name">
|
||||||
|
|
||||||
</j-tab-pane>
|
</j-tab-pane>
|
||||||
</j-tabs>
|
</j-tabs>
|
||||||
|
@ -9,26 +9,60 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { queryTypes, queryRelation } from '@/api/relation'
|
||||||
|
const props = defineProps({
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'device'
|
||||||
|
}
|
||||||
|
})
|
||||||
const activeKey = ref('user')
|
const activeKey = ref('user')
|
||||||
const relationOptions = [{
|
const relationOptions = ref()
|
||||||
text:'用户',
|
|
||||||
value:'user'
|
|
||||||
},{
|
|
||||||
text:'产品',
|
|
||||||
value:'product'
|
|
||||||
},{
|
|
||||||
text:'设备',
|
|
||||||
value:'device'
|
|
||||||
},{
|
|
||||||
text: '组织',
|
|
||||||
value:'organization'
|
|
||||||
},{
|
|
||||||
text:'角色',
|
|
||||||
value:'role'
|
|
||||||
}]
|
|
||||||
const closeDrawer = () => {
|
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>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped></style>
|
||||||
</style>
|
|
|
@ -319,7 +319,7 @@
|
||||||
</j-button>
|
</j-button>
|
||||||
</div>
|
</div>
|
||||||
</FullPage>
|
</FullPage>
|
||||||
<!-- <Relation></Relation> -->
|
<Relation></Relation>
|
||||||
</page-container>
|
</page-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue