CamerasOverview.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="camera-page">
  3. <ConditionQuery />
  4. <div class="camera-list">
  5. <BasicTable
  6. :columns="columns"
  7. :data-source="cameraItems"
  8. :row-key="(row) => row.code"
  9. :action-column="actionColumn"
  10. :pagination="false"
  11. :loading="loading"
  12. :tableSetting="{
  13. size: false,
  14. redo: false,
  15. fullscreen: false,
  16. striped: false,
  17. setting: false,
  18. }"
  19. :striped="true"
  20. ref="tableRef"
  21. @order-change="orderByItem"
  22. >
  23. <template #tableTitle>
  24. <el-button type="primary" :icon="Plus" @click="showAddPopover = true">添加</el-button>
  25. </template>
  26. <template #empty>
  27. <div class="empty-content flex flex-col items-center">
  28. <img :src="emptyImg" class="empty-img" />
  29. <span class="empty-text">目前无内容,请先添加相机</span>
  30. </div>
  31. </template>
  32. </BasicTable>
  33. </div>
  34. <AddCamera class="add-popover" v-model="showAddPopover" />
  35. <EditCamera class="add-popover" v-model="showEditPopover" :edit-data="editCameraData" />
  36. </div>
  37. </template>
  38. <script setup lang="ts">
  39. import { h, onMounted, reactive, ref } from 'vue';
  40. import { BasicTable, TableActionIcons } from '@/components/Table';
  41. import { BasicColumn } from '@/components/Table';
  42. import { columns } from './overviewColumns';
  43. import ConditionQuery from './components/ConditionQuery.vue';
  44. import AddCamera from './components/CameraAddPopover.vue';
  45. import EditCamera from './components/CameraEditPopover.vue';
  46. import emptyImg from '@/assets/images/table/table-empty.png';
  47. import { Plus } from '@element-plus/icons-vue';
  48. import previewIcon from '@/assets/images/table/table-preview.png';
  49. import editIcon from '@/assets/images/table/table-edit.png';
  50. import deleteIcon from '@/assets/images/table/table-delete.png';
  51. import useCameraOverview from './stores/useCameraOverview';
  52. import { storeToRefs } from 'pinia';
  53. import { CameraIPItem } from './type';
  54. const cameraOverview = useCameraOverview();
  55. const { cameraItems, loading } = storeToRefs(cameraOverview);
  56. const { getCameraItems } = cameraOverview;
  57. // 添加弹窗相关
  58. const showAddPopover = ref(false);
  59. const showEditPopover = ref(false);
  60. const editCameraData = ref<CameraIPItem | null>();
  61. //操作列
  62. const actionColumn: BasicColumn = reactive({
  63. width: 150,
  64. title: '操作',
  65. prop: 'action',
  66. key: 'action',
  67. fixed: 'right',
  68. render(record) {
  69. return h(TableActionIcons as any, {
  70. space: 20,
  71. color: '#629bf9',
  72. style: 'img',
  73. size: 16,
  74. actionIcons: [
  75. {
  76. label: '预览',
  77. icon: previewIcon,
  78. onClick: handlePreview.bind(null, record.row),
  79. },
  80. {
  81. label: '编辑',
  82. icon: editIcon,
  83. onClick: handleEdit.bind(null, record.row),
  84. },
  85. {
  86. label: '删除',
  87. icon: deleteIcon,
  88. onClick: handleDelete.bind(null, record.row),
  89. },
  90. ],
  91. });
  92. },
  93. });
  94. // 列排序操作
  95. const orderByItem = () => {};
  96. const handlePreview = () => {};
  97. const handleDelete = () => {};
  98. const handleEdit = (row) => {
  99. showEditPopover.value = true;
  100. editCameraData.value = row;
  101. };
  102. onMounted(() => {
  103. getCameraItems();
  104. });
  105. </script>
  106. <style scoped>
  107. .camera-page {
  108. position: relative;
  109. height: calc(100vh - 64px - 12px);
  110. background-color: #ffffff;
  111. }
  112. .camera-list {
  113. padding: 0 21px;
  114. }
  115. .empty-content {
  116. margin: auto;
  117. padding: 125px 0;
  118. }
  119. .empty-img {
  120. width: 396px;
  121. }
  122. .empty-text {
  123. font-size: 22px;
  124. color: #8e8e8e;
  125. line-height: 30px;
  126. text-align: center;
  127. }
  128. .add-popover {
  129. position: absolute;
  130. width: calc(100% - 21px);
  131. height: 622px;
  132. top: 0;
  133. bottom: 0;
  134. margin: auto;
  135. z-index: 99;
  136. }
  137. </style>