Przeglądaj źródła

Merge branch 'dev-fix-downloadNvr' into 'all'

Dev fix download nvr

See merge request skyeye/skyeye_frontend/skyeye-admin!162
孙宏耀 1 rok temu
rodzic
commit
4c54129539

+ 23 - 6
src/api/datamanagement/getDevMode.ts

@@ -4,14 +4,31 @@ import { http } from '@/utils/http/axios';
 export const getDevMode = () => {
   return http.request({
     url: '/issue/getDevMode',
-    method: 'get'
+    method: 'get',
   });
 };
 
 // 切换开发者模式开关状态
 export const switchDevMode = () => {
-    return http.request({
-      url: '/issue/switchDevMode',
-      method: 'post'
-    });
-  };
+  return http.request({
+    url: '/issue/switchDevMode',
+    method: 'post',
+  });
+};
+
+export const getVideoLength = () => {
+  return http.request({
+    url: '/sysconfig/getVideoLength',
+    method: 'get',
+  });
+};
+
+export const updateVideoLength = (len: number) => {
+  return http.request({
+    url: '/sysconfig/updateVideoLength',
+    method: 'post',
+    data: {
+      videoLength: len,
+    },
+  });
+};

+ 87 - 0
src/views/datamanager/alertformdata/components/common/Prequalification.vue

@@ -0,0 +1,87 @@
+<template>
+  <div class="opt-container">
+    <div class="prequal-container" v-if="hasDevModePermisson()">
+      <div>预审后生效模式:</div>
+      <el-switch :model-value="devMode" @change="switchDevMode" />
+    </div>
+    <div style="display: flex" v-if="hasDataDelete()">
+      <div>报警视频截取时长:</div>
+      <el-select
+        v-model="videoLength"
+        style="width: 80px; margin: 0 10px"
+        @change="updateNewVideoLength"
+      >
+        <el-option v-for="item in videoLengthOptions" :key="item" :label="item" :value="item" />
+      </el-select>
+      <div>s</div>
+    </div>
+  </div>
+</template>
+
+<script setup lang="ts">
+  import { onMounted, ref } from 'vue';
+  import {
+    getDevMode,
+    switchDevMode as SDM,
+    getVideoLength,
+    updateVideoLength,
+  } from '@/api/datamanagement/getDevMode';
+  import { useUserStore } from '@/store/modules/user';
+  import { ElMessage } from 'element-plus';
+
+  const userStore = useUserStore();
+
+  const devMode = ref(true);
+  getDevMode().then((res) => {
+    devMode.value = res;
+  });
+
+  const switchDevMode = () => {
+    SDM();
+    devMode.value = !devMode.value;
+  };
+
+  const hasDevModePermisson = () => {
+    return userStore.checkPermission('control_activation');
+  };
+
+  const hasDataDelete = () => {
+    return userStore.checkPermission('data_delete');
+  };
+
+  const videoLength = ref(10);
+  const videoLengthOptions = [10, 20, 40, 60];
+
+  const getCurVideoLength = () => {
+    getVideoLength().then((res) => {
+      videoLength.value = res;
+    });
+  };
+
+  const updateNewVideoLength = () => {
+    updateVideoLength(videoLength.value).then(() => {
+      ElMessage({
+        message: '报警视频截取长度设置成功',
+        type: 'success',
+      });
+    });
+  };
+
+  onMounted(() => {
+    getCurVideoLength();
+  });
+</script>
+
+<style scoped>
+  .opt-container {
+    margin-bottom: 10px;
+    display: flex;
+    line-height: 33px;
+    text-wrap: nowrap;
+  }
+
+  .prequal-container {
+    display: flex;
+    margin-right: 30px;
+  }
+</style>

+ 2 - 0
src/views/datamanager/alertformdata/components/default-simple/Default.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="box">
+    <Prequalification />
     <div class="search-form">
       <QueryFormSimple
         :is-show-tab="false"
@@ -55,6 +56,7 @@
   import Pagination from '../common/Pagination.vue';
   import { useIssueType } from '../../hooks/useIssueType';
   import { useWorkLocation } from '../../hooks/useWorkLocation';
+  import Prequalification from '../common/Prequalification.vue';
   import { getDefaultTableData, deleteDefaultTableData } from '@/api/datamanagement/alert-default';
 
   const { aiOptions, manualOptions, getAIOptions, getManualOptions } = useIssueType();

+ 2 - 18
src/views/datamanager/alertformdata/components/default/Default.vue

@@ -1,9 +1,6 @@
 <template>
   <div class="box">
