#
whycq
2022-11-28 44f46bb05117aee03c659f3a441bcf9310ced006
Monitor-APP/pages/home/home.vue
@@ -1,6 +1,6 @@
<template>
   <view class="container">
      <!-- 主视图 -->
      <uni-transition :duration="duration" :mode-class="homeMode" :show="homeViewShow">
         <view class="home-view">
            <view class="head">
@@ -10,7 +10,7 @@
            <view class="time-tools">{{calendar}}</view>
            <view class="button-left" @click="ejected()"></view>
            <view class="button-right" @click="ejected()"></view>
            <!-- 主体 -->
            <!-- 主视图 -->
            <view class="main">
               <view class="mian-item">
                  <view class="mian-item-box">
@@ -195,22 +195,23 @@
                  </view>
               </view>
            </view>
         </view>
      </uni-transition>
      <!-- 全板/拣料信息 -->
      <uni-transition :duration="duration" :mode-class="infoMode" :show="infoViewShow">
         <view class="info-view">
         <view class="home-view">
            <view class="head">
               <text>拣 料</text>
               <text>全板 / 拣料</text>
            </view>
            <!-- 日历 -->
            <view class="time-tools">{{calendar}}</view>
            <view class="button-left"></view>
            <view class="button-right"></view>
            <view class="button-left" @click="ejected()"></view>
            <view class="button-right" @click="ejected()"></view>
            <!-- 主体 -->
            <view class="info-main" >
            <view class="info-main">
               <view class="info-box">
                  <y-box></y-box>
                  <y-box>{{text}}</y-box>
               </view>
            </view>
         </view>
@@ -228,7 +229,7 @@
            <!-- 主体 -->
            <view class="info-main" >
               <view class="info-box">
                  <y-box></y-box>
                  <y-box>{{text1}}</y-box>
               </view>
            </view>
         </view>
@@ -278,6 +279,7 @@
<script>
   import demodata from '@/mockdata/demodata.json';
   import ycqdata from '@/pages/index/data.json';
   export default {
      data() {
         return {
@@ -320,6 +322,14 @@
            basePort: '',
            baseLedId: '',
            baseCrnId: '',
            info: null,
            error: null,
            infoType: 0,
            text: '',
            text1: '',
            
         }
      },
@@ -334,11 +344,13 @@
         this.getDate()
         setInterval(()=>{
            this.getDate()
            this.getInfo()
            this.getError()
            this.controller()
         },1000)
         setInterval(()=>{
            // this.controller()
         },5000)
         },2000)
      },
      methods: {
         getUrl() {
@@ -348,30 +360,131 @@
            this.chartsDataLine1=JSON.parse(JSON.stringify(demodata.Line))
            this.chartsDataPie2=JSON.parse(JSON.stringify(demodata.PieA))
         },
         getInfo() {
            let that = this
            uni.request({
               url: "http://192.168.1.111:8088/sxjzwms/system/error",
               method:"GET",
               success(result) {
                  var   res = result.data
                  if (res.data && res.data !== "") {
                     if (that.infoType == 2 || that.infoType == 3) {
                        return;
                     }
                     that.infoType = 1
                     that.text = res
                  } else {
                     if (that.infoType == 2 || that.infoType == 3) {
                        return;
                     }
                     that.infoType = 0
                  }
               }
            })
         },
         getError() {
            let that = this
            uni.request({
               url:"http://192.168.1.111:8088/sxjzwms/mat/info",
               method:"GET",
               success(result) {
                  var   res = result.data
                  if (res.data && res.data !== "") {
                     if (that.infoType == 1) {
                        that.infoType = 3
                        that.text1 = res
                        return
                     }
                     that.infoType = 2
                     that.text1 = res
                  } else {
                     if (that.infoType == 1) {
                        return
                     }
                     that.infoType = 0
                  }
               }
            })
         },
         // 控制器
         controller() {
            if (this.homeViewShow) {
               this.homeViewShow = !this.homeViewShow
               this.homeMode = ['fade', 'slide-bottom']
               setTimeout(()=>{
                  this.infoViewShow = !this.infoViewShow
                  this.infoMode = ['fade', 'slide-bottom']
               },1100)
            } else if(this.infoViewShow) {
               this.infoViewShow = !this.infoViewShow
               this.infoMode = ['fade', 'slide-bottom']
               setTimeout(()=>{
                  this.errorInfoViewShow = !this.errorInfoViewShow
                  this.errorInfoMode = ['fade', 'slide-bottom']
               },1100)
            } else {
               this.errorInfoViewShow = !this.errorInfoViewShow
               this.errorInfoMode = ['fade', 'slide-bottom']
               setTimeout(()=>{
                  this.homeViewShow = !this.homeViewShow
                  this.homeMode = ['fade', 'slide-bottom']
               },1100)
            switch(this.infoType) {
               // 有信息 但 没有错误信息
               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;
               default :
                  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)
                  }
                  return;
            }
         },
         // 主屏幕
         handle(type) {
@@ -427,13 +540,83 @@
            }
            this.calendar = year + "年" + month + "月" + day + "日 " + hours + ":" + minutes + ":" + seconds + " " + weeks
         },
         getDateFormat(value) {
                     var date = new Date();// 获取当前时间
                     date.setDate(date.getDate() + value);// 设置天数 -1 天
                     var m = date.getMonth() + 1
                     var d = date.getDate()
                     var newDate = m + '-' + d
                     return newDate
                  },
         /*************** 折线图 *****************************************************************************************************/
                  initlineChart() {
                     let that = this
                     uni.request({
                        url: that.commonUrl + "/monitor/line/charts",
                        method:'GET',
                        success(result) {
                           var res = result.data
                           if (res.code === 200) {
                              that.chartsData.Line.categories = [
                                 that.getDateFormat(-11),that.getDateFormat(-10),that.getDateFormat(-9),that.getDateFormat(-8),
                                 that.getDateFormat(-7),that.getDateFormat(-6),that.getDateFormat(-5),that.getDateFormat(-4),
                                 that.getDateFormat(-3),that.getDateFormat(-2),that.getDateFormat(-1),that.getDateFormat(0),]
                              that.chartsData.Line.series = res.data.rows
                           }
                        }
                     })
                  },
         /*************** 饼图 *****************************************************************************************************/
                  initPieChart() {
                     let that = this
                     uni.request({
                        url: that.commonUrl + "/monitor/loc/rep",
                        method:'GET',
                        success(result) {
                           var res = result.data
                           if (res.code === 200) {
                              that.chartsData.Pie.series[0].data = res.data.pie
                              that.stockCount = res.data.stockCunt
                              that.emptyCount = res.data.emptyCount
                              that.noneCount = res.data.noneCount
                              that.used = res.data.used
                              that.usedPr = res.data.usedPr
                           }
                        }
                     })
                  },
                  getOther() {
                     let that = this
                     uni.request({
                        // http://10.10.0.222:9090/jkwcs/monitor/led?ledId=186
                        url: that.commonUrl + "/monitor/other",
                        data: {
                           crnId: that.baseCrnId,
                           ledId: 1,
                        },
                        success(result) {
                           console.log(result);
                           var res = result.data
                           if (res.code === 200) {
                              that.xDistance = res.data.xDistance
                              that.yDistance = res.data.yDistance
                              that.xDuration = res.data.xDuration
                              that.yDuration = res.data.yDuration
                           } else if (res.code === 403) {
                           } else {
                           }
                        }
                     })
                  },
      }
      
   }
</script>
<style>
   @import url("../../static/css/common.css");
   /* @import url("../../static/css/common.css"); */
   /* 列 */
   .flex-col {
      display: flex;