根据权限获取指定用户机构节点
用于根据权限获取指定用户机构顶级节点以及子节点。 如果只传参数userId时是获取当前用户的顶级节点,也就是根节点root机构信息; 如果userId以及deptId都传时,查询的是当前节点下的用户有权限管理的子机构数据。
请求参数:
| Parameters | Type/Value | Require | Description |
|---|---|---|---|
| userId | [string] | 是 | 用户ID |
| deptId | [string] | 否 | 父节点ID |
请求例子:
- 通过CDN方式引入使用
<script src="https://cdn.jsdelivr.net/npm/umeet-js-sdk@1.0.16/UmeetJsSdk.min.js" type="text/javascript"></script> <script type="text/javascript"> // 获取部门--根节点 var currentDept = null; function getOrganizationsRoot() { let params = { userId: currentUser ? currentUser.id : '' }; UmeetJsSdk.getOrganizations(params, function (res) { console.log(res) if (res.status === 200) { currentDept = res.data[0]; } else { console.log(res.data.message) } }) } // 获取部门--子节点 function getOrganizationsChild() { let params = { userId: currentUser ? currentUser.id : '', deptId: currentDept.id }; UmeetJsSdk.getOrganizations(params, function (res) { if (res.status === 200) { } else { console.log(res.data.message) } }) } </script> - 通过NPM引入使用
import UmeetJsSdk from 'umeet-js-sdk'; // 获取部门--根节点 getOrganizationsRoot () { let that = this; let params = { userId: that.currentUser ? that.currentUser.id : '' }; UmeetJsSdk.getOrganizations(params).then(res => { if (res.status === 200) { that.currentDept = res.data[0]; } else { console.log(res.data.message) } }) }, // 获取部门--子节点 getOrganizationsChild () { let that = this; let params = { userId: that.currentUser ? that.currentUser.id : '', deptId: that.currentDept.id }; UmeetJsSdk.getOrganizations(params).then(res => { if (res.status === 200) { console.log(res); } else { console.log(res.data.message) } }) }
响应结果:
请求成功时,http status code =200,响应体内容如下:
| Parameters | Type/Value | Description |
|---|---|---|
| id | [string] | 机构id |
| capacity | [int] | 方数 |
| hasChildren | [boolean] | 是否有子机构 |
| levels | [string] | 机构层级 |
| name | [string] | 机构名称 |
| parentId | [string] | 父机构ID |
| parentIdList | [string] | 父机构IDS |
| self | [boolean] | |
| sort | [int] | 排序 |
如:
{
status: 200,
data: [
{
capacity: 3,
hasChildren: true,
id: "66232e9d-1e69-459d-8d3b-9f3d36e424f2",
levels: "集团总部/test",
name: "test",
parentId: "34d23d15-0b51-44bf-98d7-e788db384322",
parentIdList: "bef8c225-2587-4f53-8bba-7cd1eb3585ee,34d23d15-0b51-44bf-98d7-e788db384322",
self: true,
sort: 1
}
]
}