<!--
  @description: 项目经理查看异议列表
  @Modifier: haoFx
  @routerPath:/objection/objectionList
  @date: 2020/3/3-10:43
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />异议列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus?'arrow-is-active':''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="110px"
            label-position="left"
          >
            <el-form-item ref="objectionMode" label="问题类型" prop="objectionMode">
              <el-select v-model="searchForm.objectionMode" placeholder="请选择" style="width: 200px">
                <el-option
                  v-for="item in objectionModeList"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item ref="supplierName" label="异议人" prop="supplierName">
              <el-input v-model.trim="searchForm.supplierName" placeholder="异议人" @keyup.enter.native="onSearch" />
            </el-form-item>
            <el-form-item ref="tenderName" label="项目名称" prop="tenderName">
              <el-input v-model.trim="searchForm.tenderName" placeholder="项目名称" @keyup.enter.native="onSearch" />
            </el-form-item>
            <el-form-item ref="tenderNo" label="项目编号" prop="tenderNo">
              <el-input v-model.trim="searchForm.tenderNo" placeholder="项目编号" @keyup.enter.native="onSearch" />
            </el-form-item>
            <el-form-item ref="objectionNo" label="申请单号" prop="objectionNo">
              <el-input v-model.trim="searchForm.objectionNo" placeholder="申请单号" @keyup.enter.native="onSearch" />
            </el-form-item>
            <el-form-item ref="packNo" label="标段（包）编号" prop="packNo">
              <el-input v-model.trim="searchForm.packNo" placeholder="标段（包）编号" @keyup.enter.native="onSearch" />
            </el-form-item>
            <el-form-item ref="packName" label="标段（包）名称" prop="packName">
              <el-input v-model.trim="searchForm.packName" placeholder="标段（包）名称" @keyup.enter.native="onSearch" />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </div>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <div class="mb10">
        <el-button type="primary" plain @click="exportObjectionList">
          导出异议列表
        </el-button>
      </div>
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column

            header-align="center"
            prop="tenderName"
            label="招标项目名称"
            min-width="230"
          />
          <el-table-column
            prop="tenderNo"
            align="center"
            label="招标项目编号"
            width="160"
          />
          <el-table-column

            header-align="center"
            label="标段（包）名称"
            prop="packNames"
            align="left"
            min-width="200"
          />
          <el-table-column
            header-align="center"
            label="标段（包）编号"
            prop="packNos"
            min-width="180"
          />
          <el-table-column
            header-align="center"
            prop="complaintType"
            label="投诉方式"
            min-width="75"
            align="center"
          >
            <template slot-scope="scope">
              <span
                v-for="(item,index) in clarificationObjectionTypeList"
                v-if="scope.row.complaintType===item.typecode"
                :key="index"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <el-table-column

            header-align="center"
            prop="supplierName"
            label="异议人"
            min-width="200"
          />
          <el-table-column

            header-align="center"
            prop="objectionNo"
            label="申请单号"
            min-width="200"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="grantauthPersonPhone"
            label="被授权人电话"
            min-width="110"
            align="center"
          />
          <el-table-column
            header-align="center"
            prop="objectionMode"
            label="问题类型"
            min-width="75"
            align="center"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.objectionMode==='00'">异议</span>
              <span v-if="scope.row.objectionMode==='01'">投诉</span>
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="objectionType"
            label="异议类型"
            min-width="75"
            align="center"
          >
            <template slot-scope="scope">
              <span
                v-for="(item,index) in objectionTypeList"
                v-if="scope.row.objectionType===item.typecode"
                :key="index"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            prop="createTime"
            label="提交时间"
            width="140"
            align="center"
          />
          <el-table-column
            :formatter="formatterUseStatusList"
            header-align="center"
            prop="useStatus"
            label="状态"
            min-width="100"
          />
          <el-table-column
            header-align="center"
            label="操作"
            fixed="right"
            width="230"
          >
            <template slot-scope="scope">
              <!--有效状态 00:待受理 01:已受理待审批 02:审批未通过 03:待复核 04:复核异议不通过 05:已审批待回复 06已回复-->
              <el-link
                v-if="scope.row.useStatus!=='00'"
                type="primary"
                @click="preview(scope.row)"
              >
                [查看]
              </el-link>
              <!--项目经理操作-->
              <template v-if="roleCode==='11'">
                <template v-if="scope.row.useStatus==='00' || scope.row.useStatus==='02'|| scope.row.useStatus==='04'">
                  <el-link type="primary" @click="acceptance(scope.row)">
                    [受理]
                  </el-link>
                  <el-link type="primary" @click="notEntertained(scope.row)">
                    [不受理]
                  </el-link>
                </template>
                <el-link v-if="scope.row.useStatus==='05'" type="primary" @click="sendReplyLetter(scope.row)">
                  [发送回复函]
                </el-link>
                <el-link v-if="clarificationObjectSourceType && scope.row.useStatus!=='00'" type="primary" @click.stop="handleDetail(scope.row)">
                  [流程追踪]
                </el-link>
              </template>
              <!--风险监控人员操作-->
              <el-link v-if="scope.row.useStatus==='03' && roleCode!=='11'" type="primary" @click="reCheck(scope.row)">
                [复核]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
    <!--流程追踪查看弹框-->
    <flow-detail-dialog ref="tracingFlow" />
  </div>
