<!--
  @description: 招标文件
  @Modifier: ht
  @routerPath: /bidding/backOfProject
  @date: 2021/07/07
-->
<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="tenderNo" label="招标项目编号" prop="tenderNo">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="招标项目编号"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
        <el-input
          v-model.trim="searchForm.tenderName"
          style="width:220px"
          placeholder="招标项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="title" label="文件名称" prop="title">
        <el-input
          v-model.trim="searchForm.title"
          style="width:220px"
          placeholder="文件名称"
          @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
          prop="tenderNo"
          header-align="center"
          label="招标项目编号"
          min-width="100"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="180"
        />
        <el-table-column
          header-align="center"
          prop="packNos"
          label="标段（包）编号"
        />
        <el-table-column
          label="招标文件"
          filter-placement="top-end"
          enterable
          header-align="center"
          prop="title"
        />
        <el-table-column
          align="center"
          label="操作"
          min-width="40"
        >
          <template slot-scope="scope">
            <el-link
                    :underline="false"
                    type="primary"
                    @click="backBulletin(scope.row)"
            >
              [确认回退]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { backOfTenderDocList, backOfTenderDoc } from '@/api/bidding/biddingProject'// 项目列表 公告回退

export default {
  name: 'TenderProjectList',
  data() {
    return {
      loading: true,
      // 搜索
      createTime: [], // 创建时间 不传给后端只做回显
      searchForm: {
        auditStatus: '', // 审核状态 00:待审核 01:审核通过 02:审核不通过
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        qualificationMethod: '', // 00资格预审,01 资格后审
        tenderMethod: '', // 招标方式 : 公开招标 00 邀请招标 01 竞争性谈判 02 询价 03 单一来源采购 04 其他 05
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        title: '' // 文件名称
      },
      tableData: []
    }
  },
  created() {
  },
  methods: {
    // 创建时间选择
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 获取数据
    loadData(params, callback) {
      this.loading = true
      backOfTenderDocList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 回退方法
    backBulletin(row) {
      const params = {
        'id': row.procfileId
      }
      this.$confirm('确认该标段（包）的操作，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.loading = true
        // 招标文件回退
        backOfTenderDoc(params).then(response => {
          this.$message({
            message: '招标文件回退成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
