<template>
  <div class="buttonBox">
    <el-button type="primary" @click="handleDeviceInfo">装置信息 </el-button>
    <info-dialog ref="infodialog_ref"></info-dialog>
  </div>
</template>
<script>
import infoDialog from "./infoDialog.vue";
import { getTermStatus } from "@/utils/api/index";
export default {
  components: {
    infoDialog,
  },
  data() {
    return {};
  },
  watch: {
    termId: {
      handler(newVal, oldVal) {},
      deep: true,
      immediate: true,
    },
    cmdId: {
      handler(newVal, oldVal) {},
      deep: true,
      immediate: true,
    },
  },
  computed: {
    termId() {
      return this.$store.state.termId;
    },
    cmdId() {
      return this.$store.state.cmdId;
    },
  },
  methods: {
    handleDeviceInfo() {
      this.picLoading = true;
      getTermStatus({ termId: this.termId }).then((res) => {
        console.log(res);
        if (res.data.isonline) {
          this.$refs.infodialog_ref.display(this.termId, this.cmdId);
          this.$refs.infodialog_ref.getinfo();
        } else {
          this.picLoading = false;
          this.$message({
            duration: 1500,
            showClose: true,
            message: "装置下线，发送指令失败",
            type: "error",
          });
        }
      });
    },
  },
};
</script>
