overviewColumns.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { h } from 'vue';
  2. import { ElSwitch } from 'element-plus';
  3. import type { BasicColumn } from '@/components/Table';
  4. import connectedIcon from '@/assets/images/table/camera-netConnect.png';
  5. import unConnectedIcon from '@/assets/images/table/camera-netUnconnect.png';
  6. import { protocalTypeSelect } from './constant';
  7. import useCameraOverview from './stores/useCameraOverview';
  8. import { startCameraStream, stopCameraStream } from '@/api/camera/camera-overview';
  9. const cameraOverview = useCameraOverview();
  10. const { getState, getCameraItems } = cameraOverview;
  11. export const columns: BasicColumn[] = [
  12. {
  13. label: '序号',
  14. minWidth: 60,
  15. type: 'index',
  16. fixed: 'left',
  17. },
  18. {
  19. label: '名称',
  20. prop: 'name',
  21. minWidth: 100,
  22. },
  23. {
  24. label: 'IP地址',
  25. prop: 'cameraIp',
  26. minWidth: 140,
  27. },
  28. {
  29. label: '协议类型',
  30. prop: 'cameraType',
  31. minWidth: 120,
  32. render(record) {
  33. return h(
  34. 'span',
  35. {},
  36. {
  37. default: () =>
  38. protocalTypeSelect.find((item) => item.value === record.row.cameraType)?.label,
  39. },
  40. );
  41. },
  42. },
  43. {
  44. label: '端口地址',
  45. prop: 'cameraPort',
  46. minWidth: 120,
  47. },
  48. {
  49. label: 'MAC地址',
  50. prop: 'cameraMac',
  51. minWidth: 140,
  52. },
  53. {
  54. label: '设备ID',
  55. prop: 'code',
  56. minWidth: 150,
  57. },
  58. {
  59. label: '车间场景',
  60. prop: 'workshopName',
  61. minWidth: 140,
  62. },
  63. {
  64. label: '工位场景',
  65. prop: 'workspaceName',
  66. minWidth: 140,
  67. },
  68. {
  69. label: '联网状态',
  70. prop: 'networkingState',
  71. render(record) {
  72. return h(
  73. 'img',
  74. {
  75. src: record.row.networkingState === 0 ? connectedIcon : unConnectedIcon,
  76. style:
  77. 'width: 20px; height: 20px; object-fit: fill; display: inline-block; line-height: 20px; vertical-align: middle;',
  78. },
  79. {},
  80. );
  81. },
  82. minWidth: 120,
  83. align: 'center',
  84. sortable: 'custom',
  85. },
  86. {
  87. label: '是否进入平台',
  88. prop: 'integrationState',
  89. render(record) {
  90. return h(
  91. ElSwitch,
  92. {
  93. modelValue: record.row.integrationState,
  94. onChange: (val) => {
  95. record.row.status = val;
  96. if (val === 0) {
  97. startCameraStream(record.row.id).then(() => {
  98. getState();
  99. getCameraItems();
  100. });
  101. } else {
  102. stopCameraStream(record.row.id).then(() => {
  103. getState();
  104. getCameraItems();
  105. });
  106. }
  107. },
  108. activeValue: 0,
  109. inactiveValue: 1,
  110. },
  111. {},
  112. );
  113. },
  114. minWidth: 140,
  115. align: 'center',
  116. sortable: 'custom',
  117. },
  118. {
  119. label: '备注',
  120. prop: 'remark',
  121. minWidth: 60,
  122. },
  123. ];