<template>
  <div class="app-container">
    <!-- <div class="container"> -->
    <el-row :gutter="20">
      <el-col :span="12" :gutter="20">
        <div class="info">
          <div class="title">定时任务信息</div>
          <el-form :model="form" :rules="rules" ref="form" label-width="120px">
            <el-form-item label="任务名称" prop="taskName">
              <el-input v-model="form.taskName" :readonly="true"></el-input>
            </el-form-item>
            <el-form-item label="设备分类" prop="deviceType">
              <el-select v-model="form.deviceType" placeholder="请选择" style="width:100%;" :disabled="true">
                <el-option v-for="sonClass in classifies" :key="sonClass.classifyIdentifying" :label="sonClass.classifyName" :value="sonClass.classifyIdentifying"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="所属标签" prop="deviceLabel">
              <el-input v-model="form.deviceLabel" :readonly="true"></el-input>
            </el-form-item>
            <el-form-item label="cron表达式" prop="detectionCron">
              <el-input v-model="form.detectionCron" :readonly="true"></el-input>
            </el-form-item>
            <el-form-item label="是否开启" prop="onOrOff">
              <!-- <el-input v-model="form.grade"></el-input> -->
              <el-switch v-model="form.onOrOff" active-color="#13ce66" inactive-color="#ff4949" :active-value="0" :inactive-value="1" :disabled="true"></el-switch>
            </el-form-item>
            <el-form-item label="描述" prop="detectionDesc">
              <el-input type="textarea" v-model="form.detectionDesc" maxlength="300" rows='6' show-word-limit :readonly="true"></el-input>
            </el-form-item>

          </el-form>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="info">
          <!-- <div class="title">报警信息</div> -->
          <div class="topHeader">
            <div class="topHeader-title">关联设备 <span v-if="relatedEquipment != 0">( {{relatedEquipment}} )</span> </div>
            <!--<div class="topHeader-btns">
              <el-button @click="clear">清空已选</el-button>
              <el-button type="primary" @click="related">关联设备</el-button>
            </div>-->
          </div>
          <div class="equipments" v-if="cities.length !==0 ">
            <div class="relatedEquipment" v-for="city in list" :label="city" :key="city.index">
              <el-row>
                <el-col :span="24">
                  <el-card class="box-card" shadow="hover">
                    <!-- <div v-for="o in 4" :key="o" class="text item">
                    {{'列表内容 ' + o }}
                  </div> -->
                    <div class="card-title">
                      <span class="card-title-text">通风窗设备</span>
                      <span class="card-title-number">001</span>
                    </div>
                    <div class="card-content">
                      <span>标签管理：{{ city.label }}</span>
                      <span>所属仓房：{{ city.barn}}</span>
                      <span>所属建筑位置{{ city.position }}</span>
                    </div>
                  </el-card>
                </el-col>
              </el-row>
            </div>
          </div>

        </div>
      </el-col>
    </el-row>
    <!-- </div> -->
    <el-footer style="height: 41px;">
      <el-button type="primary" class="footerBtn" @click="back">返 回</el-button>
    </el-footer>
    <!--<el-drawer title="关联设备" :visible.sync="drawer" direction="rtl">
      &lt;!&ndash; <span>我来啦!</span> &ndash;&gt;
      <div class="drawer-header">
        <el-input v-model="equipmentClassificationName" placeholder="请输入设备分类名称搜索"></el-input>
        <el-button type="primary" @click="related">搜索</el-button>
      </div>
      <div class="drawer-list">

        <el-checkbox-group v-model="checkedCities">
          <el-checkbox v-for="city in cities" :label="city" :key="city.index">
            &lt;!&ndash; {{city}} &ndash;&gt;
            <el-row>
              <el-col :span="24">
                <el-card class="box-card">
                  &lt;!&ndash; <div v-for="o in 4" :key="o" class="text item">
                    {{'列表内容 ' + o }}
                  </div> &ndash;&gt;
                  <div class="card-title">
                    <span class="card-title-text">通风窗设备</span>
                    <span class="card-title-number">001</span>
                  </div>
                  <div class="card-content">
                    <span>标签管理：{{ city.label }}</span>
                    <span>所属仓房：{{ city.barn}}</span>
                    <span>所属建筑位置{{ city.position }}</span>
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </el-checkbox>

        </el-checkbox-group>
      </div>
      <div class="drawer-footer">
        <div>共 <span>{{ relatedEquipments }}</span> 项</div>
        <el-button type="primary" @click="addCorrelation">添加关联</el-button>
      </div>
    </el-drawer>-->
  </div>
</template>

<script>

import { addTimingTaskItem, } from '@/api/equipConfig/timingTask/index'
import { getNowFormatDate, } from '@/utils/index'
import {getParentList} from '@/api/equipConfig/equipClassification/index'


