Просмотр исходного кода

scd文件的重新对比和导出结果,单选

“yueshang” 1 год назад
Родитель
Сommit
6a34655b81
2 измененных файлов с 116 добавлено и 63 удалено
  1. 8 0
      src/api/scdCheck/scdCheck2.js
  2. 108 63
      src/pages/netStructPicture/components/scdTree.vue

+ 8 - 0
src/api/scdCheck/scdCheck2.js

@@ -37,4 +37,12 @@ export function compstatView(data) {
     params:data
   })
 }
+//得到souredid
+export function scdExpTableData(data) {
+  return request({
+      url: `/expTableData`,
+      method:"post",
+      data,
+  })
+}
 

+ 108 - 63
src/pages/netStructPicture/components/scdTree.vue

@@ -16,11 +16,11 @@
     </div>
     <div class="tableBox">
       <el-table
-        ref="multipleTableRef"
+        ref="multipleTable"
         :data="tableList"
         style="width: 100%; height: calc(100vh - 320px)"
         stripe
-        @selection-change="handleSelectionChange"
+        @select="select"
         :header-cell-style="{
           background: '#F7F8FB !important',
           color: '#7484AB',
@@ -149,6 +149,25 @@
         <div class="sures" v-else @click="noAnalysisClick">开始对比</div>
       </div>
     </el-dialog>
+    <!-- 导出所有结果 -->
+    <el-dialog
+      v-model="exportModal"
+      width="25vw"
+      style="height: 200px"
+      append-to-body
+      draggable
+    >
+      <template #header>
+        <div class="my-header">
+          <div class="title">数据导出</div>
+        </div>
+      </template>
+      <div v-if="!exportLink" class="export-ink">正在导出数据中...</div>
+      <div v-else class="export-ink">
+        数据文件已生成完成,
+        <el-link :href="exportLink" type="primary" class="load">点击立即下载</el-link>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -168,6 +187,7 @@ import {
   tmpParse,
   compStart,
   compstatView,
+  scdExpTableData,
 } from "@/api/scdCheck/scdCheck2";
 import scd from "@/api/scd";
 import systemRow from "@/api/systemRow";
@@ -184,13 +204,12 @@ import addPng from "@/assets/image/scdcheck/add.png";
 import uploadPng from "@/assets/image/scdcheck/upload.png";
 import uploadSPng from "@/assets/image/scdcheck/upload_success.png";
 import uploadEPng from "@/assets/image/scdcheck/upload_error.png";
-
 import { useRoute } from "vue-router";
 import createds from "@/utils/scdMqtt.js";
 const route = useRoute();
 const emit = defineEmits(["scdTreeBack", "scdView", "scdJpadList"]);
 let tableList = ref([]);
-let multipleTableRef = ref();
+let multipleTable = ref();
 let alreadyTriggered = ref(false);
 let scdid = ref([]);
 const loading = ref(false);
@@ -201,50 +220,56 @@ const loadingAdd = ref(false); //文件上传的加载状态
 const loadingAddError = ref(false); //文件上传的加载状态
 const chooseFile = ref("");
 const chooseContrast = ref(null);
-const handleSelectionChange = (e) => {
-  console.log('e==', e)
-  //复选
-  chooseContrast.value = e;
-};
-const chooseAll = (e) => {
-  //全选
-};
 const checkNow = (e) => {
   //scd比对
+  results();
+};
+const results = () => {
   lookScdModal.value = true;
   contrast.value = false;
   chooseContrast.value = null;
   AnalysisProcess.value = false;
   isAnalysis.value = false;
   chooseFile.value = "";
-
+  exportLink.value = "";
 };
