Commit af32762cb60dd81802bf71e9aa9125ce4b7a79ea
1 parent
05122beb
perf: DEFECT-806 not found data split mode default show layout
Showing
1 changed file
with
81 additions
and
10 deletions
1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
2 | import { PageWrapper } from '/@/components/Page'; | 2 | import { PageWrapper } from '/@/components/Page'; |
3 | import OrganizationIdTree from '../../common/organizationIdTree/src/OrganizationIdTree.vue'; | 3 | import OrganizationIdTree from '../../common/organizationIdTree/src/OrganizationIdTree.vue'; |
4 | - import { computed, onMounted, reactive, ref, unref, watch } from 'vue'; | ||
5 | - import { Row, Col, Spin, Button, Pagination, Empty, Space } from 'ant-design-vue'; | 4 | + import { onMounted, reactive, ref, unref, watch } from 'vue'; |
5 | + import { Spin, Button, Pagination, Space, List } from 'ant-design-vue'; | ||
6 | import { cameraPage } from '/@/api/camera/cameraManager'; | 6 | import { cameraPage } from '/@/api/camera/cameraManager'; |
7 | import { CameraRecord } from '/@/api/camera/model/cameraModel'; | 7 | import { CameraRecord } from '/@/api/camera/model/cameraModel'; |
8 | import { videoPlay as VideoPlay } from 'vue3-video-play'; | 8 | import { videoPlay as VideoPlay } from 'vue3-video-play'; |
@@ -14,6 +14,7 @@ | @@ -14,6 +14,7 @@ | ||
14 | import SvgIcon from '/@/components/Icon/src/SvgIcon.vue'; | 14 | import SvgIcon from '/@/components/Icon/src/SvgIcon.vue'; |
15 | import { isDef } from '/@/utils/is'; | 15 | import { isDef } from '/@/utils/is'; |
16 | import { getStreamingPlayUrl } from '/@/api/camera/cameraManager'; | 16 | import { getStreamingPlayUrl } from '/@/api/camera/cameraManager'; |
17 | + import { buildUUID } from '/@/utils/uuid'; | ||
17 | 18 | ||
18 | type CameraRecordItem = CameraRecord & { | 19 | type CameraRecordItem = CameraRecord & { |
19 | canPlay?: boolean; | 20 | canPlay?: boolean; |
@@ -67,15 +68,11 @@ | @@ -67,15 +68,11 @@ | ||
67 | getCameraList(); | 68 | getCameraList(); |
68 | }; | 69 | }; |
69 | 70 | ||
70 | - const getColLayout = computed(() => { | ||
71 | - const totalSpan = 24; | ||
72 | - return totalSpan / pagination.colNumber; | ||
73 | - }); | ||
74 | - | ||
75 | const getCameraList = async () => { | 71 | const getCameraList = async () => { |
76 | try { | 72 | try { |
73 | + cameraList.value = []; | ||
77 | loading.value = true; | 74 | loading.value = true; |
78 | - const { items, total } = await cameraPage({ | 75 | + let { items, total } = await cameraPage({ |
79 | page: pagination.page, | 76 | page: pagination.page, |
80 | pageSize: pagination.pageSize, | 77 | pageSize: pagination.pageSize, |
81 | organizationId: unref(organizationId)!, | 78 | organizationId: unref(organizationId)!, |
@@ -87,6 +84,14 @@ | @@ -87,6 +84,14 @@ | ||
87 | (item as CameraRecordItem).isTransform = false; | 84 | (item as CameraRecordItem).isTransform = false; |
88 | beforeVideoPlay(item); | 85 | beforeVideoPlay(item); |
89 | } | 86 | } |
87 | + if (items.length < pagination.pageSize) { | ||
88 | + const fillArr: any = Array.from({ length: pagination.pageSize - items.length }).map(() => ({ | ||
89 | + id: buildUUID(), | ||
90 | + placeholder: true, | ||
91 | + })); | ||
92 | + items = [...items, ...fillArr]; | ||
93 | + console.log(fillArr); | ||
94 | + } | ||
90 | cameraList.value = items; | 95 | cameraList.value = items; |
91 | } catch (error) { | 96 | } catch (error) { |
92 | } finally { | 97 | } finally { |
@@ -128,7 +133,10 @@ | @@ -128,7 +133,10 @@ | ||
128 | } | 133 | } |
129 | }; | 134 | }; |
130 | 135 | ||
136 | + const gridLayout = ref({ gutter: 1, column: 2 }); | ||
137 | + | ||
131 | const handleSwitchLayoutWay = (pageSize: number, layout: number) => { | 138 | const handleSwitchLayoutWay = (pageSize: number, layout: number) => { |
139 | + gridLayout.value = { gutter: 1, column: Math.sqrt(pageSize) }; | ||
132 | pagination.colNumber = layout; | 140 | pagination.colNumber = layout; |
133 | pagination.pageSize = pageSize; | 141 | pagination.pageSize = pageSize; |
134 | pagination.page = 1; | 142 | pagination.page = 1; |
@@ -238,7 +246,54 @@ | @@ -238,7 +246,54 @@ | ||
238 | </Space> | 246 | </Space> |
239 | </div> | 247 | </div> |
240 | </div> | 248 | </div> |
241 | - <section ref="videoContainer" class="bg-light-50 flex-auto dark:bg-dark-900"> | 249 | + <List |
250 | + :loading="loading" | ||
251 | + :data-source="cameraList" | ||
252 | + class="bg-light-50 flex-auto dark:bg-dark-900 split-mode-list" | ||
253 | + :grid="gridLayout" | ||
254 | + :style="{ '--height': `${100 / pagination.colNumber}%` }" | ||
255 | + > | ||
256 | + <template #renderItem="{ item }"> | ||
257 | + <List.Item> | ||
258 | + <div class="box-border w-full h-full p-1px"> | ||
259 | + <div | ||
260 | + v-if="item.placeholder" | ||
261 | + class="bg-black w-full h-full overflow-hidden relative" | ||
262 | + ></div> | ||
263 | + <div | ||
264 | + v-if="!item.placeholder" | ||
265 | + class="bg-black w-full h-full overflow-hidden relative video-container" | ||
266 | + > | ||
267 | + <Spin v-show="!item.isTransform" :spinning="!item.isTransform"> | ||
268 | + <div class="bg-black text-light-50"> </div> | ||
269 | + </Spin> | ||
270 | + <VideoPlay | ||
271 | + v-show="item.isTransform" | ||
272 | + @loadstart="handleLoadStart(item)" | ||
273 | + @loadeddata="handleLoadData(item)" | ||
274 | + v-bind="options" | ||
275 | + :src="item.videoUrl" | ||
276 | + :title="item.name" | ||
277 | + :type="item.type" | ||
278 | + /> | ||
279 | + <div | ||
280 | + v-if="item.isTransform && isDef(item.canPlay) && !item.canPlay" | ||
281 | + class="video-container-error-msk absolute top-0 left-0 text-lg w-full h-full text-light-50 flex justify-center items-center z-50 bg-black" | ||
282 | + > | ||
283 | + 视频加载出错了! | ||
284 | + </div> | ||
285 | + <div | ||
286 | + class="video-container-mask absolute top-0 left-0 z-50 text-lg w-full text-light-50 flex justify-center items-center" | ||
287 | + style="height: 100%; background-color: rgba(0, 0, 0, 0.5)" | ||
288 | + > | ||
289 | + <span>{{ item.name }}</span> | ||
290 | + </div> | ||
291 | + </div> | ||
292 | + </div> | ||
293 | + </List.Item> | ||
294 | + </template> | ||
295 | + </List> | ||
296 | + <!-- <section ref="videoContainer" class="bg-light-50 flex-auto dark:bg-dark-900"> | ||
242 | <Spin :spinning="loading" class="h-full"> | 297 | <Spin :spinning="loading" class="h-full"> |
243 | <Empty | 298 | <Empty |
244 | class="h-full flex flex-col justify-center items-center" | 299 | class="h-full flex flex-col justify-center items-center" |
@@ -283,7 +338,7 @@ | @@ -283,7 +338,7 @@ | ||
283 | </Col> | 338 | </Col> |
284 | </Row> | 339 | </Row> |
285 | </Spin> | 340 | </Spin> |
286 | - </section> | 341 | + </section> --> |
287 | </section> | 342 | </section> |
288 | </PageWrapper> | 343 | </PageWrapper> |
289 | <CameraDrawer @register="registerDrawer" @success="getCameraList" /> | 344 | <CameraDrawer @register="registerDrawer" @success="getCameraList" /> |
@@ -340,4 +395,20 @@ | @@ -340,4 +395,20 @@ | ||
340 | } | 395 | } |
341 | } | 396 | } |
342 | } | 397 | } |
398 | + | ||
399 | + .split-mode-list:deep(.ant-row) { | ||
400 | + width: 100%; | ||
401 | + height: 100%; | ||
402 | + } | ||
403 | + | ||
404 | + .split-mode-list:deep(.ant-list-item) { | ||
405 | + width: 100%; | ||
406 | + height: 100%; | ||
407 | + } | ||
408 | + | ||
409 | + .split-mode-list:deep(.ant-col) { | ||
410 | + width: 100%; | ||
411 | + // height: var(--height); | ||
412 | + height: 100%; | ||
413 | + } | ||
343 | </style> | 414 | </style> |