<!--
  @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="registerNumber" prop="registerNumber" label="统一社会信用代码">
                            <el-input v-model.trim="searchForm.registerNumber" placeholder="统一社会信用代码" width="228px" />
                        </el-form-item>
                        <el-form-item ref="companyName" label="采购单位" prop="companyName">
                            <el-input v-model.trim="searchForm.companyName" placeholder="采购单位" width="228px" />
                        </el-form-item>
                        <el-form-item ref="companyType" label="类型" prop="companyType">
                            <el-input v-model.trim="searchForm.companyType" placeholder="类型" width="228px" />
                        </el-form-item>
                        <el-form-item ref="companyAddress" label="住所" prop="companyAddress">
                            <el-input v-model.trim="searchForm.companyAddress" 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="registerNumber"
                            align="center"
                            label="统一社会信用代码"
                            width="140"
                    />
                    <el-table-column
                            header-align="center"
                            prop="companyName"
                            label="采购单位"
                            min-width="230"
                    />
                    <el-table-column
                            header-align="center"
                            label="类型"
                            prop="companyType"
                            align="left"
                            min-width="200"
                    />
                    <el-table-column
                            header-align="companyName"
                            label="住所"
                            prop="companyAddress"
                            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 { businessLicenseAllList } 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: 'BusinessLicenseList',
  components: {
    pagination, // 分页
    achievemenyInfo
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: false,
      // 搜索
      searchForm: {
        registerNumber: '', // 公告类型 招标公告 01, 资审公告 21
        companyName: '', // 采购单位
        companyType: '', // 类型
        companyAddress: '', // 住所
        companName: this.$route.query.companName, // 所属公司名称
        companId: this.$route.query.companId // 所属公司id
      },
      tableData: []
    }
  },
  watch: {
    $route() {
      this.resetForm('searchForm')
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      this.loading = true
      const params = this.getQueryParams()// 查询条件
      businessLicenseAllList(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/businessLicenseInfo',
        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>
