Browse Source

修改文件提示

plg 4 months ago
parent
commit
e7060e8b4b
3 changed files with 63 additions and 4 deletions
  1. 19 1
      vue/src/views/Category.vue
  2. 22 1
      vue/src/views/Direction.vue
  3. 22 2
      vue/src/views/DirectionAndCategory.vue

+ 19 - 1
vue/src/views/Category.vue

@@ -1,6 +1,6 @@
 <script lang="ts" setup>
 import { ref, onMounted, reactive } from "vue";
-import { ElMessage } from "element-plus";
+import { ElMessage ,ElLoading} from "element-plus";
 import { genFileId } from "element-plus";
 import axios from "axios";
 
@@ -16,6 +16,9 @@ const flag = ref<string>("");
 const disableFlag = ref<boolean>(false);
 const upload = ref<any>();
 
+//load标志
+const load =ref<any>();
+
 const formData = ref<any>();
 
 const fileType = ref<string>("");
@@ -49,6 +52,14 @@ const uploadFile = (file: any) => {
   }
 };
 const startFun = () => {
+    //判断是否上传文件
+    if(currentFile.value==''||currentFile.value==null){
+    ElMessage({
+          message: `请选择文件`,
+          type: "error",
+        });
+    return 
+  }
   const formData = new FormData();
   formData.append("file", currentFile.value);
   formData.append("userName", name.value);
@@ -60,6 +71,11 @@ const startFun = () => {
 
   formData.append("taskType", taskType.value);
   disableFlag.value = true;
+  load.value=ElLoading.service({
+    lock: true,
+    text: '努力检测中',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
   axios
     .post(`/v1/record/create`, formData)
     .then((res) => {
@@ -76,6 +92,7 @@ const startFun = () => {
       }
     })
     .catch((err) => {
+      load.value.close()
       disableFlag.value = false;
     });
   //   formData.append("userName", params.name);
@@ -84,6 +101,7 @@ const startFun = () => {
 
 const queryDetail = () => {
   axios.get(`/v1/record/${flag.value}/find`, {}).then((res) => {
+    load.value.close()
     if (res.data.code == 200) {
       //当结果为空时
       //   ElMessage({

+ 22 - 1
vue/src/views/Direction.vue

@@ -1,6 +1,6 @@
 <script lang="ts" setup>
 import { ref, onMounted, reactive } from "vue";
-import { ElMessage } from "element-plus";
+import { ElMessage,ElLoading } from "element-plus";
 import { genFileId } from "element-plus";
 import axios from "axios";
 
@@ -16,6 +16,10 @@ const flag = ref<string>("");
 const disableFlag = ref<boolean>(false);
 const upload = ref<any>();
 
+//load标志
+const load =ref<any>();
+
+
 const formData = ref<any>();
 
 const fileType = ref<string>("");
@@ -49,6 +53,14 @@ const uploadFile = (file: any) => {
   }
 };
 const startFun = () => {
+  //判断是否上传文件
+  if(currentFile.value==''||currentFile.value==null){
+    ElMessage({
+          message: `请选择文件`,
+          type: "error",
+        });
+    return 
+  }
   const formData = new FormData();
   formData.append("file", currentFile.value);
   formData.append("userName", name.value);
@@ -60,6 +72,11 @@ const startFun = () => {
 
   formData.append("taskType", taskType.value);
   disableFlag.value = true;
+  load.value=ElLoading.service({
+    lock: true,
+    text: '努力检测中',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
   axios
     .post(`/v1/record/create`, formData)
     .then((res) => {
@@ -72,9 +89,12 @@ const startFun = () => {
         //开始调用 //查询记录详情
         queryDetail();
         //发送以后得到返回的id,然后一直启动轮询一直调接口
+      }else{
+        load.value.close()
       }
     })
     .catch((err) => {
+      load.value.close()
       disableFlag.value = false;
     });
   //   formData.append("userName", params.name);
@@ -83,6 +103,7 @@ const startFun = () => {
 
 const queryDetail = () => {
   axios.get(`/v1/record/${flag.value}/find`, {}).then((res) => {
+    load.value.close()
     if (res.data.code == 200) {
       //当结果为空时
       //   ElMessage({

+ 22 - 2
vue/src/views/DirectionAndCategory.vue

@@ -1,8 +1,9 @@
 <script lang="ts" setup>
 import { ref, onMounted, reactive } from "vue";
-import { ElMessage } from "element-plus";
+import { ElMessage,ElLoading } from "element-plus";
 import { genFileId } from "element-plus";
 import axios from "axios";
+import { Loading } from "@element-plus/icons-vue/dist/types";
 
 const leftDirection = ref("东");
 const rightDirection = ref("西");
@@ -16,6 +17,9 @@ const flag = ref<string>("");
 const disableFlag = ref<boolean>(false);
 const upload = ref<any>();
 
+//load标志
+const load =ref<any>();
+
 const formData = ref<any>();
 
 const fileType = ref<string>("");
@@ -50,6 +54,14 @@ const uploadFile = (file: any) => {
   }
 };
 const startFun = () => {
+    //判断是否上传文件
+    if(currentFile.value==''||currentFile.value==null){
+    ElMessage({
+          message: `请选择文件`,
+          type: "error",
+        });
+    return 
+  }
   const formData = new FormData();
   formData.append("file", currentFile.value);
   formData.append("userName", name.value);
@@ -61,6 +73,11 @@ const startFun = () => {
 
   formData.append("taskType", taskType.value);
   disableFlag.value = true;
+  load.value=ElLoading.service({
+    lock: true,
+    text: '努力检测中',
+    background: 'rgba(0, 0, 0, 0.7)',
+  })
   axios
     .post(`/v1/record/create`, formData)
     .then((res) => {
@@ -76,6 +93,7 @@ const startFun = () => {
       }
     })
     .catch((err) => {
+      load.value.close()
       disableFlag.value = false;
     });
   //   formData.append("userName", params.name);
@@ -84,7 +102,9 @@ const startFun = () => {
 
 const queryDetail = () => {
   axios.get(`/v1/record/${flag.value}/find`, {}).then((res) => {
+    load.value.close()
     if (res.data.code == 200) {
+      
       //当结果为空时
       //   ElMessage({
       //   message: `结果为${res.data.data.Result}`,
@@ -211,7 +231,7 @@ onMounted(() => {
         </div>
         <div>检测结果:</div>
         <div class="run_dir">
-          <div>车辆类别</div>
+          <div>车辆类别</div>
           <div class="run_input">{{ car_type }}</div>
         </div>
         <div class="run_dir">