<!--
  @description: 采购员-采购单变更公告表格查看
  @Modifier: gmy
  @routerPath:/procurement/procurementDrive/procurementContentTabs/procurementAlterRecord
  @date: 2020/8/14-11:13
-->
<template>
  <el-table
    ref="smallTable"
    :data="alterList"
  >
    <el-table-column
      type="index"
      label="序号"
      align="center"
      width="60"
    />
    <el-table-column
      header-align="center"
      prop="title"
      label="名称"
      align="left"
      min-width="230"
    />
    <el-table-column
      prop="purchaseNo"
      label="发布时间"
      min-width="150"
      header-align="center"
      align="center"
    >
      <template slot-scope="scope">
        <p v-if="scope.row.publishTime">
          {{ $Moment(scope.row.publishTime).format(momentSaveFormat) }}
        </p>
      </template>
    </el-table-column>
    <el-table-column
      prop="purchaseNo"
      label="操作"
      min-width="150"
      header-align="center"
      align="center"
    >
      <template slot-scope="scope">
        <el-link
          :underline="false"
          type="primary"
          size="mini"
          plain
          @click.stop="alterLook(scope.row)"
        >
          [查看]
        </el-link>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
/* api */
import { queryChangeMessage } from '@/api/procurement/procurementBulletin' // 公开类采购变更记录查看
import { InvitationQueryChangeMessage } from '@/api/procurement/procurementInvitation' // 邀请类采购单变更记录查询

/* 公共方法 */
import { procurementAlterMixin } from './mixins/procurementAlterMixin'

export default {
  name: 'ProcurementAlterDetail',
  inject: ['getTenderBase'],
  mixins: [procurementAlterMixin],
  data() {
    return {
      alterList: [], // 变更数据
      tenderBase: this.getTenderBase(), // 获取项目信息
      procurementRole: this.$route.meta.procurementRole // 11 项目经理 12供应商
    }
  },
  created() {
    // 查询采购单变更请求
    this.queryChangeMessageRequest()
  },
  methods: {
    // 变更公告查看按钮
    alterLook(row) {
      // 项目经理
      if (this.procurementRole === '11') {
        this.$router.push({ path: '/procurement/procurementDrive/procurementAlterRecordPdf',
          query: {
            id: row.id // 变更公告列表主键id
          }
        })
        return
      }
      // 供应商
      this.$router.push({ path: '/procurement/procurementDriveSupplier/procurementAlterRecordPdf',
        query: {
          id: row.id // 变更公告列表主键id
        }
      })
    },
    // 查看变更记录请求
    queryChangeMessageRequest() {
      const packId = this.tenderBase.packId
      // 公开类项目
      if (this.tenderBase.tenderType === '00') {
        queryChangeMessage(packId).then(res => {
          this.alterList = res.data // 获取变更数据
        }).catch(() => {

        })
        return
      }
      // 邀请类项目
      InvitationQueryChangeMessage(packId).then(res => {
        this.alterList = res.data // 获取变更数据
      }).catch(() => {

      })
    }
  }
}
</script>

<style>

</style>
