<!--
  @description: 项目管理-监标人设置-已设置标段组件
  @Modifier: 张慢慢
  @routerPath:
  @date: 2021/8/9
-->
<template>
  <div>
    <el-table
      ref="table"
      :data="is_show?tableData:tableData[0]?[tableData[0]]:[]"
    >
      <el-table-column
        type="index"
        label="序号"
        width="60"
        align="center"
      />
      <el-table-column
        header-align="center"
        prop="packNo"
        label="标段（包）编号"
      />
      <el-table-column

        header-align="center"
        prop="packName"
        label="标段（包）名称"
      />
      <!--招标/资审文件状态-->
      <el-table-column
        label="监标人"
        prop="supervisorName"
        width="160px"
        header-align="center"
        align="left"
      />
      <el-table-column
        label="操作"
        align="center"
        width="150px"
      >
        <!-- isCanOperate 是否可以操作 00:否 01:是-->
        <template slot-scope="scope">
          <el-link
            v-if="scope.row.isCanOperate==='01' && tenderBase.isCanOperate"
            type="primary"
            @click="deleteRow(scope.row,scope.$index)"
          >
            [删除]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <div class="more">
      <span v-if="is_show" class="pointer" @click="is_show=false">
        收起更多（0）
        <i class="el-icon-arrow-up" />
      </span>
      <span v-else class="pointer" @click="is_show=true">
        展开更多（{{ tableData.length>0?tableData.length -1:0 }}）
        <i class="el-icon-arrow-down" />
      </span>
    </div>
  </div>
</template>

<script>
/* api*/
import { listSetBidSupervisorPages, removeBidSupervisor } from '@api/bidding/biddingProject'
/* 公用方法*/

export default {
  name: 'HaveSetPackComp',
  components: {
  },
  data() {
    return {
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      is_show: true, // 标段展示状态
      searchData: {
        tenderId: this.$route.query.id// 项目Id
      },
      tableData: []
    }
  },
  created() {
    this.initData()// 初始化数据
  },
  methods: {
    /*
    * 初始化数据
    * procfileId 寻找相同的文件id进行定时刷新
    * */
    initData(procfileId) {
      const data = {
        ...this.searchData,
        stageType: this.tenderBase.stageType
      }
      listSetBidSupervisorPages(data).then(res => {
        this.tableData = res.data.records
      })
    },
    // 删除
    deleteRow(row, index) {
      this.$confirm('确定删除已选标段（包）吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removeBidSupervisor({
          stageId: row.stageId
        }).then(res => {
          this.tableData.splice(index, 1)
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.$emit('initData')// 调用未制作标段查询接口
        })
      }).catch(() => {
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
