<!--
  @description: 费用管理-履约保证金(列表与审批列表)
  @Modifier: 张慢慢
  @routerPath: /fee/performanceBondList
  @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.rewardPunishmentPersonName"
          placeholder="法人代表"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="项目名称">
        <el-input
          v-model.trim="searchForm.rewardPunishmentBiderName"
          placeholder="项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item
        label="审核状态"
        prop="rewardPunishmentStatus"
      >
        <el-select v-model="searchForm.rewardPunishmentStatus" placeholder="请选择" style="width: 220px">
          <!-- <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          /> -->
        </el-select>
      </el-form-item>

      <el-form-item
        label="审核时间"
      >
        <!--创建日期-->
        <el-date-picker
          v-model="createTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="createTimeChange"
        />
      </el-form-item>
    </template>
    <template v-if="$route.meta.type === 'list'" v-slot:menuLeft>
      <el-button type="primary" plain @click="archivedRPMAdd('')">
        上传凭证
      </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
          prop="rewardPunishmentBiderName"
          label="项目编号"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="项目名称"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="包段编号"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="包段名称"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="代理机构名称"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="履约金缴费金额"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="提交时间"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="审核状态"
          min-width="160"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="审核时间"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="操作"
          width="160"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="updateData(scope.row)"
            >
              [上传凭证]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { getRewardPunishmentList, removeRewardPunishment } from '@/api/bidding/bidCalibration'

/* 常用方法 */
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息
/* 组件*/
export default {
  name: 'ProjectManagerTenderList',
  components: {
  },
  mixins: [initGroupMixin],
  data: function() {
    return {
      createTime: [],
      loading: true,
      // 停用参数
      initForm: {
        id: '',
        status: ''
      },
      // 删除参数
      initDetile: {
        id: '',
        deleteFlag: '1'
      },
      dateTime: [], // 最后登录时间
      // 状态-字典信息
      options: [{
        value: '00',
        label: '奖励'
      }, {
        value: '01',
        label: '惩罚'
      }],
      dialogFormVisible: false, // 取消
      dialogFormMenuVisible: false,
      dialogTableVisible: false,
      dialogStatus: '',
      value: '',
      // 搜索
      searchForm: {
        id: '', // 主键id
        rewardPunishmentStatus: '', // 奖惩类型状态
        rewardPunishmentCodeType: '', // 中标人代码类型
        rewardPunishmentBiderName: '', // 中标人名称
        rewardPunishmentPersonName: '', // 法人代表
        rewardPunishmentCode: '', // 中标人代码
        rewardPunishmentAddress: '', // 中标人联系地址
        rewardPunishmentDepartPhone: '', // 机构联系电话
        rewardPunishmentInstruction: '', // 奖惩说明
        rewardPunishmentDate: '' // 最后登录时间结束
      },
      tableData: [],
      multipleSelection: []
    }
  },
  created() {

  },
  methods: {
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 上传代理服务费凭证
    archivedRPMAdd(row) {
      this.$router.push({
        name: 'PerformanceBondAdd',
        params: {
          id: row && row.id // 项目Id
        }
      })
    },
    // 删除事件
    removeRewardPunishment(row, index) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removeRewardPunishment(row.id).then(() => {
          this.dialogFormVisible = false
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.$refs.tableCrud.onSearchChange()
        })
      }).catch(() => {
      })
    },
    // 获取数据
    loadData(params, callback) {
      getRewardPunishmentList(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>
