<template>
  <el-dialog title="通知结果" :visible.sync="open" width="850px" append-to-body destroy-on-close :close-on-click-modal="false">

    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="通知人" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入通知人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </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="recordList">
      <el-table-column label="通知人" align="center" prop="userName" />
      <el-table-column label="电话" align="center" prop="phone" />
      <el-table-column label="通知类型" align="center" prop="recordType">
        <template slot-scope="scope">
          <span v-if="scope.row.recordType == '0'">短信</span>
          <span v-else-if="scope.row.recordType == '1'">语音</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="通知结果" align="center" prop="notifyResult">
        <template slot-scope="scope">
          <span v-if="scope.row.notifyResult == '0'">成功</span>
          <span v-else-if="scope.row.notifyResult == '1'">失败</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="通知时间" align="center" prop="createTime" />
      <!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>-->
    </el-table>

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

<script>
  import { listRecord } from "@/api/emergency/notifyRecord";
  export default {
    name: "notify-list",
    data(){
        return{
          // 查询参数
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            alarmId: null,
            userName: null
          },
          total: 0,
          loading: false,
          recordList: [],
          open: false
        }
    },
    methods:{
      getNotifyList(id){
        this.queryParams.alarmId = id;
        this.getList();
        this.open = true;
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      getList(){
        this.loading = true;
        listRecord(this.queryParams).then(res => {
          this.recordList = res.rows;
          this.total = res.total;
          this.loading = false;
        });
      }
    }
  }
</script>

<style scoped>

</style>
