<template>
  <div class='box'>
    <el-row style="padding:0 10px;margin-bottom:10px;">
      <div style="float:left;">
        <label>选择时间范围 : </label>
        <el-date-picker v-model="value" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </div>
      <div style="float:left;margin-left:10px;">
        <label>发现问题:</label>
        <span>无</span>
      </div>
      <el-button style="float:right;" :disabled="true">查看收集到的问题</el-button>
    </el-row>
    <div style="background:#fff;display:flex;align-items:center;border: 1px solid #e4e4e4;justify-content:center;height:100%;">
      <div class="center">
        <i class="icon-wushuju iconfont"></i>
        暂无数据
      </div>
    </div>
    <!-- <div class='condition'>
            <p>
                <span style="margin-right: 12px">建筑名称</span>
                <el-select v-model='buildVlaue' placeholder='请选择'>
                    <el-option
                        v-for='item in options'
                        :key='item.BuildId'
                        :label='item.BuildLocalName'
                        :value='item.BuildId'
                    ></el-option>
                </el-select>
            </p>
        </div>
        <el-tabs v-model='activeName' @tab-click='handleClick' style="background:#fff">
            <el-tab-pane label='现场无法找到的资产' name='first'>
                <saga-nofind :buildVlaue='buildVlaue' :floorsObj='floorsObj'></saga-nofind>
            </el-tab-pane>
            <el-tab-pane label='未画入模型的资产' name='second'>
                <saga-nopaint :buildVlaue='buildVlaue' :floorsObj='floorsObj'></saga-nopaint>
            </el-tab-pane>
            <el-tab-pane label='无对应岗位的资产' name='third'>
                <saga-nomap :buildVlaue='buildVlaue' :floorsObj='floorsObj' :allFamilyObj='allFamilyObj'></saga-nomap>
            </el-tab-pane>
            <el-tab-pane label='未扫楼验证的资产' name='fourth'>
                <saga-verify :buildVlaue='buildVlaue' :floorsObj='floorsObj' :allEquipObj='allEquipObj'></saga-verify>
            </el-tab-pane>
        </el-tabs> -->
  </div>
</template>

<script>
import SagaNofind from './Nofind'
import SagaNopaint from './Nopaint'
import SagaVerify from './Noverify'
import { mapGetters } from 'vuex'
//api
import {
  getBuildSelect, //根据项目ID获得建筑列表
  getAllbusiness,
  getAllFamily
} from '@/api/scan/request'
export default {
  name: 'build-assets',
  data() {
    return {
      activeName: 'first',
      buildVlaue: '',
      options: [],
      floorsObj: {},
      allFamilyObj: {},
      allEquipObj: {},
      value: '',//
    }
  },
  computed: {
    ...mapGetters('layout', ['projectId', 'userId', 'secret'])
  },
  components: {
    SagaNofind,
    SagaNopaint,
    SagaVerify
  },
  methods: {
    handleClick() { },
    //获取建筑列表
    getBuilding() {
      let param = {
        ProjId: this.projectId,
        UserId: this.userId
      }
      getBuildSelect(param).then(res => {
        if (res.data.Result == 'success') {
          let data = res.data.BuildList
          this.options = data
          this.buildVlaue = data.length ? data[0].BuildId : ''
        }
      })
    },
    //获取所有楼层
    getFloors() {
      let param = {
        ProjId: this.projectId,
        secret: this.secret,
        id: this.projectId,
        type: ['Fl']
      }
      getAllbusiness(param).then(res => {
        if (res.data.Result == 'success') {
          res.data.Content.forEach(item => {
            this.floorsObj[item.infos.FloorID] = item.infos.FloorLocalName
          })

        }
      })
    },
    //获取设备组
    getAllFamily() {
      getAllFamily().then(result => {
        if (result.data.Result == "success") {
          console.log(result.data.Content)
          let list = result.data.Content;
          list.forEach(ele => {
            this.allFamilyObj[ele.code] = ele
          })
          this.allEquipObj = {}
          this.getEquip(list)
        }
      });
    },
    getEquip(list) {
      list.forEach(ele => {
        if (ele.content) {
          ele.content.forEach(keng => {
            this.allEquipObj[keng.code] = keng.name
          })
        }
      })
    },
    async init() {
      await this.getAllFamily();
      await this.getFloors();
      await this.getBuilding()
    }
  },
  created() {
    this.init()
  },
  watch: {
    projectId() {
      this.init()
    }
  }
}
</script>

<style scoped lang='less'>
.box {
  .condition {
    padding: 10px;
    display: flex;
    border: 1px solid #dfe6ec;
    background: #fff;
    margin-bottom: 10px;
  }
  /deep/ .el-tabs__nav {
    margin-left: 10px;
  }
}
</style>

