<!--
  @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>
    </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"
          align="center"
          label="招标项目编号"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="200"
        />
        <el-table-column
          prop="bulletinPublishTime"
          align="center"
          label="发布时间"
          min-width="150"
        />
        <el-table-column
          header-align="center"
          label="包编号"
          prop="packNos"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="状态"
          prop="auditStatus"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.auditStatus==='00'" class="status2">待审核</span>
            <span v-if="scope.row.auditStatus==='01'" class="status1">审核通过</span>
            <span v-if="scope.row.auditStatus==='02'" class="status3">审核不通过</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="publishStatus"
          label="内网发布状态"
          min-width="200"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.publishStatus ==='01'" class="status1">已发布</span>
            <span v-else class="status2">未发布</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="sendStatusNew"
          label="公共平台发布状态"
          min-width="200"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.sendStatusNew ==='01'" class="status1">已发布</span>
            <span v-else class="status2">未发布</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="公告回退"
          min-width="200"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              :underline="false"
              type="primary"
              @click="backBulletin(scope.row)"
            >
              [退回确认]
            </el-link>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="推送公共服务平台"
          min-width="200"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              :underline="false"
              type="primary"
              @click="backPTBulletin(scope.row)"
            >
              [推送公共服务平台]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { backOfCandiDateBulletinList, backOfCandiDateBulletin, pubCandidateBullentin } from '@/api/bidding/biddingProject'// 项目列表 项目删除
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息
export default {
  name: 'TenderProjectList',
  mixins: [initGroupMixin],
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      phaseTypeList: [], // 资格审查方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      createTime: [], // 创建时间 不传给后端只做回显
      searchForm: {
        auditStatus: '', // 审核状态 00:待审核 01:审核通过 02:审核不通过
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        qualificationMethod: '', // 00资格预审,01 资格后审
        tenderMethod: '', // 招标方式 : 公开招标 00 邀请招标 01 竞争性谈判 02 询价 03 单一来源采购 04 其他 05
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  created() {
    this.initGroup() // 获取字典方法
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'phaseType'// 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 表格字典值替换文本-招标方式
    formatTenderMethod(row, column, cellValue) {
      return filterDictText(this.bidTypeList, cellValue)
    },
    // 创建时间选择
    createTimeChange(val) {
      this.searchForm.createBeginTime = val[0]// 开始日期
      this.searchForm.createEndTime = val[1]// 结束日期
    },
    // 获取数据
    loadData(params, callback) {
      this.loading = true
      backOfCandiDateBulletinList(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.id
      }
      this.$confirm('确认该标段（包）的操作，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.loading = true
        // 候选人公示回退
        backOfCandiDateBulletin(params).then(response => {
          this.$message({
            message: '候选人公示回退成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    },
    // 重新推送公共服务平台
    backPTBulletin(row) {
      this.$confirm('确认该标段（包）的操作，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.loading = true
        pubCandidateBullentin(row.id).then(response => {
          this.$message({
            message: '重新推送公共服务平台成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