</template>

<script>
/* 接口*/
import { listManagerRaiseObjectionPages, listManagerRaiseObjectionPagesOfExport } from '@api/bidding/tenderObjection'
/* 公用方法*/
import { filterObj, download } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { objectionConfigMixin } from '../mixins/objectionConfigMixin'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import flowDetailDialog from '@views/work/process/flowDetail-dialog' //  流程追踪组件
export default {
  name: 'ClarificationList',
  components: {
    pagination, // 分页
    flowDetailDialog
  },
  mixins: [ListMixin, objectionConfigMixin],
  data() {
    return {
      /* 字典信息-start */
      objectionTypeList: [], // 异议类型
      clarificationObjectionTypeList: [], // 投诉方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        packName: '', // 标段名称
        packNo: '', // 标段编号
        supplierName: '', // 异议人
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        objectionNo: '', // 申请单号
        objectionMode: '' // 问题类型
      },
      tableData: [],
      roleCode: this.$store.getters.info.currentRol.roleCode // 项目经理角色 11
    }
  },
  mounted() {
    // 获取列表信息
    this.loadData()
    this.initGroup() // 获取字典方法
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'objectionType', // 异议类型
        'clarificationObjectionType'// 异议投诉方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 导出异议列表
    exportObjectionList() {
      const params = this.getQueryParams()// 查询条件
      listManagerRaiseObjectionPagesOfExport(params).then(res => {
        download(res, '投标人异议投诉列表.xls')
      })
    },
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listManagerRaiseObjectionPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 受理
    acceptance(row) {
      this.$router.push({
        path: '/objection/objectionTabs/objectionAcceptanceAdd',
        name: 'ObjectionAcceptanceAdd',
        params: {
          objectionId: row.objectionId
        }
      })
    },
    // 不受理
    notEntertained(row) {
      this.$router.push({
        path: '/objection/objectionTabs/objectionNotAcceptanceAdd',
        name: 'ObjectionNotAcceptanceAdd',
        params: {
          objectionId: row.objectionId
        }
      })
    },
    // 发送回复函
    sendReplyLetter(row) {
      this.$router.push({
        path: '/objection/objectionTabs/sendReply',
        name: 'SendReply',
        params: {
          objectionId: row.objectionId, // 异议id
          receiptStatus: row.receiptStatus, // 接受状态 01:受理 02:不受理
          showTbsStatus: '01' // 页面显示tab 00显示回复函受理/回复函编辑 01显示回复函/审批信息
        }
      })
    },
    // 查看
    preview(row) {
      // 接受状态 01:受理 02:不受理
      let routerName = 'ObjectionAcceptanceDetail' // 01:受理
      // 不受理跳转不受理详情
      if (row.receiptStatus === '02') {
        routerName = 'ObjectionNotAcceptanceDetail'
      }
      this.$router.push({
        name: routerName,
        params: {
          receiptStatus: row.receiptStatus, // 接受状态 01:受理 02:不受理
          objectionId: row.objectionId,
          showTbsStatus: '01' // 页面显示tab 00显示回复函受理/回复函编辑 01显示回复函/审批信息
        }
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    },
    // 流程追踪详情
    handleDetail(row) {
      this.$refs.tracingFlow.openDialogInitData(row.receiptId)
    },
    /* 风险控制部复核异议*/
    reCheck(row) {
      this.$router.push({
        name: 'ObjectionAcceptanceRecheck',
        params: {
          receiptStatus: row.receiptStatus, // 接受状态 01:受理 02:不受理
          objectionId: row.objectionId,
          showTbsStatus: '01' // 页面显示tab 00显示回复函受理/回复函编辑 01显示回复函/审批信息
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>

