<!--
  @description: 采购人-物资分配组件
  @author: gmy
  @routerPath:
  @date: 2020-9-2 17:03:58
-->
<template>
  <div>
    <el-tabs v-model="tabsActiveValue" class="main" style="margin-top:0" @tab-click="handleClick">
      <el-tab-pane label="中选汇总" name="00" />
      <el-tab-pane label="行项目报价明细" name="01" />
    </el-tabs>
    <div class="main">
      <!-- 审核状态图片 -->
      <div v-if="!isDetail && auditMark" class="procurement_auditStatus">
        <!-- 待审核 -->
        <img v-if="resultData.auditStatus==='00'" src="@assets/img/common/audit//auditWait.png" alt="">
        <!-- 审核通过 -->
        <img v-if="resultData.auditStatus==='01'" src="@assets/img/common/audit//auditOk.png" alt="">
        <!-- 审核不通过 -->
        <img v-if="resultData.auditStatus==='02'" src="@assets/img/common/audit//auditNo.png" alt="">
      </div>
      <template v-if="tabsActiveValue==='00'">
        <!--采购单信息-->
        <p class="page-title">
          1.采购单信息
        </p>
        <table class="tableData">
          <tr>
            <td>采购单编号</td>
            <td>{{ purchaseOrderInfo.tenderNo }}</td>
            <td>采购单名称</td>
            <td>{{ purchaseOrderInfo.tenderName }}</td>
          </tr>
          <tr>
            <td>采购员</td>
            <td>{{ purchaseOrderInfo.sourcingUserRealName }}</td>
            <td>报价截止时间</td>
            <td>{{ purchaseOrderInfo.quoteEndTime }}</td>
          </tr>
          <tr>
            <!--            <td>整单净预算(元)</td>
            <td>{{ purchaseOrderInfo.budgetTotalMoney }}</td>-->
            <td>报价家数</td>
            <td colspan="3">
              {{ purchaseOrderInfo.offerNum }}
            </td>
          </tr>
          <!--          <tr>
            <td>采购室主任分配时间</td>
            <td>{{ purchaseOrderInfo.tenderCreateTime }}</td>
            <td>提交公告审批时间</td>
            <td>{{ purchaseOrderInfo.packAssignTime && purchaseOrderInfo.packAssignTime }}</td>
          </tr>-->
          <tr>
            <td>公告发布时间</td>
            <td colspan="3">{{ purchaseOrderInfo.packAuditPassTime && purchaseOrderInfo.packAuditPassTime }}</td>
