diff --git a/src/views/report/dashboardList/index.vue b/src/views/report/dashboardList/index.vue index da2e78a1..8185705a 100644 --- a/src/views/report/dashboardList/index.vue +++ b/src/views/report/dashboardList/index.vue @@ -97,8 +97,8 @@ v-for="dict in getStrDictOptions('mes_goview_type')" :key="dict.value" :label="d +v-model="createForm.orgId" :data="organizationTree" :props="lineTreeProps" filterable clearable + check-strictly class="!w-240px" :placeholder="t('ReportDashboard.DashboardList.dialogOrgPlaceholder')" @change="handleOrgChange" />
@@ -226,7 +226,8 @@ const organizationTree = ref([]) const lineTreeProps = { label: 'name', children: 'children', - value: 'name' + disabled: 'disabled', + value: 'id' } const deviceList = ref([]) @@ -455,7 +456,17 @@ const handleDelete = async (item: DashboardItem) => { const loadOrganizationTree = async () => { const data = await OrganizationApi.getOrganizationList() - organizationTree.value = handleTree(data, 'id', 'parentId') + const tree = handleTree(data, 'id', 'parentId') + const markPipelineSelectable = (nodes: any[], parentInPipeline = false) => { + nodes.forEach((node) => { + const inPipeline = parentInPipeline || node?.orgClass === 'pipeline' + node.disabled = !inPipeline + const children = Array.isArray(node.children) ? node.children : [] + if (children.length) markPipelineSelectable(children, inPipeline) + }) + } + markPipelineSelectable(tree, false) + organizationTree.value = tree } const findOrgNode = (nodes: any[], id: any): any | undefined => { @@ -480,15 +491,15 @@ const findOrgNodeByName = (nodes: any[], name: any): any | undefined => { return undefined } -const handleOrgChange = () => { - if (!createForm.orgName) { +const handleOrgChange = (value?: number | string) => { + if (!value) { createForm.orgId = undefined createForm.orgName = '' return } - const org = findOrgNodeByName(organizationTree.value || [], createForm.orgName) - createForm.orgId = org?.id ?? undefined - createForm.orgName = org?.name || createForm.orgName + const org = findOrgNode(organizationTree.value || [], value) + createForm.orgId = org?.id ?? value + createForm.orgName = org?.name || '' } const loadDeviceList = async () => {