 <!--
  @description: 变更公告发布列表
  @Modifier: haoFx
  @routerPath:/bidding/changeBulletinPublishList
  @date: 2020/3/12-15:37
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      变更公告发布列表
    </template>
    <template v-slot:search="search">
      <el-form-item ref="title" label="变更公告" prop="title">
        <el-input v-model.trim="searchForm.title" placeholder="变更公告" width="228px" @keyup.enter.native="search.onSearch" />
      </el-form-item>
      <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
        <el-input v-model.trim="searchForm.tenderName" placeholder="招标项目名称" width="228px" @keyup.enter.native="search.onSearch" />
      </el-form-item>
    </template>
    <template v-slot:GXTable>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="title"
          label="变更公告"
          min-width="230"
        />
        <el-table-column
          prop="bulletinPublishTime"
          align="center"
          label="发布时间"
          width="140"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          label="包编号"
          prop="packNo"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="状态"
          prop="auditStatus"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.publishStatus==='00'" class="status2">未发布</span>
            <span v-if="scope.row.publishStatus==='01'" class="status1">已发布</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          width="90"
        >
          <template slot-scope="scope">
            <el-link
              v-if="scope.row.publishStatus=== null || scope.row.publishStatus==='00'"
              type="primary"
              @click="sendBulletin(scope.row)"
            >
              [发布]
            </el-link>
            <el-link
              v-if="scope.row.publishStatus==='01'"
              type="primary"
              @click="examineBulletin(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>

<script>
/* 接口*/
import { releaseChangeBulletinList } from '@/api/bidding/changeBulletin'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'BulletinAllList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        tenderName: '', // 项目名称
        title: '' // 公告标题
      },
      tableData: []
    }
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      releaseChangeBulletinList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 发布公告
    sendBulletin(row) {
      this.$router.push({
        path: '/bidding/publishChangeBulletin',
        query: {
          changeBulletinId: row.changeBulletinId
        }
      })
    },
    // 查看结果公示
    examineBulletin(row) {
      this.$router.push({
        path: '/bidding/changeBulletinPdfDetail',
        query: {
          changeBulletinId: row.changeBulletinId
        }
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    }
  }
}
</script>

<style lang="less" scoped>

</style>
