style:大屏管理-产线可选节点条件判断

main
黄伟杰 3 days ago
parent 56532d415f
commit 8c976d81ff

@ -97,8 +97,8 @@ v-for="dict in getStrDictOptions('mes_goview_type')" :key="dict.value" :label="d
</el-form-item> </el-form-item>
<el-form-item :label="t('ReportDashboard.DashboardList.dialogOrgLabel')" prop="orgId"> <el-form-item :label="t('ReportDashboard.DashboardList.dialogOrgLabel')" prop="orgId">
<el-tree-select <el-tree-select
v-model="createForm.orgName" :data="organizationTree" :props="lineTreeProps" filterable clearable v-model="createForm.orgId" :data="organizationTree" :props="lineTreeProps" filterable clearable
class="!w-240px" :placeholder="t('ReportDashboard.DashboardList.dialogOrgPlaceholder')" @change="handleOrgChange" /> check-strictly class="!w-240px" :placeholder="t('ReportDashboard.DashboardList.dialogOrgPlaceholder')" @change="handleOrgChange" />
</el-form-item> </el-form-item>
<el-form-item :label="t('ReportDashboard.DashboardList.dialogDeviceLabel')" v-if="createForm.type === '1'"> <el-form-item :label="t('ReportDashboard.DashboardList.dialogDeviceLabel')" v-if="createForm.type === '1'">
<div class="dashboard-device-group-list"> <div class="dashboard-device-group-list">
@ -226,7 +226,8 @@ const organizationTree = ref<any[]>([])
const lineTreeProps = { const lineTreeProps = {
label: 'name', label: 'name',
children: 'children', children: 'children',
value: 'name' disabled: 'disabled',
value: 'id'
} }
const deviceList = ref<any[]>([]) const deviceList = ref<any[]>([])
@ -455,7 +456,17 @@ const handleDelete = async (item: DashboardItem) => {
const loadOrganizationTree = async () => { const loadOrganizationTree = async () => {
const data = await OrganizationApi.getOrganizationList() 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 => { const findOrgNode = (nodes: any[], id: any): any | undefined => {
@ -480,15 +491,15 @@ const findOrgNodeByName = (nodes: any[], name: any): any | undefined => {
return undefined return undefined
} }
const handleOrgChange = () => { const handleOrgChange = (value?: number | string) => {
if (!createForm.orgName) { if (!value) {
createForm.orgId = undefined createForm.orgId = undefined
createForm.orgName = '' createForm.orgName = ''
return return
} }
const org = findOrgNodeByName(organizationTree.value || [], createForm.orgName) const org = findOrgNode(organizationTree.value || [], value)
createForm.orgId = org?.id ?? undefined createForm.orgId = org?.id ?? value
createForm.orgName = org?.name || createForm.orgName createForm.orgName = org?.name || ''
} }
const loadDeviceList = async () => { const loadDeviceList = async () => {

Loading…
Cancel
Save