<!--
  @description: 奖惩记录管理-奖惩管理列表（投标人奖惩、招标人奖惩、代理机构奖惩、专家奖惩）
  @Modifier: 张慢慢
  @routerPath: /testAndCertify/bidRewardPunishmentList
  @routerPath: /testAndCertify/theTenderRewardPunishmentList
  @routerPath: /testAndCertify/agencyRewardPunishmentList
  @routerPath: /testAndCertify/expertsRewardPunishmentList
  @date: 2019/12/05
-->
<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="奖惩状态"
        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-input
          v-model.trim="searchForm.rewardPunishmentBiderName"
          placeholder="中标人名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--法人代表-->
      <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-date-picker
          v-model="createTime"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="createTimeChange"
        />
      </el-form-item>
    </template>
    <template 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
          label="状态"
          prop="rewardPunishmentStatus"
          align="center"
          width="80"
        >
          <template slot-scope="scope">
            <p v-if="scope.row.rewardPunishmentStatus === '00'">
              奖励
            </p>
            <p v-if="scope.row.rewardPunishmentStatus === '01'">
              惩罚
            </p>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="中标人代码类型"
          prop="rewardPunishmentCodeType"
          align="left"
          min-width="200"
        />
        <el-table-column
          prop="rewardPunishmentBiderName"
          label="中标人名称"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="rewardPunishmentPersonName"
          label="法人代表"
          min-width="110"
        />
        <el-table-column
          header-align="center"
          label="中标人代码"
          prop="rewardPunishmentCode"
          align="left"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="联系地址"
          prop="rewardPunishmentAddress"
          align="left"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          prop="rewardPunishmentDepartPhone"
          label="机构联系电话"
          width="120"
          align="center"
        />
        <el-table-column
          header-align="center"
          label="奖惩说明"
          prop="rewardPunishmentInstruction"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="最后修改时间"
          prop="rewardPunishmentDate"
          align="center"
          width="130"
        >
          <template slot-scope="scope">
            <span>
              {{ scope.row.rewardPunishmentDate && $Moment(scope.row.rewardPunishmentDate) }}
            </span>
          </template>
        </el-table-column>
        <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="removeRewardPunishment(scope.row,scope.$index)"
            >
              [删除]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { getRewardPunishmentList, removeRewardPunishment } from '@/api/bidding/bidCalibration'

/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 常用方法 */
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'
// 分页

export default {
  name: 'ProjectManagerTenderList',
  components: {
    pagination // 分页
  },
  mixins: [ListMixin, 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: [],
      // 跳转添加页面
      routePathObj: {
        '1': 'BidRewardPunishmentAdd', // 投标人
        '2': 'TheTenderRewardPunishmenAdd', // 招标人
        '3': 'AgencyRewardPunishmentAdd', // 代理机构
        '4': 'ExpertsRewardPunishmentAdd' // 专家
      }
    }
  },
  created() {

  },
  methods: {
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 添加奖惩目录
    archivedRPMAdd(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
        }
      })
    },
    // 删除事件
    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>
