<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="100px">
      <div class="info">
        <div class="title">设备基础信息</div>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="设备编号" prop="deviceNumber">
              <el-input v-model="form.deviceNumber"></el-input>
            </el-form-item>
            <el-form-item label="设备类型" prop="deviceType">
              <el-input v-model="form.deviceType"></el-input>
            </el-form-item>
            <el-form-item label="创建时间" prop="createTime">
              <el-date-picker v-model="form.createTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间" style="width:100%;">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="质保日期" prop="warrantyTime">
              <el-date-picker v-model="form.warrantyTime" type="datetime" placeholder="选择日期时间" align="right" value-format="yyyy-MM-dd HH:mm:ss" style="width:100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备名称" prop="deviceName">
              <el-input v-model="form.deviceName"></el-input>
            </el-form-item>
            <el-form-item label="设备标签" prop="deviceLabel">
              <el-input v-model="form.deviceLabel"></el-input>
            </el-form-item>
            <el-form-item label="设备状态" prop="deviceStatus">
              <el-select v-model="form.deviceStatus" placeholder="请选择" style="width:100%;">
                <el-option label="设备异常" value="1"></el-option>
                <el-option label="设备预警" value="2"></el-option>
                <el-option label="设备故障" value="3"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设备型号" prop="deviceModel">
              <el-input v-model="form.deviceModel"></el-input>
            </el-form-item>
            <el-form-item label="所属仓房" prop="houseCode">
              <el-input v-model="form.houseCode"></el-input>
            </el-form-item>
            <el-form-item label="最后上线" prop="lastSeenTime">
              <el-date-picker v-model="form.lastSeenTime" type="datetime" placeholder="选择日期时间" align="right" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" style="width:100%;">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="info">
        <div class="title1">
          <span>安装位置</span>
          <span class="title-right">设备安装点位由项目空间点位+安装位置描述两部分构成</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="安装位置" prop="installPoint">
              <el-input v-model="form.installPoint"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="info">
        <div class="title">
          <span>设备配置信息</span>

        </div>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="粮情编号" prop="foodNumber">
              <el-input v-model="form.foodNumber"></el-input>
            </el-form-item>
            <el-form-item label="站点编号" prop="siteCode">
              <el-input v-model="form.siteCode"></el-input>
            </el-form-item>
            <el-form-item label="层数" prop="layerNumber">
              <el-input v-model="form.layerNumber"></el-input>
            </el-form-item>
            <el-form-item label="方位" prop="foodPosition">
              <el-input v-model="form.foodPosition"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通道号" prop="channelNumber">
              <el-input v-model="form.channelNumber"></el-input>
            </el-form-item>
            <el-form-item label="起始电缆号" prop="startCableNumber">
              <el-input v-model="form.startCableNumber"></el-input>
            </el-form-item>
            <el-form-item label="行数" prop="rowNumber">
              <el-input v-model="form.rowNumber"></el-input>
            </el-form-item>
            <el-form-item label="是否反置" prop="isReverse">
              <el-select v-model="form.isReverse" placeholder="请选择" style="width:100%;">
                <el-option label="是" value="0"></el-option>
                <el-option label="否" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="粮情名称" prop="foodName">
              <el-input v-model="form.foodName"></el-input>
            </el-form-item>
            <el-form-item label="结束电缆号" prop="endCableNumber">
              <el-input v-model="form.endCableNumber"></el-input>
            </el-form-item>
            <el-form-item label="列数" prop="columnNumber">
              <el-input v-model="form.columnNumber"></el-input>
            </el-form-item>
            <el-form-item label="粮情/油情" prop="isFood">
              <el-select v-model="form.isFood" placeholder="请选择" style="width:100%;">
                <el-option label="粮情" value="0"></el-option>
                <el-option label="油情" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="描述">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <div class="btns" style="text-align:center;">
              <el-button type="primary" @click="update">保 存</el-button>
              <el-button @click="goback()">返 回</el-button>
            </div>
          </el-col>

        </el-row>
      </div>
      <!-- <div class="info">
        <div class="title1">
          <span>定时任务</span>
          <span class="title-right">设备安装点位由项目空间点位+安装位置描述两部分构成</span>
        </div>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="定时任务">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div> -->

    </el-form>
  </div>
</template>

<script>
import { getGrainCheckItem, updateGrainCheckItem } from '@/api/equipConfig/equipConfiguration/index'
export default {
  data () {
    return {
      pickerOptions: {
        shortcuts: [{
          text: '今天',
          onClick (picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick (picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick (picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      },
      form: {
        orgCode: JSON.parse(localStorage.getItem("userInfo")).orgCode,
        id: '',
        deviceNumber: '',// 设备编号
        deviceModel: '',//设备型号
        createTime: '',//创建时间
        warrantyTime: '',//质保日期
        deviceName: '',//设备名称
        deviceLabel: '',//设备标签
        deviceStatus: '',//设备状态
        deviceType: '',// 设备类型
        houseCode: '', //所属仓房
        lastSeenTime: '',//最后上线时间
        installAdress: '',//安装位置
        installPoint: '',//安装点位
        deviceAddress: '',//设备详细地址

        foodNumber: '',// 粮情编号
        foodName: '',// 粮情名称
        channelNumber: '',// 通道号
        startCableNumber: '',// 起始电缆号
        endCableNumber: '', // 结束电缆号
        siteCode: '',//站点编号
        layerNumber: '',// 层数
        rowNumber: '',//行数
        columnNumber: '',//列数
        foodPosition: '',//方位
        isReverse: '',//是否反置
        isFood: '',//粮情/油情
        foodDescribe: '',//描述
        // timingTask: '',//定时任务
      },
    }
  },
  created () {
    console.log(this.$route.params, 'query')
  },
  mounted () {
    this.getDetail()
  },
  methods: {
    tableDataAdd () {
      // this.tableData.
    },
    getDetail () {
      let id = this.$route.params.data.id
      getGrainCheckItem(id).then(res => {
        console.log(res, 'this.$route.params')
        if (res.code == 200) {
          this.form = res.data
        }
      }).catch(err => {
        console.log(err)
      })
    },
    update () {
      updateGrainCheckItem(this.form).then(res => {
        console.log(res, 'updateGrainCheckItem')
        if (res.code == 200) {
          this.$router.push({ name: "EquipGrainDetection" })
        }
      })
    },
    goback () {
      this.$router.push({ name: "EquipGrainDetection" })
    }
  }
}
</script>
<style lang='scss' scoped>
.info {
  background-color: #fff;
  border-radius: 15px;
  padding: 10px 15px;
  .title {
    border-left: 4px solid #4a7de6;
    padding-left: 10px;
    margin-bottom: 20px;
  }
  .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;
  }
}
.btns {
  margin-bottom: 25px;
}
.info:nth-of-type(n + 2) {
  margin-top: 15px;
}

// ::v-deep .el-input__inner {
//   text-align: center;
// }
</style>