+const exportModal = ref(false);
+const exportLink = ref("");
 const excelPort = () => {
-  //导出excel
-  systemRow
-    .portExcel({
-      code: "scd-comp-result",
-    })
-    .then((res) => {
-      if (res.data) {
-        return;
-      } else {
-        ElMessage({
-          message: res.msg,
-          type: "info",
-        });
-      }
+  exportLink.value = "";
+  if (!chooseContrast.value) {
+    return ElMessage({
+      type: "warning",
+      message: "请选择一条历史校验记录或创建新一致性校验!",
     });
+  }
+  exportModal.value = true;
+  //导出excel
+  scdExpTableData({
+    code: "scd-comp-result",
+    caption: "SCD一致性对比结果",
+    expcols:
+      "source_scd_name,target_scd_name,ied_name,ied_desc,opt,diff_object_type,diff_object_name,desc",
+    expcolnames:
+      "基准SCD,目标比对SCD,装置名称,装置描述,操作,比对内容类型,差异项,差异内容",
+    comp_id: chooseContrast.value.id,
+  }).then((res) => {
+    if (res.data) {
+      exportLink.value = window.ApiServer + '/' + res.data;
+    } else {
+      ElMessage({
+        message: res.msg,
+        type: "info",
+      });
+    }
+  });
 };
 const contrast = ref(false); //是否是重新对比
-const reloadCheck =async () => {
+const reloadCheck = async () => {
   contrast.value = true;
   mesg.value = null;
   //重新比对
-  if (
-    !chooseContrast.value ||
-    (chooseContrast.value && chooseContrast.value.length == 0)
-  ) {
+  if (!chooseContrast.value) {
     ElMessage({
       type: "warning",
       message: "请选择一条历史校验记录或创建新一致性校验!",
@@ -396,7 +421,7 @@ watch(
     }
   }
 );
-const referenceData = ref(null)
+const referenceData = ref(null);
 //解析完成开始对比的点击
 const yesAnalysisClick = () => {
   ElMessageBox.confirm(
@@ -415,43 +440,39 @@ const yesAnalysisClick = () => {
         duration: 0,
       });
       let anRes;
-      if (mesg.value&&!contrast.value) {
-      //为了得到基准文件的soureid
-      referenceData.value = tableList.value.filter(item=>item.source_id==mesg.value.rootid);
-      console.log(' referenceData.value', referenceData.value)
+      if (mesg.value && !contrast.value) {
         anRes = await compStart({
           type: "SCD",
           station_id: route.query.stationId,
           source_scd_id: route.query.id,
           target_scd_id: mesg.value.rootid,
           comp_id: 0,
-        })
-      }else if(chooseContrast.value){
-        console.log('chooseContrast.value', chooseContrast.value)
-       anRes = await compStart({
+        });
+      } else if (chooseContrast.value) {
+        console.log("chooseContrast.value", chooseContrast.value);
+        anRes = await compStart({
           type: "SCD",
           station_id: route.query.stationId,
-          source_scd_id: chooseContrast.value[0].source_id,
-          target_scd_id: chooseContrast.value[0].target_id,
-          comp_id: chooseContrast.value[0].id
-        })
+          source_scd_id: chooseContrast.value.source_id,
+          target_scd_id: chooseContrast.value.target_id,
+          comp_id: chooseContrast.value.id,
+        });
+      }
+      if (anRes.code == 0) {
+        loadingAdd.value = false;
+        aktType();
+        ElMessage({
+          type: "success",
+          message: "对比完成!",
+        });
+        ElNotification.closeAll();
+        lookScdModal.value = false;
+      } else {
+        ElMessage({
+          type: "error",
+          message: err.msg,
+        });
       }
-        if (anRes.code == 0) {
-          loadingAdd.value = false;
-          aktType();
-          ElMessage({
-            type: "success",
-            message: "对比完成!",
-          });
-          ElNotification.closeAll();
-          lookScdModal.value = false;
-        } else {
-          ElMessage({
-            type: "error",
-            message: err.msg,
-          });
-        }
-
     })
     .catch((err) => {});
 };
@@ -463,7 +484,21 @@ const noAnalysisClick = () => {
   });
 };
 const parentData = ref(null);
-onMounted(() => {
+const isDelete = ref(true);
+// 表格单选操作
+const select = (selection, row) => {
+  multipleTable.value.clearSelection();
+  // 主要用于将当前勾选的表格状态清除;
+  // 当表格数据都没有被勾选的时候就返回;
+  if (selection.length == 0) {
+    isDelete.value = true;
+    return;
+  }
+  chooseContrast.value = row;
+  multipleTable.value.toggleRowSelection(row, true);
+  isDelete.value = false;
+};
+onMounted(async () => {
   parentData.value = JSON.parse(route.query.parentData);
   aktType();
 });
@@ -554,7 +589,14 @@ onMounted(() => {
   background: #255ce7;
 }
 
-.sureUpload {
+.export-ink {
+  display: flex;
+  text-align: center;
+  justify-content: center;
+  .load{
+    margin-left: 10px;
+    border-bottom: 1px solid #409eff;
+  }
 }
 
 .file-title {
@@ -585,5 +627,8 @@ onMounted(() => {
 
 :deep(.el-message-box) {
   vertical-align: inherit !important;
+} // 取消多选第一列的展示(即:将多选变成单选的第一步); 取消该样式后,就不会出现多选的情况;但由此可知还有其他的方法来实现单选;
+::v-deep(.el-table th.el-table__cell:nth-child(1) .cell) {
+  visibility: hidden;
 }
 </style>