<!-- 性诱测报控制 -->
<template>
  <div class=''>
    <div class="equipId">设备ID：{{equipId}}</div>
	  <el-form
          ref="equipContrlRef1"
          :model="setFrom"
          label-position="top"
          label-width="130px"
        >
          <el-form-item label="操作：" >
            <el-button class="ctrlbtns" type="blueInfo" size="mini" @click="equipControl('reboot')">重启</el-button>
            <el-button class="ctrlbtns" type="blueInfo" size="mini" @click="searchInterval('data')">刷新</el-button>
          </el-form-item>
          <el-form-item label="显示屏设置：" >
            <el-input style="margin-bottom: 20px" v-model="setFrom.content" placeholder="标题文字设置"></el-input>
            <el-input
              type="number"
              min="0"
              placeholder="显示时间设置(min)"
              v-model="setFrom.timeout"
            ></el-input>
          </el-form-item>
          <el-form-item label="上传时间间隔：">
            <el-slider
              v-model="setFrom.interval"
              show-input
              :min="1"
              :max="360"
            ></el-slider>
          </el-form-item>
          <el-form-item >
            <el-button class="updatetime" type="blueInfo" size="mini" @click="searchInterval('interval')">查询上传时间间隔</el-button>
          </el-form-item>
          <el-form-item class="handAddFormBtn">
            <el-button
              type="blueInfo"
              size="small"
              @click="equipSetSubm()"
              >确定</el-button>
            <!-- <el-button type="grayInfo" size="small" @click="resetForm()"
              >取消</el-button> -->
          </el-form-item>
        </el-form>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
props: ["equipId", "equipType","d_id","model"],
//import引入的组件需要注入到对象中才能使用
components: {},
data() {
//这里存放数据
return {
  setFrom: {
    //设备控制
    content: "",
    timeout: null,
    interval: 0,
  },
};
},
//监听属性 类似于data概念
computed: {},
//监控data中的数据变化
watch: {},
//方法集合
methods: {
    equipControl(cmd) {
      this.$axios({
        method: "POST",
        url:
          "/api/api_gateway?method=forecast.send_control.admin_device_control",
        data: this.qs.stringify({
          device_type_id: 5,
          d_id: this.d_id,
          cmd: cmd,
        }),
      }).then((res) => {
        if (res.data.message == "") {
          this.$message.success("操作成功");
        } else {
          this.$message.err("操作失败");
        }
      });
    },
    searchInterval(cmd) {
      this.$axios({
        method: "POST",
        url: "/api/api_gateway?method=forecast.send_control.get_device_config",
        data: this.qs.stringify({
          device_type_id: 5,
          d_id: this.d_id,
          control_type: cmd,
        }),
      }).then((res) => {
        if (res.data.message == "") {
          this.$message.success("操作成功");
        } else {
          this.$message.err("操作失败");
        }
      });
    },
    equipSetSubm() {
      console.log(this.setFrom);
      this.$axios({
        method: "POST",
        url: "/api/api_gateway?method=forecast.send_control.device_control",
        data: this.qs.stringify({
          device_type_id: 5,
          d_id: this.d_id,
          config: JSON.stringify(this.setFrom),
        }),
      }).then((res) => {
        if (res.data.message == "") {
          this.$message.success("操作成功");
        } else {
          this.$message.err("操作失败");
        }
        this.setDialogVisible = false;
      });
    },
},
//生命周期 - 创建完成（可以访问当前this实例）
created() {

},
//生命周期 - 挂载完成（可以访问DOM元素）
mounted() {
},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang="less">
.equipId{
  line-height: 33px;
  text-align: center;
  background: #eee;
}
.handAddFormBtn{
  margin-top: 20px;
  text-align: right;
}
.ctrlbtns{
  padding: 10px 30px;
}
.updatetime{
  margin-top: 10px;
  width: 100%;
  line-height: 22px;
}
/deep/.el-slider__input{
  width: 103px;
}
/deep/.el-input-number--small .el-input-number__decrease, /deep/.el-input-number--small .el-input-number__increase{
  width: 26px;
}
/deep/.el-slider__runway.show-input{
  margin-right: 119px;
}
</style>