<template>
  <div class="home-content">
    <el-form :model="query" ref="queryForm" size="large" :inline="true" label-width="68px" style="margin-bottom: 20px">
      <el-form-item label="公告标题" prop="uTitle" label-width="100px">
        <el-input v-model.trim="query.uTitle" size="mini" placeholder="请输入公告标题" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="公告类型" prop="fjType" label-width="100px">
        <el-select v-model="query.fjType" size="mini" placeholder="请选择" clearable>
          <el-option v-for="dict in dict.type.jc_publicity_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" style="margin-left: 30px">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!--招标公示-->
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column type="index" label="序号" align="center">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column property="uTitle" label="公告标题">
        <template slot-scope="scope">
          <router-link :to="{ path: '/bidnoticedetail', query: { uid: scope.row.uid } }" style="color: #409EFF;">
            {{ scope.row.uTitle }}
          </router-link>
        </template>
      </el-table-column>
      <el-table-column property="uTitle" label="公告类型" :width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jc_publicity_type" :value="scope.row.fjType" />
        </template>
      </el-table-column>
      <el-table-column align="center" prop="uUpdateTime" label="发布时间" :width="180" sortable />
    </el-table>
    <pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList"
      style="text-align: right" />
  </div>
</template>

<script>
import Pagination from "@/components/Pagination/index.vue";
import { selectPurchase } from "@/api/home";
export default {
  dicts: ['jc_publicity_type'],
  components: {
    Pagination
  },
  data () {
    return {
      query: {
        pageNum: 1,
        pageSize: 10,
        uTitle: null,
        fjType: null,
      },
      total: 0,
      tableData: []
    }
  },
  created () {
    this.getList()
  },
  methods: {
    getList () {
      selectPurchase(this.query).then(res => {
        this.tableData = res.rows
        this.total = res.total
      })
    },
    handleQuery () {
      this.query.pageNum = 1
      this.getList()
    },
    resetQuery () {
      this.query.uTitle = null
      this.query.fjType = null
      this.handleQuery()
    }
  }

}
</script>

<style lang="scss" scoped></style>
