<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="时间:" label-width="50px">
        <el-date-picker style="vertical-align: middle;width:340px"
          v-model="dateRange"
          size="small"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="完成状态：">
        <el-select v-model.trim="queryParams.isComplete"  size="small" style="width:160px" placeholder="请选择完成状态">
          <el-option value="false" label="未完成"></el-option>
          <el-option value="true" label="已完成"></el-option>
        </el-select>
      </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-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:admin:export']"
        >导出</el-button> -->
      </el-form-item>
    </el-form>
    <el-row :gutter="20" v-loading="loading2">
      <el-col :span="2.4">
        <el-col class="event">
            维保人员数量<span class="color1 colorc">{{collectList.userCount}}</span>
        </el-col>
      </el-col>
      <el-col :span="2.4">
        <el-col class="event">
            今日任务<span class="color2 colorc">{{collectList.todayCount}}</span>
        </el-col>
      </el-col>
      <el-col :span="2.4" >
        <el-col class="event">
            超时任务<span class="color3 colorc">{{collectList.todayTimeOutCount}}</span>
        </el-col>
      </el-col>
      <el-col :span="2.4">
        <el-col class="event">
            今日完成任务
            <span class="color4 colorc">{{collectList.todayCompleteCount}}</span>
        </el-col>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="adminList" style="margin-top:20px;" height="calc(100vh - 34vh)">
      <el-table-column label="任务名称" align="center" prop="planName" show-overflow-tooltip />
      <el-table-column label="维保点位" align="center" prop="pointName" show-overflow-tooltip />
      <el-table-column label="应完成时间" align="center" prop="ywcTime" show-overflow-tooltip />
      <!-- <el-table-column label="当前状态" align="center" prop="property" show-overflow-tooltip >
        <template slot-scope="scope">
          <span :class="scope.row.alarmStatus == 0 ? 'color3' : 'color4'">{{scope.row.alarmStatus == 0 ? "未处理" : "已处理"}}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="完成情况" align="center" prop="isComplete" show-overflow-tooltip >
        <template slot-scope="scope">
          <span :class="scope.row.isComplete == false ? 'color3' : 'color4'">{{scope.row.isComplete == false ? "未完成" : "已完成"}}</span>
        </template>
      </el-table-column> 
      <el-table-column label="相关责任人" align="center" prop="dutyName" show-overflow-tooltip />
      <el-table-column label="联系电话" align="center" prop="dutyPhone" show-overflow-tooltip />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
    <!-- 导出-->
    <a href="" download="" id="xz" style="position: absolute;z-index: -1;opacity: 0;"></a>
  </div>
</template>
<script>
import { getMaintianLog, exportMaintianLog,getCollect } from "@/api/business/OM/MochaITOM/record";
import { BASEPATH } from "@/assets/js/common.js";
export default {
  name: "TbAlarm",
  data() {
    return {
      piliang:false,
      exportLoading:false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 参数表格数据
      adminList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
        name: undefined,
        startTime:undefined,
        endTime:undefined,
        isComplete:undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {

      },
      // 日期范围
      dateRange: [],
      //综合数据
      collectList:[

      ],
      loading2:true,
    };
  },
  created() {
    this.getList();//初始化table
    // this.getCollect();//初始化table
  },
  methods: {
    //强制el-input刷新
    onInput(){
        this.$forceUpdate();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.queryParams = {
        name:undefined,
        current:1,
        size:10,
        type:1
      }
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 查询参数列表 */
    getList() {
      this.loading = true;
      if(this.dateRange.length>0){
        this.queryParams.startTime = this.dateRange[0]
        this.queryParams.endTime = this.dateRange[1]
      }
      getMaintianLog(this.queryParams).then(response => {
        this.adminList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
      /** 综合列表列表 */
      getCollect(this.queryParams).then(response => {
        this.collectList = response.data
        this.loading2 = false
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      exportMaintianLog(this.queryParams).then(response =>{
        this.exportLoading = false;
        document.getElementById("xz").href = BASEPATH() + response.data
        document.getElementById("xz").download = response.data
        document.getElementById("xz").click()
      })
    },
  }
};
</script>

