<!--
  @description:招标--项目-招标公告列表/资审公告列表
  @Modifier:haoFx/肖文龙
  @routerPath:/bidding/projectDrive/bulletin/bidBulletinList
  @date:2019/11/14-10:36
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <div class="main">
    <template v-if="tenderBase.isCanOperate">
      <div v-if="display==='00'" class="mb10 clearfix">
        <div class="fl">
          <el-button type="primary" icon="iconfont icon-tianjia1" @click="addNotice">
            新增
          </el-button>
        </div>
      </div>
    </template>
    <div>
      <el-table
        ref="table"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center"
        />
        <el-table-column

          header-align="center"
          label="公告标题"
          prop="title"
          min-width="200"
        >
          <template slot-scope="scope">
            <div>{{ scope.row.title }}</div>
          </template>
        </el-table-column>
        <el-table-column

          header-align="center"
          prop="packNos"
          label="关联标段"
        />
        <el-table-column
          prop="auditStatus"
          label="审核状态"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.auditStatus!=='02' && scope.row.useStatus==='00'" 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 label="操作" header-align="center" width="100px">
          <template v-if="tenderBase.isCanOperate" slot-scope="scope">
            <el-link
              v-if="scope.row.auditStatus==='00'||scope.row.auditStatus==='01'"
              type="primary"
              @click="examine(scope.row)"
            >
              [查看]
            </el-link>
            <el-link
              v-if="scope.row.auditStatus==='02'||!scope.row.auditStatus"
              type="primary"
              @click="edit(scope.row)"
            >
              [编辑]
            </el-link>
            <el-link
              v-if="scope.row.auditStatus==='02'||!scope.row.auditStatus"
              type="primary"
              @click="deleteRow(scope.$index,scope.row)"
            >
              [删除]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
  </div>
</template>

<script>
/* api*/
import { listTenderBulletinByTenderIdPages, removeBulletinByBulletinId } from '@/api/bidding/bidBulletin'
import { getSystemConfigValueByConfigType } from '@/api/common/systemConfigCenter'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  components: {
    pagination
  },
  mixins: [ListMixin],
  props: {
    display: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      tableData: [], // 已制作公告
      searchForm: {
        bulletinType: '', // 公告类型 招标公告 01, 资审公告 21,变更公告11,中标候选人公示05,中标公示06
        tenderId: this.$store.getters.tenderBase.tenderId// 项目Id
      },
      isSimpleBulletin: '' // 公告页面 00老版 01简易版
    }
  },
  created() {
    this.searchForm.bulletinType = this.tenderBase.bulletinType// 21资审公告 01招标公告
    this.loadData()// 获取公告列表
    this.getSystemConfigValueByConfigType()
  },
  methods: {
    // 获取招标公告显示版本控制 01启用简易版招标公告
    getSystemConfigValueByConfigType() {
      getSystemConfigValueByConfigType('tenderBulletin-isSimpleBulletin').then((res) => {
        this.isSimpleBulletin = res.data
      })
    },
    // 获取公告列表
    loadData() {
      this.searchForm.pageNo = this.paginationData.pageNo
      this.searchForm.pageSize = this.paginationData.pageSize
      listTenderBulletinByTenderIdPages(this.searchForm).then(response => {
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 新增公告
    addNotice() {
      // 携带参数
      const data = {
        ...this.$route.query,
        bulletinId: ''// 招标公告(资审公告)Id
      }
      if (this.isSimpleBulletin === '01') {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/newTenderBulletin-add', query: data })
      } else {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/tabs/tenderBulletIinInfo-add', query: data })
      }
    },
    // 查看
    examine(row) {
      // 携带参数
      const query = {
        ...this.$route.query,
        bulletinId: row.bulletinId// 招标公告Id
      }
      if (this.isSimpleBulletin === '01') {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/newTenderBulletin-detail', query: query })
      } else {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/makeTenderingBulletinPdf', query: query })
      }
    },
    // 编辑
    edit(row) {
      // 携带参数
      const data = {
        ...this.$route.query,
        bulletinId: row.bulletinId// 招标公告Id
      }
      if (this.isSimpleBulletin === '01') {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/newTenderBulletin-add', query: data })
      } else {
        this.$router.push({ path: '/bidding/projectDrive/bulletin/tabs/tenderBulletIinInfo-add', query: data })
      }
    },
    //  删除
    deleteRow(index, row) {
      this.$confirm('此操作将永久删除该公告, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        removeBulletinByBulletinId(row.bulletinId).then(res => {
          this.tableData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功'
          })
        }).catch(() => {

        })
      }).catch(() => {
      })
    }
  }

}
</script>

<style lang="less" scoped>

</style>
