<!--
  @description: 证书列表
  @Modifier: ht
  @date: 2021-01-19-10:57
-->
<template>
    <div>
        <!--标题-->
        <div class="title title_border p0-16">
            <i class="el-icon-s-home" />
            证书列表
        </div>
        <section class="p0-16">
            <!--查询条件-->
            <div class="crud_menu_title clearfix">
                <span class="icon-line fl">查询条件</span>
            </div>
            <div class="clearfix SearchContent">
                <div class="SearchContent_leftInput fl">
                    <el-form
                            ref="searchForm"
                            :model="searchForm"
                            inline
                            label-position="right"
                    >
                        <el-form-item ref="certificateName" prop="certificateName" label="证书名称">
                            <el-input v-model.trim="searchForm.certificateName" placeholder="证书名称" width="228px" />
                        </el-form-item>
                        <el-form-item ref="articleType" label="证书类型" prop="articleType">
                            <el-select v-model="searchForm.articleType" placeholder="请选择" style="width: 200px">
                                <el-option
                                        v-for="item in chapterTypeList"
                                        :key="item.typecode"
                                        :label="item.typename"
                                        :value="item.typecode"
                                />
                            </el-select>
                        </el-form-item>
                        <el-form-item ref="projectName" label="获奖工程名称" prop="projectName">
                            <el-input v-model.trim="searchForm.projectName" placeholder="获奖工程名称" width="228px" />
                        </el-form-item>
                        <el-form-item ref="awardLevel" label="获奖等级" prop="awardLevel">
                            <el-input v-model.trim="searchForm.awardLevel" placeholder="获奖等级" width="228px" />
                        </el-form-item>
                    </el-form>
                </div>
                <div class="fr">
                    <el-button type="primary" @click="onSearch">
                        搜 索
                    </el-button>
                    <el-button plain type="info" @click="resetForm('searchForm')">
                        重 置
                    </el-button>
                </div>
            </div>
            <!--查询结果-->
            <div class="crud_menu_title">
                <span class="icon-line">查询结果</span>
            </div>
            <div>
                <el-table
                        ref="smallTable"
                        v-loading="loading"
                        :data="tableData"
                >
                    <el-table-column
                            type="index"
                            label="序号"
                            width="60px"
                            align="center"
                    />
                    <el-table-column
                            prop="certificateName"
                            align="center"
                            label="证书名称"
                            width="140"
                    />
                    <el-table-column
                            header-align="center"
                            prop="awardProjectName"
                            label="获奖项目"
                            min-width="230"
                    />
                    <el-table-column
                            header-align="center"
                            label="证书类型"
                            prop="articleName"
                            align="left"
                            min-width="200"
                    />
                    <el-table-column
                            header-align="center"
                            label="获奖等级"
                            prop="awardLevel"
                            align="center"
                            width="100"
                    >
                    </el-table-column>
                    <el-table-column
                            header-align="center"
                            label="操作"
                            width="120"
                    >
                        <template slot-scope="scope">
                            <el-link
                                    type="primary"
                                    @click="examineBulletin(scope.row)"
                            >
                                [查看]
                            </el-link>
                        </template>
                    </el-table-column>
                </el-table>
                <!--分页组件-->
                <pagination :pagination-data="paginationData" @change="loadData" />
            </div>
        </section>
        <div class="but_footer">
            <div class="but_footer-h" />
            <div class="but_footer-but">
                <el-button @click="back()">
                    返 回
                </el-button>
            </div>
        </div>
    </div>
</template>

<script>
/* 接口*/
import { certificateAllList } from '@/api/bidding/bidderRepresentative'// 公告列表
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import achievemenyInfo from './achievement-info'
export default {
  name: 'CertificateAllList',
  components: {
    pagination, // 分页
    achievemenyInfo
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: false,
      // 搜索
      searchForm: {
        certificateName: '', // 证书名称
        projectName: '', // 获奖工程名称
        articleType: '', // 证书类型
        articleName: '', // 证书类型名称
        awardLevel: '', // 获奖等级
        companName: this.$route.query.companName, // 所属公司名称
        companId: this.$route.query.companId // 所属公司id
      },
      tableData: [],
      chapterTypeList: [{
        typecode: 'EQ_Qualification_ZLTX',
        typename: '质量体系认证证书' },
      {
        typecode: 'EQ_Qualification_HBTX',
        typename: '环境管理体系认证证书' },
      {
        typecode: 'EQ_Qualification_SJ_GCJX',
        typename: '所建工程省部级奖励' },
      {
        typecode: 'EQ_Qualification_ZYJK',
        typename: '职业健康安全管理提醒证书' },
      {
        typecode: 'EQ_Qualification_GJ_GCJX',
        typename: '所建工程国家级奖励' },
      {
        typecode: 'EQ_Qualification_GJ_JX',
        typename: '国家级奖项' },
      {
        typecode: 'EQ_Qualification_ZXDJ',
        typename: '资信等级' },
      {
        typecode: 'EQ_Qualification_SCXK',
        typename: '安全生产许可证' },
      {
        typecode: 'EQ_Qualification',
        typename: '其他资质证书名称' },
      {
        typecode: 'EQ_Qualification_SJ_JX',
        typename: '省部级奖励' }
      ]
    }
  },
  watch: {
    $route() {
      this.resetForm('searchForm')
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      this.loading = true
      const params = this.getQueryParams()// 查询条件
      certificateAllList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        this.$forceUpdate()
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看公告
    examineBulletin(row) {
      this.$router.push({
        path: '/bidderRepresentative/certificateInfo',
        query: {
          id: row.id
        }
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.$refs[formName].resetFields()
      this.onSearch()
    },
    back() {
      this.$router.push({
        path: '/bidderRepresentative/bidderList'
      })
    }
  }
}
</script>

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