<!--
  @description: 项目包组信息表
  @author: sunxinman
  @routerPath: /backstage/packageGroupInfoList
  @date: 2020-1-15 16:35
-->
<template>
  <div>
    <section class="title p0-16">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      项目包组信息表
    </section>
    <section class="p0-16">
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          width="100%"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            prop="packNo"
            label="包组编号"
            width="160"
          />
          <el-table-column
            header-align="center"
            prop="packName"
            label="包组名称"
            min-width="100"
          />
          <el-table-column
            header-align="center"
            prop="contractBudget"
            label="本包预算（元）"
            width="150"
            align="right"
          />
          <el-table-column
            header-align="center"
            prop="maxLimitedPrice"
            label="包组最高限价（元）"
            width="150"
            align="right"
          />
          <el-table-column
            header-align="center"
            prop="orderlevel"
            label="排序"
            width="60"
            align="right"
          />
          <el-table-column
            label="操作"
            align="center"
            width="170"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="delRedPackage(scope.row.stageId)"
              >
                [清除redis]
              </el-link>
              <el-link
                type="primary"
                @click="supplierOpt(scope.row.stageId)"
              >
                [供应商信息]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="getPackageRedisList" />
      </div>
    </section>
  </div>
</template>

<script>
// api
import { listPackageRedisResetPages } from '@/api/bidding/biddingProject'
import { delRedisByStageId } from '@/api/bidding/bid'
// 公共方法混入
import { ListMixin } from '@/mixins/ListMixin'
// 组件
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'PackageRedisList',
  components: {
    pagination
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      tableData: []
    }
  },
  created() {
    this.getPackageRedisList()
  },
  methods: {
    // 清除redis模块-根据项目id获取标段信息列表
    getPackageRedisList() {
      const params = {
        tenderId: this.$route.params.tenderId,
        ...this.paginationData
      }
      listPackageRedisResetPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
      })
    },
    // 清除redis
    delRedPackage(stageId) {
      this.$confirm('是否清除该包组redis？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        delRedisByStageId(stageId).then(res => {
          this.$message.success(res.header.msg)
        }).catch(() => {
        })
      }).catch(() => {
      })
    },
    // 供应商信息
    supplierOpt(stageId) {
      this.$router.push({
        name: 'supplierRedis',
        params: {
          stageId: stageId,
          ...this.$route.params
        }
      })
    },
    // 返回
    back() {
      this.$router.push({
        name: 'projectRedis'
      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>