<!--            <td>公告发布距报价截至工作日天数</td>
            <td>{{ purchaseOrderInfo.workingDay }}</td>-->
          </tr>
          <tr v-if="purchaseOrderInfo.lastAssignTime">
            <td>上一次公告提交审批时间</td>
            <!-- <td>{{ purchaseOrderInfo.packAuditPassTime }}</td> -->
            <td>{{ purchaseOrderInfo.lastAssignTime && purchaseOrderInfo.lastAssignTime }}</td>
            <td>上一次公告发布时间</td>
            <!-- <td>{{ purchaseOrderInfo.packAssignTime }}</td> -->
            <td>{{ purchaseOrderInfo.lastAuditPassTime && purchaseOrderInfo.lastAuditPassTime }}</td>
          </tr>
        </table>
      </template>
      <!--供应商信息列表-->
      <supplierOfferHallInfoList
        v-if="tableData.tableData && tableData.tableData.length>0"
        ref="supplierInfo"
        :result-data="resultData"
        :table-data="tableData"
        :offer-single-click="offerSingleClick"
        :tabs-active-value="tabsActiveValue"
        @supplierRadioInfo="supplierRadioInfo"
      />
      <template v-if="tabsActiveValue==='00'">
        <!-- 中选信息 -->
        <div class="page-title">
          3.中选信息
        </div>
        <table class="tableData">
          <!--  文字补充说明  -->
          <tr>
            <td>中选供应商</td>
            <td>{{ selectedSupplierInfo.supplierName }}</td>
            <td>中选净总价（元）</td>
            <td>{{ selectedSupplierInfo.offerTotal }}</td>
          </tr>
          <tr class="singleRow">
            <td>中选信息</td>
            <td colspan="3">
              <!-- 非编辑 -->
              <span v-if="!resultData.isEdit">{{ fromData.remark }}</span>
              <!-- 编辑 -->
              <el-input
                v-else
                v-model="fromData.remark"
                :autosize="{ minRows: 3, maxRows: 3 }"
                type="textarea"
                maxlength="2000"
                show-word-limit
                style="width: 96%"
              />
            </td>
          </tr>
          <!-- isOTO 是否是线上线下的说明文件 true线下 false线上 -->
          <tr v-if="isOTO" class="singleRow">
            <td>
              <span v-if="resultData.isEdit" class="red-star">*</span>
              说明文件
            </td>
            <td colspan="3" style="line-height:40px">
              <!-- 非编辑 -->
              <downloadFile
                v-if="!resultData.isEdit"
                :data="procurementResultReviewReport"
              />
              <!-- 编辑 -->
              <upload
                v-else
                ref="upload"
                :title="''"
                :code="'001_006_008'"
                :on-change="resultReviewReportChange"
                :data="procurementResultReviewReport"
                :auto-delete="true"
                :auto-upload="true"
                :file-size="200"
                tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）单个文件不得超过200M"
                accept=".doc,.docx,.pdf,.png,.jpg,.zip.jpeg;.txt.xlsx;.xls,.ppt,.pptx,.rar"
                file-ref="fileRef"
                but-text="点击上传"
              />
            </td>
          </tr>
          <!-- isOTO 是否是线上线下的说明文件 true线下 false线上 -->
          <tr v-if="!isOTO" class="singleRow">
            <td>说明文件</td>
            <td colspan="3" style="line-height:40px">
              <span v-for="(item, index) in evaluationReviewReport" :key="index">
                <downloadFile
                  style="display:inline"
                  :down-load="true"
                  :data="item.resultFileData"
                />
              </span>
            </td>
          </tr>
          <tr class="singleRow">
            <td>附件</td>
            <td colspan="3" style="line-height:40px">
              <!-- isEdit(采购结果列表中useStatus 控制 01 正在进行 03 已过期) 布尔值 -->
              <downloadFile
                v-if="!resultData.isEdit"
                :data="procurementResultFile"
              />
              <!-- 编辑 -->
              <upload
                v-else
                ref="upload"
                :title="''"
                :code="'001_006_009'"
                :on-change="principalFile"
                :data="procurementResultFile"
                :auto-delete="true"
                :auto-upload="true"
                :file-size="200"
                tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）单个文件不得超过200M"
                accept=".doc,.docx,.pdf,.png,.jpg,.zip.jpeg;.txt.xlsx;.xls,.ppt,.pptx,.rar"
                file-ref="fileRef"
                but-text="点击上传"
              />
            </td>
          </tr>
        </table>
        <template v-if="returnSubjectMatterList.length>0">
          <el-form ref="form" :rules="rules" :model="fromData" :inline-message="true">
            <!--4.预退回计划-->
            <preReturnPlanList :return-subject-matter-list="returnSubjectMatterList" />
            <table class="from_table mt10">
              <tr>
                <td>
                  <el-form-item label="退回原因" prop="returnReason" />
                </td>
                <td>
                  <el-form-item>
                    <gx-input
                      v-model="fromData.returnReason"
                      :disabled="!resultData.isEdit"
                      :autosize="{ minRows: 3, maxRows: 3 }"
                      type="textarea"
                      gx-maxlength="varchar500"
                      show-word-limit
                    />
                  </el-form-item>
                </td>
              </tr>
              <tr>
                <td>
                  <el-form-item label="退回附件" />
                </td>
                <td>
                  <downloadFile v-if="!resultData.isEdit" :data="backFileData" />
                  <upload
                    v-else
                    ref="upload"
                    :title="''"
                    :code="'001_006_015'"
                    :data="backFileData"
                    :auto-delete="true"
                    :auto-upload="true"
                    :file-size="200"
                    tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.xlsx;*.xls;*.rar）单个文件不得超过200M"
                    accept=".doc,.docx,.pdf,.png,.jpg,.zip,.jpeg,.txt,.xls,.ppt,.pptx,.rar"
                    file-ref="fileRef"
                    but-text="点击上传"
                  />
                </td>
              </tr>
            </table>
          </el-form>
        </template>
        <!--5.审核信息列表 -->
        <!-- 暂时隐藏 -->
        <!-- <template v-if="!flowStatus">
          <p class="title">
            5.审核信息
          </p>
          <flowAuditList :biz-id="winResultId" flow-type="00" />
        </template> -->
      </template>
      <!--行项目报价明细 01-->
      <template v-if="tabsActiveValue==='01'">
        <div class="page-title">
          2.行项目列表
        </div>
        <offerHallTableComp
          ref="resultTableComp"
          :offer-single-click="offerSingleClick"
          :table-data="tableData"
          :result-data="resultData"
          :materials-change="materialsChange"
        />
      </template>
      <!-- isShowBut 是否显示底部操作按钮 订单采购结果查看时不显示底部操作按钮其他情况显示 true显示 false不显示 -->
      <template v-if="isShowBut">
        <div class="but_footer">
          <div class="but_footer-h">
            <div class="but_footer-but" :style="{'position':isDetail?'static': ''}">
              <gx-button
                v-if="labelInfo.line==='01'"
                :code="'001_006_010'"
                :loading="confirmLoading"
                type="primary"
                @click="resultPrev"
              >
                上一步
              </gx-button>
              <gx-button :type="resStyle==='01'?'danger':'primary'" plain :code="'001_006_005'" @click="recordLook">
                查看报价记录
              </gx-button>
              <gx-button v-if="tabsActiveValue==='01'" :code="'001_006_004'" :loading="confirmLoading" @click="selectLowestPrice">
                全部展开
              </gx-button>
              <template v-if="resultData.isEdit">
                <gx-button
                  v-if="tabsActiveValue==='01'"
                  :code="'001_006_003'"
                  :loading="confirmLoading"
                  @click="selectLowestPrice"
                >
                  按条目自动选择最低报价
                </gx-button>
                <gx-button
                  :loading="confirmLoading"
                  type="primary"
                  :code="'001_006_014'"
                  @click="onSave"
                >
                  保 存
                </gx-button>
                <gx-button
                  :code="'001_006_002'"
                  :loading="confirmLoading"
                  type="primary"
                  @click="submit"
                >
                  提 交
                </gx-button>
              </template>
              <gx-button :code="'001_006_006'" :loading="confirmLoading" type="primary" @click="exportFile('00')">
                导出比价分析表
              </gx-button>
              <gx-button :code="'001_006_007'" :loading="confirmLoading" type="primary" @click="exportFile('01')">
                打印供应商报价
              </gx-button>
            </div>
          </div>
        </div>
      </template>
    </div>
    <!-- 查看供应商报价弹框 -->
    <supplierOfferInfo-dialog :dialog-data="supplierOfferDialog" />
    <!-- 查看报价记录 -->
    <offerRecordPurchasist :dialog-data="offerSupplierRecord" />
    <!--工作流选择节点组件-->
    <processNodeCom
      ref="processNode"
      :process-definition-key="processDefinitionKey"
      @processNodeData="processNodeData"
    />
    <!--工作流流程节点/获取审核用户-->
    <departDialog
      ref="departDialog"
      :process-node="processNode"
      @isSingleUser="isSingleUser"
      @processInitData="processInitData"
      @submit="subFlow"
    />
  </div>
