liyangzheng преди 1 година
родител
ревизия
9c3135656b

+ 16 - 7
src/pages/mission/MissionVue.vue

@@ -13,10 +13,10 @@
             <!-- 功能盒子 -->
             <div class="settingBox">
                 <!-- 无检测任务时显示的盒子 -->
-                <NoBox v-if="btnSelect == 0 && taskList.length == 0 && sizeNum == 0" :btnSelect="btnSelect"
-                    :taskList="taskList" @backToMission="backToMission"></NoBox>
+                <NoBox v-if="btnSelect == 0 && listLength == 0 && sizeNum == 0" :btnSelect="btnSelect" :taskList="taskList"
+                    @backToMission="backToMission"></NoBox>
                 <!-- 有检测任务的盒子 -->
-                <HaveMis v-if="btnSelect == 0 && taskList.length != 0 && sizeNum == 0" @moreBack="moreBack" @hmBack="hmBack"
+                <HaveMis v-if="btnSelect == 0 && listLength != 0 && sizeNum == 0" @moreBack="moreBack" @hmBack="hmBack"
                     @haveBack="haveBack" @haveInCreate="haveInCreate"></HaveMis>
                 <!-- 新建任务盒子 -->
                 <CreateNew v-if="btnSelect == 1" :btnSelect="btnSelect" :taskList="taskList" :editRow="editRow"
@@ -75,13 +75,16 @@ export default {
         let startMis = ref({})//开始检测
         let editRow = ref({})//需要编辑的任务
         let status = ref(0)
+        let listLength = ref(0)//有无任务
         function searchAllTask() {
             // 0为待检测
             task.getTask({ pageno: 1, pagesize: 10, state: 0 }).then(res => {
                 if (res.data == null) {
                     return
                 } else {
-                    taskList.value = res.data
+                    // taskList.value = res.data
+                    listLength.value = res.count - 0
+                    console.log(listLength.value, '待检测');
                 }
             })
             // 2为完成检测
@@ -89,7 +92,9 @@ export default {
                 if (res.data == null) {
                     return
                 } else {
-                    taskList.value = res.data
+                    // taskList.value = res.data
+                    listLength.value = res.count - 0
+                    console.log(listLength.value, '完成检测');
                 }
             })
             // 1为正在检测
@@ -97,7 +102,9 @@ export default {
                 if (res.data == null) {
                     return
                 } else {
-                    taskList.value = res.data
+                    // taskList.value = res.data
+                    listLength.value = res.count - 0
+                    console.log(listLength.value, '正在检测');
                 }
             })
         }
@@ -134,7 +141,8 @@ export default {
             if (data == null) {
                 taskList.value = []
             } else {
-                taskList.value = data
+                listLength.value = data.length
+                console.log(listLength.value, 'mission');
             }
         }
         function moreBack(data) {
@@ -172,6 +180,7 @@ export default {
             editRow,//需要编辑的任务
             status,
             moreBack,
+            listLength,//有无任务
         }
     },
     components: {

+ 14 - 13
src/pages/mission/components/HaveMis.vue

@@ -29,26 +29,27 @@
           </p>
         </div>
         <div style="display: flex;justify-content: flex-start;align-items: center;overflow-x: auto;"
-          v-if="nowRunList.name || misList.length > 0">
-          <div :class="setImg(nowRunList)" v-if="nowRunList.name" @click="startNow(nowRunList)">
+          v-if="nowRunList.length > 0 || misList.length > 0">
+          <div :class="setImg(item)" v-if="nowRunList.length > 0" v-for="(item, index) in nowRunList">
             <div class="intBoxOne">
               <p class="intOne">
-                <span style="font-size: 18px;color: white;">{{ nowRunList.name }}</span>
+                <span style="font-size: 18px;color: white;">{{ item.name }}</span>
               </p>
               <p style="margin-left: 8px;">
                 <img style="width: 15px;height: 15px;float: left;padding-top:2px"
                   src="../../../assets/icon/white_flash.png" alt="" />
-                <span style="font-size: 12px;color:white" class="commonSpan">{{ nowRunList.station_name }}</span>
+                <span style="font-size: 12px;color:white" class="commonSpan">{{ item.station_name }}</span>
               </p>
               <p style="margin-left: 8px;">
                 <img style="width: 15px;height: 15px;float: left;padding-top:2px"
                   src="../../../assets/icon/white_clock.png" alt="" />
-                <span style="font-size: 12px;color:white" class="commonSpan">{{ nowRunList.ct }}</span>
+                <span style="font-size: 12px;color:white" class="commonSpan">{{ item.ct }}</span>
               </p>
             </div>
             <!-- 点击检测 -->
             <div class="setNow">
-              <span style="font-size: 16px;color:white" class="setnowspan">检测中<em v-loading="emLoading"></em></span>
+              <span style="font-size: 16px;color:white" class="setnowspan" @click="startBefore(item, index)">检测中<em
+                  v-loading="emLoading"></em></span>
             </div>
           </div>
           <div class="intBox" v-for="(item, index) in misList" :style="setImg(item, index)" @mouseover="intOver(index)"
@@ -152,7 +153,7 @@ export default {
     let lookingTask = ref({}) //当前点击查看的任务对象
     let taskModels = ref([]) //任务模型列表
     let misList = ref([])//待检测任务列表
-    let nowRunList = ref({})//正在检测任务列表
+    let nowRunList = ref([])//正在检测任务列表
     let passList = ref([])//已完成检测任务列表
     let currEditTaskModels = ref(null)
     let emLoading = ref(true)
@@ -177,7 +178,6 @@ export default {
         let models = res.data.models
         if (models === null || models.length === 0) return
         taskModels.value = models
-        console.log(taskModels.value, 'task');
       })
     }
     function startNow(row, num) {
@@ -254,7 +254,8 @@ export default {
               return 0; // 不需要交换位置
             }
           });
