<!--
  @description: 绩效记录管理-绩效管理列表（投标人绩效、招标人绩效、代理机构绩效、专家绩效）
  @Modifier: 张慢慢
  @routerPath: /testAndCertify/bidPerformanceList
  @routerPath: /testAndCertify/theTenderPerformanceList
  @routerPath: /testAndCertify/agencyPerformanceList
  @routerPath: /testAndCertify/expertsPerformanceList
  @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="招标项目名称">
        <el-input
          v-model.trim="searchForm.tenderName"
          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.packName"
          placeholder="包件名"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="包件编号">
        <el-input
          v-model.trim="searchForm.packNo"
          placeholder="包件编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="招标人名称">
        <el-input
          v-model.trim="searchForm.tenderPersonName"
          placeholder="招标人名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="代理机构名称">
        <el-input
          v-model.trim="searchForm.agencyName"
          placeholder="代理机构名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="中标人名称">
        <el-input
          v-model.trim="searchForm.bidName"
          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="archivedPMAdd('')">
        添加绩效记录
      </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="tenderName"
          align="left"
          min-width="200"
        />
        <el-table-column
          prop="tenderNo"
          label="招标项目编号"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          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="招标人名称"
          prop="tenderPersonName"
          align="left"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="招标代理机构名称"
          prop="agencyName"
          align="left"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="中标人名称"
          prop="bidName"
          align="left"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="bidDepartPhone"
          label="机构联系电话"
          width="120"
          align="center"
        />
        <el-table-column
          label="中标日期时间"
          prop="rewardPunishmentDate"
          align="center"
          width="130"
        >
          <template slot-scope="scope">
            <span>
              {{ scope.row.bidDate && $Moment(scope.row.bidDate) }}
            </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="removePerformanceManagement(scope.row,scope.$index)"
            >
              [删除]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { getAllPerformanceManagement, removePerformanceManagement } 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: [], // 最后登录时间
      dialogFormVisible: false, // 取消
      dialogFormMenuVisible: false,
      dialogTableVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑角色',
        create: '添加角色'
      },
      value: '',
      // 搜索
      searchForm: {
        tenderName: '', // 招标项目名称
        tenderNo: '', // 招标项目编号
        packName: '', // 包件名称
        packNo: '', // 包件编号
        tenderPersonName: '', // 招标人名称
        agencyName: '', // 招标代理机构名称
        bidName: '', // 中标人名称
        bidDepartPhone: '', // 机构联系电话
        bidDate: '', // 中标日期
        bidPrice: '' // 中标价格
      },
      tableData: [],
      multipleSelection: [],
      // 跳转添加页面
      routePathObj: {
        '1': 'BidPerformanceAdd', // 投标人
        '2': 'TheTenderPerformanceAdd', // 招标人
        '3': 'AgencyPerformanceAdd', // 代理机构
        '4': 'ExpertsPerformanceAdd' // 专家
      }
    }
  },
  created() {

  },
  methods: {
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 添加奖惩目录
    archivedPMAdd(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
        }
      })
    },
    // 删除事件
    removePerformanceManagement(row, index) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removePerformanceManagement(row.id).then(() => {
          this.dialogFormVisible = false
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.$refs.tableCrud.onSearchChange()
        })
      }).catch(() => {
      })
    },
    // 获取数据
    loadData(params, callback) {
      getAllPerformanceManagement(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>
