#
zjj
2025-07-10 d306991caf17e3ba029f0f7d2c33d4aded6100cd
Monitor-APP/pages/home/home.vue
@@ -27,19 +27,16 @@
                              circular 是否采用衔接滑动,即播放到末尾后重新回到开头
                              vertical 滑动方向是否为纵向 
                              display-multiple-items 同时显示的滑块数量 -->
                              <swiper class="swiper-body-main" vertical="true"
                              display-multiple-items="5"
                              circular="true" :autoplay="true" :interval="3000" :duration="2000">
                                 <swiper-item class="swiper-item" v-for="(item,i) in locList" :key="i">
                                    <!-- <view style="width: 30%;">{{i+1}} / {{swiperList.length}}</view> -->
                                    <!-- <view style="width: 30%;">料号: {{item.matnr}}</view> -->
                                    <view style="width: 50%; font-size: 1vw;">物料码: {{item.matnr}}</view>
                                    <view style="width: 50%; font-size: 1vw;">数量: {{item.matnrCount}}</view>
                                 <view style="width: 100%;display: flex;" v-for="(item,i) in locList" :key="i">
                                    <view style="display: flex; justify-content: center;align-items: center;width: 48%; font-size: 1.3vw;">物料码: {{item.matnr}}</view>
                                    <view style="display: flex; justify-content: center;align-items: center;width: 48%; font-size: 1.3vw;">数量: {{item.matnrCount}}</view>
                                    
                                    
                                    
                                 </swiper-item>
                              </swiper>
                                 </view>
                              
                              
                           </view>
@@ -317,9 +314,9 @@
</template>
<!-- {"msg":"操作成功","code":200,"data":[{"title":"全板出库","workNo":7460,"staNo":110,"sourceStaNo":null,"locNo":null,"sourceLocNo":"0807102","matDtos":[{"matNo":"50460834","maknx":"200x60桌面","count":26.0}],"emptyMk":false,"ioType":101}]} -->
<script>
   import demodata from '@/mockdata/demodata.json';
   import ycqdata from '@/pages/index/data.json';
   import {WebSocketClient} from "@/static/js/WebSocketClient"
   import WebSocketUtil from './uniWebSocket';
   let socket;
   export default {
@@ -332,10 +329,6 @@
            homeMode: [],
            infoMode: [],
            errorInfoMode: [],
            needUpdateCharts: false,
            viewSwitchTimer: null, // 视图切换定时器
            viewSwitchInProgress: false, // 添加这一行来跟踪视图切换状态
            timerIds: [], // 存储定时器ID
            baseInfo: {
               xDistance: 1,
               yDistance: 2,
@@ -358,7 +351,7 @@
                  }]
               },
            },
            duration: 1000,
            duration: 300,
            calendar: '',
            ringOpts:{},
            chartsDataLine1: {},
