<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--机构数据-->
      <el-col :span="24" :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="请选择"   clearable>
          <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" width="140" prop="city" />
      <el-table-column label="预警区域" align="center" width="100" prop="area"/>
      <el-table-column label="预警等级" align="center" width="100" prop="alarmLevel"></el-table-column>
      <el-table-column label="预警类型" align="center" width="100" prop="alarmType"></el-table-column>
      <el-table-column label="预警内容" align="center"   prop="alarmContent">
        <template slot-scope="r"><p :title="r.row.alarmContent" class="line-style">{{r.row.alarmContent}}</p></template>
      </el-table-column>
      <el-table-column label="预警发布时间" align="center"   prop="alarmTime">
      </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;
        console.log(this.weatherList);
        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.queryParams.code = null;
      this.handleQuery();
    },

  }
};
</script>
<style lang="scss" scoped>
.line-style{
  display : -webkit-box;
  -webkit-line-clamp: 3 ; //限定显示行数
  -webkit-box-orient: vertical;
  overflow : hidden ;
  text-overflow: ellipsis;
}
</style>
