<!--
  @description: 项目经理澄清
  @Modifier: haoFx/肖文龙
  @routerPath:/bidding/projectDrive/clarification/clarificationList
  @date: 2020/3/13-14:11
isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <section>
    <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
          header-align="center"
          label="澄清标题"
          prop="clarificationTitle"
          align="left"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          label="标段编号"
          prop="packNos"
          align="left"
          min-width="200"
        />
        <el-table-column
          prop="clarificationSendTime"
          align="center"
          label="澄清发送时间"
          width="160"
        >
          <template slot-scope="scope">
            {{ scope.row.clarificationSendTime && $Moment(scope.row.clarificationSendTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="bidderNumber"
          align="right"
          label="有效投标人"
          width="100"
        />
        <el-table-column
          prop="replyDepartNumber"
          align="right"
          label="已回购机构数"
          width="100"
        />
        <el-table-column
          prop="clarificationType"
          align="center"
          label="类型"
          width="100"
        >
          <template slot-scope="scope">
            <span v-for="(item,index) in clarificationTypeList" v-if="scope.row.clarificationType===item.typecode" :key="index" :class="item.class">
              {{ item.typename }}
            </span>
          </template>
        </el-table-column>
        <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-for="(item,index) in auditStatusList"
              v-if="scope.row.auditStatus===item.typecode"
              :key="index"
              :class="item.class"
            >
              {{ item.typename }}
            </span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="操作"
          align="left"
          width="230"
        >
          <template slot-scope="scope">
            <!--登录用户有权限则显示-->
            <template v-if="tenderBase.isCanOperate">
              <!--auditStatus 02 审核不通过useStatus 00 草稿-->
              <el-link
                v-if="scope.row.auditStatus==='02'||scope.row.useStatus==='00'"
                type="primary"
                @click.stop="edit(scope.row)"
              >
                [编辑]
              </el-link>
              <!--auditStatus 02 审核不通过useStatus 00 草稿-->
              <el-link
                v-if="scope.row.auditStatus==='02'||scope.row.useStatus==='00'"
                type="primary"
                @click.stop="deleteRow(scope.row)"
              >
                [删除]
              </el-link>
            </template>
            <!--auditStatus 01 审核通过 00 待审核-->
            <el-link
              v-if="scope.row.auditStatus==='01'||scope.row.auditStatus==='00'"
              type="primary"
              @click.stop="preview(scope.row)"
            >
              [查看]
            </el-link>
            <template v-if="clarificationConfigType">
              <el-link
                v-if="scope.row.auditStatus && scope.row.clarificationType==='01'"
                type="primary"
                @click.stop="handleDetail(scope.row.clarificationId)"
              >
                [流程追踪]
              </el-link>
            </template>
            <!--auditStatus 01 审核通过-->
            <el-link
              v-if="scope.row.auditStatus==='01'"
              type="primary"
              @click.stop="seeReceipt(scope.row)"
            >
              [查看回执机构]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </section>
</template>

<script>
/* 接口*/
import { listClarificationPages, removeClarificationInfo } from '@/api/bidding/bidClarification'// 澄清
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
import { clarificationGroupMixin } from '../../mixins/clarificationGroupMixin'// 澄清质疑-字典信息
export default {
  name: 'ClarificationQuestionList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin, clarificationGroupMixin],
  data() {
    return {
      clarificationConfigType: this.$store.getters.systemConfigVo.configType, // true走工作流 false隐藏流程追踪
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      loading: true,
      tableData: []
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = {
        tenderId: this.$store.getters.tenderBase.tenderId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      listClarificationPages(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/clarification/clarificationAdd',
        query: {
          ...this.$route.query,
          clarificationId: ''// 澄清Id
        }
      })
    },
    // 删除
    deleteRow(row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        const clarificationId = row.clarificationId// 澄清Id
        removeClarificationInfo(clarificationId).then(res => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.loadData()// 获取数据
        }).catch(() => {

        })
      }).catch(() => {
      })
    },
    // 编辑
    edit(row) {
      let path = ''// 路由
      if (row.clarificationType === '00') { // 答遗
        path = '/bidding/projectDrive/clarificationQuestionReply/clarificationQuestionAdd'
      } else if (row.clarificationType === '01') { // 补遗
        path = '/bidding/projectDrive/clarification/clarificationAdd'
      }
      this.$router.push({
        path: path,
        query: {
          ...this.$route.query,
          clarificationId: row.clarificationId// 澄清Id
        }
      })
    },
    // 查看
    preview(row) {
      this.$router.push({
        path: '/bidding/projectDrive/clarification/clarificationLetterPdfDetail',
        query: {
          ...this.$route.query,
          clarificationId: row.clarificationId// 澄清Id
        }
      })
    },
    // 查看回执机构
    seeReceipt(row) {
      this.$router.push({
        path: '/bidding/projectDrive/clarification/clarificationReceiptDetail',
        query: {
          ...this.$route.query,
          clarificationId: row.clarificationId// 澄清Id
        }
      })
    },
    // 流程追踪详情
    handleDetail(id) {
      this.$refs.tracingFlow.openDialogInitData(id)
    }
  }
}
</script>

<style scoped lang="less">

</style>
