import { NTag } from 'naive-ui' import type { SiteInfo } from '@/service/siteInfoManage/interface' export const renderActStatus = (data: SiteInfo): string | VNode => { if (data.activeStatus === 0) { return h( NTag, { round: true, bordered: false, type: 'warning' }, // props { default: () => '未激活(0)', // 默认插槽内容 icon: () => h('span', { class: 'i-ph:info-fill text-gray-400' }), // icon 插槽 }, ) } else if (data.activeStatus === 1) { const activeStatusNodes: VNode[] = [ h( NTag, { round: true, bordered: false, type: 'success' }, // props { default: () => '已激活(1)', // 默认插槽内容 icon: () => h('span', { class: 'i-ph:check-circle-fill text-green-500' }), // icon 插槽 }, ), ] if (data.activeTime.length !== 0) { activeStatusNodes.push(h('div', `${data.activeTime}(北京时间)`)) } if (data.localActiveTime.length !== 0) { activeStatusNodes.push(h('div', `${data.localActiveTime}(设备时间)`)) } return h('div', activeStatusNodes) } else { return `unknown(${data.activeStatus})` } } export const renderEmsModel = (data: SiteInfo): string => { return `Model ID - ${data.emsModel}` } export const renderGridType = (data: SiteInfo): string => { if (data.electricityType === 0) { return '离网设备(0)' } else if (data.electricityType === 1) { return '并网设备(1)' } else { return `unknown(${data.electricityType})` } } export const renderGridStatus = (data: SiteInfo): string => { if (data.elecnetStatus === 0) { return '离网(0)' } else if (data.elecnetStatus === 1) { return '并网(1)' } else { return `unknown(${data.elecnetStatus})` } } export const renderRunStatus = (data: SiteInfo): string => { if (data.runStatus === 0) { return '待机(0)' } else if (data.runStatus === 1) { return '充电(1)' } else if (data.runStatus === 2) { return '放电(2)' } else if (data.runStatus === 3) { return '故障(3)' } else { return `unknown(${data.runStatus})` } } export const renderDspStatus = (data: SiteInfo): string => { if (data.slaverStat === 0) { return '初始化(0)' } else if (data.slaverStat === 1) { return '参数获取(1)' } else if (data.slaverStat === 2) { return '监听(2)' } else if (data.slaverStat === 3) { return '待机(3)' } else if (data.slaverStat === 4) { return '并网运行(4)' } else if (data.slaverStat === 5) { return '离网运行(5)' } else if (data.slaverStat === 6) { return '油机接入运行' } else if (data.slaverStat === 7) { return '故障(7)' } else { return `unknown(${data.slaverStat})` } } export const renderAPowerSn = (data: SiteInfo): VNode => { return h( 'div', { class: 'space-y-2' }, data.fhpSn.split(',').map((item) => { return h( NTag, { round: true, bordered: false, type: 'info' }, // props { default: () => item, // 默认插槽内容 }, ) }), ) }