diff --git a/src/views/govern/alarm/Device.vue b/src/views/govern/alarm/Device.vue index cba533c..791d7a6 100644 --- a/src/views/govern/alarm/Device.vue +++ b/src/views/govern/alarm/Device.vue @@ -6,7 +6,7 @@ v-model="tableStore.table.params.cascader" placeholder="请选择数据来源" @change="sourceChange" - :options="props.deviceTree" + :options="deviceTreeOptions" :show-all-levels="false" :props="{ checkStrictly: true }" clearable @@ -103,21 +103,27 @@ tableStore.table.params.status = '' tableStore.table.params.target = [] tableStore.table.params.userId = '' +const deviceTreeOptions = ref(props.deviceTree) +deviceTreeOptions.value.map((item: any, index: any) => { + if (item.children.length == 0) { + deviceTreeOptions.value.splice(index, 1) + } +}) const sourceChange = (e: any) => { tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.projectId = e[2] || '' - const zlIndex = props.deviceTree.findIndex((item: any) => { + const zlIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '治理设备' }) - const bxsIndex = props.deviceTree.findIndex((item: any) => { + const bxsIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '便携式设备' }) //便携式设备特殊处理 - if (props.deviceTree[bxsIndex].id == e[0] && e.length == 2) { + if (bxsIndex != -1 && deviceTreeOptions.value[bxsIndex].id == e[0] && e.length == 2) { tableStore.table.params.deviceId = e[1] } //治理设备 - if (props.deviceTree[zlIndex].id == e[0]) { + if (zlIndex != -1 && deviceTreeOptions.value[zlIndex].id == e[0]) { tableStore.table.params.deviceId = e[2] || '' } } diff --git a/src/views/govern/alarm/Steady.vue b/src/views/govern/alarm/Steady.vue index 662df17..005a1b7 100644 --- a/src/views/govern/alarm/Steady.vue +++ b/src/views/govern/alarm/Steady.vue @@ -6,7 +6,7 @@ v-model="tableStore.table.params.cascader" placeholder="请选择数据来源" @change="sourceChange" - :options="props.deviceTree" + :options="deviceTreeOptions" :show-all-levels="false" :props="{ checkStrictly: true }" clearable @@ -102,25 +102,30 @@ tableStore.table.params.userId = '' tableStore.table.params.cascader = '' // tableStore.table.params.level='' +const deviceTreeOptions = ref(props.deviceTree) +deviceTreeOptions.value.map((item: any, index: any) => { + if (item.children.length == 0) { + deviceTreeOptions.value.splice(index, 1) + } +}) const sourceChange = (e: any) => { tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.projectId = e[2] || '' - const zlIndex = props.deviceTree.findIndex((item: any) => { + const zlIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '治理设备' }) - const bxsIndex = props.deviceTree.findIndex((item: any) => { + const bxsIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '便携式设备' }) //便携式设备特殊处理 - if (props.deviceTree[bxsIndex].id == e[0] && e.length == 2) { + if (bxsIndex != -1 && deviceTreeOptions.value[bxsIndex].id == e[0] && e.length == 2) { tableStore.table.params.deviceId = e[1] } //治理设备 - if (props.deviceTree[zlIndex].id == e[0]) { + if (zlIndex != -1 && deviceTreeOptions.value[zlIndex].id == e[0]) { tableStore.table.params.deviceId = e[2] || '' } } - onMounted(() => { tableStore.index() }) diff --git a/src/views/govern/alarm/Transient.vue b/src/views/govern/alarm/Transient.vue index 747667c..9dde192 100644 --- a/src/views/govern/alarm/Transient.vue +++ b/src/views/govern/alarm/Transient.vue @@ -7,7 +7,7 @@ placeholder="请选择数据来源" @change="sourceChange" v-model="tableStore.table.params.cascader" - :options="props.deviceTree" + :options="deviceTreeOptions" :show-all-levels="false" :props="{ checkStrictly: true }" clearable @@ -215,21 +215,27 @@ tableStore.table.params.userId = '' tableStore.table.params.cascader = '' // tableStore.table.params.level='' +const deviceTreeOptions = ref(props.deviceTree) +deviceTreeOptions.value.map((item: any, index: any) => { + if (item.children.length == 0) { + deviceTreeOptions.value.splice(index, 1) + } +}) const sourceChange = (e: any) => { tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.projectId = e[2] || '' - const zlIndex = props.deviceTree.findIndex((item: any) => { + const zlIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '治理设备' }) - const bxsIndex = props.deviceTree.findIndex((item: any) => { + const bxsIndex = deviceTreeOptions.value.findIndex((item: any) => { return item.name == '便携式设备' }) //便携式设备特殊处理 - if (props.deviceTree[bxsIndex].id == e[0] && e.length == 2) { + if (bxsIndex != -1 && deviceTreeOptions.value[bxsIndex].id == e[0] && e.length == 2) { tableStore.table.params.deviceId = e[1] } //治理设备 - if (props.deviceTree[zlIndex].id == e[0]) { + if (zlIndex != -1 && deviceTreeOptions.value[zlIndex].id == e[0]) { tableStore.table.params.deviceId = e[2] || '' } }