liwei19941102 2 лет назад
Родитель
Сommit
fab3332837
2 измененных файлов с 91 добавлено и 39 удалено
  1. 0 2
      src/components/Public/timeLine.vue
  2. 91 37
      src/views/yunying/scheduling/index.vue

+ 0 - 2
src/components/Public/timeLine.vue

@@ -144,8 +144,6 @@ const getCurrentStation = () => {
     var passStationsArry = stationObj.passStations.split(",");
     if (stationObj.currentStation == "null" || stationObj.currentStation == "") {
       for (var index in list) {
-        console.log(passStationsArry[passStationsArry.length - 1]);
-        console.log(list[index].stationName)
         if (passStationsArry[passStationsArry.length - 1] == list[index].stationName) {
           if (index == list.length - 1) {
             carIndex.value = index

+ 91 - 37
src/views/yunying/scheduling/index.vue

@@ -40,42 +40,47 @@
             <el-tag style="margin-left: 40px;" type="danger" effect="dark" round>异常作业</el-tag>
         </div>
 
-        <div v-for="(item, index) in carScheduleList">
-            <el-card shadow="never">
-                <div class="carDiv" style="position: relative;">
-                    <div
-                        style="width: 18%;background: #7BC932;text-align: center;display: flex;flex-direction: column;justify-content: center;align-items:center;">
-                        <div class="carDetail">{{ item.carNum }}</div>
-                        <div class="carFont" style="font-size: 12px;">{{ getTimeFormat(item.pathInfo) }}</div>
-                        <div class="carFont" style="font-size: 12px;margin-top:8px;">{{ getAddr(item.pathInfo) }}</div>
-                        <!-- <div class="carFont">{{ JSON.parse(item.pathInfo).driver_info.nickName }}</div> -->
-                        <div class="carFont" style="font-size: 12px;margin-top:8px;color:rgba(255,255,255,0.9)">
-                            司机:{{ getUserName(JSON.parse(item.pathInfo).driverInfo) }}
+        <div v-if="reloadData">
+            <div v-for="(item, index) in carScheduleList">
+                <el-card shadow="never">
+                    <div class="carDiv" style="position: relative;">
+                        <div
+                            style="width: 18%;background: #7BC932;text-align: center;display: flex;flex-direction: column;justify-content: center;align-items:center;">
+                            <div class="carDetail">{{ item.carNum }}</div>
+                            <div class="carFont" style="font-size: 12px;">{{ getTimeFormat(item.pathInfo) }}</div>
+                            <div class="carFont" style="font-size: 12px;margin-top:8px;">{{ getAddr(item.pathInfo) }}
+                            </div>
+                            <!-- <div class="carFont">{{ JSON.parse(item.pathInfo).driver_info.nickName }}</div> -->
+                            <div class="carFont" style="font-size: 12px;margin-top:8px;color:rgba(255,255,255,0.9)">
+                                司机:{{ getUserName(JSON.parse(item.pathInfo).driverInfo) }}
+                            </div>
+                            <div class="carFont" style="font-size: 12px;margin-top:8px">{{ getCatInfo(item.carNum) }}
+                            </div>
                         </div>
-                        <div class="carFont" style="font-size: 12px;margin-top:8px">{{ getCatInfo(item.carNum) }}</div>
-                    </div>
-                    <div style="width: 80%;">
-                        <el-scrollbar ref="scrollbarRef" height="400px" always @scroll="scroll">
-                            <timeLineDiv :list="JSON.parse(item.pathInfo).pathLine"
-                                :stationInfo="JSON.parse(item.stationInfo)"></timeLineDiv>
-                        </el-scrollbar>
-                    </div>
-                    <div style="position:absolute;top:10px;right:6px">
-                        <div style="width: 30px;height: 30px; cursor: pointer;" @click="openMapDiv(item)">
-                            <img style="width: 28px;height: 28px;" src="@/assets/images/icon/map1.png" />
+                        <div style="width: 80%;">
+                            <el-scrollbar ref="scrollbarRef" height="400px" always @scroll="scroll">
+                                <timeLineDiv :list="JSON.parse(item.pathInfo).pathLine"
+                                    :stationInfo="JSON.parse(item.stationInfo)"></timeLineDiv>
+                            </el-scrollbar>
                         </div>
-                        <div style="width: 30px;height: 20px; cursor: pointer;" @click="dialog.visible = true">
-                            <img style="width: 28px;height: 28px;" src="@/assets/images/icon/cam.png" />
+                        <div style="position:absolute;top:10px;right:6px">
+                            <div style="width: 30px;height: 30px; cursor: pointer;" @click="openMapDiv(item)">
+                                <img style="width: 28px;height: 28px;" src="@/assets/images/icon/map1.png" />
+                            </div>
+                            <div style="width: 30px;height: 20px; cursor: pointer;" @click="dialog.visible = true">
+                                <img style="width: 28px;height: 28px;" src="@/assets/images/icon/cam.png" />
+                            </div>
+                        </div>
+                        <div style="position:absolute;bottom:10px;right:6px;font-size:10px">
+                            <span>乘客:11人 </span> <span style="margin-left: 10px;">货物:11个</span>
                         </div>
                     </div>
-                    <div style="position:absolute;bottom:10px;right:6px;font-size:10px">
-                        <span>乘客:11人 </span> <span style="margin-left: 10px;">货物:11个</span>
-                    </div>
-                </div>
-            </el-card>
+                </el-card>
+            </div>
         </div>
 
-        <el-dialog v-if="dialogMap.visible" :title="dialogMap.title" v-model="dialogMap.visible" width="40vw" append-to-body>
+        <el-dialog v-if="dialogMap.visible" :title="dialogMap.title" v-model="dialogMap.visible" width="40vw"
+            append-to-body>
             <mapDiv style="width:40vw;height:40vh;" ref="mapElmDiv"></mapDiv>
         </el-dialog>
 
@@ -122,6 +127,8 @@ const multiple = ref(true);
 const total = ref(0);
 const value2 = ref('')
 const carScheduleList = ref<CarScheduleVO[]>([]);
+const timer = ref(null);
+const mapTimer = ref(null);
 
 const queryFormRef = ref<ElFormInstance>();
 const carInfoFormRef = ref<ElFormInstance>();
@@ -150,6 +157,8 @@ const columns = ref([
     { label: '类型', prop: 'people', pprop: "ext1", visible: true, isTemplate: false, },
 ])
 
+const reloadData = ref(true)
+
 const initFormData: CarInfoForm = {
     id: undefined,
     carNum: undefined,
@@ -242,6 +251,7 @@ const goadd = () => {
 }
 
 const getScheduleList = async () => {
+    reloadData.value = false;
     var date = new Date();
     var param = {
         params: {
@@ -252,13 +262,18 @@ const getScheduleList = async () => {
     }
     const res = await listCarSchedule(param);
     carScheduleList.value = res.rows;
+    reloadData.value = true
 }
 
 const getTimeFormat = (data) => {
     var value = JSON.parse(data).pathLine
     console.log(JSON.parse(data))
-    if (value[0].planInTime && value[value.length - 1].planOutTime) {
-        return value[0].planInTime + '-' + value[value.length - 1].planOutTime
+    if (value.length > 0) {
+        if (value[0].planInTime && value[value.length - 1].planOutTime) {
+            return value[0].planInTime + '-' + value[value.length - 1].planOutTime
+        } else {
+            return "请填写路线时间"
+        }
     } else {
         return "请填写路线时间"
     }
@@ -266,7 +281,9 @@ const getTimeFormat = (data) => {
 
 const getAddr = (data) => {
     var value = JSON.parse(data).pathLine
-    return value[0].stationName + '-' + value[value.length - 1].stationName
+    if(value.length > 0){
+        return value[0].stationName + '-' + value[value.length - 1].stationName
+    }
 }
 
 const getList = async () => {
@@ -339,14 +356,27 @@ const openMapDiv = (data) => {
         // mapElm.value.getGpsDataList(param);
         setTimeout(() => {
             mapElmDiv.value.getGpsDataList(param);
+            mapTimer.value = setInterval(() => {
+                console.log(2222222222222)
+                console.log(dialogMap.visible)
+                if (dialogMap.visible) {
+                    console.log(222222)
+                    mapElmDiv.value.getGpsDataList(param);
+                }
+            }, 30000);
         }, 1000);
     }
 }
 
 /** 重置按钮操作 */
 const resetQuery = () => {
-    queryFormRef.value?.resetFields();
-    handleQuery();
+    //queryFormRef.value?.resetFields();
+    //handleQuery();
+    getScheduleList();
+    // reloadData.value = false;
+    // setTimeout(() => {
+    //     reloadData.value = true;
+    // }, 500);
 }
 
 /** 多选框选中数据 */
@@ -441,13 +471,37 @@ const getCatInfoData = (value) => {
     }
 }
 
-onUnmounted(() =>{
+onUnmounted(() => {
 
 })
 
+onBeforeUnmount(() => {
+    clearInterval(timer.value)
+    clearInterval(mapTimer.value)
+    timer.value = null;
+    mapTimer.value = null;
+})
+
 onMounted(() => {
     initData();
-});
+    //每5s刷新数据
+    timer.value = setInterval(() => {
+        console.log(11111)
+        getScheduleList();
+        reloadData.value = false;
+        setTimeout(() => {
+            reloadData.value = true;
+        }, 500);
+    }, 30000);
+    // mapTimer.value = setInterval(() => {
+    //     console.log(2222222222222)
+    //     console.log(dialog.visible)
+    //     if (dialog.visible) {
+    //         console.log(222222)
+    //         mapElmDiv.value.getGpsDataList(param);
+    //     }
+    // }, 2000);
+}); 
 </script>
 
 <style lang="scss" scoped>