<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
    
      <el-form-item label="" prop="deviceName">
        <el-select v-model="queryParams.deviceName" placeholder="风机名称" clearable>
          <el-option
            v-for="dict in deviceName"
            :key="dict.value"
            :label="dict.name"
            :value="dict.name"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="风机名称" align="center" prop="deviceName" width="120"/>
      <el-table-column label="风机编号" align="center" prop="deviceId" width="120"/>
      <el-table-column label="监测时间" align="center" prop="time" width="160" />
      <el-table-column label="电源电压预警值(V)" align="center" prop="powerSupplyVoltage" width="140" />
      <el-table-column label="电机电流预警值(A)" align="center" prop="motorCurrent" width="140" />
      <el-table-column label="运行频率预警值(HZ)" align="center" prop="operatingFrequency" width="140" />
      <el-table-column label="设定频率预警值(HZ)" align="center" prop="setFrequency" width="140" />
      <el-table-column label="风压预警值(Kpa)" align="center" prop="windPressure" width="120" />
      <el-table-column label="风速预警值(m/s)" align="center" prop="windSpeed" width="120" />
      <el-table-column label="风量预警值(m³/s)" align="center" prop="airVolume" width="140" />
      <el-table-column label="前轴温预警值(℃)" align="center" prop="frontAxisTemperature" width="120" />
      <el-table-column label="后轴温预警值(℃)" align="center" prop="rearAxisTemperature" width="120" />
      <el-table-column label="电机温度预警值(℃)" align="center" prop="motorTemperature" width="140" />
      <el-table-column label="前振动预警值(mm/s)" align="center" prop="frontVibration" width="150" />
      <el-table-column label="后振动预警值(mm/s)" align="center" prop="rearVibration"  width="150"/>
     
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    
  </div>
</template>

<script>
  import { listrealFan } from "@/api/tyler/fan";
  import { fanDeviceName } from "@/api/tyler/common";

  export default {
  name: "Info",
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 风机基本信息表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deviceName: null,
        deviceId: null,
    
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "id不能为空", trigger: "blur" }
        ],
        deviceName: [
          { required: true, message: "风机名称不能为空", trigger: "blur" }
        ],
        deviceId: [
          { required: true, message: "风机编号不能为空", trigger: "blur" }
        ],
      },
      deviceName:[],
      dateRange:[],
    };
  },
  created() {
    fanDeviceName().then(res=>{
      this.deviceName = res.data;
    })
    this.getList();
  },
  methods: {
    /** 查询风机基本信息列表 */
    getList() {
      this.loading = true;
      listrealFan(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        deviceName: null,
        deviceId: null,
        installationLocation: null,
        powerSupplyVoltage: null,
        motorCurrent: null,
        operatingFrequency: null,
        setFrequency: null,
        windPressure: null,
        windSpeed: null,
        airVolume: null,
        frontAxisTemperature: null,
        rearAxisTemperature: null,
        motorTemperature: null,
        frontVibration: null,
        rearVibration: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm("queryForm");
      this.handleQuery();
    },
 
    
  
  }
};
</script>
