<!--
  @description: 投标人提出问题列表
  @Modifier: 郝定康
  @routerPath:/procurement/procurementDrive/procClarificationQuestionReply/procClarificationQuestionList
  @date: 2021-02-08 10:31:37
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <section>
    <!-- v-if="tenderBase.isCanOperate" -->
    <!-- roleCode 11 采购员  OFF_EXPERT 评标专家-->
    <gx-button
      v-if="roleCode !=='OFF_EXPERT'"
      :code="'001_012_001'"
      type="primary"
      class="mb10"
      @click="addeClarification"
    >
      回 复
    </gx-button>
    <div>
      <el-table
        v-loading="loading"
        :data="tableData"
        width="100%"
        @selection-change="selectionChange"
      >
        <el-table-column
          type="selection"
          align="center"
          width="50"
        />
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          label="标段编号"
          prop="packNo"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="问题提交单位"
          header-align="center"
          prop="supplierName"
          min-width="230"
        />
        <el-table-column
          prop="submitQuestionTime"
          align="center"
          label="问题提出时间"
          width="160"
        />
        <el-table-column
          label="问题描述"
          header-align="center"
          prop="questionDescribe"
          min-width="230"
        />
        <el-table-column
          label="状态"
          prop="questionStatus"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            {{ filterDictText(bidderStatusList, scope.row.questionStatus) }}
          </template>
        </el-table-column>
        <el-table-column
          label="回复数"
          header-align="center"
          prop="replyNumber"
          width="60"
        />
        <el-table-column
          header-align="center"
          label="操作"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <!--登录用户有权限则显示-->
            <!-- v-if="tenderBase.isCanOperate" -->
            <gx-link
              v-if="scope.row.questionStatus !== '02'&&roleCode !=='OFF_EXPERT'"
              :code="'001_012_002'"
              type="primary"
              @click.stop="replyClarify(scope.row)"
            >
              [回复]
            </gx-link>
            <gx-link
              type="primary"
              :code="'001_012_004'"
              @click.stop="preview(scope.row)"
            >
              [查看]
            </gx-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
  </section>
</template>

<script>
/* 接口*/
import { listClarificationQuestionPages } from '@/api/procurement/procurementProject'// 澄清
/* 公共方法*/
import { filterDictText } from '@/assets/js/utils' // 常用方法
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { clarificationGroupMixin } from '../mixins/clarificationGroupMixin'// 澄清质疑-公用参数
import { clarificationMixin } from '../mixins/clarificationMixin'// 澄清质疑-公用参数
export default {
  name: 'ProcClarificationQuestionList',
  components: {
    pagination// 分页
  },
  inject: ['getTenderBase'],
  mixins: [ListMixin, clarificationGroupMixin, clarificationMixin],
  data() {
    return {
      tenderBase: this.getTenderBase(), // 项目信息
      loading: true,
      tableData: [], // 列表数据
      selectionData: []// 已选的数据
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 字典检索
    filterDictText,
    // 获取数据
    loadData() {
      const params = {
        packId: this.tenderBase.packId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      listClarificationQuestionPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 选择 投标人提出的问题
    selectionChange(val) {
      this.selectionData = val
    },
    /*
    * 回复澄清-存储相应的参数
    * row 如果是单个回复有参数 否则无参数
    * */
    setClarification(row) {
      const questionIdList = []
      if (row) { // 单个回复
        questionIdList.push(row.questionId)
      } else { // 批量回复
        // 循环-取相应的Id
        this.selectionData.map(item => {
          questionIdList.push(item.questionId)
        })
      }
      return questionIdList
    },
    // 新增回复澄清
    addeClarification() {
      if (this.selectionData.length > 0) {
        const questionIdList = this.setClarification()
        // rrouter-跳转
        this.$router.push({
          name: 'procClarificationQuestionAdd',
          params: {
            packId: this.tenderBase.packId,
            questionIdList
          }
        })
      } else {
        this.$message({
          message: '请选择投标人提出的问题！',
          type: 'warning'
        })
      }
    },
    // 回复澄清
    replyClarify(row) {
      const questionIdList = this.setClarification(row)// // 回复澄清-存储相应的参数
      this.$router.push({
        name: 'procClarificationQuestionAdd',
        params: {
          packId: this.tenderBase.packId,
          questionIdList
        }
      })
    },
    // 查看
    preview(row) {
      // 如果是专家评标-澄清质疑 roleCode 11 采购员  OFF_EXPERT 评标专家
      if (this.roleCode === 'OFF_EXPERT') {
        this.$router.push({
          name: 'objectionExpertDetail',
          params: {
            questionId: row.questionId// 澄清问题Id
          }
        })
      } else {
        this.$router.push({
          name: 'objectionDetail',
          params: {
            questionId: row.questionId// 澄清问题Id
          }
        })
      }
    }
  }
}
</script>

<style scoped lang="less">

</style>