@@ -450,8 +443,7 @@
         // that.webSockerInit()
      },
      onLoad() {         
         // 存储定时器ID以便后续清理
         const timerId1 = setInterval(()=>{
         setInterval(()=>{
            this.getServerData()
            // this.initlineChart()
            // this.initPieChart()
@@ -468,48 +460,45 @@
            // 测试用
            
         },1000)
         this.timerIds.push(timerId1)
         
         const timerId2 = setInterval(()=> {
         setInterval(()=> {
            setTimeout(()=>{
               plus.runtime.restart();
            },100)
            
         },1000*60*60*4)
         this.timerIds.push(timerId2)
         //安卓内存占用打印
         // setInterval(() => {
         //    plus.android.importClass('android.os.Debug');
         //              const mem = plus.android.invoke(
         //                'android.os.Debug',
         //                'getNativeHeapAllocatedSize'
         //              ) / 1048576;
         //              console.log(mem.toFixed(1))
         // 每小时触发一次垃圾回收
         const memoryCleanerId = setInterval(() => {
            if (plus.os.name.toLowerCase() === 'android') {
               // 强制触发 GC
               plus.android.importClass('java.lang.System');
               plus.android.invoke('java.lang.System', 'gc');
               console.log('手动触发 GC');
            }
            // 清理不再需要的大型数据对象
            if (this.oldData && this.oldData.length > 100) {
               this.oldData = [];
            }
         }, 3000*10); // 每小时执行一次
         // setInterval(()=> {
         //    setTimeout(()=>{
         //       var time = new Date();
         //       var hh = time.getHours();
         //       var mm = time.getMinutes();
         //       if(hh > this.oldHours && mm >this.oldMin && this.oldMin - mm < 55){
         //          plus.runtime.restart();
         //       }
         //       if(mm >this.oldMin && mm - this.oldMin >2){
         //          plus.runtime.restart();
         //       }
         //    },100)
            
         //    }, 2000)
      },
      onUnload() {
         // 清理所有定时器
         this.timerIds.forEach(id => clearInterval(id))
         this.timerIds = []
      },
      beforeDestroy() {
         // 清理WebSocket连接
         if (this.socketClient) {
            this.socketClient.close()
            this.socketClient = null
         }
         // 清理所有定时器
         this.timerIds.forEach(id => clearInterval(id))
         this.timerIds = []
         // 清理视图切换定时器
         if (this.viewSwitchTimer) {
            clearTimeout(this.viewSwitchTimer)
            this.viewSwitchTimer = null
         }
         // },1000*30)
      },
      methods: {
         uniWebSocket(){
@@ -609,8 +598,6 @@
         showDate(data){
            const that = this
            if(data.type === "default"){
               // 设置标记,表示数据已更新,需要重新渲染图表
               that.needUpdateCharts = true
               that.chartsData.Pie.series[0].data = data.pie
               that.baseInfo.stockCount = data.stockCunt
               that.baseInfo.emptyCount = data.emptyCount
@@ -707,12 +694,8 @@
            this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePort + "/" +this.baseUrl            
         },
         getServerData() {
            // 只在数据变化时才进行深拷贝
            if (this.needUpdateCharts) {
               this.chartsDataLine1=JSON.parse(JSON.stringify(this.chartsData.Line))
               this.chartsDataPie2=JSON.parse(JSON.stringify(this.chartsData.Pie))
               this.needUpdateCharts = false
            }
            this.chartsDataLine1=JSON.parse(JSON.stringify(this.chartsData.Line))
            this.chartsDataPie2=JSON.parse(JSON.stringify(this.chartsData.Pie))
         },
         // 获取错误信息
         getInfo2() {
@@ -870,147 +853,91 @@
         },
         // 控制器
         controller() {
    // 如果视图切换正在进行中,不要中断
    if (this.viewSwitchInProgress) {
        return;
    }
    // 清除之前的视图切换定时器
    if (this.viewSwitchTimer) {
        clearTimeout(this.viewSwitchTimer)
        this.viewSwitchTimer = null
    }
    switch(this.infoType) {
        // 有信息 但 没有错误信息
        case 0:
            if (this.errorInfoViewShow) {
                this.viewSwitchInProgress = true;
                this.errorInfoViewShow = false
                this.errorInfoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.homeViewShow = true
                    this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                this.infoViewShow = false
                this.infoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.homeViewShow = true
                    this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            } else if (this.errorInfoViewShow && this.infoViewShow) {
                this.viewSwitchInProgress = true;
                this.errorInfoViewShow = false
                this.infoViewShow = false
                this.infoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.homeViewShow = true
                    this.homeMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            }
            return;
        case 1:
            if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                this.homeViewShow = false
                this.homeMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.infoViewShow = true
                    this.infoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            } else if (this.errorInfoViewShow) {
                this.viewSwitchInProgress = true;
                this.errorInfoViewShow = false
                this.errorInfoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.infoViewShow = true
                    this.infoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            }
            return;
            // 有信息 且 有错误信息
        case 2:
            if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                this.homeViewShow = false
                this.homeMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.errorInfoViewShow = true
                    this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                this.infoViewShow = false
                this.infoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.errorInfoViewShow = true
                    this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            }
            return;
        // 有信息 且 有错误信息
        case 3:
            if (this.homeViewShow) {
                this.viewSwitchInProgress = true;
                this.homeViewShow = false
                this.homeMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.errorInfoViewShow = true
                    this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            } else if (this.infoViewShow) {
                this.viewSwitchInProgress = true;
                this.infoViewShow = false
                this.infoMode = ['fade', 'slide-bottom']
                this.viewSwitchTimer = setTimeout(()=>{
                    this.errorInfoViewShow = true
                    this.errorInfoMode = ['fade', 'slide-bottom']
                    // 设置另一个定时器来重置进行中标志
                    setTimeout(() => {
                        this.viewSwitchInProgress = false;
                    }, 1000);
                },1000)
            }
            return;
    }
},
            switch(this.infoType) {
               // 有信息 但 没有错误信息
               case 0:
                  if (this.errorInfoViewShow) {
                     this.errorInfoViewShow = false
                     this.errorInfoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                     },1000)
                  } else if (this.infoViewShow) {
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                     },1000)
                  } else if (this.errorInfoViewShow && this.infoViewShow) {
                     this.errorInfoViewShow = false
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.homeViewShow = true
                        this.homeMode = ['fade', 'slide-bottom']
                     },1000)
                  }
                  return;
               case 1:
                  if (this.homeViewShow) {
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.infoViewShow = true
                        this.infoMode = ['fade', 'slide-bottom']
                     },1000)
                  } else if (this.errorInfoViewShow) {
                     this.errorInfoViewShow = false
                     this.errorInfoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.infoViewShow = true
                        this.infoMode = ['fade', 'slide-bottom']
                     },1000)
                  }
                  return;
                  // 有信息 且 有错误信息
               case 2:
                  if (this.homeViewShow) {
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                     },1000)
                  } else if (this.infoViewShow) {
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                     },1000)
                  }
                  return;
               // 有信息 且 有错误信息
               case 3:
                  if (this.homeViewShow) {
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                     },1000)
                  } else if (this.infoViewShow) {
                     this.infoViewShow = false
                     this.infoMode = ['fade', 'slide-bottom']
                     setTimeout(()=>{
                        this.errorInfoViewShow = true
                        this.errorInfoMode = ['fade', 'slide-bottom']
                     },1000)
                  }
                  return;
            }
         },
         // 主屏幕
         handle(type) {
            this.homeViewShow = !this.homeViewShow