<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" size="small" label-width="100px">
      <el-form-item label="内容关键字">
        <el-input v-model="queryParams.noticeContent" clearable style="width: 200px;" placeholder="请输入内容关键字"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">搜索</el-button>
        <el-button @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <h3 class="toolbar">
      <span class="title">列表</span>
    </h3>
    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="通知类型" prop="noticeType" width="120" align="center" />
      <el-table-column label="内容" prop="noticeContent" align="center"></el-table-column>
      <el-table-column label="状态" prop="status" align="center" width="120" />
      <el-table-column label="发送时间" align="center" prop="createTime" width="160"></el-table-column>
      <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="text" @click="handleView(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"/>
  </div>
</template>

<script>
  import {listMsgApi} from "@/api/admin/msg/msg"
  import {entStateOptions, getLabel, authStateOptions} from '@/utils/dataFormat'
  export default {
    data () {
      return {
        loading: false,
        addTaxVisible: false,
        type: '',
        provinceDataList: [],
        cityDataList: [],
        districtDataList: [],
        entStateOptions: entStateOptions,
        authStateOptions: authStateOptions,
        // 模板状态
        // statusOptions: accessStatus,
        dateRange: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          noticeContent: ''
        },
        list: [],
        total: 0,
        open: false,
        openInfo: false,
      }
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        this.loading = true;
        listMsgApi(this.queryParams).then(response => {
          this.list = response.data.records;
          this.total = response.data.total;
          this.loading = false;
        });
      },
      handleView(row) {
        this.$router.push("message/info/"+row.noticeId)
      },
      // 重置
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 搜索
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      statusFormat(row, col, val, index) {
        return getLabel(accessStatus, val)
      },
      entSateFormat(row, col, val, index) {
        return getLabel(entStateOptions, val)
      },
      authStateFormat(row, col, val, index) {
        return getLabel(authStateOptions, val)
      }
    }
  }
</script>

<style>
</style>
