devRender.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { NTag } from 'naive-ui'
  2. import type { SiteInfo } from '@/service/siteInfoManage/interface'
  3. export const renderActStatus = (data: SiteInfo): string | VNode => {
  4. if (data.activeStatus === 0) {
  5. return h(
  6. NTag,
  7. { round: true, bordered: false, type: 'warning' }, // props
  8. {
  9. default: () => '未激活(0)', // 默认插槽内容
  10. icon: () => h('span', { class: 'i-ph:info-fill text-gray-400' }), // icon 插槽
  11. },
  12. )
  13. } else if (data.activeStatus === 1) {
  14. const activeStatusNodes: VNode[] = [
  15. h(
  16. NTag,
  17. { round: true, bordered: false, type: 'success' }, // props
  18. {
  19. default: () => '已激活(1)', // 默认插槽内容
  20. icon: () => h('span', { class: 'i-ph:check-circle-fill text-green-500' }), // icon 插槽
  21. },
  22. ),
  23. ]
  24. if (data.activeTime.length !== 0) {
  25. activeStatusNodes.push(h('div', `${data.activeTime}(北京时间)`))
  26. }
  27. if (data.localActiveTime.length !== 0) {
  28. activeStatusNodes.push(h('div', `${data.localActiveTime}(设备时间)`))
  29. }
  30. return h('div', activeStatusNodes)
  31. } else {
  32. return `unknown(${data.activeStatus})`
  33. }
  34. }
  35. export const renderEmsModel = (data: SiteInfo): string => {
  36. return `Model ID - ${data.emsModel}`
  37. }
  38. export const renderGridType = (data: SiteInfo): string => {
  39. if (data.electricityType === 0) {
  40. return '离网设备(0)'
  41. } else if (data.electricityType === 1) {
  42. return '并网设备(1)'
  43. } else {
  44. return `unknown(${data.electricityType})`
  45. }
  46. }
  47. export const renderGridStatus = (data: SiteInfo): string => {
  48. if (data.elecnetStatus === 0) {
  49. return '离网(0)'
  50. } else if (data.elecnetStatus === 1) {
  51. return '并网(1)'
  52. } else {
  53. return `unknown(${data.elecnetStatus})`
  54. }
  55. }
  56. export const renderRunStatus = (data: SiteInfo): string => {
  57. if (data.runStatus === 0) {
  58. return '待机(0)'
  59. } else if (data.runStatus === 1) {
  60. return '充电(1)'
  61. } else if (data.runStatus === 2) {
  62. return '放电(2)'
  63. } else if (data.runStatus === 3) {
  64. return '故障(3)'
  65. } else {
  66. return `unknown(${data.runStatus})`
  67. }
  68. }
  69. export const renderDspStatus = (data: SiteInfo): string => {
  70. if (data.slaverStat === 0) {
  71. return '初始化(0)'
  72. } else if (data.slaverStat === 1) {
  73. return '参数获取(1)'
  74. } else if (data.slaverStat === 2) {
  75. return '监听(2)'
  76. } else if (data.slaverStat === 3) {
  77. return '待机(3)'
  78. } else if (data.slaverStat === 4) {
  79. return '并网运行(4)'
  80. } else if (data.slaverStat === 5) {
  81. return '离网运行(5)'
  82. } else if (data.slaverStat === 6) {
  83. return '油机接入运行'
  84. } else if (data.slaverStat === 7) {
  85. return '故障(7)'
  86. } else {
  87. return `unknown(${data.slaverStat})`
  88. }
  89. }
  90. export const renderAPowerSn = (data: SiteInfo): VNode => {
  91. return h(
  92. 'div',
  93. { class: 'space-y-2' },
  94. data.fhpSn.split(',').map((item) => {
  95. return h(
  96. NTag,
  97. { round: true, bordered: false, type: 'info' }, // props
  98. {
  99. default: () => item, // 默认插槽内容
  100. },
  101. )
  102. }),
  103. )
  104. }