overviewColumns.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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: 'companyName',
  21. minWidth: 100,
  22. },
  23. {
  24. label: '名称',
  25. prop: 'name',
  26. minWidth: 100,
  27. },
  28. {
  29. label: 'IP地址',
  30. prop: 'cameraIp',
  31. minWidth: 140,
  32. },
  33. {
  34. label: '协议类型',
  35. prop: 'cameraType',
  36. minWidth: 120,
  37. render(record) {
  38. return h(
  39. 'span',
  40. {},
  41. {
  42. default: () =>
  43. protocalTypeSelect.find((item) => item.value === record.row.cameraType)?.label,
  44. },
  45. );
  46. },
  47. },
  48. {
  49. label: '端口地址',
  50. prop: 'cameraPort',
  51. minWidth: 120,
  52. },
  53. {
  54. label: 'MAC地址',
  55. prop: 'cameraMac',
  56. minWidth: 140,
  57. },
  58. {
  59. label: '设备ID',
  60. prop: 'code',
  61. minWidth: 150,
  62. },
  63. {
  64. label: '车间场景',
  65. prop: 'workshopName',
  66. minWidth: 140,
  67. },
  68. {
  69. label: '工位场景',
  70. prop: 'workspaceName',
  71. minWidth: 140,
  72. },
  73. {
  74. label: '联网状态',
  75. prop: 'networkingState',
  76. render(record) {
  77. return h(
  78. 'img',
  79. {
  80. src: record.row.networkingState === 0 ? connectedIcon : unConnectedIcon,
  81. style:
  82. 'width: 20px; height: 20px; object-fit: fill; display: inline-block; line-height: 20px; vertical-align: middle;',
  83. },
  84. {},
  85. );
  86. },
  87. minWidth: 120,
  88. align: 'center',
  89. sortable: 'custom',
  90. },
  91. {
  92. label: '是否进入平台',
  93. prop: 'integrationState',
  94. render(record) {
  95. return h(
  96. ElSwitch,
  97. {
  98. modelValue: record.row.integrationState,
  99. onChange: (val) => {
  100. record.row.status = val;
  101. if (val === 0) {
  102. startCameraStream(record.row.id).then(() => {
  103. getState();
  104. getCameraItems();
  105. });
  106. } else {
  107. stopCameraStream(record.row.id).then(() => {
  108. getState();
  109. getCameraItems();
  110. });
  111. }
  112. },
  113. activeValue: 0,
  114. inactiveValue: 1,
  115. },
  116. {},
  117. );
  118. },
  119. minWidth: 140,
  120. align: 'center',
  121. sortable: 'custom',
  122. },
  123. {
  124. label: '备注',
  125. prop: 'remark',
  126. minWidth: 60,
  127. },
  128. ];