Ver código fonte

feat: 地图更新记录选择逻辑

LingxinMeng 10 meses atrás
pai
commit
f188c383bb
1 arquivos alterados com 66 adições e 58 exclusões
  1. 66 58
      src/views/ReportView.vue

+ 66 - 58
src/views/ReportView.vue

@@ -37,12 +37,28 @@
               <el-button type="danger" @click="onSubmit">重置</el-button>
             </el-form-item>
           </el-form>
-          <el-button type="primary" @click="goToMapUpdate">地图更新</el-button>
+          <el-button type="primary" @click="updateMap">地图更新</el-button>
           <el-button type="primary" @click="goToUpdateStat">地图更新统计</el-button>
           <el-button type="primary" @click="mapDialogVisible = true">地图续扫提醒阈值</el-button>
           <el-button type="primary" @click="goToMapRescan">地图续扫提醒</el-button>
 
 
+          <el-dialog
+              v-model="updateDialogVisible"
+              title="地图更新"
+              width="400"
+              :before-close="handleClose"
+          >
+            <el-steps style="max-width: 600px" :active="active" finish-status="success">
+              <el-step title="数据格式检查"/>
+              <el-step title="地图生成"/>
+            </el-steps>
+
+            <template #footer>
+              <el-button @click="goToMapUpdate" :disabled="active !== 2">去部署</el-button>
+            </template>
+          </el-dialog>
+
           <el-dialog
               v-model="mapDialogVisible"
               title="地图续扫提醒"
@@ -128,7 +144,7 @@
           </div>
         </div>
         <el-table stripe style="background-color: rgba(255,0,0,99%);width: 100%" border :data="tableData"
-                  fixed ref="multipleTableRef" :cell-style="{ textAlign: 'center'}" :header-cell-style="{ textAlign: 'center'}">
+                  fixed ref="multipleTableRef" @selection-change="handleSelectionChange" :cell-style="{ textAlign: 'center'}" :header-cell-style="{ textAlign: 'center'}">
           <el-table-column type="selection" width="55"/>
           <el-table-column prop="dataName" label="数据名称"/>
           <el-table-column prop="dataSize" label="数据容量" :formatter="dataSizeFormatter"/>
@@ -169,11 +185,13 @@ import {onBeforeMount, ref} from "vue";
 import axios from "axios";
 import {reactive} from 'vue'
 import {ElTable} from "element-plus";
+import { ElMessage } from "element-plus";
 import {useRouter} from 'vue-router'; // 导入 Vue Router 的 useRouter 钩子
 
 
 const value
     = ref(true)
+const active = ref(0)
 const router = useRouter();
 const algorithmContainerState = ref(false)
 const gazeboState = ref(false)
@@ -182,11 +200,14 @@ const multipleTableRef = ref<InstanceType<typeof ElTable>>
 
 const algorithmDialogVisible = ref(false)
 const mapDialogVisible = ref(false)
+const updateDialogVisible = ref(false)
 
 const handleClose = (done: () => void) => {
   done()
 }
 
+const multipleSelection = ref<[]>([])
+
 // do not use same name with ref
 const algorithmForm = reactive({
   sudoPassword: '',
@@ -244,6 +265,48 @@ const dataSizeFormatter = (row, column, cellValue, index) => {
   return cellValue; // 如果cellValue为null或undefined,则返回原值或你想要的默认值
 }
 
+const isPropertySame= (array, propertyName) => {
+  if (array.length <= 1) {
+    return true; // 空数组或但个元素视为所有值相同
+  }
+
+  const firstValue = array[0][propertyName];
+
+  for (let i = 1; i < array.length; i++) {
+    if (array[i][propertyName] !== firstValue) {
+      return false; // 发现不同的值
+    }
+  }
+
+  return true; // 所有值都是相同的
+}
+
+const updateMap = () => {
+  if (multipleSelection.value.length == 0) {
+    ElMessage.error("请选择记录!");
+    return;
+  }
+  const isEquipmentSame = isPropertySame(multipleSelection.value, "equipmentId")
+  if (!isEquipmentSame) {
+    ElMessage.error("所选择的记录属于多个设备,请进行检查!");
+    return;
+  } else {
+    updateDialogVisible.value = true;
+    console.log(JSON.stringify(multipleSelection.value))
+  }
+}
+
+
+const handleSelectionChange = (rows: []) => {
+  multipleSelection.value = rows
+  const isEquipmentSame = isPropertySame(rows, "equipmentId")
+  if (!isEquipmentSame) {
+    ElMessage.error("所选择的记录属于多个设备,请进行检查!");
+  } else {
+    console.log(JSON.stringify(multipleSelection.value))
+  }
+}
+
 const gazebo = () => {
   if (gazeboState.value) {
     if (window.electronAPI) {
@@ -278,61 +341,6 @@ const rviz = () => {
   }
 }
 
-
-const downloadPdf = (index: number, row: any) => {
-  console.log(index, row)
-  axios.post('http://36.110.106.142:12341/web_server/exam/report',
-      {
-        "id": row.id,
-        "teamName": row.teamName,
-        "scoreOnline": row.scoreOnline,
-        "beginTime": row.beginTime,
-        "endTime": row.endTime
-      },
-      {
-        headers: {
-          "Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"
-        },
-        responseType: 'blob' // 设置响应类型为二进制流
-      }
-  ).then(function (response) {
-    const url = window.URL.createObjectURL(new Blob([response.data]));
-    const link = document.createElement('a');
-    link.href = url;
-    link.setAttribute('download', row.topic + "-" + row.teamName + "-评分报告.pdf"); // 设置下载的文件名
-    document.body.appendChild(link);
-    link.click();
-  }).catch(function (error) {
-    console.log(error);
-  });
-}
-
-
-const openPdf = (index: number, row: any) => {
-  console.log(index, row)
-  axios.post('http://36.110.106.142:12341/web_server/exam/report',
-      {
-        "id": row.id,
-        "teamName": row.teamName,
-        "scoreOnline": row.scoreOnline,
-        "beginTime": row.beginTime,
-        "endTime": row.endTime
-      },
-      {
-        headers: {
-          "Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"
-        },
-        responseType: 'blob' // 设置响应类型为二进制流
-      }
-  ).then(function (response) {
-    const url = window.URL.createObjectURL(new Blob([response.data], {type: 'application/pdf'}));
-    window.open(url, '_blank');
-  }).catch(function (error) {
-    console.log(error);
-  });
-}
-
-
 const queryLine = reactive({
   dataName: '',
   equipmentName: '',
@@ -352,7 +360,7 @@ onBeforeMount(() => {
 })
 
 function page() {
-  axios.get('http://1.202.169.139:8081/open/scene/list?equipmentType=YI_DAO_JI_QI_REN&page=' + currentPage.value + '&size=' + pageSize.value,
+  axios.get('http://36.110.106.156:11121/open/scene/list?equipmentType=YI_DAO_JI_QI_REN&page=' + currentPage.value + '&size=' + pageSize.value,
       {
         headers: {
           "Authorization": "4773hd92ysj54paflw2jem3onyhywxt2"