<template>
|
<LogicManageContainerV2
|
ref="logicManageContainerV2Ref"
|
type="select-list"
|
:selectFolderIcon="(_, data) => data.LogicType !== LOGIC_SITE_CODE"
|
:select="{
|
label: '泵站',
|
requestApi: GetLogicTreeListByPolicyIDStd,
|
code: LOGIC_SITE_CODE,
|
treeProps,
|
}"
|
:defaultSelectID="defaultSelectID"
|
:list="{
|
label: '机组',
|
requestApi: GetCatalogTreeItemListByBelongTypeAndBelongIDStd,
|
extraParams: {
|
Catalog: ENGINE_PUMP_CODE,
|
},
|
checkFirst,
|
}"
|
:folderIcon="() => false"
|
:contentRef="contentRef"
|
:req="request"
|
:expandOnClickNode="false"
|
@listClick="listClick"
|
@selectChange="selectChange"
|
>
|
<template #main="{ listNode, selectNode }">
|
<slot name="main" :listNode="listNode" :selectNode="selectNode" :selectTreeProps="treeProps"> </slot>
|
</template>
|
|
<template #listNodeSuffix="{ data, node }">
|
<div
|
v-if="runRecordMap[data.ID]"
|
class="run-status flex-center mr5"
|
:class="{ 'run-status_work': runRecordMap[data.ID]?.RSa > 0 }"
|
>
|
{{ runRecordMap[data.ID]?.RSa > 0 ? '开' : '关' }}
|
</div>
|
</template>
|
</LogicManageContainerV2>
|
</template>
|
|
<script setup lang="ts">
|
import LogicManageContainerV2 from '/@/projectCom/components/manage/LogicManageContainerV2.vue';
|
import request from '/@/utils/request';
|
import { ENGINE_PUMP_CODE, EQUIPMENT_CODE, LOGIC_SITE_CODE } from '/@/constants';
|
import { GetCatalogTreeItemListByBelongTypeAndBelongIDStd, GetEquipmentTreeDataStd } from '/@/api/assets/equipmentStd';
|
import { GetLogicTreeListByPolicyIDStd } from '/@/api/phm/logicTreeStd';
|
|
import { computed, nextTick, ref, toRefs, watch } from 'vue';
|
import { getRunRealRecordListStd } from '/@/api/run/runRealRecord';
|
import { isFilledArray } from '/@/utils/types';
|
import { travelTree, getItemMap } from '/@/utils/util';
|
const props = defineProps({
|
contentRef: {
|
type: Object,
|
},
|
showRunStatus: {
|
type: Boolean,
|
default: true,
|
},
|
});
|
const { showRunStatus } = toRefs(props);
|
|
const emits = defineEmits<{
|
(event: 'selectChange', data): void;
|
(event: 'listClick', data): void;
|
}>();
|
const defaultSelectID = ref(window.moduleConfig.comprehensive.logicSite.defaultSelectID);
|
|
const selectChange = (data) => {
|
window.moduleConfig.comprehensive.logicSite.defaultSelectID = data[treeProps.id];
|
defaultSelectID.value = data[treeProps.id];
|
emits('selectChange', data);
|
};
|
const checkFirst = (data) => {
|
return data.ID === defaultListID.value;
|
};
|
const defaultListID = ref(window.moduleConfig.assets.equipment.defaultSelectID);
|
const listClick = (data) => {
|
window.moduleConfig.assets.equipment.defaultSelectID = data.ID;
|
defaultListID.value = data.ID;
|
nextTick(() => {
|
props.contentRef?.getTableData();
|
});
|
emits('listClick', data);
|
};
|
const treeProps = {
|
id: 'LogicID',
|
label: 'Name',
|
children: 'Children',
|
};
|
|
//#region ====================== 获取实时运行状态 ======================
|
const logicManageContainerV2Ref = ref<InstanceType<typeof LogicManageContainerV2>>(null);
|
const runRecordMap = ref({});
|
|
if (showRunStatus.value) {
|
const treeListData = computed(() => logicManageContainerV2Ref.value?.treeListData);
|
|
watch(
|
() => treeListData.value,
|
async (val) => {
|
// 先置空,防止网络过慢,状态没更新
|
runRecordMap.value = {};
|
|
if (!isFilledArray(val)) {
|
return;
|
}
|
const equipIds = [];
|
travelTree(val, (item) => {
|
equipIds.push(item.ID);
|
});
|
|
const realRunRecordList = await getRunRealRecordListStd({
|
ObjectType: EQUIPMENT_CODE,
|
ObjectIds: equipIds.join(','),
|
});
|
|
runRecordMap.value = getItemMap(realRunRecordList, 'ObjectID');
|
}
|
);
|
}
|
//#endregion
|
</script>
|
<style scoped lang="scss">
|
$run-status-size: 20px;
|
.run-status {
|
width: $run-status-size;
|
height: $run-status-size;
|
border-radius: 50%;
|
font-size: 14px;
|
color: white;
|
background-color: rgb(159 159 159);
|
|
&_work {
|
background-color: rgb(1 198 1);
|
}
|
}
|
</style>
|