<!--
  @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="title" label="中标结果公示" prop="title">
        <el-input v-model.trim="searchForm.title" placeholder="中标结果公示" width="228px" />
      </el-form-item>
      <el-form-item ref="tenderName" label="招标项目名称" prop="tenderName">
        <el-input v-model.trim="searchForm.tenderName" placeholder="招标项目名称" width="228px" />
      </el-form-item>
      <el-form-item ref="tenderName" label="项目编号" prop="tenderNo">
        <el-input v-model.trim="searchForm.tenderNo" placeholder="项目编号" width="228px" />
      </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
          header-align="center"
          prop="title"
          label="中标结果公示"
          min-width="230"
        />
        <el-table-column
          prop="bulletinPublishTime"
          align="center"
          label="发布时间"
          width="140"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <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="180"
        >
          <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="pushBiddingEvaluationButten(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="pubBidWinBullentin(scope.row)"
            >
              [推送公共服务平台]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { backOfWinBidResultList, backOfWinBidResult, pushBiddingEvaluation, pubBidWinBullentin } from '@/api/bidding/biddingProject'// 项目列表 项目删除
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息

export default {
  name: 'BackOfWinBidResultList',
  mixins: [initGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      createTime: [], // 创建时间 不传给后端只做回显
      searchForm: {
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        title: '' // 公告标题
      },
      tableData: []
    }
  },
  created() {
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取数据
    loadData(params, callback) {
      this.loading = true
      backOfWinBidResultList(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
        // 中标结果公示回退
        backOfWinBidResult(params).then(response => {
          this.$message({
            message: '中标结果公示回退成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    },
    pushBiddingEvaluationButten(row) {
      this.$confirm('手动推送该标段（包）的评标公示，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.loading = true
        // 手动推送评标公示
        pushBiddingEvaluation(row.packId).then(response => {
          this.$message({
            message: '手动推送评标公示成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    },
    // 重新推送公共服务平台
    pubBidWinBullentin(row) {
      this.$confirm('确认该标段（包）的操作，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.loading = true
        pubBidWinBullentin(row.id).then(response => {
          this.$message({
            message: '重新推送公共服务平台成功',
            type: 'success'
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