</template>

<script>
/* api接口*/
import { queryBaseProcurementProjectInfo } from '@/api/procurement/procurementProject'
import { distinguishBetween } from '@/api/procurement/procurementProject' // 获取项目轮次数据请求
import { checkOfferRecord } from '@/api/procurement/procurementOffer'
import {
  queryMinimumTransactionPriceWinningResultInfo, // 物资分页页面数据请求
  queryMinimumTransactionPriceWinningResultDetailList,
  exportPriceComparisonAnalysisTable, // 导出比价分析表
  saveMinimumTransactionPrice, // 提交中选
  queryResultVersionList, // 查询中选行项目tab列表请求
  printSupplierOfferNew // 打印供应商报价
} from '@/api/procurement/procurementResult'
import { qryProcurementEvalReportList, qryEvalProjectFinishStatusType } from '@/api/procurement/procurementEvaluation' // 项目经理中选结果页面查看评审报表
/* 公共方法*/
import { download, filterDictText, cloneObject } from '@/assets/js/utils' // 下载文件流文件
import { characters1_auto } from '@/assets/js/validate'// 校验输入内容

/* 混入 */
import { commonMxin } from '@/mixins/commonMxin'
import { procurementResultArr } from '../mixins/procurementResult'
import { procurementResultGroupArr } from '../mixins/procurementResultGroupMixins'
import { procurementGroupMixins } from '@/views/procurement/mixins/procurementGrounpMixins.js'
/* 公共组件*/
import upload from '@comp/common/updownload/upload' // 文件上传组件
import downloadFile from '@comp/common/updownload/downloadFile'
import flowAuditList from '@views/work/process/flowAudit-list' // 审核列表