export default {
  data () {
    return {
      relatedEquipment: '3',// 关联设备数量
      relatedEquipments: "6",// 抽屉数据列表数量-添加关联
      drawer: false,
      equipmentClassificationName: '', //设备分类名称
      classifies: [],
      form: {
        orgCode: JSON.parse(localStorage.getItem("userInfo")).orgCode,
        id: '',
        beanName: '',
        taskName: '定时任务测试03',
        deviceType: '测温设备',
        deviceLabel: '测温设备',
        buildTime: '',
        onOrOff: 0,
        detectionDesc: '123',
        methodParams: '',
        methodName: '',
        eqSum: 3,
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
      },
      list: [
        {
          name: 'P001', equipName: '1号仓粮情设备', number: '0', layer: '4', row: '5', col: '9'
        },
      ],

      checkAll: false,
      checkedCities: [],
      cities: [
        {
          index: 1, titleNo: 'P001', equipName: '通风窗设备', label: '2022年3月16日', barn: '202102030002', position: '东区',
        },

      ],
      isIndeterminate: true
    }
  },
  created () {

  },
  mounted () {
    this.form = this.$route.params.data;
    this.runBtnEvent();
  },
  methods: {
    /*related () {
      this.drawer = true
    },*/
    /*clear () {
      this.cities = []
    },*/
    back () {
      this.$router.push({ name: "TimedTask" })
    },
    runBtnEvent(data) {
      getParentList(data).then(res => {
        this.classifies = res.data;
      }).catch(err => {
        console.log(err);
      });
    },
    /*addCorrelation () {

    },*/
    handleCheckAllChange (val) {
      this.checkedCities = val ? cityOptions : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange (value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.cities.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    }
  }
}
</script>
<style lang='scss' scoped>
.app-container {
  height: 100%;
  position: relative;
  .el-row {
    height: 100%;
    .el-col {
      height: 100%;
    }
  }

  .el-footer {
    text-align: center;
    background-color: #fff;
    width: 98%;
    // height: 41px;
    // line-height: 41px;
    // background: #e5e5e7;
    color: #888;
    font-weight: 500;
    font-family: Source Han Sans CN;
    font-size: 14px;
    text-align: center;
    position: absolute;
    bottom: 30px;
    // z-index: 9999;
    .footerBtn {
      width: 300px;
      border-radius: 20px;
    }
  }
}
.info {
  height: 100%;
  background-color: #fff;
  border-radius: 15px;
  padding: 10px 15px;
  position: relative;
  .title {
    border-left: 4px solid #4a7de6;
    padding-left: 10px;
    margin-bottom: 20px;
  }
  .topHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    // position: absolute;
  }
  .equipments {
    height: calc(100% - 80px);
    overflow-y: auto;
    padding: 5px;
    margin-top: 10px;
    &::-webkit-scrollbar-track-piece {
      background: transparent;
    }

    &::-webkit-scrollbar {
      width: 6px;
      // width: 10px;
      // height: 0;
      // background-color: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: #424242;

      border-radius: 20px;
    }
    .relatedEquipment {
      width: 100%;
      // background-color: #fff;
      // background-color: #ccc;
      // margin-bottom: 10px;
      border-radius: 10px;
      display: flex;
      flex-direction: column;

      .box-card {
        margin-bottom: 15px;
        background-color: #f9f9f9;
        .card-title {
          display: flex;
          flex-direction: column;
          justify-content: space-evenly;
          border-bottom: 1px solid #ccc;
          span {
            padding: 10px;
          }
        }
        .card-content {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          padding-top: 20px;
          span {
            padding: 10px 0;
          }
        }
      }
    }
  }
  .title1 {
    border-left: 4px solid #4a7de6;
    padding-left: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    .title-right {
      color: #ccc;
      font-size: 12px;
    }
  }
  .el-form {
    margin-top: 15px;
    padding-top: 10px;
    padding: 0 20px 0 10px;
    .el-switch {
      float: right;
    }
  }
}
::v-deep .el-drawer {
  .drawer-header {
    // width: 92%;
    display: flex;
    justify-content: center;
    .el-input {
      width: 70%;
    }
  }
  .drawer-list {
    height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 5px;
    margin-top: 10px;
    &::-webkit-scrollbar-track-piece {
      background: transparent;
    }

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background: #424242;

      border-radius: 20px;
    }
    // .el-c
    .el-checkbox-group {
      .el-checkbox {
        display: flex;
        align-items: center;
        margin-right: 0;
        .el-checkbox__label {
          width: 100%;
        }
        .el-checkbox__inner {
          width: 25px;
          height: 25px;
          border-radius: 50%;
          // 中间的 “✔” 的位置调整
          &::after {
            height: 14px;
            width: 5px;
            left: 9px;
            top: 2px;
          }
          &:hover {
            border-color: #4a62e7;
          }
        }

        .box-card {
          margin-bottom: 15px;
          background-color: #f9f9f9;
          .card-title {
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
            border-bottom: 1px solid #ccc;
          }
          .card-content {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding-top: 20px;
          }
        }
      }
    }
  }
  .drawer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 20px;
  }
}
// ::v-deep .el-input__inner {
//   text-align: center;
// }
::v-deep .el-drawer__header {
  text-align: center;
}
</style>
