<!--
  @description: 开标大厅-开标中（不分包，非宫格图）{集中解密，非集中解密公用} 需要引用packageBidderInfo.vue子页面
  @Modifier: haoFx
  @routerPath:/bidding/projectDrive/bidOpening/noPackageBidOpeningDecryptionRedis
  @date: 2020/4/2-18:11
-->
<template>
  <div>
    <div class="open-info">
      <el-row type="flex" class="row-bg">
        <!-- 左边小屏幕 -->
        <el-col :span="5" class="left-center-left">
          <div class="openInfo-left">
            <p>当前时间</p>
            <span>
              {{ presentTime?presentTime: sysCurrentTime }}
            </span>
          </div>
        </el-col>
        <!-- 大屏幕 -->
        <el-col :span="14" class="left-center-right">
          <div class="bg-purple-light">
            <div class="open_type_title">
              {{ openStageTypeTitle }}
            </div>
            <!--标段投标人信息-->
            <packageBidderInfo ref="packageBidderInfo" />
          </div>
        </el-col>
        <!-- 右边小屏幕 -->
        <el-col :span="5" class="right-center-right">
          <div class="openInfo-right">
            <p>开标时间</p>
            <span>
              {{ todayOpeningInfo.openBidStartTime && $Moment(todayOpeningInfo.openBidStartTime).format(momentDateTime) }}
            </span>
          </div>
        </el-col>
      </el-row>
      <!--底部信息-->
      <div class="footer_bottom_wrap clearfix">
        <!--<div class="mask">
          <el-scrollbar class="mask_scrollbar scrollbar">
            <ul>
              <li v-for="(item,index) in openingInfo" :key="index" >
                【 {{ item.supplierName }}】
                【 {{ item.info }}】
                【 {{ item.time }}】
              </li>
            </ul>
          </el-scrollbar>
        </div>-->
        <!--更多操作-->
        <template v-if="todayOpeningInfo.bidDocumentDecryptionMethod==='01'">
          <el-dropdown trigger="click" class="more-dropdown" @command="handleCommand">
            <el-button type="primary" @click="moreOperation">
              更多操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item :disabled="refreshDisabled" command="00">
                刷新
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
        <!--启动视频会议-->
        <template v-if="tenderOpenVideoConferenceDisplay==='01'">
          <el-button
            type="primary"
            icon="iconfont icon-shipinhuiyi"
            @click="startVideoConferencing"
          >
            启动视频会议
          </el-button>
          <!--启动视频会议-->
          <el-button
            type="primary"
            icon="iconfont icon-yaoqing"
            @click="videoConferenceInvitation"
          >
            会议邀请
          </el-button>
        </template>
        <!--投标人解密显示 服务端集中解密不显示 发送消息-->
        <el-button
          v-if="todayOpeningInfo.bidDocumentDecryptionMethod ==='00'"
          type="primary"
          icon="iconfont icon-xiaoxi"
          @click="sendMsg"
        >
          发送消息
        </el-button>
        <el-button
          type="primary"
          icon="iconfont icon-xuanzhongshangcheng"
          @click="backHome"
        >
          返回主页
        </el-button>
      </div>
      <!-- 监标人-图片-->
      <div class="bidTenderSupervisor" />
    </div>
    <!--通知消息组件-->
    <msg-writer ref="msgWriter" />
    <!--视频会议邀请投标人-->
    <supplierVideoConferenceDialog ref="supplierVideoConference" />
  </div>
</template>

<script>
/* api*/
import { managerOpenFSMeetingRoom, startFocusBidOpening } from '@api/bidding/bidOpening'
/* 组件*/
import packageBidderInfo from './packageBidderInfoRedis'
import msgWriter from '../msgWriterCom/msgWriter'
import supplierVideoConferenceDialog from '../supplierVideoConference/supplierVideoConference-dialog' // 邀请投标人参与视频会议
/* 公共方法*/
import { bidOpeningMixin } from '../mixins/bidOpeningMixin'

