<template>
  <el-drawer
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    @close="handleClose"
    width="500px"
  >
  <div>
    <div class="container_left">
      <h3>设备信息</h3>
      <el-row>
        <el-col :span="11">
          <img :src="equipment"/>
        </el-col>
        <el-col :span="13">
          <div class="equipment_right" v-for="(item,index) in list" :key="index">
            <el-row>
              <el-col :span="8">
                <label>{{item.label}}</label>
              </el-col>
              <el-col :span="16">
                <span class="content">{{item.text}}</span>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
      <h3>当前使用记录</h3>
      <el-row>
        <el-col :span="12" v-for="(item,index) in current_history" :key="index">
          <el-row>
            <el-col :span="8">
              <label>{{item.label}}</label>
            </el-col>
            <el-col :span="16">
              <span class="content">{{item.text}}</span>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <div class="year_history">
        <h3>年度使用记录</h3>
        <el-select placeholder="年份" style="width: 150px;">
        </el-select>
      </div>
      <el-row>
        <el-col :span="12" v-for="item in current_history" :key="item.label">
          <el-row>
            <el-col :span="8">
              <label>{{item.label}}</label>
            </el-col>
            <el-col :span="16">
              <span class="content">{{item.text}}</span>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </div>
    <div style="margin-right:20px;">
      <echartsGradient style="margin-top:20px"/>
    </div>
  </div>
  </el-drawer>
</template>

<script>
import { assign } from 'lodash-es';
import equipment from './assets/equipment.svg'
import echartsGradient from './echartsGradient.vue';
export default {
  name: 'rightEquipment',
  props: {
    data: {
      default() {
        return {};
      }
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  components: {
    echartsGradient
  },
  data() {
    return {
      year_history: [{
        label: '使用次数：',
        text:'50次'
      },{
        label: '使用人数：',
        text:'20人'
      },{
        label: '累计用水量：',
        text:'10000  m³ /s'
      },{
        label: '累计用电量：',
        text:'42,125°'
      }],
      current_history: [{
        label: '使用农户：',
        text:'张三'
      },{
        label: 'IC卡号：',
        text:'545454545454545'
      },{
        label: '当前流速：',
        text:'10000  m³ /s'
      },{
        label: '瞬时流量：',
        text:'10000  m³ /s'
      },{
        label: '已用时长：',
        text:'2小时30分钟'
      }],
      list:[{
        label: '设备名称：',
        text: '1号水电双计设备'
      },{
        label: '设备编号：',
        text: '54545415315569'
      },{
        label: '水源名称：',
        text: '001号水井'
      },{
        label: '所属区域：',
        text: '1号基地'
      },{
        label: '所在位置：',
        text: '河南省郑州市金水区瀚海北金商业写字楼B座'
      },{
        label: '在线状态：',
        text: '在线'
      },{
        label: '运行状态：',
        text: '开'
      }],
      equipment: equipment,
      dialogVisible: false,
      baseForm: {
        productValue: '',
        productName: '',
        stockAmount: '',
        goodsUnit: '',
        goodsSpecValue: '',
        imageArr1: [],
        supplierId: '',
        imageArr2: []
      },
      hasFetched: false,
    };
  },
  watch: {
    visible(val) {
      if (val !== this.dialogVisible) {
        this.dialogVisible = val;
        if (val) {
          assign(this.baseForm, this.data);
          if (!this.hasFetched) {
            this.hasFetched = true;
          }
        }
      }
    },
    data: {
      deep: true,
      handler(val) {
        assign(this.baseForm, val);
      }
    }
  },
  methods: {
    resetForm(formName) {
      this.dialogVisible = false;
    },
    handleClose() {
      this.$emit('update:visible', false);
      this.resetForm('baseForm');
    },
  }
};
</script>

<style lang="scss" scoped>
.container_left{
  width: 90%;
  padding: 0 5%;
  h3{
    color: #333;
    font-family: Source Han Sans CN VF;
    font-size: 16px;
    font-style: normal;
    font-weight: 700;
    line-height: 26px;
  }
  .equipment_right{
    margin-bottom:5px;
    position: relative;
  }
  
  label{
    color: #999;
    text-overflow: ellipsis;
    font-family: Source Han Sans CN VF;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 18px;
  }
  .content{
    color:  #333;
    font-family: Source Han Sans CN VF;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 18px;
  }
  .year_history{
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
</style>
