Explorar o código

fix: 修复第一次没有发送请求

拎壶冲 hai 6 meses
pai
achega
975a0c3850
Modificáronse 1 ficheiros con 14 adicións e 8 borrados
  1. 14 8
      src/views/hl/check/widget/nCheckReport.vue

+ 14 - 8
src/views/hl/check/widget/nCheckReport.vue

@@ -6,7 +6,7 @@
     <el-table :data="reportData" style="width: 100%;" border :span-method="spanMethod">
       <el-table-column prop="className" label="分类" width="180" align="center"/>
       <el-table-column prop="checkName" label="巡检项"/>
-      <el-table-column label="巡检结果" width="160" align="center" prop="resultL" />
+      <el-table-column label="巡检结果" width="160" align="center" prop="resultL"/>
       <el-table-column prop="remark" label="备注" align="center" width="160">
         <template #default="{row}">
         <span :style="`color:${row.resultR === '正常'?'#1ab43f':'#e43'}`">
@@ -20,24 +20,26 @@
 <script setup lang="ts">
 import {chkcResult} from "@/api/check/chkc"
 import axios from "axios";
-import { getToken } from '@/utils/auth'
+import {getToken} from '@/utils/auth'
+import {onMounted} from "vue";
+
 const props = defineProps({
   crId: {
     type: Number,
     default: 0
   },
-  spanMethod:{
-    type:Function
+  spanMethod: {
+    type: Function
   }
 })
 const reportData = ref([])
 
-const exportReport=async ()=>{
+const exportReport = async () => {
   const response = await axios({
-    url: import.meta.env.VITE_APP_BASE_API+'/check/chkc/export/' + props.crId,
+    url: import.meta.env.VITE_APP_BASE_API + '/check/chkc/export/' + props.crId,
     method: 'GET',
     responseType: 'blob',
-    headers: { 'Authorization': 'Bearer ' + getToken() }
+    headers: {'Authorization': 'Bearer ' + getToken()}
   });
   const url = window.URL.createObjectURL(new Blob([response.data]));
   const link = document.createElement('a');
@@ -53,7 +55,11 @@ const getReport = async () => {
   reportData.value = res.data.detailList
 }
 
-watch(()=>props.crId,()=>{
+watch(() => props.crId, () => {
+  getReport()
+})
+
+onMounted(() => {
   getReport()
 })