<!--
  @description: 履约记录管理-（投标人履约、招标人履约、代理机构履约）
  @Modifier: 张慢慢
  @routerPath: /testAndCertify/bidHonourList
  @routerPath: /testAndCertify/theTenderHonourList
  @routerPath: /testAndCertify/agencyHonourList
  @date: 2021/05/22
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="100px"
    :menu="true"
    @on-load="loadData"
  >
    <template v-slot:header>
      {{ $route.meta.name }}
    </template>
    <template v-slot:search="search">
      <el-form-item label="合同名称">
        <el-input
          v-model.trim="searchForm.contractName"
          placeholder="合同名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="项目编号">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="项目编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="项目名称">
        <el-input
          v-model.trim="searchForm.tenderName"
          placeholder="项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
    </template>
    <template v-slot:menuLeft>
      <el-button type="primary" plain @click="archivedBHAdd('')">
        添加履约记录
      </el-button>
    </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"
          label="合同名称"
          prop="contractName"
          align="left"
          min-width="200"
        />
        <el-table-column
          prop="tenderNo"
          label="项目编号"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="项目名称"
          min-width="110"
        />
        <el-table-column
          header-align="center"
          label="标段编号"
          prop="packNo"
          align="left"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="操作"
          width="160"
        >
          <template slot-scope="scope">
            <!-- v-if="scope.row.auditStatus==='01'" -->
            <el-link
              type="primary"
              @click.stop="updateData(scope.row)"
            >
              [修改]
            </el-link>
            <!-- v-if="scope.row.useStatus==='00'" -->
            <el-link
              type="primary"
              @click.stop="removeBidderHonour(scope.row,scope.$index)"
            >
              [删除]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { getAllBidderHonour, removeBidderHonour } from '@/api/bidding/bidCalibration'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 常用方法 */
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息
// 分页

export default {
  name: 'ProjectManagerTenderList',
  components: {
  },
  mixins: [ListMixin, initGroupMixin],
  data: function() {
    return {
      createTime: [],
      loading: true,
      // 停用参数
      initForm: {
        id: '',
        status: ''
      },
      // 删除参数
      initDetile: {
        id: '',
        deleteFlag: '1'
      },
      dateTime: [], // 最后登录时间
      dialogFormVisible: false, // 取消
      dialogFormMenuVisible: false,
      dialogTableVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑角色',
        create: '添加角色'
      },
      value: '',
      // 搜索
      searchForm: {
        id: '', // 主键id
        tenderName: '', // 招标项目名称
        tenderNo: '', // 招标编号
        packName: '', // 包件名称
        packNo: '', // 包件编号
        contractNo: '', // 合同编号
        contractName: '', // 合同名称
        bidName: '', // 中标人名称
        honourText: '', // 履约记录
        createDate: '' // 创建日期
      },
      tableData: [],
      multipleSelection: [],
      // 跳转添加页面
      routePathObj: {
        '1': 'BidHonourAdd', // 投标人
        '2': 'TheTenderHonourAdd', // 招标人
        '3': 'AgencyHonourAdd' // 代理机构
      }
    }
  },
  created() {

  },
  methods: {
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 添加奖惩目录
    archivedBHAdd(row) {
      this.$router.push({
        name: this.routePathObj[this.$route.meta.type],
        params: {
          id: row && row.id // 项目Id
        }
      })
    },
    // 修改奖惩目录
    updateData(row) {
      // 点击编辑确定（调接口）
      this.$router.push({
        name: this.routePathObj[this.$route.meta.type],
        params: {
          id: row.id // 项目Id
        }
      })
    },
    // 删除事件
    removeBidderHonour(row, index) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removeBidderHonour(row.id).then(() => {
          this.dialogFormVisible = false
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.$refs.tableCrud.onSearchChange()
        })
      }).catch(() => {
      })
    },
    // 获取数据
    loadData(params, callback) {
      getAllBidderHonour(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>
