Browse Source

master: Added 更改视频细节风格,样式有问题

gitboyzcf 4 months ago
parent
commit
8112a4c42b
2 changed files with 100 additions and 38 deletions
  1. 99 37
      src/views/preview-list/children/preview-info.vue
  2. 1 1
      src/views/preview-list/index.vue

+ 99 - 37
src/views/preview-list/children/preview-info.vue

@@ -140,15 +140,37 @@
                       @mouseenter="handleMouseEnter(i)"
                       @mouseenter="handleMouseEnter(i)"
                       @dblclick="handleDoubleClick(i)"
                       @dblclick="handleDoubleClick(i)"
                     >
                     >
-                      <a-spin v-if="activeObj[i].loading" dot />
-                      <div v-if="!activeObj[i].workerObj" class="video-box-tip"
+                      <a-spin v-if="activeObj[i]?.loading" dot />
+                      <div v-if="!activeObj[i]?.workerObj" class="video-box-tip"
                         ><span>{{ t('previewList.wxh') }}</span></div
                         ><span>{{ t('previewList.wxh') }}</span></div
                       >
                       >
-                      <div class="video-tools">
+                      <div v-if="activeObj[i]?.isCloseBtn" class="video-tools">
+                        <!-- 截图 录像 -->
+                        <a-tooltip
+                          v-for="tool in activeObj[i]?.tools"
+                          :key="tool.type"
+                          :content="tool.title"
+                        >
+                          <a-button
+                            type="text"
+                            size="mini"
+                            @click="partToolsClick(tool, activeObj[i])"
+                          >
+                            <template #icon>
+                              <Icon
+                                :icon="tool.icon"
+                                :color="tool.color"
+                                :class="[tool.iconClass]"
+                                width="24"
+                                height="24"
+                              />
+                            </template>
+                          </a-button>
+                        </a-tooltip>
                         <!-- 关闭 -->
                         <!-- 关闭 -->
                         <a-tooltip :content="$t('previewList.close')">
                         <a-tooltip :content="$t('previewList.close')">
                           <a-button
                           <a-button
-                            v-if="activeObj[i].isCloseBtn"
+                            v-if="i != 0"
                             type="text"
                             type="text"
                             size="mini"
                             size="mini"
                             @click="handleClose(i)"
                             @click="handleClose(i)"
@@ -179,7 +201,7 @@
                         </a-tooltip> -->
                         </a-tooltip> -->
                       </div>
                       </div>
                       <canvas
                       <canvas
-                        v-if="activeObj[i].isReset"
+                        v-if="activeObj[i]?.isReset"
                         :id="'video-canvas-part' + i"
                         :id="'video-canvas-part' + i"
                         :style="{
                         :style="{
                           width: '100%',
                           width: '100%',
@@ -369,7 +391,7 @@
   }>();
   }>();
   const qjLoading = ref(false);
   const qjLoading = ref(false);
   const radioActive = ref<number>(2);
   const radioActive = ref<number>(2);