-    <div style="margin-bottom: 10px; display: flex" v-if="hasDevModePermisson()">
-      <div style="line-height: 33px">预审后生效模式:</div>
-      <el-switch :model-value="devMode" @change="switchDevMode" />
-    </div>
+    <Prequalification />
     <div class="search-form">
       <QueryForm
         :is-show-tab="false"
@@ -107,7 +104,7 @@
     updateDefaultPriority,
     updateDefaultPriorityAll,
   } from '@/api/datamanagement/alert-default';
-  import { getDevMode, switchDevMode as SDM } from '@/api/datamanagement/getDevMode';
+  import Prequalification from '../common/Prequalification.vue';
 
   import { useUserStore } from '@/store/modules/user';
   import { useGlobSetting } from '@/hooks/setting';
@@ -477,19 +474,6 @@
     return userStore.checkPermission('question_mock_edit_admin');
   };
 
-  const hasDevModePermisson = () => {
-    return userStore.checkPermission('control_activation');
-  };
-
-  const devMode = ref(true);
-  getDevMode().then((res) => {
-    devMode.value = res;
-  });
-  const switchDevMode = () => {
-    SDM();
-    devMode.value = !devMode.value;
-  };
-
   onMounted(() => {
     getTableData();
   });

+ 32 - 7
src/views/datamanager/playback/components/NvrTimeSelect.vue

@@ -3,7 +3,6 @@
     <div class="head">
       <div class="line"></div>
       <div class="title">视频下载</div>
-      <span class="tips">(请先拖动进度条,再点击选取时间按钮)</span>
     </div>
 
     <div class="timeselect">
@@ -16,13 +15,14 @@
           format="YYYY-MM-DD HH:mm:ss"
           value-format="YYYY-MM-DD HH:mm:ss"
           :clearable="true"
-          placeholder="拖动进度条选择时间"
+          placeholder="点击选择时间"
+          @change="changeStart"
         />
         <!-- <el-input
           v-model="startTime"
           style="width: 160px; margin: 0 8px"
           disabled
-          placeholder="拖动进度条选择时间"
+          placeholder="点击选择时间"
         /> -->
         <el-tooltip
           class="picker-tooltip"
@@ -49,14 +49,16 @@
           type="datetime"
           format="YYYY-MM-DD HH:mm:ss"
           value-format="YYYY-MM-DD HH:mm:ss"
+          :disabled="!startTime || !startTime.length"
           :clearable="true"
-          placeholder="拖动进度条选择时间"
+          placeholder="点击选择时间"
+          @change="judgeDate"
         />
         <!-- <el-input
           v-model="endTime"
           style="width: 160px; margin: 0 8px"
           disabled
-          placeholder="拖动进度条选择时间"
+          placeholder="点击选择时间"
         /> -->
         <el-tooltip
           class="picker-tooltip"
@@ -79,7 +81,7 @@
       <el-button
         type="primary"
         :loading="isCallingDownload"
-        :disabled="!startTime.length || !endTime.length"
+        :disabled="!startTime || !endTime || !startTime.length || !endTime.length"
         @click="nvrDownload"
         >下 载</el-button
       >
@@ -89,9 +91,10 @@
 
 <script setup lang="ts">
   import { ref } from 'vue';
-  import { ElInput } from 'element-plus';
+  // import { ElInput } from 'element-plus';
   import { Refresh } from '@element-plus/icons-vue';
   import { ElIcon, ElTooltip } from 'element-plus';
+  import { ElMessage } from 'element-plus';
 
   const isCallingDownload = ref(false);
   const startTime = ref('');
@@ -106,11 +109,33 @@
   const nvrDownload = () => {
     emit('downloadNvr');
   };
+
+  const changeStart = (val) => {
+    if (!val) {
+      endTime.value = '';
+    }
+  };
   const clearTime = () => {
     startTime.value = '';
     endTime.value = '';
   };
 
+  const judgeDate = (value) => {
+    if (!endTime.value) {
+      return;
+    }
+    const startTimeStamp = new Date(startTime.value).getTime();
+    const endTimeStamp = new Date(value).getTime();
+    if (endTimeStamp <= startTimeStamp) {
+      ElMessage.warning('结束时间不能小于开始时间');
+      endTime.value = '';
+    }
+    if (endTimeStamp - startTimeStamp > 10 * 60 * 1000) {
+      ElMessage.warning('视频下载时间不能超过10分钟');
+      endTime.value = '';
+    }
+  };
+
   defineExpose({ isCallingDownload, startTime, endTime, clearTime });
 </script>