<template>
  <div id="root">
    <el-form ref="monitoringForm" :model="formInfo" label-width="120px" style="margin-top: 20px; width: 500px; margin-left: auto; margin-right: auto;">
      <div style="margin: 20px 15px 10px 15px;">
        <el-form-item label="视频流地址">
          <el-input v-model="formInfo.url" :disabled="false" name="name"/>
        </el-form-item>
        <el-form-item label="地址">
          <el-input v-model="formInfo.address" :disabled="false" name="address"/>
        </el-form-item>
        <el-form-item label="安保人员电话">
          <el-input v-model="formInfo.securityGuardTel" :disabled="false" name="phone"/>
        </el-form-item>
        <el-form-item label="保安室电话">
          <el-input v-model="formInfo.securityRoomTel" :disabled="false" name="phone-2"/>
        </el-form-item>
      </div>
      <el-form-item>
        <el-button type="primary" @click="monitoringSubmit" >提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'MonitoringAdd',
  data() {
    return {
      formInfo: {
        address: '',
        addressId: '',
        communityId: '',
        createTime: '',
        createUser: '',
        equipmentTreeId: '',
        equipmentType: '',
        id: '',
        securityGuardTel: '',
        securityGuardTelId: '',
        securityRoomTel: '',
        securityRoomTelId: '',
        updateTime: '',
        updateUser: '',
        url: '',
        urlId: '',
        uuid: '',
        uuidId: ''
      }
    }
  },
  mounted() {
    this.formInfo.id = this.$route.query.id
    this.getMonitoringById()
  },
  methods: {
    monitoringSubmit() { // 监控提交
      console.log('monitoringForm : ', this.formInfo)
      this.$store.dispatch('EquipmentMonitoring', this.formInfo).then((res) => {
        if (res.code === '0') {
          this.$message.success(res.message)
          // 监控
          // this.equipmentGetAll()
          this.$router.go(-1)
        }
      }).catch(() => {
        console.log('EquipmentMonitoring error')
      })
    },
    getMonitoringById() { // 查询设备
      const dataQuery = { id: this.formInfo.id, type: 1 }
      this.$store.dispatch('GetMonitoringById', dataQuery).then((res) => {
        if (res.code === '0') {
          // 监控
          this.formInfo = res.data
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
