<template>
  <el-dialog
    title="选择设备"
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    class="deviceBoxDialog"
    width="326px"
  >
    <div class="device">
      <el-form :model="sblxform">
        <el-form-item label="设备类型">
          <el-select v-model="sblxform.sblxId" placeholder="请选择设备类型">
            <el-option
              v-for="item in sblxOptions"
              :key="item.id"
              :label="item.mc"
              :value="item.id"
            >
              {{ item.mc }}
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确定导出</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { modevtypeListAllApi } from "@/utils/api/index";

export default {
  name: "deviceBoxDialog",
  components: {},
  data() {
    return {
      sblxform: {
        sblxId: "",
      },
      dialogVisible: false,
      sblxOptions: [],
      startTime: "",
      endTime: "",
      page: 1, // 当前页数
      pageSize: 20, // 每页数量
      total: 0, //总条数
    };
  },
  created() {},
  watch: {},
  mounted() {},
  methods: {
    getdeviceList() {
      modevtypeListAllApi()
        .then((res) => {
          console.log(res);
          this.sblxOptions = res.data;
        })
        .catch((err) => {
          console.log(err); //代码错误、请求失败捕获
        });
    },

    onSubmit() {
      console.log(this.sblxform);
      console.log(this.startTime, this.endTime);
      window.location.href =
        "/cac-api/nsensor/export?typeId=" +
        this.sblxform.sblxId +
        "&startTime=" +
        this.startTime +
        "&endTime=" +
        this.endTime;
      this.dialogVisible = false;
    },

    display(stime, etime) {
      this.startTime = stime;
      this.endTime = etime;
      this.dialogVisible = true;
      this.getdeviceList();
    },
    handleClose() {
      this.dialogVisible = false;
      this.sblxform.sblxId = "";
    },
  },
};
</script>

<style lang="less">
.deviceBoxDialog {
}
</style>
