<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="cageSection">
      <el-select v-model="queryParams.cageSection" 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="dataList">
      <el-table-column label="提升机名称" align="center" prop="cageSection" />
      <el-table-column label="电渠电流" align="center" prop="powerChannelCurrent" />
      <el-table-column label="闸压力" align="center" prop="gatePressure" />
      <el-table-column label="电极电流" align="center" prop="electrodeCurrent" />
      <el-table-column label="电机轴承温度" align="center" prop="motorBearingTemperature" />
      <el-table-column label="水泵轴承温度" align="center" prop="pumpBearingTemperature" />
      <el-table-column label="水泵流量" align="center" prop="pumpFlow" />
      <el-table-column label="排水管路压力" align="center" prop="drainagePipePressure" />
      <el-table-column label="监测时间" align="center" prop="monitoringTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.monitoringTime) }}</span>
        </template>
      </el-table-column>
     
    </el-table>

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

   
  </div>
</template>

<script>
  import { listHoistHisData, listHoistSelectData} from "@/api/tyler/hoistSys";

  export default {
  name: "Data",
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 提升机历史数据表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cageSection: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        cageSection: [
          { required: true, message: "罐笼所在中段不能为空", trigger: "blur" }
        ],
       
      },
      deviceName:[],
      dateRange:[],
    };
  },
  created() {
    listHoistSelectData().then(res => {
      this.deviceName = res.data;
    })
    this.getList();
  },
  methods: {
    /** 查询提升机历史数据列表 */
    getList() {
      this.loading = true;
      listHoistHisData(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        cageSection: null,
        powerChannelCurrent: null,
        gatePressure: null,
        electrodeCurrent: null,
        motorBearingTemperature: null,
        pumpBearingTemperature: null,
        pumpFlow: null,
        drainagePipePressure: null,
        monitoringTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
   
};
</script>
