<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--机构数据-->
      <el-col :span="20" :xs="24">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">


      <el-form-item label="预警标题" prop="taskName">
        <el-input
          v-model="queryParams.alarmTitle"
          placeholder="请输入预警标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="预警时间" prop="planStartTime">
        <el-date-picker
          v-model="queryParams.alarmDates"
          style="width: 240px"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="预警区域" prop="roleId">
        <el-select v-model="queryParams.code" placeholder="请选择">
          <el-option v-for="item in areaList" :key="item.key" :label="item.value" :value="item.key"></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-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="weatherList">

      <el-table-column label="预警标题" align="center" prop="alarmTitle" />
      <el-table-column label="预警城市" align="center" prop="city" />
      <el-table-column label="预警区域" align="center" prop="area"/>
      <el-table-column label="预警等级" align="center"  prop="alarmLevel"></el-table-column>
      <el-table-column label="预警类型" align="center"  prop="alarmType"></el-table-column>
      <el-table-column label="预警内容" align="center"  prop="alarmContent"></el-table-column>
      <el-table-column label="预警发布时间" align="center"  prop="alarmTime">
        <template slot-scope="r">{{ $moment(r.row.alarmTime).format(
          "YYYY-MM-DD HH:mm:ss"
        ) }}</template>
      </el-table-column>
    </el-table>

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

<script>
import { findWeatherList,findAreaList} from "@/api/core/weather";

export default {
  components: {},
  name: "Weather",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 监控调阅任务表格数据
      weatherList: [],
      areaList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        alarmTitle: null,
        alarmDates:[],
        code:null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
    };
  },
  created() {
    this.getList();
    this.getAreaList();
  },
  methods: {
    /** 查询监控调阅任务列表 */
    getList() {
      this.loading = true;
      findWeatherList(this.queryParams).then(response => {
        this.weatherList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getAreaList() {
      findAreaList({}).then(response => {
        this.areaList = response.data;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.alarmDates = [];
      this.handleQuery();
    },

  }
};
</script>