import procurementSuplierOffer from '@/views/procurement/components/procurementLookSupplierOffer-dialog' // 查看供应商报价弹框
import preReturnPlanList from '../components/preReturnPlan-list'
import supplierOfferHallInfoList from '../../components/supplierOfferHallInfo-list' // 供应商报价信息列表
import offerHallTableComp from '../../components/offerHallTableComp'
import offerRecordPurchasist from '@/views/procurement/procurementOffer/procurementOfferYetOpen/procurementOfferRecord-dialog.vue' // 报价记录

/* ==========工作流===========*/
import { workCommonMixins } from '@views/work/mixins/workCommonMixins' // 工作流公共配置
import workconstant from '@/assets/js/workutils/workconstant/purProject' // 配置流程key
import processNodeCom from '@views/work/processNodeCom' // 工作流选择节点组件
import departDialog from '@views/work/depart-dialog' // 选择审核人员
/* ============================*/
export default {
  name: 'ProcurementResultGoodsAllotComp',
  components: {
    offerRecordPurchasist, // 报价记录
    supplierOfferHallInfoList, // 供应商报价信息列表
    preReturnPlanList, // 预退回计划列表
    offerHallTableComp,
    upload,
    downloadFile,
    flowAuditList,
    'supplierOfferInfo-dialog': procurementSuplierOffer, // 查看供应商报价弹框
    processNodeCom, // 工作流选择节点组件
    departDialog // 选择审核人员
  },
  mixins: [commonMxin, workCommonMixins, procurementResultArr, procurementResultGroupArr, procurementGroupMixins],
  props: {
    // 业务参数
    goodsData: {
      type: Object,
      default: function() {
        return {
          tenderId: ''// 项目id
        }
      }
    },
    // 是否为详情页 true办结查看详情 false 编辑
    isDetail: {
      type: Boolean,
      default: false
    },
    // 审批标志
    auditMark: {
      type: Boolean,
      default: true
    },
    // 是否显示底部操作按钮 true显示 false 不显示
    isShowBut: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      resStyle: '00', // 按钮文字标红状态 00 普通 01 标红
      flowStatus: this.$route.query.flowStatus, // true 工作流进入编辑
      projectData: {}, // 项目基本信息
      tabsActiveValue: '00', // tab页默认选中状态
      processDefinitionKey: '', // 工作流节点key
      confirmLoading: false, // 提交loding
      isOTO: false, // 是否线上线下 线下true 线上 false
      status: '', // 从明细切换到汇总列表标识 01切换 null/00 等代表其他
      /* 表格组件需要的参数-start */
      // 表格组件数据
      tableData: {
        tableData: [], // 供应商信息
        tableList: [], // 行项目信息
        key: '' // 动态的key值
      },
      // 退回附件信息
      backFileData: {
        bizId: '',
        fileType: 'winning_result_return_reason_file'
      },
      rules: {
        returnReason: [{ required: true, validator: characters1_auto, trigger: 'blur' }] // 审批意见
      },
      resultTabList: [], // 采购结果列表
      activeValue: '', // 当前索引
      // 表格其他参数
      resultData: {
        tableIsEdit: false, // 表头是否可编辑 false 可以编辑 true 不可以编辑
        isEdit: true, // 页面是否可编辑 布尔值 根据采购列表判断 01 true 可编辑 03 不可编辑
        auditStatus: '', // 审核状态  null 未提交 00 已提交  01审核通过   02审核驳回
        reviewMethod: '', // 评审办法 00 综合 01 最低
        remark: '', // 备注
        isShowBeChosen: true,
        isShowReview: false // 是否显示供应商评审字段 00不显示 01显示 布尔值
      },
      // 释放说明参数
      relesaeData: {
        ids: '', // 表格行项目物资id集合
        tenderId: '', // 项目id
        reason: '' // 释放说明
      },
      /* 表格组件需要的参数-end */
      // 供应商报价单查看弹框
      supplierOfferDialog: {
        dialog: false,
        stageId: '', // 轮次id
        packId: '', // 标段id
        supplierId: '' // 供应商id
      },
      // 获取评审办法和币种
      labelInfo: {
        reviewMethod: '', // 评审办法 00综合 02 最低
        currency: '', // 币种
        line: '' // 评审方式 00 线下 01 线上
      },
      // 提交采购结果
      fromData: {
        status: '', // 提交01 保存00
        packId: '', // 标段id
        stageId: '', // 阶段id
        reviewMethod: '', // 评审方式
        remark: '', // 中选备注
        returnReason: '' // 退回原因
      },
      selectedSupplierInfo: {}, // 中选供应商信息
      principalList: [], // 其他传附件列表
      resultReviewReport: [], // 说明文件列表
      evaluationReviewReport: [], // 说明文件列表
      returnSubjectMatterList: [], // 预退回计划列表
      hallList: [], // 行项目信息
      winResultId: '', // 中选结果id
      // 采购单信息
      purchaseOrderInfo: {
        tenderName: '',
        tenderNo: '',
        sourcingUserRealName: '',
        quoteEndTime: ''
      },
      // 查看报价记录弹框
      offerSupplierRecord: {
        stageId: '', // 当前项目的轮次id
        dialog: false
      }
    }
  },
  created() {
    // 获取项目id
    const tenderId = this.goodsData.tenderId
    if (tenderId) {
      // 获取采购项目信息
      this.getProjectBase(tenderId)
    }
    this.procurementResultAudit() // 提交中选工作流配置
    // 查询项目规则数据字典
    this.initqueryProcurementProjectRuleInitInfo()
    this.processDefinitionKey = workconstant.winningResultConfirm // 工作流流程key
  },
  methods: {
    filterDictText,
    // 查看报价记录按钮
    recordLook() {
      this.offerSupplierRecord.dialog = true
    },
    // 获取采购项目信息
    getProjectBase(tenderId) {
      queryBaseProcurementProjectInfo({ tenderId: tenderId }).then(res => {
        this.projectData = res.data // 获取项目信息 后续接口入参需要
        // 初始化请求数据
        this.getDistinguishBetween()
      })
    },
    /*
    获取物资分配页面轮次id评审方式
    入参： packId项目标段id
  */
    getDistinguishBetween() {
      const packId = this.projectData.packId
      distinguishBetween(packId).then(res => {
        // line 00快速 01标准
        if (res.data.line === '00') {
          // 是否显示手动上传说明文件true是 false不是
          this.isOTO = true
        } else {
          // 标准的调用查看评审状态请求
          this.getqryEvalProjectFinishStatusType(packId)
        }
        this.fromData.stageId = res.data.stageList[0].id // 获取最后一轮报价的轮次id
        // 当前轮次stageId
        this.offerSupplierRecord.stageId = this.fromData.stageId
        // 获取采购结果列表接口
        this.queryResultVersionList()
        const params = {
          stageId: this.offerSupplierRecord.stageId
        }
        checkOfferRecord(params).then(({ data }) => {
          this.resStyle = data
        })
      }).catch(() => {
      })
    },
    /*
      获取采购结果列表页
      入参： packId项目标段id stageId 项目当前轮次id tenderId 项目id tenderNo 项目编号 tenderName 项目名称
       */
    queryResultVersionList() {
      const data = {
        packId: this.projectData.packId,
        stageId: this.fromData.stageId,
        tenderId: this.projectData.id,
        tenderNo: this.projectData.tenderNo,
        tenderName: this.projectData.tenderName
      }
      queryResultVersionList(data).then(respose => {
        const resultTabList = respose.data
        this.resultTabList = resultTabList.map((tabItem, index) => {
          // 默认最后一轮高亮
          this.activeValue = tabItem.versionId
          // 表格数据是否可编辑
          this.resultData.isEdit = tabItem.useStatus === '01'
          return {
            ...tabItem,
            version: tabItem.version.toString(),
            versionName: '版本' + tabItem.version.toString()
          }
        })
        // 查询页面信息 获取最后一轮的versionId
        this.goOfferHall(this.resultTabList[this.resultTabList.length - 1].versionId)
      })
    },
    /*
        获取物资分配页面请求
        入参：versionId 列表的versionID
      */
    goOfferHall(versionId) {
      let offerId = ''
      if (this.selectedSupplierInfo && this.selectedSupplierInfo.supplierRadio) {
        offerId = this.selectedSupplierInfo.id
      }
      const data = {
        status: this.status,
        offerId: offerId,
        packId: this.projectData.packId,
        stageId: this.fromData.stageId,
        versionId: versionId,
        subjectMatterIds: this.relesaeData.ids || ''
      }
      queryMinimumTransactionPriceWinningResultInfo(data).then(res => {
        const {
          data: { offerList, returnSubjectMatterList }, remark, winResultId, auditStatus, reviewMethod,
          currency, line, tenderName, tenderNo, sourcingUserRealName, quoteEndTime, isShow, budgetTotalMoney, offerNum,
          tenderCreateTime, timeInfo: { packAssignTime, packAuditPassTime }, lastBulletinInfo: { packAssignTime: lastAssignTime, packAuditPassTime: lastAuditPassTime },
          workingDay,
          returnReason
        } = res.data
        this.fromData.returnReason = returnReason // 退回原因
        // auditStatus 00待审核 01审核通过 02驳回
        if (this.isDetail) {
          this.resultData.isEdit = false
        } else {
          this.resultData.isEdit = auditStatus === '02' || auditStatus === null // 表格组件是否可编辑 true 可编辑 false 不可编辑
        }
        this.resultData.auditStatus = auditStatus // 审核字段 null 未提交 00 已提交  01审核通过   02审核驳回 03变更中选
        this.resultData.isShowReview = isShow === '01' // 供应商信息列表是否展示评标价 基准价 评审得分字段  00不展示 01展示
        this.fromData.remark = remark// 备注
        this.fromData.reviewMethod = reviewMethod// 评审办法
        // 采购单信息
        this.purchaseOrderInfo = Object.assign(this.purchaseOrderInfo, {
          tenderName,
          tenderNo,
          sourcingUserRealName,
          quoteEndTime,
          budgetTotalMoney,
          offerNum,
          tenderCreateTime,
          packAssignTime,
          packAuditPassTime,
          lastAssignTime,
          lastAuditPassTime,
          workingDay
        })
        // 采购结果id
        if (winResultId) {
          this.procurementResultFile.bizId = winResultId// 采购结果id及附件主键id
          this.procurementResultReviewReport.bizId = winResultId // 说明文件主键id
          this.backFileData.bizId = winResultId // 退回附件id
        }
        this.winResultId = winResultId // 业务id
        this.labelInfo.reviewMethod = reviewMethod // 评审办法 00 综合 01最低
        this.labelInfo.currency = currency // 币种 00 人命币 01 欧元 02 美元
        this.labelInfo.line = line // 评审方式 00 线下 01 线上
        if (returnSubjectMatterList && returnSubjectMatterList.length > 0) {
          this.returnSubjectMatterList = returnSubjectMatterList
          const data = []
          this.returnSubjectMatterList.map((item) => {
            data.push(item.id)
          })
          // 选择的行项目id集合
          const materialsIds = data.toString()
          this.relesaeData.ids = materialsIds
        } else {
          this.returnSubjectMatterList = []
        }
        if (offerList) {
          this.tableData = {
            tableData: offerList, // 供应商信息
            tableList: this.hallList, // 行项目信息
            key: new Date() * 1
          }
        }
        this.queryWinningResultDetailList(offerList)
        // this.$forceUpdate()
      })
    },
    // 最低成交价法(行项目报价明细)
    queryWinningResultDetailList(offerListResultInfo) {
      const data = {
        packId: this.projectData.packId,
        stageId: this.fromData.stageId,
        subjectMatterIds: this.relesaeData.ids || ''
      }
      queryMinimumTransactionPriceWinningResultDetailList(data).then(res => {
        const { offerList, hallList } = res.data
        this.hallList = hallList
        this.tableData = {
          tableList: hallList, // 行项目信息
          tableData: offerListResultInfo || offerList, // 汇总有值传汇总接口返回的否则取明细供应商信息
          key: new Date() * 1
        }
      }).catch(() => {
      })
    },
    // -----------采购单表格组件-方法-Start-----------
    // 供应商-采购单点击事件 supplier 供应商报价信息
    offerSingleClick(supplier) {
      this.supplierOfferDialog.stageId = supplier.stageId // 轮次id
      this.supplierOfferDialog.packId = supplier.packId // 项目标段id
      this.supplierOfferDialog.supplierId = supplier.supplierId // 项目标段id
      this.supplierOfferDialog.dialog = true
    },
    // 采购单表格选择行项目释放复选框回调
    materialsChange(lineItemIds) {
      // 获取选中的行项目id集合
      this.relesaeData.ids = lineItemIds
      // this.goOfferHall(this.resultTabList[this.resultTabList.length - 1].versionId)
    },
    // -----------采购单表格组件-方法-End-----------
    // 上一步
    resultPrev() {
      this.$router.push({ path: '/procurement/procurementDrive/offerResultContent/confirmConclude-add' })
    },
    // 提交中选参数
    getParamsData() {
      let offerId = ''
      if (this.selectedSupplierInfo && this.selectedSupplierInfo.supplierRadio) {
        offerId = this.selectedSupplierInfo.id
      }
      // this.processInitDto.type = '01' // 01：初次提交 02：审核驳回再次提交
      const data = {
        ...this.fromData, // 获取中选备注和项目信息
        offerId: offerId,
        tenderId: this.projectData.id, // 项目id
        packId: this.projectData.packId, // 标段id
        subjectMatterIds: this.relesaeData.ids
        // processInitDto: this.processInitDto // 审核人信息传回得信息
      }
      // 判断是否进入工作流
      if (this.procurementResultAuditConfig) {
        data.processInitDto = this.processInitDto // 审核人信息传回得信息
      }
      return data
    },
    // 保存
    onSave() {
      const params = {
        ...this.getParamsData()
      }
      params.status = '00'
      this.setSaveMinimumTransactionPrice(params)
    },
    // 校验退回原因
    validateFormReturnReason() {
      // 预退回计划 校验退回原因
      let validate = true
      if (this.returnSubjectMatterList.length > 0) {
        this.$refs['form'].validate((valid) => {
          if (valid) {
            validate = true
          } else {
            validate = false
            this.$message.warning('请注意页面提示！')
          }
        })
      }
      return validate
    },
    // 提交采购结果按钮
    submit() {
      // 采购中选结果，说明文件字段改为必填项 线下验证必填
      if (this.resultReviewReport.length < 1 && this.isOTO) {
        this.$message.warning('请上传说明文件')
        return false
      }
      if (!this.validateFormReturnReason()) {
        return
      }
      // 校验每行是否有选中的供应商 最少一家
      if (this.selectedSupplierInfo && this.selectedSupplierInfo.supplierRadio) {
        this.$confirm('确认提交中选审核吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          // 判断是否进入工作流
          if (this.procurementResultAuditConfig) {
            // 判断审核人员是否是多个
            if (JSON.stringify(this.processNode) !== '{}' && this.processNode.nodeId) {
              this.$refs.departDialog.getUserDepart(this.processNode)
            }
          } else {
            // 直接提交
            this.subFlow()
          }
        })
      } else {
        // 一家也未选中不得提交
        this.$alert('供应商未选中请检查', '提示', {
          type: 'warning',
          confirmButtonText: '确定'
        })
      }
    },
    // 按条目自动选择最低报价
    selectLowestPrice() {
      this.$refs.resultTableComp.selectLowestPrice()// 表格组件组-按条目自动选择最低报价
    },
    /* 导出比价分析表/打应供应商报价
      type 00导出比价分析表 01打应供应商报价
      */
    exportFile(type) {
      this.confirmLoading = true
      const { offerIds } = this.$refs.supplierInfo.getExportSupplier()// 获取已选的供应商信息
      if (offerIds.length > 0) {
        if (type === '00') {
          // 导出比价分析表
          this.exportPriceParityTable(offerIds)
          return
        }
        // 打应供应商报价
        this.exportSupplierOffer(offerIds)
        return
      }
      // 一家也未选中不得提交
      this.$alert('至少有一家供应商选中才可导出', '提示', {
        type: 'warning',
        confirmButtonText: '确定'
      })
      this.confirmLoading = false
    },
    // 说明文件
    resultReviewReportChange(file, fileList) {
      this.resultReviewReport = fileList
    },
    // 其他附件上传
    principalFile(file, fileList) {
      this.principalList = fileList
    },
    /*
      * 导出比价分析表
      * 入参: packId 项目标段id stageId 项目轮次id offerIds 供应商报价id集合
      * */
    exportPriceParityTable(offerIds) {
      const data = {
        packId: this.projectData.packId,
        stageId: this.fromData.stageId,
        offerIds: offerIds.join(',')
      }
      exportPriceComparisonAnalysisTable(data).then(res => {
        download(res, '【' + this.projectData.tenderName + '，' + this.projectData.tenderNo + '】比价分析表.xls')
        this.confirmLoading = false
      })
    },
    /*
    * 打印供应商报价信息
    * 入参:  stageId 项目轮次id, columnsSupplierNum:下载pdf参数  offerIds 供应商报价id集合
    * */
    exportSupplierOffer(offerIds) {
      // 获取项目名称
      const data = {
        stageId: this.fromData.stageId, // 轮次id
        subjectMatterIds: this.relesaeData.ids || '', // 退回的行项目ids 如果有退回需传入/无可以为空
        offerIds: offerIds.join(',') // 需要打印的供应商报价ids
      }
      printSupplierOfferNew(data).then(res => {
        // 调用下载文件方法
        download(res, '【' + this.projectData.tenderName + '】报价文件.pdf')
        this.confirmLoading = false
      }).catch(() => {
        this.confirmLoading = false
      })
    },
    // 保存中选审核信息
    setSaveMinimumTransactionPrice(data) {
      this.confirmLoading = true
      saveMinimumTransactionPrice(data).then(res => {
        this.$message({ type: 'success', message: '操作成功' })
        this.confirmLoading = false
        // 工作流驳回提交后退出 否则是驱动刷新页面
        if (this.flowStatus) {
          this.handleCancel()
        } else {
          this.queryResultVersionList()
        }
      }).catch(() => {
        // 提交失败
        this.confirmLoading = false
      })
    },
    // 工作流提交
    subFlow() {
      this.setSaveMinimumTransactionPrice(this.getParamsData())
    },
    // 提交后退出页面
    handleCancel() {
      const routePathStatus = sessionStorage.getItem('routePathStatus') // 工作流处理 00桌面进入 01待办列表进入
      let path = ''
      // 桌面进入
      if (routePathStatus === '00') {
        path = '/home'
      }
      // 待办进入
      if (routePathStatus === '01') {
        path = '/work/todo'
      }
      this.$router.push({
        path: path
      })
    },
    /*
       评标完成根据评标结果区分说明文件的显示
        终止评审的 说明文件有项目经理手动上传
        正常结束的调用查看评审列表的请求
      */
    getqryEvalProjectFinishStatusType(packId) {
      qryEvalProjectFinishStatusType(packId).then(res => {
        // finishEvalType 结束评标方式 00-终止(跳转物资分配页面) 01-废标(不开启中选结果节点) 02-正常结束(跳转确定成交人) 03-未结束(不开启中选结果节点)
        const { finishEvalType } = res.data
        if (finishEvalType === '02') {
          this.isOTO = false
          this.getQryProcurementEvalReportList(packId)
          return
        }
        // 00 终止情况下有项目经理手动上传说明文件
        this.isOTO = true
      })
    },
    /*
       查看评审报表请求
      */
    getQryProcurementEvalReportList(packId) {
      qryProcurementEvalReportList(packId).then(res => {
        const tableData = cloneObject(res.data)
        /* 循环数组信息进行合并*/
        tableData.forEach((item, index) => {
          this.getFile(item, index)// 获取附件信息
        })
      })
    },
    /*
      * 获取附件信息
      * item 每条文件信息
      * index 每条文件信息的索引
      * */
    getFile(item, index) {
      /* 说明文件文件*/
      const reViewFileData = {
        fileType: item.cgFormField, // 文件类型
        bizId: item.cgFormId // 文件Id
      }
      item.resultFileData = cloneObject(reViewFileData)
      this.$set(this.evaluationReviewReport, index, item)
    },
    // 中选供应商信息
    supplierRadioInfo(data) {
      this.selectedSupplierInfo = data
    },
    // 中选汇总/明细切换
    handleClick(val) {
      if (val.name === '00') {
        this.status = '01'
      } else {
        this.status = null
      }
      this.goOfferHall(this.resultTabList[this.resultTabList.length - 1].versionId)
    }
  }
}
</script>

<style lang="less" scoped>
    // 申报图片
    .procurement_auditStatus {
        position: absolute;
        top: -22px;
        right: 60px;
      z-index: 99;
    }
</style>
