import dayjs from 'dayjs'; import { toLabel as toLabelFreq } from '../common/dataMaintainFrequency'; import { toLabel as toLabelOwner } from '../common/dataOwnership'; import { toLabel as toLabelStatus } from '../common/dataRunningStatus'; import { toLabel as toLabelMonitor } from '../common/dataMonitorDeviceType'; import { toLabel as toLabelTreatment } from '../common/dataTreatmentDeviceType'; import { toLabel as toLabelProduction } from '../common/dataProductionDeviceType'; // 监测设备 export function getMonitorDevice(data) { data._updateTime = dayjs(data.diUpdateTime).format('YYYY年MM月DD日'); data._maintainFrequency = toLabelFreq(data.diMaintainFrequency); data._ownership = toLabelOwner(data.diOwnership); data._runningStatus = toLabelStatus(data.diRunningStatus); const labelArr = toLabelMonitor(data.diSceneTypeId, [data.diTypeId, data.diSubtypeId]); data._type = labelArr[0]; data._subType = labelArr[1]; return data } // 治理设备 export function getTreatmentDevice(data) { data._updateTime = dayjs(data.piUpdateTime).format('YYYY年MM月DD日'); data._maintainFrequency = toLabelFreq(data.piMaintainFrequency); data._ownership = toLabelOwner(data.piOwnership); data._runningStatus = toLabelStatus(data.piRunningStatus); const labelArr = toLabelTreatment(data.piSceneTypeId, [data.piTypeId, data.piSubtypeId]); data._type = labelArr[0]; data._subType = labelArr[1]; return data } // 生产设备 export function getProductionDevice(data) { data._updateTime = dayjs(data.wiUpdateTime).format('YYYY年MM月DD日'); data._ownership = toLabelOwner(data.wiOwnership); data._runningStatus = toLabelStatus(data.wiRunningStatus); const labelArr = toLabelProduction(data.wiSceneTypeId, [data.wiTypeId, data.wiSubtypeId]); data._type = labelArr[0]; data._subType = labelArr[1]; return data } export function getDeviceList(dataList, deviceType) { return dataList.map(item => { // 监测设备 if (deviceType == 0) { return getMonitorDevice(item); } // 治理设备 else if (deviceType == 1) { return getTreatmentDevice(item); } // 生产设备 else if (deviceType == 2) { return getProductionDevice(item); } }); }