|
|
@ -48,7 +48,8 @@ |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { Component, Vue } from 'vue-property-decorator' |
|
|
import { Component, Vue } from 'vue-property-decorator' |
|
|
import OrganizationUnitService, { OrganizationUnitCreate } from '@/api/organizationunit' |
|
|
import { ListResultDto } from '@/api/types' |
|
|
|
|
|
import OrganizationUnitService, { OrganizationUnitCreate, OrganizationUnit } from '@/api/organizationunit' |
|
|
|
|
|
|
|
|
class OrganizationUnitTree { |
|
|
class OrganizationUnitTree { |
|
|
id?: string |
|
|
id?: string |
|
|
@ -86,25 +87,17 @@ export default class extends Vue { |
|
|
rootOrganizationUnit.displayName = '组织机构' |
|
|
rootOrganizationUnit.displayName = '组织机构' |
|
|
return resolve([rootOrganizationUnit]) |
|
|
return resolve([rootOrganizationUnit]) |
|
|
} |
|
|
} |
|
|
|
|
|
let organizationUnitItems = new ListResultDto<OrganizationUnit>() |
|
|
if (node.data.id === undefined) { |
|
|
if (node.data.id === undefined) { |
|
|
const result = await OrganizationUnitService.findOrganizationUnitLastChildren(node.data.id) |
|
|
// 根节点 |
|
|
if (result) { |
|
|
organizationUnitItems = await OrganizationUnitService.getRootOrganizationUnits() |
|
|
const organizationUnit = new OrganizationUnitTree() |
|
|
|
|
|
organizationUnit.id = result.id |
|
|
|
|
|
organizationUnit.parentId = result.parentId |
|
|
|
|
|
organizationUnit.code = result.code |
|
|
|
|
|
organizationUnit.displayName = result.displayName |
|
|
|
|
|
const children = node.data.children as OrganizationUnitTree[] |
|
|
|
|
|
if (!children.every(x => x.id === result.id)) { |
|
|
|
|
|
children.push(organizationUnit) |
|
|
|
|
|
} |
|
|
|
|
|
return resolve([organizationUnit]) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
const result = await OrganizationUnitService.findOrganizationUnitChildren(node.data.id, undefined) |
|
|
// 子节点 |
|
|
if (result.items.length !== 0) { |
|
|
organizationUnitItems = await OrganizationUnitService.findOrganizationUnitChildren(node.data.id, undefined) |
|
|
|
|
|
} |
|
|
|
|
|
if (organizationUnitItems.items.length !== 0) { |
|
|
const organizationUnits = new Array<OrganizationUnitTree>() |
|
|
const organizationUnits = new Array<OrganizationUnitTree>() |
|
|
result.items.map((item) => { |
|
|
organizationUnitItems.items.map((item) => { |
|
|
const organizationUnit = new OrganizationUnitTree() |
|
|
const organizationUnit = new OrganizationUnitTree() |
|
|
organizationUnit.id = item.id |
|
|
organizationUnit.id = item.id |
|
|
organizationUnit.parentId = item.parentId |
|
|
organizationUnit.parentId = item.parentId |
|
|
@ -118,7 +111,6 @@ export default class extends Vue { |
|
|
}) |
|
|
}) |
|
|
return resolve(organizationUnits) |
|
|
return resolve(organizationUnits) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return resolve([]) |
|
|
return resolve([]) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|