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 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { PageWrapper } from '/@/components/Page'; |
| 3 | 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 | 6 | import { cameraPage } from '/@/api/camera/cameraManager'; |
| 7 | 7 | import { CameraRecord } from '/@/api/camera/model/cameraModel'; |
| 8 | 8 | import { videoPlay as VideoPlay } from 'vue3-video-play'; |
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | import SvgIcon from '/@/components/Icon/src/SvgIcon.vue'; |
| 15 | 15 | import { isDef } from '/@/utils/is'; |
| 16 | 16 | import { getStreamingPlayUrl } from '/@/api/camera/cameraManager'; |
| 17 | + import { buildUUID } from '/@/utils/uuid'; | |
| 17 | 18 | |
| 18 | 19 | type CameraRecordItem = CameraRecord & { |
| 19 | 20 | canPlay?: boolean; |
| ... | ... | @@ -67,15 +68,11 @@ |
| 67 | 68 | getCameraList(); |
| 68 | 69 | }; |
| 69 | 70 | |
| 70 | - const getColLayout = computed(() => { | |
| 71 | - const totalSpan = 24; | |
| 72 | - return totalSpan / pagination.colNumber; | |
| 73 | - }); | |
| 74 | - | |
| 75 | 71 | const getCameraList = async () => { |
| 76 | 72 | try { |
| 73 | + cameraList.value = []; | |
| 77 | 74 | loading.value = true; |
| 78 | - const { items, total } = await cameraPage({ | |
| 75 | + let { items, total } = await cameraPage({ | |
| 79 | 76 | page: pagination.page, |
| 80 | 77 | pageSize: pagination.pageSize, |
| 81 | 78 | organizationId: unref(organizationId)!, |
| ... | ... | @@ -87,6 +84,14 @@ |
| 87 | 84 | (item as CameraRecordItem).isTransform = false; |
| 88 | 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 | 95 | cameraList.value = items; |
| 91 | 96 | } catch (error) { |
| 92 | 97 | } finally { |
| ... | ... | @@ -128,7 +133,10 @@ |
| 128 | 133 | } |
| 129 | 134 | }; |
| 130 | 135 | |
| 136 | + const gridLayout = ref({ gutter: 1, column: 2 }); | |
| 137 | + | |
| 131 | 138 | const handleSwitchLayoutWay = (pageSize: number, layout: number) => { |
| 139 | + gridLayout.value = { gutter: 1, column: Math.sqrt(pageSize) }; | |
| 132 | 140 | pagination.colNumber = layout; |
| 133 | 141 | pagination.pageSize = pageSize; |
| 134 | 142 | pagination.page = 1; |
| ... | ... | @@ -238,7 +246,54 @@ |
| 238 | 246 | </Space> |
| 239 | 247 | </div> |
| 240 | 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 | 297 | <Spin :spinning="loading" class="h-full"> |
| 243 | 298 | <Empty |
| 244 | 299 | class="h-full flex flex-col justify-center items-center" |
| ... | ... | @@ -283,7 +338,7 @@ |
| 283 | 338 | </Col> |
| 284 | 339 | </Row> |
| 285 | 340 | </Spin> |
| 286 | - </section> | |
| 341 | + </section> --> | |
| 287 | 342 | </section> |
| 288 | 343 | </PageWrapper> |
| 289 | 344 | <CameraDrawer @register="registerDrawer" @success="getCameraList" /> |
| ... | ... | @@ -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 | 414 | </style> | ... | ... |