|
@@ -1,16 +1,73 @@
|
|
|
import Card from '@/components/Card';
|
|
|
import { useIncidentStore } from '@/store';
|
|
|
-import { computed, defineComponent, ref } from 'vue-demi';
|
|
|
+import { time } from 'console';
|
|
|
+import {
|
|
|
+ computed,
|
|
|
+ defineComponent,
|
|
|
+ onMounted,
|
|
|
+ onUnmounted,
|
|
|
+ ref,
|
|
|
+} from 'vue-demi';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'LiveMonitoringCard',
|
|
|
setup() {
|
|
|
const store = useIncidentStore();
|
|
|
|
|
|
+ const liveRef = ref<HTMLElement>();
|
|
|
+ const timer = ref();
|
|
|
+ const current = ref(0);
|
|
|
+
|
|
|
+ const length = computed(
|
|
|
+ () =>
|
|
|
+ (store.incidentDetail?.baseInfo?.pic?.split(',') ?? []).length +
|
|
|
+ (store.incidentDetail?.baseInfo?.video?.split(',') ?? []).length,
|
|
|
+ );
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ let itemWidth = 0;
|
|
|
+ let liveWidth = 0;
|
|
|
+ let contentWidth = 0;
|
|
|
+ timer.value = setInterval(() => {
|
|
|
+ if (liveRef.value) {
|
|
|
+ itemWidth =
|
|
|
+ itemWidth ||
|
|
|
+ (liveRef.value?.querySelector('.live-item')?.scrollWidth ?? 0);
|
|
|
+ contentWidth =
|
|
|
+ contentWidth || (liveRef.value.parentElement?.clientWidth ?? 0);
|
|
|
+ liveWidth = liveWidth || (liveRef.value?.scrollWidth ?? 0);
|
|
|
+ const count = Math.floor(liveWidth / (contentWidth || 1));
|
|
|
+
|
|
|
+ const transformCount = length.value / count || 1;
|
|
|
+
|
|
|
+ current.value += 1;
|
|
|
+
|
|
|
+ if (current.value < transformCount) {
|
|
|
+ liveRef.value.style.transform = `translateX(-${
|
|
|
+ itemWidth * count * current.value
|
|
|
+ }px)`;
|
|
|
+ } else {
|
|
|
+ current.value = 0;
|
|
|
+ liveRef.value.style.transform = `translateX(0px)`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
+ });
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ clearInterval(timer.value);
|
|
|
+ });
|
|
|
+
|
|
|
return () => (
|
|
|
<Card cardType="live-monitoring">
|
|
|
+ {/* <el-button icon="el-icon-arrow-left" type="info" circle /> */}
|
|
|
+ {/* <el-button icon="el-icon-arrow-right" type="info" circle /> */}
|
|
|
<div class="live-container">
|
|
|
- <div style={{ width: 'calc((1.0911458333rem + 10px) * 6) ' }}>
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ width: `calc((1.0911458333rem + 10px) * ${length.value}) `,
|
|
|
+ }}
|
|
|
+ ref={liveRef}>
|
|
|
{(store.incidentDetail?.baseInfo?.pic?.split(',') ?? []).map(
|
|
|
(item) => (
|
|
|
<div class="live-item">
|