<!-- 管理端工作台 -->
<template>
  <view class="manage-workbench" :style="{paddingTop:navHeight+'rpx'}">
    <nav-bar :title="title"></nav-bar>
    <top-warn></top-warn>
    <homeConfigurationSlot v-for="(item,index) in homeConfigData" :key="index" :homeConfig="item"></homeConfigurationSlot>
    <tab-bar></tab-bar>
  </view>
</template>

<script>
  import {getSafeWarnList, laboratoryAppletSubList,
    systemAppletLayoutSelect,laboratoryAppletGetSubDetailInfo
  } from '@/pages/api/index.js'
  import {getHomeConfig} from '@/utils/homeConfig'
	// #ifdef MP-WEIXIN
	import {tabBar} from '@/pages/component/tabBar.vue'
	import {topWarn} from '@/pages/component/topWarn.vue'
	import {navBar} from '@/pages/component/navbar.vue'
	import {homeConfigurationSlot} from '@/pages/component/homeConfigurationSlot'
	// #endif
  export default {
    name: 'manageWorkbench',
		// #ifdef MP-WEIXIN
    components: {
      tabBar,
      topWarn,
      navBar,
      homeConfigurationSlot,
    },
		// #endif
		// #ifdef H5
		components: {
			"tabBar": () => import('@/pages/component/tabBar.vue'),
			"topWarn": () => import('@/pages/component/topWarn.vue'),
			"navBar": () => import('@/pages/component/navbar.vue'),
			"homeConfigurationSlot": () => import('@/pages/component/homeConfigurationSlot.vue'),
		},
		// #endif
    data() {
      return {
        homeConfigData: [],
        navHeight: uni.getStorageSync('navHeight'),
        title: '实验室安全智能监测与控制系统',
        //banner图片
        homepageBanner: uni.getStorageSync('homepageBanner'),
        subject_classData: [],
        securityAlertNum: "",
        //安全报警
        alarmList: [{
			subDiyVo:{
				levelName:'三大法师的',
				name:'111111',
				typeName:'sdfasfasd',
				subAddrrStr:'111111111111'
			},
			sensorSet:[
				'voc监测数值异常'
			]
		}],
        //实验室数据
        dataList: [],
        fanList: [],//控制记录触发方式
        // 查询参数
        queryParams: {
          page: 1,
          pageSize: 20,
        },
        safeWarnQueryParams:{
          page: 1,
          pageSize: 20,
          count: 0,
          groupStatus: 1,
        }
      }
    },
    created() {

    },
    mounted() {
      this.systemAppletLayoutSelect();
      this.laboratoryAppletSubList();
      //this.getSafeWarnList();
    },
    methods: {
      //获取菜单配置
      async systemAppletLayoutSelect() {
        const {data} = await systemAppletLayoutSelect({module: 'home'})
        if (data.code == 200) {
          let list = JSON.parse(JSON.stringify(data.data))
          for (let i = 0; i < list.length; i++) {
            list[i].layout = JSON.parse(list[i].layout);
          }
          this.$set(this, 'homeConfigData', getHomeConfig(list));
        }
      },
      //获取实验室列表
      async laboratoryAppletSubList() {
        let self = this;
        const {data} = await laboratoryAppletSubList(this.queryParams);
        if (data.code == 200) {
          this.$set(this,'dataList',data.data.records);
        }
      },
      //获取报警信息列表
      async getSafeWarnList() {
        const {data} = await getSafeWarnList(this.safeWarnQueryParams);
        if (data.code == 200) {
          this.alarmList = data.rows;
          if (data.rows[0]) {
            this.securityAlertNum = data.rows[0].todayHappenCount;
          } else {
            this.securityAlertNum = 0;
          }
        }
      },
	   tableButton(type,row){
        let self = this;
        if(type == 'subDetail'){
          //实验室详情
		  this.laboratoryAppletGetSubDetailInfo(row.infoId)

        }
      },
	  //获取实验室详情
	  async laboratoryAppletGetSubDetailInfo(infoId) {
	    const {data} = await laboratoryAppletGetSubDetailInfo({infoId:infoId});
	    if (data.code == 200) {
			uni.navigateTo({
				url: '/pages_manage/views/laboratory/infoPage?infoData='+encodeURIComponent(JSON.stringify(data.data))
			});
	    }
	  },
    },
    beforeDestroy() {

    }
  }
