#
whycq
2022-11-19 4687664bba4ae431daa48a18a401117f3ad234cd
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,8 +10,8 @@
            <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="main" v-if="aaaaa">
               <view class="mian-item">
                  <view class="mian-item-box">
                     <y-box>
@@ -195,25 +195,23 @@
                  </view>
               </view>
            </view>
            <!-- 主体 -->
            <view class="info-main" v-if="bbbbb">
               <view class="info-box">
                  <y-box>{{text}}</y-box>
               </view>
            </view>
            <!-- 主体 -->
            <view class="info-main"  v-if="ccccc">
               <view class="info-box">
                  <y-box>{{text}}</y-box>
               </view>
            </view>
         </view>
      </uni-transition>
      <!-- 全板/拣料信息 -->
      <uni-transition :duration="duration" :mode-class="infoMode" :show="infoViewShow">
         <view class="info-view">
            <view class="head">
               <text>拣 料</text>
            </view>
            <!-- 日历 -->
            <view class="time-tools">{{calendar}}</view>
            <view class="button-left"></view>
            <view class="button-right"></view>
            <!-- 主体 -->
            <view class="info-main" >
               <view class="info-box">
                  <y-box></y-box>
               </view>
            </view>
         </view>
      </uni-transition>
      <!-- 异常信息 -->
      <uni-transition :duration="duration" :mode-class="errorInfoMode" :show="errorInfoViewShow">
@@ -228,7 +226,7 @@
            <!-- 主体 -->
            <view class="info-main" >
               <view class="info-box">
                  <y-box></y-box>
                  <y-box>{{text}}</y-box>
               </view>
            </view>
         </view>
@@ -278,6 +276,7 @@
<script>
   import demodata from '@/mockdata/demodata.json';
   import ycqdata from '@/pages/index/data.json';
   export default {
      data() {
         return {
@@ -320,6 +319,15 @@
            basePort: '',
            baseLedId: '',
            baseCrnId: '',
            info: null,
            error: null,
            infoType: 0,
            text: '',
            aaaaa: true,
            bbbbb: false,
            ccccc: false,
            
         }
      },
@@ -332,13 +340,16 @@
      onLoad() {
         this.getServerData()
         this.getDate()
         this.change()
         setInterval(()=>{
            this.getDate()
            this.getInfo()
            this.getError()
            this.controller()
         },1000)
         setInterval(()=>{
            // this.controller()
         },5000)
         // setInterval(()=>{
         //    this.controller()
         // },5000)
      },
      methods: {
         getUrl() {
@@ -348,30 +359,87 @@
            this.chartsDataLine1=JSON.parse(JSON.stringify(demodata.Line))
            this.chartsDataPie2=JSON.parse(JSON.stringify(demodata.PieA))
         },
         getInfo() {
            let that = this
            var result = ycqdata.dataYYY
            var   res = result.data
            if (res.data && res.data !== "") {
               if (this.infoType == 2 || this.infoType == 3) {
                  return;
               }
               this.infoType = 1
               this.text = res
            } else {
               if (this.infoType == 2 || this.infoType == 3) {
                  return;
               }
               this.infoType = 0
            }
         },
         getError() {
            let that = this
            var result = ycqdata.dataEEE
            var   res = result.data
            if (res.data && res.data !== "") {
               if (this.infoType == 1) {
                  this.infoType = 3
                  this.text = res
                  return
               }
               this.infoType = 2
               this.text = res
            } else {
               if (this.infoType == 1) {
                  return
               }
               this.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
            switch(this.infoType) {
               case 1:
                  this.homeViewShow = false
                  this.homeMode = ['fade', 'slide-bottom']
               },1100)
                  setTimeout(()=>{
                     this.homeViewShow = true
                     this.aaaaa = false
                     this.bbbbb = true
                     this.homeMode = ['fade', 'slide-bottom']
                  },1000)
                  return;
               case 2:
                  this.homeViewShow = false
                  this.homeMode = ['fade', 'slide-bottom']
                  setTimeout(()=>{
                     this.aaaaa = false
                     this.ccccc = true
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                  },1000)
                  return;
               case 3:
                  this.homeViewShow = false
                  this.homeMode = ['fade', 'slide-bottom']
                  setTimeout(()=>{
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                  },1000)
                  return;
               default :
                  this.homeViewShow = false
                  this.homeMode = ['fade', 'slide-bottom']
                  setTimeout(()=>{
                     this.homeViewShow = false
                     this.homeMode = ['fade', 'slide-bottom']
                  },1000)
                  return;
            }
         },
         change() {
         },
         // 主屏幕
         handle(type) {
@@ -427,6 +495,76 @@
            }
            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 {
                           }
                        }
                     })
                  },
      }
      
   }