-          misList.value = sortedList;
+          misList.value = res.data;
+          console.log(misList.value, 'misList');
           emit("haveBack", misList.value);
           loading.close()
         }
@@ -271,12 +272,12 @@ export default {
       // 1为正在检测
       task.getTask({ pageno: 1, pagesize: 10, state: 1 }).then(res => {
         if (res.data == null) {
-          nowRunList.value = {}
-          lookingTask.value = {}
+          nowRunList.value = []
+          lookingTask.value = []
           return
         } else {
-          nowRunList.value = res.data[0]
-          lookingTask.value = res.data[0] //默认查看该任务信息
+          nowRunList.value = res.data
+          lookingTask.value = res.data //默认查看该任务信息
         }
       })
     }

+ 74 - 34
src/pages/mission/components/StartMission.vue

@@ -104,44 +104,82 @@ export default {
             })
             emit("smBack", arrow.value)
         }
-        function picReload() {
-            loadingMis.value = props.startMis
-            scdIds.value = loadingMis.value.scd_id
-            loading.value = true
-            task.tackStart({ id: loadingMis.value.id }).then(res => {
-                let countTime = setInterval(() => {
-                    task.lookStep({ id: loadingMis.value.id - 0 }).then(res => {
+        async function misState() {
+            try {
+                const res = await task.lookStep({ id: loadingMis.value.id - 0 });
+                if (res.data) {
+                    stepList.value = res.data;
+                    console.log(stepList.value, 'step');
+                } else {
+                    showError(res.msg);
+                }
+            } catch (error) {
+                showError("获取数据时发生错误。");
+            }
+        }
+
+        async function picReload() {
+            try {
+                loadingMis.value = props.startMis;
+                scdIds.value = loadingMis.value.scd_id;
+                loading.value = true;
+                const startRes = await task.tackStart({ id: loadingMis.value.id - 0 });
+                if (startRes.code != 0) {
+                    ElMessage({
+                        message: res.msg,
+                        type: "error"
+                    })
+                } else {
+                    const countTime = setInterval(async () => {
+                        let shouldClearInterval = true;
+                        try {
+                            const res = await task.lookStep({ id: loadingMis.value.id - 0 });
+                            if (res.code === 0) {
+                                for (const item of res.data) {
+                                    if (!(item.state === '2' || item.state === '3')) {
+                                        shouldClearInterval = false;
+                                        await misState();
+                                        break;  // Stop checking if one item doesn't meet the condition
+                                    }
+                                }
+                            }
+                        } catch (error) {
+                            shouldClearInterval = true;  // Handle errors as you see fit
+                            showError("检查步骤时发生错误。");
+                        }
+                        if (shouldClearInterval) {
+                            clearInterval(countTime);
+                            end.value = false;
+                        }
+                    }, 1000);
+                    setTimeout(async () => {
+                        const res = await slc.getScdByIdFromMission({
+                            scd_id: loadingMis.value.scd_id - 0,
+                            pageno: 1,
+                            pagesize: 20,
+                        });
                         if (res.data) {
-                            stepList.value = res.data
+                            endList.value = res.data;
+                            loading.value = false;
+                            misState()
                         } else {
-                            ElMessage({
-                                message: res.msg,
-                                type: "error"
-                            })
+                            endList.value = [];
+                            loading.value = false;
                         }
-                    })
-                }, 1000)
-                setTimeout(() => {
-                    clearInterval(countTime)
-                    end.value = false
-                }, 40000)
-            })
-            setTimeout(() => {
-                slc.getScdByIdFromMission({
-                    scd_id: loadingMis.value.scd_id - 0,
-                    pageno: 1,
-                    pagesize: 20,
-                }).then(res => {
-                    if (res.data) {
-                        endList.value = res.data
-                        loading.value = false
-                    }else{
-                        endList.value = []
-                        loading.value = false
-                    }
-                })
-            }, 30000)
+                    }, 30000);
+                }
+            } catch (error) {
+                showError("启动任务时发生错误。");
+            }
         }
+
+        function showError(message) {
+            ElMessage({
+                message: message,
+                type: "error"
+            });
+        }
+
         function backDown() {
             emit("smBack", arrow.value)
         }
@@ -180,6 +218,8 @@ export default {
             lineMsg,
             lineClose,
             loading,
+            misState,
+            showError,
         }
     },
     components: {

+ 9 - 1
src/pages/mission/components/StepMethod.vue

@@ -41,7 +41,15 @@ export default {
             })
         })
         function reload() {
-            console.log(steps.value, '组件内');
+            steps.value = props.stepList.map((item, index) => {
+                return {
+                    title: item.step_name,
+                    description: item.state_msg,
+                    status: item.state,
+                    msg: item.state_msg
+                }
+            })
+            console.log(steps.value,'steps');
         }
         function nextStep() {
             if (activeStep.value > 0 && activeStep.value < steps.value.length) {