  <!--
  @description:重新招标列表
  @Modifier: haofengxian
  @routerPath: /bidding/projectDrive/rebiddingRecord/rebiddingRecordList
  @date: 2020-5-13-10:09
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <section class="main">
    <el-button
      v-if="tenderBase.isCanOperate"
      type="primary"
      class="mb10"
      @click="addRebiddingRecord"
    >
      新增
    </el-button>
    <div>
      <el-table
        v-loading="loading"
        :data="tableData"

        width="100%"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          label="标段（包）编号"
          prop="packNo"
          align="left"
          min-width="200"
        />
        <!--        <el-table-column
          label="是否重新制作招标文件"
          header-align="center"
          prop="isChangeDoc"
          min-width="200"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.isChangeDoc==='01'">是</span>
            <span v-if="scope.row.isChangeDoc==='00'">否</span>
          </template>
        </el-table-column>-->
        <el-table-column
          prop="createTime"
          align="center"
          label="创建时间"
          min-width="140"
        />
        <el-table-column
          label="状态"
          prop="auditStatus"
          align="center"
          min-width="100"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.useStatus==='00' && scope.row.auditStatus!=='02'" class="status4">草稿</span>
            <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
          header-align="center"
          label="操作"
          width="100"
        >
          <template slot-scope="scope">
            <!--登录用户有权限则显示-->
            <template v-if="tenderBase.isCanOperate">
              <el-link
                v-if="scope.row.auditStatus==='02'||!scope.row.auditStatus"
                type="primary"
                @click="editProject(scope.row)"
              >
                [编辑]
              </el-link>
              <el-link
                v-if="scope.row.auditStatus==='02'||!scope.row.auditStatus"
                type="primary"
                @click="deleteProject(scope.row,scope.$index)"
              >
                [删除]
              </el-link>
            </template>
            <el-link
              v-if="scope.row.auditStatus==='00'||scope.row.auditStatus==='01'"
              type="primary"
              @click="preview(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
  </section>
</template>

<script>
/* 接口*/
import { getRebiddingRecordList, deleteRebiddingRecordByRebiddingRecordId } from '@api/bidding/rebiddingRecord'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
export default {
  name: 'RebiddingRecordList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      tenderId: this.$route.query.id, // 项目id
      loading: true, // 表格loading
      tableData: []
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
    sessionStorage.removeItem('bizId') // 清除重新招标id
  },
  methods: {
    // 获取数据
    loadData() {
      const params = {
        tenderId: this.tenderId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      getRebiddingRecordList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 新增变更公告
    addRebiddingRecord() {
      this.$router.push({
        path: '/bidding/projectDrive/rebiddingRecord/rebiddingRecordAdd',
        query: {
          ...this.$route.query
        }
      })
    },
    // 删除
    deleteProject(row, index) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        deleteRebiddingRecordByRebiddingRecordId(row.rebiddingRecordId).then(res => {
          this.tableData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.loadData()
        }).catch(() => {
        })
      }).catch(() => {
      })
    },
    // 编辑
    editProject(row) {
      this.$router.push({
        path: '/bidding/projectDrive/rebiddingRecord/rebiddingRecordAdd',
        query: {
          ...this.$route.query
        }
      })
      this.sessionStorageId(row.rebiddingRecordId)
    },
    // 查看
    preview(row) {
      this.$router.push({
        path: '/bidding/projectDrive/rebiddingRecord/rebiddingRecordDetail',
        query: {
          ...this.$route.query
        }
      })
      this.sessionStorageId(row.rebiddingRecordId)
    },
    // 存储重新招标id
    sessionStorageId(rebiddingRecordId) {
      sessionStorage.setItem('bizId', rebiddingRecordId)// 重新招标公告id
    }
  }
}
</script>

<style scoped>

</style>
