|
|
|
|
@ -8,9 +8,18 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item :label="t('EnergyManagement.EnergyDeviceCheck.searchOrgLabel')" prop="orgId">
|
|
|
|
|
<el-select v-model="queryParams.orgId" filterable clearable :placeholder="t('EnergyManagement.EnergyDeviceCheck.searchOrgPlaceholder')" class="!w-240px">
|
|
|
|
|
<el-option v-for="opt in orgOptions" :key="String(opt.value)" :label="opt.label" :value="opt.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-tree-select
|
|
|
|
|
v-model="queryParams.orgId"
|
|
|
|
|
:data="orgSelectTree"
|
|
|
|
|
:props="orgTreeSelectProps"
|
|
|
|
|
filterable
|
|
|
|
|
check-strictly
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-240px"
|
|
|
|
|
:placeholder="t('EnergyManagement.EnergyDeviceCheck.searchOrgPlaceholder')"
|
|
|
|
|
:loading="analysisLoading"
|
|
|
|
|
:render-after-expand="false"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item :label="t('EnergyManagement.EnergyDeviceCheck.searchTimeRangeLabel')" prop="timeRange">
|
|
|
|
|
@ -93,7 +102,7 @@ v-if="getPointDetailsRows(scope.row).length" :data="getPointDetailsRows(scope.ro
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import download from '@/utils/download'
|
|
|
|
|
import { EnergyDeviceApi, EnergyDeviceDataRecordVO } from '@/api/mes/energydevice'
|
|
|
|
|
import { OrganizationApi, OrganizationVO } from '@/api/mes/organization'
|
|
|
|
|
import { OrganizationApi } from '@/api/mes/organization'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'EnergyDeviceCheckRecord' })
|
|
|
|
|
|
|
|
|
|
@ -118,7 +127,59 @@ const updatePlanTableMaxHeight = async () => {
|
|
|
|
|
const expandRowKeys = ref<Array<string | number>>([])
|
|
|
|
|
const selectedIds = ref<Array<number | string>>([])
|
|
|
|
|
|
|
|
|
|
const orgOptions = ref<{ label: string; value: string | number; raw?: OrganizationVO }[]>([])
|
|
|
|
|
const analysisLoading = ref(false)
|
|
|
|
|
|
|
|
|
|
type AnalysisOrgNode = {
|
|
|
|
|
id: number | string
|
|
|
|
|
name: string
|
|
|
|
|
orgClass?: string
|
|
|
|
|
parentId?: number | string | null
|
|
|
|
|
children?: AnalysisOrgNode[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type OrgSelectNode = {
|
|
|
|
|
id: number | string
|
|
|
|
|
name: string
|
|
|
|
|
orgClass?: string
|
|
|
|
|
parentId?: number | string | null
|
|
|
|
|
children?: OrgSelectNode[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const orgSelectTree = ref<OrgSelectNode[]>([])
|
|
|
|
|
|
|
|
|
|
const orgTreeSelectProps = {
|
|
|
|
|
label: 'name',
|
|
|
|
|
children: 'children',
|
|
|
|
|
value: 'id'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const normalizeAnalysisTree = (nodes: any[] = []): AnalysisOrgNode[] => {
|
|
|
|
|
return nodes.map((node) => ({
|
|
|
|
|
id: node?.id,
|
|
|
|
|
name: String(node?.name ?? ''),
|
|
|
|
|
orgClass: node?.orgClass ? String(node.orgClass) : undefined,
|
|
|
|
|
parentId: node?.parentId ?? undefined,
|
|
|
|
|
children: Array.isArray(node?.children) ? normalizeAnalysisTree(node.children) : undefined
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const buildOrgSelectTree = (nodes: AnalysisOrgNode[] = []): OrgSelectNode[] => {
|
|
|
|
|
return nodes.map((node) => ({
|
|
|
|
|
id: node.id,
|
|
|
|
|
name: node.name,
|
|
|
|
|
orgClass: node.orgClass,
|
|
|
|
|
parentId: node.parentId,
|
|
|
|
|
children: Array.isArray(node.children) ? buildOrgSelectTree(node.children) : undefined
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const extractAnalysisOrgs = (res: any): AnalysisOrgNode[] => {
|
|
|
|
|
if (Array.isArray(res)) return normalizeAnalysisTree(res)
|
|
|
|
|
if (Array.isArray(res?.data)) return normalizeAnalysisTree(res.data)
|
|
|
|
|
if (Array.isArray(res?.result)) return normalizeAnalysisTree(res.result)
|
|
|
|
|
if (Array.isArray(res?.list)) return normalizeAnalysisTree(res.list)
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getDisabledTime = () => {
|
|
|
|
|
const all = Array.from({ length: 60 }, (_, i) => i)
|
|
|
|
|
@ -288,18 +349,26 @@ const handleExport = async () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const loadOrgOptions = async () => {
|
|
|
|
|
if (orgOptions.value.length) return
|
|
|
|
|
const data: any = await OrganizationApi.getOrganizationList({})
|
|
|
|
|
const rows = (Array.isArray(data) ? data : data?.list ?? data?.data ?? []) as OrganizationVO[]
|
|
|
|
|
orgOptions.value = rows
|
|
|
|
|
.filter((r) => r?.id !== undefined && r?.name)
|
|
|
|
|
.map((r) => ({ label: r.name, value: r.id, raw: r }))
|
|
|
|
|
const loadAnalysis = async () => {
|
|
|
|
|
if (orgSelectTree.value.length > 0) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
analysisLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await OrganizationApi.deviceParameterAnalysis({
|
|
|
|
|
showDevices: 0,
|
|
|
|
|
filterNoDeviceLine: 0
|
|
|
|
|
})
|
|
|
|
|
const analysisTree = extractAnalysisOrgs(res)
|
|
|
|
|
orgSelectTree.value = buildOrgSelectTree(analysisTree)
|
|
|
|
|
} finally {
|
|
|
|
|
analysisLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await loadOrgOptions()
|
|
|
|
|
await loadAnalysis()
|
|
|
|
|
await getList()
|
|
|
|
|
updatePlanTableMaxHeight()
|
|
|
|
|
window.addEventListener('resize', updatePlanTableMaxHeight)
|
|
|
|
|
|