export default {
  name: 'NoPackageClientDecryption',
  components: {
    packageBidderInfo, // 开标大厅-开标中-不分包子页面）
    'msg-writer': msgWriter, // 发送消息组件
    supplierVideoConferenceDialog // 邀请投标人参与视频会议
  },
  mixins: [bidOpeningMixin],
  data() {
    return {
      // 开标信息
      openingInfo: []
    }
  },
  mounted() {
    // 视频会议是否显示: 00 不显示 01 显示
    this.getReSingingButtonDisplay()
    // 不分包进入页面初始化组件投标人信息
    this.$nextTick(function() {
      this.$refs.packageBidderInfo.openPackage()
    })
    // 初始化获取系统当前时间
    this.getCurrentTime('setIntervalTime')
    this.$store.dispatch('setIsTool')// 获取是否是使用工具端访问
  },
  beforeDestroy() {
    clearTimeout(this.refreshDisabledTime)
  },
  methods: {
    // 返回主页
    backHome() {
      const path = this.todayOpeningInfo.path ? this.todayOpeningInfo.path : '/bidOpeningHallRedis/bidOpeningTodayList'
      // 判断是否是工具登陆 isTool true工具 false正常浏览器
      // 如果是工具端返回主页则需要调用工具端方法
      console.log(this.$store.state.app.isTool)
      if (this.$store.state.app.isTool) {
        // 调用工具端返回方法
        window.WebKitAppObj.returnBidOpeningHall()
      } else {
        // 驱动进入
        if (this.todayOpeningInfo.path) {
          sessionStorage.setItem('isShowOneStepsBidOpening', '00') // 驱动进入返回显示‘进入开标大厅按钮’
        }
        this.$router.push({
          path: path,
          query: {
            ...this.$route.query
          }
        })
        // 离开开标大厅页面清除-session存储信息
        sessionStorage.removeItem('todayOpeningInfo')
      }
    },
    // 发送消息
    sendMsg() {
      this.$refs.msgWriter.openMsgDialog()
    },
    // 启动视频会议
    startVideoConferencing() {
      managerOpenFSMeetingRoom(this.openTypeStageIds).then(res => {
        window.open(res.data.visitUrl, '_self')
      }).catch(() => {
      })
    },
    // 视频会议邀请
    videoConferenceInvitation() {
      this.$refs.supplierVideoConference.openDialogSupplierVideoConference(this.openTypeStageIds)
    },
    // 点击更多操作
    moreOperation() {
      const bidderDecryptionInfoSum = this.$refs.packageBidderInfo.bidderDecryptionInfo // 子组件有效投标数，已签到，已解密数，解密失败数
      const sumDecryptionNum = bidderDecryptionInfoSum.decryptionNumber // 解密数
      const sumValidDecryptNum = bidderDecryptionInfoSum.validDecryptNumber // 可解密
      // 解密总数 === 可解密 则不可刷新 否则可以点击刷新
      if (sumDecryptionNum === sumValidDecryptNum) {
        this.refreshDisabled = true
      }
    },
    // 点击菜单项后会触发事件（刷新00）
    handleCommand(command) {
      if (command === '00') {
        // 刷新调用的集中解密方法
        this.refreshDecryption()
        this.refreshDisabled = true
        const that = this
        this.refreshDisabledTime = setTimeout(() => {
          that.refreshDisabled = false
        }, this.millisec)
        // this.millisec 定时器时间变量
      }
    },
    // 刷新调用的集中解密方法
    refreshDecryption() {
      const data = {
        stageIds: this.openTypeStageIds.stageIds,
        openStageType: this.openTypeStageIds.openStageType,
        openBidStartTime: this.openTypeStageIds.openBidStartTime
      }
      startFocusBidOpening(data).then(() => {
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped lang="less">
  @import "../index";
  .open_type_title{
    background-color: #2B59C6;
    padding-left: 15px;
    line-height: 25px;
    color: #fff;
  }
</style>