-  const screenActive = ref<number>(0);
+  const screenActive = ref<number>(1);
 
 
   const btnList = computed<IBtn[]>(() => [
   const btnList = computed<IBtn[]>(() => [
     {
     {
@@ -430,6 +452,26 @@
         break;
         break;
     }
     }
   };
   };
+  const partToolsClick = (tool: any, ao: any) => {
+    if (!ao.workerObj) return;
+    switch (tool.type) {
+      case 'lx':
+        state.value = !state.value;
+        tool.icon = state.value ? 'fad:armrecording' : 'bx:video-recording';
+        tool.color = state.value ? 'red' : '#8ac5ff';
+        tool.iconClass = state.value ? '.fade-open' : '';
+        ao.workerObj.WebSocketWork.postMessage({
+          type: 'lx',
+          lx: state.value,
+        });
+        break;
+      case 'jt':
+        ao.workerObj.worker.postMessage({ type: 'jt' });
+        break;
+      default:
+        break;
+    }
+  };
   const gridCount = computed<number>(() => {
   const gridCount = computed<number>(() => {
     let result = 4;
     let result = 4;
     switch (radioActive.value) {
     switch (radioActive.value) {
@@ -457,7 +499,16 @@
       isSignal: boolean;
       isSignal: boolean;
       [key: string]: any;
       [key: string]: any;
     }[]
     }[]
-  >([]);
+  >([
+    {
+      loading: false,
+      isSignal: false,
+      workerObj: null,
+      isCloseBtn: false,
+      isReset: false,
+      tools: ref(tools.value.map((v) => ({ ...v, color: '#8ac5ff' }))),
+    },
+  ]);
   const alarmColumns = [
   const alarmColumns = [
     {
     {
       title: t('previewList.bjlx'),
       title: t('previewList.bjlx'),
@@ -497,14 +548,15 @@
   ) => {
   ) => {
     radioActive.value = typeof v === 'number' ? v : 2;
     radioActive.value = typeof v === 'number' ? v : 2;
     if (typeof v === 'number') {
     if (typeof v === 'number') {
-      screenActive.value = 0;
+      screenActive.value = 1;
       // eslint-disable-next-line no-plusplus
       // eslint-disable-next-line no-plusplus
-      for (let i = 0; i < v; i++) {
+      for (let i = 1; i < v; i++) {
         handleClose(i);
         handleClose(i);
       }
       }
     }
     }
   };
   };
   const handleScreen = (i: number) => {
   const handleScreen = (i: number) => {
+    if (!i) return;
     screenActive.value = i;
     screenActive.value = i;
   };
   };
   const handleMouseEnter = (v: number) => {
   const handleMouseEnter = (v: number) => {
@@ -598,16 +650,16 @@
   watch(
   watch(
     radioActive,
     radioActive,
     (newV) => {
     (newV) => {
-      activeObj.value = [];
+      activeObj.value = [activeObj.value[0]];
       // eslint-disable-next-line no-plusplus
       // eslint-disable-next-line no-plusplus
-      for (let i = 0; i < newV; i++) {
-        handleClose(i);
+      for (let i = 1; i < newV; i++) {
         activeObj.value.push({
         activeObj.value.push({
           loading: false,
           loading: false,
           isSignal: false,
           isSignal: false,
           workerObj: null,
           workerObj: null,
           isCloseBtn: false,
           isCloseBtn: false,
           isReset: false,
           isReset: false,
+          tools: ref(tools.value.map((v) => ({ ...v, color: '#8ac5ff' }))),
         });
         });
       }
       }
     },
     },
@@ -616,32 +668,42 @@
   watch(
   watch(
     () => app.partObj,
     () => app.partObj,
     (newV: any) => {
     (newV: any) => {
-      const partVideoUrl = `${app.ip}/VideoShow/Preview/Part/Main?GUID=${props.data.id}&X=${newV.PartCenterX}&Y=${newV.PartCenterY}`;
       handleClose(screenActive.value).then(() => {
       handleClose(screenActive.value).then(() => {
         ((active: number) => {
         ((active: number) => {
-          const ao = activeObj.value[active];
-          ao.loading = true;
-          ao.isReset = true;
+          let ao: any;
+          let partVideoUrl;
+          let className;
+          if (newV.PartCenterX) {
+            ao = activeObj.value[active];
+            ao.loading = true;
+            ao.isReset = true;
+            partVideoUrl = `${app.ip}/VideoShow/Preview/Part/Main?GUID=${props.data.id}&X=${newV.PartCenterX}&Y=${newV.PartCenterY}`;
+            className = `#video-canvas-part${active}`;
+          } else {
+            [ao] = activeObj.value;
+            ao.loading = true;
+            ao.isReset = true;
+            partVideoUrl = `${app.ip}/VideoShow/Preview/Part/Main?GUID=${props.data.id}&X=0&Y=0`;
+            className = `#video-canvas-part${0}`;
+          }
           nextTick(() => {
           nextTick(() => {
-            ao.workerObj = useWorker(
-              partVideoUrl,
-              `#video-canvas-part${active}`,
-              null,
-              () => {
-                ao.loading = false;
-                ao.isSignal = false;
+            ao.workerObj = useWorker(partVideoUrl, className, null, () => {
+              ao.loading = false;
+              ao.isSignal = false;
+              if (newV.PartCenterX) {
                 useWheel(
                 useWheel(
                   document.querySelectorAll('.video-box')[active],
                   document.querySelectorAll('.video-box')[active],
-                  `#video-canvas-part${active}`
+                  className
                 );
                 );
-              },
-              JSON.stringify(cropFullInfo.value)
-            );
+              } else {
+                useWheel(document.querySelectorAll('.video-box')[0], className);
+              }
+            });
           });
           });
         })(screenActive.value);
         })(screenActive.value);
       });
       });
     },
     },
-    { deep: true }
+    { deep: true, immediate: true }
   );
   );
 
 
   let eventSource: EventSource;
   let eventSource: EventSource;
@@ -691,18 +753,17 @@
       cropFullInfo.value = res.data;
       cropFullInfo.value = res.data;
       const videoUrl = `${app.ip}/VideoShow/Preview/Full/Main?GUID=${props.data.id}`;
       const videoUrl = `${app.ip}/VideoShow/Preview/Full/Main?GUID=${props.data.id}`;
       qjLoading.value = true;
       qjLoading.value = true;
-      workerObj.value.qj = useWorker(
-        videoUrl,
-        `#video-canvas-qj`,
-        null,
-        () => {
-          qjLoading.value = false;
-        },
-        JSON.stringify(cropFullInfo.value)
-      );
+      workerObj.value.qj = useWorker(videoUrl, `#video-canvas-qj`, null, () => {
+        qjLoading.value = false;
+      });
     });
     });
   });
   });
   onUnmounted(() => {
   onUnmounted(() => {
+    handleClose(0);
+    app.partObj = Object.assign(app.partObj as any, {
+      PartCenterX: '',
+      PartCenterY: '',
+    });
     workerObj.value.qj?.close();
     workerObj.value.qj?.close();
     workerObj.value.qj = null;
     workerObj.value.qj = null;
     eventSource?.close();
     eventSource?.close();
@@ -827,6 +888,7 @@
     background-color: #000;
     background-color: #000;
     overflow: hidden;
     overflow: hidden;
     box-sizing: content-box;
     box-sizing: content-box;
+    border: 1px solid #000000;
     cursor: pointer;
     cursor: pointer;
     .arco-spin {
     .arco-spin {
       position: absolute;
       position: absolute;

+ 1 - 1
src/views/preview-list/index.vue

@@ -500,7 +500,7 @@
 
 
     return loop<any>(originTreeData.value);
     return loop<any>(originTreeData.value);
   }
   }
-  const fetchData = async (params: PolicyParams = { Status: '1' }) => {
+  const fetchData = async (params: PolicyParams = {}) => {
     setLoading(true);
     setLoading(true);
     try {
     try {
       const { data } = await queryPolicyList(params);
       const { data } = await queryPolicyList(params);