<!--
  @description: 履约管理管理-添加履约文件-合同列表弹框
  @Modifier: 张慢慢
  @routerPath:
  @date: 2021-05-22
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialog"
    :close-on-click-modal="false"
    title="合同列表"
    width="840px"
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <!--搜索-->
    <div class="clearfix">
      <el-form ref="searchForm" :model="searchForm" inline>
        <el-form-item label="招标项目编号" prop="tenderNo">
          <el-input
            v-model.trim="searchForm.tenderNo"
            placeholder="招标项目编号"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="招标项目名称" prop="tenderName">
          <el-input
            v-model.trim="searchForm.tenderName"
            placeholder="招标项目名称"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <!-- <el-form-item label="包件编号'" prop="packNo">
          <el-input
            v-model.trim="searchForm.packNo"
            placeholder="包件编号"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="包件名称'" prop="packName">
          <el-input
            v-model.trim="searchForm.packName"
            placeholder="包件名称"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="合同编号'" prop="contractNo">
          <el-input
            v-model.trim="searchForm.contractNo"
            placeholder="合同编号"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="合同名称'" prop="contractName">
          <el-input
            v-model.trim="searchForm.contractName"
            placeholder="合同名称"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="中标人名称'" prop="bidName">
          <el-input
            v-model.trim="searchForm.bidName"
            placeholder="中标人名称"
            @keyup.enter.native="search"
          />
        </el-form-item>
        <el-form-item label="创建日期'" prop="createDate">
          <el-input
            v-model.trim="searchForm.createDate"
            placeholder="创建日期"
            @keyup.enter.native="search"
          />
        </el-form-item> -->
        <el-form-item class="fr">
          <el-button
            type="primary"
            @click="search('searchForm')"
          >
            搜索
          </el-button>
          <el-button
            plain
            type="info"
            @click="resetForm('searchForm')"
          >
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--查询列表-->
    <div>
      <el-table
        ref="singleTable"
        v-loading="loading"
        :data="list"
        class="pointer"
        size="mini"
        highlight-current-row
        @current-change="currentChange"
      >
        <el-table-column type="index" label="序号" align="center" width="80" />
        <el-table-column label="招标项目编号" prop="tenderNo" align="center" width="200" />
        <el-table-column label="招标项目名称" prop="tenderName" header-align="center" width="200" />
        <el-table-column label="包件编号" prop="packNo" header-align="center" width="200" />
        <el-table-column label="包件名称" prop="packName" header-align="center" width="150" />
        <el-table-column label="合同编号" prop="contractNo" header-align="center" width="200" />
        <el-table-column label="合同名称" prop="contractName" header-align="center" width="150" />
        <el-table-column label="中标人名称" prop="bidName" header-align="center" width="200" />
        <el-table-column label="创建日期" prop="createDate" header-align="center" width="200" />
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ensure">确 定</el-button>
      <el-button @click="dialog = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { getAllBidderHonour } from '@/api/bidding/bidCalibration'// 供应商信息选择
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 过滤空的key
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页/* 混入-字典信息 */
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'ConsignContractSelectDialog',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      /* 字典信息-end */
      dialog: false, // 弹框打开状态
      // 搜索信息
      searchForm: {
        id: '', // 主键Id
        tenderName: '', // 招标项目名称
        tenderNo: '', // 招标编号
        packName: '', // 包件名称
        packNo: '', // 包件编号
        contractNo: '', // 合同编号
        contractName: '', // 合同名称
        bidName: '', // 中标人名称
        honourText: '', // 履约记录
        createDate: '' // 创建日期
      },
      list: [], // 列表数据
      currentData: {}// 当前选择的信息
    }
  },
  // created() {
  //   // 获取字典方法
  //   this.initGroup()
  // },
  methods: {
    // filterDictText,
    // // 获取字典方法
    // initGroup() {
    //   const data = ['']
    //   this.$store.dispatch('getGroupType', data).then(res => {
    //     Object.keys(res.bidTypeData).forEach((key) => {
    //       this[key] = res.bidTypeData[key]
    //     })
    //   })
    // },
    // 打开弹窗
    open() {
      this.dialog = true
      // 弹框已打开
      // 加载数据
      this.searchForm.contractName = ''
      // this.searchForm.rewardPunishmentPersonName = ''
      // this.searchForm.rewardPunishmentAddress = ''
      // this.searchForm.rewardPunishmentDepartPhone = ''
      this.loadData()
    },
    // 当前选择的信息
    currentChange(val) {
      this.currentData = val
    },
    // 加载数据
    loadData() {
      const params = this.getParams()// 查询条件
      getAllBidderHonour(params).then(response => {
        this.loading = false
        this.list = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)// 过滤空的key
    },
    // 选择信息-确定
    ensure() {
      if (this.currentData) {
        const data = {
          code: this.currentData.contractName // 文档模版编号
          // Name: this.formData.rewardPunishmentPersonName,
          // Address: this.formData.rewardPunishmentPersonName,
          // Phone: this.formData.rewardPunishmentDepartPhone
        }
        this.$emit('call-back', data)
        this.dialog = false
      } else {
        this.$message({
          message: `请选择文档模版`,
          type: 'warning'
        })
      }
    },
    // 搜索重置
    resetForm(formName) {
      this.$refs[formName].resetFields()
      this.search()
    },
    // 搜索
    search() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    }
  }
}
</script>

<style scoped lang="less">

</style>