</script>

<style lang="stylus" scoped>
.manage-workbench {
  height: 100%;
  width: 100%;
  overflow-y: scroll;
  box-sizing: border-box;
  .top-big-img {
    height: 342 rpx;
    width: 750 rpx;
  }
  /*安全报警和我的实验室头部*/
  .for-title-p{
    border-top-left-radius 20rpx
    border-top-right-radius 20rpx
    background #fff
    padding-left:25rpx;
    display flex
    margin:0 20rpx;
    border-bottom:1rpx solid #e0e0e0;
    .left-img{
      height:34rpx;
      width:34rpx;
      margin:22rpx 10rpx 0 0;
    }
    .name-view{
      line-height:77rpx;
      font-size:30rpx;
      color:#333;
    }
    .num-view{
      width:28rpx;
      height:28rpx;
      font-size:20rpx;
      background:#EE3A3A;
      border-radius:50%;
      text-align :center;
      line-height:24rpx;
      color:#fff;
      margin:26rpx 0 0 10rpx;
    }
    .null-view{
      flex:1;
    }
    .right-img{
      height:20rpx;
      width:10rpx;
      margin:28rpx 19rpx 0 0;
    }
  }
  /*我的实验室*/
  .for-max-box{
    margin:0 20rpx 120rpx;
    background: #fff
    overflow: hidden
    border-bottom-left-radius 20rpx
    border-bottom-right-radius 20rpx
    .null-img{
      display block
      width:276rpx;
      height:321rpx;
      margin:40rpx auto;
    }
    .for-box:nth-child(1){
      border-top:none;
    }
    .for-box{
      border-top:4rpx solid #dedede;
      overflow hidden
      background #ffffff
      margin-bottom:20rpx;

      .title-box{
        margin:20rpx 20rpx 0;
        display flex
        view:nth-child(1){
          height:40rpx;
          line-height:40rpx;
          font-size:20rpx;
          border-radius:10rpx;
          padding:0 20rpx;
          color:#fff;
          margin-right:20rpx;
        }
        view:nth-child(2){
          line-height:42rpx;
          font-size:30rpx;
          color:#333;
          max-width:600rpx;
          flex:1;
        }
        img{
          width:12rpx;
          height:20rpx;
          margin-top:11rpx;
        }
        .colorA{
          background:#aa2315;
        }
        .colorB{
          background:#ff9b09;
        }
        .colorC{
          background:#3ea3e9;
        }
        .colorD{
          background:#3ea34c;
        }

      }
      .address-box{
        margin:20rpx 20rpx;
        font-size:26rpx;
        color:#999999;
        span{
          margin-right:60rpx;
        }
      }
      .address-box-two{
        display flex
        margin:0 20rpx 20rpx 20rpx;
        img{
          width:28rpx;
          height:30rpx;
          margin-right:18rpx;
        }
        view{
          line-height:30rpx;
          font-size:24rpx;
          color:#999999;
        }
      }
      /*安全报警*/
      .for-img-box{
        border-top:1rpx solid #e0e0e0;
        margin:0 20rpx;
        .for-img-min-box{
          display flex
          img{
            width:30rpx;
            height:27rpx;
            margin-top:24rpx;
            margin-right:10rpx;
          }
          view{
            line-height:74rpx;
            text-align center
            font-size:28rpx;
            color:#EE3A3A;
          }
        }
      }
      .button-view{
        margin:0 20rpx;
        border-top:1rpx dashed #e0e0e0;
        line-height:90rpx;
        text-align :center;
        font-size:26rpx;
        color:#333;
      }
    }
  }
}
</style>
