<!--
  @description: 变更公告列表
  @Modifier: haoFx
  @routerPath: /bidding/projectDrive/changeBulletin/changeBulletinList
  @date: 2020/3/12-9:59
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <div class="main">
    <el-button
      v-if="tenderBase.isCanOperate"
      type="primary"
      class="mb10"
      @click="addChangeBulletin"
    >
      新增
    </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
          label="变更公告"
          header-align="center"
          prop="title"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          label="标段（包）编号"
          prop="packNo"
          align="left"
          min-width="200"
        />
        <el-table-column
          prop="bulletinPublishTime"
          align="center"
          label="发布时间"
          width="140"
        />
        <el-table-column
          label="状态"
          prop="auditStatus"
          align="center"
          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="180"
        >
          <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 v-if="changeBulletinConfigType">
              <el-link
                v-if="scope.row.auditStatus"
                type="primary"
                @click="handleDetail(scope.row.changeBulletinId)"
              >
                [流程追踪]
              </el-link>
            </template>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </div>
</template>

<script>
/* 接口*/
import { changeBulletinList, deleteChangeBulletin } from '@/api/bidding/changeBulletin'// 公告列表
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
export default {
  name: 'ChangeBulletinList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin],
  data() {
    return {
      changeBulletinConfigType: this.$store.getters.systemConfigVo.configType, // true走工作流 false隐藏流程追踪
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      tenderId: this.$route.query.id,
      loading: true,
      tableData: []
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
    sessionStorage.removeItem('bizId')
  },
  methods: {
    // 获取数据
    loadData() {
      const params = {
        tenderId: this.tenderId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      changeBulletinList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 新增变更公告
    addChangeBulletin() {
      this.$router.push({
        path: '/bidding/projectDrive/changeBulletin/changeBulletinAdd',
        query: {
          ...this.$route.query,
          changeBulletinId: ''
        }
      })
    },
    // 删除
    deleteProject(row, index) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        deleteChangeBulletin(row.changeBulletinId).then(res => {
          this.tableData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.loadData()
        }).catch(() => {
        })
      }).catch(() => {
      })
    },
    // 编辑
    editProject(row) {
      this.$router.push({
        path: '/bidding/projectDrive/changeBulletin/changeBulletinAdd',
        query: {
          ...this.$route.query,
          changeBulletinId: row.changeBulletinId // 变更公告id
        }
      })
    },
    // 查看
    preview(row) {
      this.$router.push({
        path: '/bidding/projectDrive/changeBulletin/makeChangeBulletinPdfDetail',
        query: {
          ...this.$route.query,
          changeBulletinId: row.changeBulletinId // 变更公告id
        }
      })
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style scoped lang="less">

</style>
