<template>
  <div class="spectrum-analysis">
    <!-- 顶部操作栏 -->
    <div class="spectrum-analysis-operators">
      <template v-for="operation in operations">
        <a-dropdown
          v-if="operation.show !== false"
          class="spectrum-analysis-operators-item"
          overlayClassName="spectrum-analysis-operators-dropdown-overlay"
          :overlay-style="operation.style"
          :key="operation.title"
        >
          <a-button type="primary">{{ operation.title }}</a-button>
          <div slot="overlay">
            <template v-for="(child, index) in operation.children">
              <component :is="child.type" :key="index" v-bind="child.attrs" v-on="child.on">
                <template v-for="item in child.children">
                  <component v-if="item.show !== false" :is="item.type" :key="item.title" @click="item.handler">
                    {{ item.title }}
                  </component>
                </template>
              </component>
            </template>
          </div>
        </a-dropdown>
      </template>
    </div>
    <!-- 顶部操作栏结束 -->

    <!-- 频谱分析部分 -->
    <div class="spectrum-analysis-main">
      <!-- Gamma 分析 -->
      <gamma-analysis v-if="isGamma" ref="gammaAnalysisRef" :sample="sampleData" />
      <!-- Gamma 分析 -->

      <!-- Beta-Gamma 分析 -->
      <beta-gamma-analysis v-else-if="isBetaGamma" ref="betaGammaAnalysisRef" :sample="sampleData" />
      <!-- Beta-Gamma 分析 -->
      <div v-else class="empty">
        Please Select a Sample
      </div>
      <resize-observer @notify="handleResize" />
    </div>
    <!-- 频谱分析部分结束 -->

    <!-- 从数据库加载开始 -->
    <load-from-db-modal v-model="loadFromDbModalVisible" @loadSample="handleLoadSampleFromDB" />
    <!-- 从数据库加载结束 -->

    <!-- 从文件加载开始 -->
    <load-from-file-modal v-model="loadFromFileModalVisible" />
    <!-- 从文件加载结束 -->

    <!-- Strip 弹窗开始 -->
    <strip-modal v-model="stripModalVisible" />
    <!-- Strip 弹窗结束 -->

    <!-- Ftransit 弹窗开始 -->
    <ftranslt-modal v-model="ftransltModalVisible" />
    <!-- Ftransit 弹窗结束 -->

    <!-- Peak Infomation 弹窗开始 -->
    <peak-infomation v-model="peakInfomationModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Peak Infomation 弹窗结束 -->

    <!-- Nuclide Activity and MDC 弹窗开始 -->
    <nuclide-activity-and-mdc-modal v-model="nuclideActivityAndMDCModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Nuclide Activity and MDC 弹窗结束 -->

    <!-- Save Setting 弹窗开始 -->
    <save-setting-modal v-model="saveSettingModalVisible" />
    <!-- Save Setting 弹窗结束 -->

    <!-- 分析-设置弹窗开始 -->
    <analyze-setting-modal v-model="analyzeConfigureModalVisible" :sampleId="sampleData.sampleId" />
    <!-- 分析-设置弹窗结束 -->

    <!-- 分析工具弹窗开始 -->
    <analyze-interactive-tool-modal v-model="analyzeInteractiveToolModalVisible" :sampleId="sampleData.sampleId" />
    <!-- 分析工具弹窗结束 -->

    <!-- Korsum 弹窗开始 -->
    <korsum-modal v-model="korsumModalShow" />
    <!-- Korsum 弹窗结束 -->

    <!-- ReProcessing 弹窗开始 -->
    <re-processing-modal v-model="reprocessingModalVisible" />
    <!-- ReProcessing 弹窗结束 -->

    <!-- Zero Time 弹窗开始 -->
    <zero-time-modal v-model="zeroTimeModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Zero Time 弹窗结束 -->

    <!-- Efficiency Calibration 弹窗开始 -->
    <efficiency-calibration-modal v-model="efficiencyCalibrationModalShow" />
    <!-- Efficiency Calibration 弹窗结束 -->

    <!-- Energy Calibration 弹窗开始 -->
    <energy-calibration-modal v-model="energyCalibrationModalShow" :sampleId="sampleData.sampleId" />
    <!-- Energy Calibration 弹窗结束 -->

    <!-- Resolution Calibration 弹窗开始 -->
    <resolution-calibration-modal v-model="resolutionCalibrationModalShow" />
    <!-- Resolution Calibration 弹窗结束 -->

    <!-- SpectrumComments 弹窗开始 -->
    <spectrum-comments-modal
      v-model="gammaCommentsModalVisible"
      :isAdd="isGammaCommentsAdd"
      :sampleId="sampleData.sampleId"
    />
    <!-- SpectrumComments 弹窗结束 -->

    <!-- Color Config 弹窗开始 -->
    <color-config-modal v-model="colorConfigModalVisible" />
    <!-- Color Config 弹窗结束 -->

    <!-- Data Processing Log 弹窗开始 -->
    <data-processing-log-modal v-model="dataProcessingLogModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Data Processing Log 弹窗结束 -->

    <!-- Config User Library 弹窗开始 -->
    <config-user-library-modal v-model="configUserLibModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Config User Library 弹窗结束 -->

    <!-- Nuclide Library 弹窗开始 -->
    <nuclide-library-modal v-model="nuclideLibraryModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Nuclide Library 弹窗结束 -->

    <!-- Arr 和 RRR 弹窗开始 -->
    <arr-rrr-modal
      v-model="arrOrRRRModalVisible"
      :type="arrOrRRRModalType"
      :sampleId="this.sampleData.sampleId"
      :extraData="this.arrOrRRRModalExtraData"
    />
    <!-- Arr 弹窗结束 -->

    <!-- Spectrum 弹窗开始 -->
    <spectrum-modal v-model="spectrumModalVisible" :sampleId="this.sampleData.sampleId" />
    <!-- Spectrum 弹窗结束 -->

    <!-- SampleInfo 弹窗开始 -->
    <sample-infomation-modal v-model="sampleInfomationModalVisible" :sampleId="sampleData.sampleId" />
    <!-- SampleInfo 弹窗结束 -->

    <!-- Qc Results 弹窗开始 -->
    <qc-results-modal v-model="qcResultsModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Qc Results 弹窗结束 -->

    <!-- RLR 弹窗开始 -->
    <rlr-modal v-model="rlrModalVisible"  :sampleId="sampleData.sampleId" />
    <!-- RLR 弹窗结束 -->

    <automatic-analysis-log-modal v-model="autoAnalysisMogModalVisible" />

    <!-- Beta-Gamma 的Comments 弹窗 -->
    <beta-gamma-comments-modal
      v-model="betaGammaCommentsModalVisible"
      :isAdd="isBetaGammaCommentsAdd"
      :sampleId="this.sampleData.sampleId"
    />
    <!-- Beta-Gamma 的Comments 结束 -->

    <!-- Beta-Gamma 的Energy Calibration开始 -->
    <beta-gamma-energy-calibration-modal
      v-model="betaGammaEnergyCalibrationModalVisible"
      :sampleId="this.sampleData.sampleId"
    />
    <!-- Beta-Gamma 的Energy Calibration结束 -->

    <!-- Beta-Gamma 的 Extrapolation 弹窗开始 -->
    <beta-gamma-extrapolation-modal v-model="betaGammaExtrapolationModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Beta-Gamma 的 Extrapolation 弹窗结束 -->

    <!-- Beta-Gamma 的 Spectrum 弹窗 -->
    <beta-gamma-spectrum-modal v-model="betaGammaSpectrumModalVisible" :sampleId="this.sampleData.sampleId" />
    <!-- Beta-Gamma 的 Spectrum 弹窗 结束 -->

    <!-- Beta-Gamma 的 Sample Infomation 弹窗 -->
    <beta-gamma-sample-infomation-modal
      v-model="betaGammaSampleInfomationModalVisible"
      :sampleId="this.sampleData.sampleId"
    />
    <!-- Beta-Gamma 的 Sample Infomation 弹窗 结束 -->

    <!-- Beta-Gamma 的 QC Result 弹窗 -->
    <beta-gamma-qc-results-modal v-model="betaGammaQCResultsModalVisible" :sampleId="this.sampleData.sampleId" />
    <!-- Beta-Gamma 的 QC Result 弹窗 结束 -->

    <!-- Beta-Gamma 的 RLR 弹窗 -->
    <beta-gamma-rlr-modal v-model="betaGammaRlrModalVisible" :sampleId="sampleData.sampleId" />
    <!-- Beta-Gamma 的 RLR 弹窗 结束 -->

    <!-- Beta-Gamma 的 Statistics Paramer History 弹窗 -->
    <statistics-paramer-history-modal
      v-model="statisticsParamerHistoryModalVisible"
      :sampleId="this.sampleData.sampleId"
    />
    <!-- Beta-Gamma 的 Statistics Paramer History 弹窗 结束 -->
  </div>
</template>
<script>
import GammaAnalysis from './gamma-analysis.vue'
import BetaGammaAnalysis from './beta-gamma-analysis.vue'
import SpectraListInMenu from './components/SpectraListInMenu.vue'
import LoadFromDbModal from './components/Modals/LoadFromDBModal.vue'
import LoadFromFileModal from './components/Modals/LoadFromFileModal.vue'
import PeakInfomation from './components/PeakInfomation.vue'
import NuclideActivityAndMdcModal from './components/Modals/NuclideActivityAndMDCModal.vue'
import MultiLevelMenu from './components/MultiLevelMenu.vue'
import SaveSettingModal from './components/Modals/SaveSettingModal.vue'
import AnalyzeSettingModal from './components/Modals/AnalyzeSettingModal.vue'
import AnalyzeInteractiveToolModal from './components/Modals/AnalyzeInteractiveToolModal/index.vue'
import KorsumModal from './components/Modals/KorsumModal.vue'
import ReProcessingModal from './components/Modals/ReProcessingModal/index.vue'
import ZeroTimeModal from './components/Modals/ZeroTimeModal.vue'
import EfficiencyCalibrationModal from './components/Modals/EfficiencyCalibrationModal.vue'
import EnergyCalibrationModal from './components/Modals/EnergyCalibrationModal.vue'
import ResolutionCalibrationModal from './components/Modals/ResolutionCalibrationModal.vue'
import SpectrumCommentsModal from './components/Modals/SpectrumCommentsModal.vue'
import ColorConfigModal from './components/Modals/ColorConfigModal.vue'
import DataProcessingLogModal from './components/Modals/DataProcessingLogModal.vue'
import ConfigUserLibraryModal from './components/Modals/ConfigUserLibraryModal.vue'
import NuclideLibraryModal from './components/Modals/NuclideLibraryModal.vue'
import ArrRrrModal from './components/Modals/ArrRrrModal.vue'
import SpectrumModal from './components/Modals/SpectrumModal.vue'
import SampleInfomationModal from './components/Modals/SampleInfomationModal.vue'
import QcResultsModal from './components/Modals/QcResultsModal.vue'
import RlrModal from './components/Modals/RLRModal/index.vue'
import BetaGammaCommentsModal from './components/Modals/BetaGammaModals/BetaGammaCommentsModal.vue'
import BetaGammaSpectrumModal from './components/Modals/BetaGammaModals/BetaGammaSpectrumModal.vue'
import BetaGammaSampleInfomationModal from './components/Modals/BetaGammaModals/BetaGammaSampleInfomationModal.vue'
import BetaGammaQcResultsModal from './components/Modals/BetaGammaModals/BetaGammaQCResultsModal.vue'
import BetaGammaRlrModal from './components/Modals/BetaGammaModals/BetaGammaRLRModal/index.vue'
import StatisticsParamerHistoryModal from './components/Modals/BetaGammaModals/StatisticsParamerHistoryModal.vue'
import FtransltModal from './components/Modals/FtransltModal/index.vue'
import BetaGammaEnergyCalibrationModal from './components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/index.vue'
import StripModal from './components/Modals/StripModal.vue'
import AutomaticAnalysisLogModal from './components/Modals/BetaGammaModals/AutomaticAnalysisLogModal.vue'
import BetaGammaExtrapolationModal from './components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue'

// 分析类型
const ANALYZE_TYPE = {
  GAMMA: 'gammaAnalysis',
  BETA_GAMMA: 'betaGammaAnalysis'
}
export default {
  components: {
    BetaGammaAnalysis,
    GammaAnalysis,
    SpectraListInMenu,
    LoadFromDbModal,
    LoadFromFileModal,
    PeakInfomation,
    NuclideActivityAndMdcModal,
    MultiLevelMenu,
    SaveSettingModal,
    AnalyzeSettingModal,
    AnalyzeInteractiveToolModal,
    KorsumModal,
    ReProcessingModal,
    ZeroTimeModal,
    EfficiencyCalibrationModal,
    EnergyCalibrationModal,
    ResolutionCalibrationModal,
    SpectrumCommentsModal,
    ColorConfigModal,
    DataProcessingLogModal,
    ConfigUserLibraryModal,
    NuclideLibraryModal,
    ArrRrrModal,
    SpectrumModal,
    SampleInfomationModal,
    QcResultsModal,
    RlrModal,
    BetaGammaCommentsModal,
    BetaGammaSpectrumModal,
    BetaGammaSampleInfomationModal,
    BetaGammaQcResultsModal,
    BetaGammaRlrModal,
    StatisticsParamerHistoryModal,
    FtransltModal,
    BetaGammaEnergyCalibrationModal,
    StripModal,
    AutomaticAnalysisLogModal,
    BetaGammaExtrapolationModal
  },
  data() {
    this.ANALYZE_TYPE = ANALYZE_TYPE

    return {
      analysisType: null, // 分析类型

      sampleList: [],

      loadFromDbModalVisible: false, // 从数据库加载弹窗
      loadFromFileModalVisible: false, // 从文件加载弹窗
      stripModalVisible: false, // Strip 弹窗
      ftransltModalVisible: false, // Ftransit 弹窗

      sampleData: {}, // 要分析的谱数据

      saveSettingModalVisible: false, // 保存设置弹窗

      analyzeConfigureModalVisible: false, // 分析设置弹窗
      reprocessingModalVisible: false, // 重新分析弹窗
      analyzeInteractiveToolModalVisible: false, // 分析工具弹窗
      zeroTimeModalVisible: false, // Zero Time 弹窗
      korsumModalShow: false, // Korsum 弹窗

      efficiencyCalibrationModalShow: false, // Calibration -> Efficiency 弹窗
      energyCalibrationModalShow: false, // Calibration -> Energy 弹窗
      resolutionCalibrationModalShow: false, // Calibration -> Resolution 弹窗

      gammaCommentsModalVisible: false, // Comments -> Spectrum Comments 弹窗
      isGammaCommentsAdd: true, // Spectrum Comments 是否是新增

      colorConfigModalVisible: false, // Help -> Color Config 弹窗

      dataProcessingLogModalVisible: false, // Log -> Data Processing Log 弹窗

      configUserLibModalVisible: false, // NuclideLibrary -> Config User Library 弹窗
      nuclideLibraryModalVisible: false, // NuclideLibrary -> Nuclide Library 弹窗

      peakInfomationModalVisible: false, // Reports -> PeakInfo 弹窗
      arrOrRRRModalVisible: false, // Reports -> ARR 或RRR 弹窗
      arrOrRRRModalType: 1, // Reports -> ARR 或RRR 弹窗类型
      arrOrRRRModalExtraData: {},

      nuclideActivityAndMDCModalVisible: false, // Reports -> Radionuclide Activity 弹窗
      spectrumModalVisible: false, // Reports -> Spectrum 弹窗
      sampleInfomationModalVisible: false, // Reports -> Sample Infomation 弹窗
      qcResultsModalVisible: false, // Reports -> Qc Results 弹窗
      rlrModalVisible: false, // Reports -> RLR 弹窗

      autoAnalysisMogModalVisible: false, // Log -> Automatic Analysis Log 弹窗

      /**
       *  以下是beta-gamma跟前面不同的弹窗
       **/
      betaGammaCommentsModalVisible: false, // beta-gamma Comments
      isBetaGammaCommentsAdd: false, // beta-gamma comments 是否新增

      betaGammaEnergyCalibrationModalVisible: false, // beta-gamma 的 Energy Calibration 弹窗
      betaGammaExtrapolationModalVisible: false, // beta-gamma 的 Extrapolation 弹窗

      betaGammaSpectrumModalVisible: false, // beta-gamma spectrum 弹窗
      betaGammaSampleInfomationModalVisible: false, // beta-gamma sample infomation 弹窗
      betaGammaQCResultsModalVisible: false, // beta-gamma QC Result 弹窗
      betaGammaRlrModalVisible: false, // beta-gamma RLR 弹窗
      statisticsParamerHistoryModalVisible: false // beta-gamma Statistics Paramer History 弹窗
    }
  },
  created() {
    this.$bus.$on('reanalyse', this.handleReanalyse)
    this.loadSelectedSample({
      sampleId: 426530,
      sampleType: 'G',
      dbName: 'auto'
    })
  },

  destroyed() {
    this.$bus.$off('reanalyse', this.handleReanalyse)
  },

  methods: {
    /**
     * 从数据库加载-选择完成
     * @param {any[]} sampleList
     */
    handleLoadSampleFromDB(sampleList) {
      const ids = this.sampleList.map(item => item.sampleId) // 当前Sample列表中的所有id
      const willAddList = sampleList.filter(item => !ids.includes(item.sampleId))
      this.sampleList = this.sampleList.concat(willAddList)
    },

    // 加载选中的样本
    async loadSelectedSample(sample) {
      // B是beta-gamma  P G是gamma
      if (sample.sampleType == 'B') {
        this.analysisType = ANALYZE_TYPE.BETA_GAMMA
      } else {
        this.analysisType = ANALYZE_TYPE.GAMMA
      }
      this.sampleData = sample
    },

    // 清理全部
    handleCleanAll() {
      this.sampleList = []
      this.analysisType = undefined
      this.sampleData = {}
    },

    // 保存结果到文件， 服务端生成文件，前端下载
    handleSaveResultsToFile() {
      this.saveSettingModalVisible = true
    },

    /**
     * 保存结果到数据库
     * @param { 'all' | 'current' } type
     */
    handleSaveResultsToDB(type) {
      console.log('%c [ saveResultsToDB ]-157', 'font-size:13px; background:pink; color:#bf2c9f;', type)
    },

    /**
     * 将谱列表中所有谱数据均以IMS2.0格式保存为PHD文件，
     * 服务端生成文件，前端下载
     * @param { 'all' | 'current' } type
     */
    handleSavePHDToFile(type) {
      console.log('%c [ savePHDToFile ]-162', 'font-size:13px; background:pink; color:#bf2c9f;', type)
    },

    handleReprocessAll() {
      console.log('%c [ handleReprocessAll ]-216', 'font-size:13px; background:pink; color:#bf2c9f;')
    },

    // 查看Comments
    handleViewComments() {
      // 如果是gamma
      if (this.isGamma) {
        this.gammaCommentsModalVisible = true
        this.isGammaCommentsAdd = false
      }
      // 如果是beta-gamma
      else {
        this.betaGammaCommentsModalVisible = true
        this.isBetaGammaCommentsAdd = false
      }
    },

    // 添加Comments
    handleAddComments() {
      // 如果是gamma
      if (this.isGamma) {
        this.gammaCommentsModalVisible = true
        this.isGammaCommentsAdd = true
      }
      // 如果是beta-gamma
      else {
        this.betaGammaCommentsModalVisible = true
        this.isBetaGammaCommentsAdd = true
      }
    },

    // 查看软件操作帮助文档
    handleHelp() {
      console.log('%c [ handleHelp ]-221', 'font-size:13px; background:pink; color:#bf2c9f;')
    },

    handleResize() {
      this.$refs.gammaAnalysisRef && this.$refs.gammaAnalysisRef.resize()
      this.$refs.betaGammaAnalysisRef && this.$refs.betaGammaAnalysisRef.resize()
    },

    // Beta-Gamma Energy Calibration 的重新分析
    handleReanalyse(...data) {
      this.$refs.betaGammaAnalysisRef.reanalyse(data)
    }
  },
  computed: {
    // 顶部菜单栏配置
    operations() {
      return [
        {
          title: 'SAMPLE',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Load From DB',
                  handler: () => (this.loadFromDbModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Load From File',
                  handler: () => (this.loadFromFileModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Clean All',
                  handler: this.handleCleanAll
                },
                {
                  type: 'a-menu-item',
                  title: 'Strip',
                  show: this.isGamma,
                  handler: () => (this.stripModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Ftransit',
                  show: this.isGamma,
                  handler: () => (this.ftransltModalVisible = true)
                }
              ]
            },
            {
              type: 'a-divider',
              attrs: {
                style: {
                  marginTop: '5px',
                  marginBottom: '5px',
                  display: this.sampleList.length ? '' : 'none'
                }
              }
            },
            {
              type: 'SpectraListInMenu',
              attrs: {
                list: this.sampleList
              },
              on: {
                change: spectra => {
                  if (spectra) {
                    this.loadSelectedSample(spectra)
                  } else {
                    this.analysisType = undefined
                    this.sampleData = {}
                  }
                }
              }
            }
          ]
        },
        {
          title: 'SAVE',
          children: [
            {
              type: 'MultiLevelMenu',
              attrs: {
                children: [
                  {
                    title: 'Save Results to File'
                  },
                  {
                    title: 'Save Results to DB',
                    children: [
                      {
                        title: 'Save Current',
                        key: 'current'
                      },
                      {
                        title: 'Save All',
                        key: 'all'
                      }
                    ]
                  },
                  {
                    title: 'Save PHD to File',
                    children: [
                      {
                        title: 'Save Current',
                        key: 'current'
                      },
                      {
                        title: 'Save All',
                        key: 'all'
                      }
                    ]
                  }
                ],
                width: '170px'
              },
              on: {
                menuClick: () => {
                  this.handleSaveResultsToFile()
                },
                submenuClick: ({ item, child }) => {
                  if (item.title == 'Save Results to DB') {
                    this.handleSaveResultsToDB(child.key)
                  } else if (item.title == 'Save PHD to File') {
                    this.handleSavePHDToFile(child.key)
                  }
                }
              }
            }
          ]
        },
        {
          title: 'ANALYZE',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Configure',
                  show: this.isGamma,
                  handler: () => (this.analyzeConfigureModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'ReProcessing',
                  show: this.isGamma,
                  handler: () => (this.reprocessingModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Reprocess All',
                  show: this.isGamma,
                  handler: this.handleReprocessAll
                },
                {
                  type: 'a-menu-item',
                  title: 'Interactive Tool',
                  show: this.isGamma,
                  handler: () => (this.analyzeInteractiveToolModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Zero Time',
                  show: this.isGamma,
                  handler: () => (this.zeroTimeModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Korsum',
                  show: this.isGamma,
                  handler: () => (this.korsumModalShow = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Analyze current spectrum',
                  show: this.isBetaGamma,
                  handler: () => {}
                },
                {
                  type: 'a-menu-item',
                  title: 'Analyze all spectra',
                  show: this.isBetaGamma,
                  handler: () => {}
                }
              ]
            }
          ]
        },
        {
          title: 'CALIBRATION',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Energy',
                  show: this.isGamma,
                  handler: () => (this.energyCalibrationModalShow = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Resolution',
                  show: this.isGamma,
                  handler: () => (this.resolutionCalibrationModalShow = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Efficiency',
                  show: this.isGamma,
                  handler: () => (this.efficiencyCalibrationModalShow = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Energy Calibration',
                  show: this.isBetaGamma,
                  handler: () => (this.betaGammaEnergyCalibrationModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Extrapolation',
                  show: this.isBetaGamma,
                  handler: () => (this.betaGammaExtrapolationModalVisible = true)
                }
              ]
            }
          ]
        },
        {
          title: 'NUCLIDELIBRARY',
          show: !this.isBetaGamma,
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Nuclide Library',
                  handler: () => (this.nuclideLibraryModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'Config User Library',
                  handler: () => (this.configUserLibModalVisible = true)
                }
              ]
            }
          ]
        },
        {
          title: 'STATISTIC',
          show: this.isBetaGamma,
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'MDC & Activity Concentration',
                  handler: () => (this.statisticsParamerHistoryModalVisible = true)
                }
              ]
            }
          ]
        },
        {
          title: 'COMMENTS',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'View Comments',
                  show: this.isBetaGamma,
                  handler: this.handleViewComments
                },
                {
                  type: 'a-menu-item',
                  title: 'Add Comments',
                  show: this.isBetaGamma,
                  handler: this.handleAddComments
                },
                {
                  type: 'a-menu-item',
                  title: 'View',
                  show: this.isGamma,
                  handler: this.handleViewComments
                },
                {
                  type: 'a-menu-item',
                  title: 'Add',
                  show: this.isGamma,
                  handler: this.handleAddComments
                }
              ]
            }
          ]
        },
        {
          title: 'REPORTS',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Peak Infomation',
                  handler: () => (this.peakInfomationModalVisible = true),
                  show: this.isGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'ARR',
                  handler: () => {
                    this.arrOrRRRModalVisible = true
                    this.arrOrRRRModalExtraData = {}
                    this.arrOrRRRModalType = 1
                  },
                  show: this.isGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'RRR',
                  handler: () => {
                    this.arrOrRRRModalVisible = true
                    this.arrOrRRRModalExtraData = {}
                    this.arrOrRRRModalType = 2
                  },
                  show: this.isGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'Radionuclide Activity',
                  handler: () => (this.nuclideActivityAndMDCModalVisible = true),
                  show: this.isGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'Spectrum',
                  handler: () => (this.spectrumModalVisible = true),
                  show: this.isGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'Sample Infomation',
                  handler: () => (this.sampleInfomationModalVisible = true),
                  show: this.isGamma
                },

                {
                  type: 'a-menu-item',
                  title: 'QC Results',
                  handler: () => (this.qcResultsModalVisible = true),
                  show: this.isGamma
                },

                {
                  type: 'a-menu-item',
                  title: 'RLR',
                  handler: () => (this.rlrModalVisible = true),
                  show: this.isGamma
                },

                // 以下是beta-gamma的下拉
                {
                  type: 'a-menu-item',
                  title: 'View ARR',
                  handler: () => {
                    this.arrOrRRRModalVisible = true
                    this.arrOrRRRModalExtraData = {}
                    this.arrOrRRRModalType = 3
                  },
                  show: this.isBetaGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'View RRR',
                  handler: () => {
                    this.arrOrRRRModalVisible = true
                    this.arrOrRRRModalExtraData = {
                      dbName: this.sampleData.dbName,
                      sampleData: false,
                      GasBgData: false,
                      DetBgData: false,
                      QCData: false,
                      bGammaEnergyValid: false,
                      bBetaEnergyValid: false
                    }
                    this.arrOrRRRModalType = 4
                  },
                  show: this.isBetaGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'View spectrum',
                  handler: () => (this.betaGammaSpectrumModalVisible = true),
                  show: this.isBetaGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'View Sample Infomation',
                  handler: () => (this.betaGammaSampleInfomationModalVisible = true),
                  show: this.isBetaGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'QC results',
                  handler: () => (this.betaGammaQCResultsModalVisible = true),
                  show: this.isBetaGamma
                },
                {
                  type: 'a-menu-item',
                  title: 'RLR',
                  handler: () => (this.betaGammaRlrModalVisible = true),
                  show: this.isBetaGamma
                }
              ]
            }
          ]
        },
        {
          title: 'LOG',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Automatic Analysis Log',
                  show: this.isBetaGamma,
                  handler: () => (this.autoAnalysisMogModalVisible = true)
                },
                {
                  type: 'a-menu-item',
                  title: 'BG log viewer',
                  show: this.isBetaGamma,
                  handler: () => {}
                },
                {
                  type: 'a-menu-item',
                  title: 'GammaViewer Log',
                  show: this.isGamma,
                  handler: () => (this.dataProcessingLogModalVisible = true)
                }
              ]
            }
          ]
        },
        {
          title: 'HELP',
          children: [
            {
              type: 'a-menu',
              children: [
                {
                  type: 'a-menu-item',
                  title: 'Help',
                  handler: this.handleHelp
                },
                {
                  type: 'a-menu-item',
                  title: 'Color Config',
                  handler: () => (this.colorConfigModalVisible = true)
                }
              ]
            }
          ]
        }
      ]
    },

    // 当前类型是否是Gamma
    isGamma() {
      return this.analysisType == ANALYZE_TYPE.GAMMA
    },

    // 当前类型是否是Beta-Gamma
    isBetaGamma() {
      return this.analysisType == ANALYZE_TYPE.BETA_GAMMA
    }
  }
}
</script>
<style lang="less" scoped>
.spectrum-analysis {
  padding-top: 17px;
  height: 100%;
  display: flex;
  flex-direction: column;

  // 顶部操作栏开始
  &-operators {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    flex-wrap: nowrap;
    overflow: auto;

    &-item {
      width: 158px;
      border: 1px solid rgba(12, 235, 201, 0.6);
      border-top-width: 3px;
      height: 30px;
      background-color: rgba(51, 202, 217, 0.2);
      color: #ccede8;

      &:not(:last-child) {
        margin-right: 15px;
      }

      ::v-deep {
        span {
          text-shadow: none;
          line-height: 26px;
          letter-spacing: 2px;
        }
      }

      &:nth-child(4) {
        width: 224px;
      }
      &:nth-child(5) {
        width: 268px;
      }
      &:nth-child(6) {
        width: 257px;
      }
      &:nth-child(7) {
        width: 234px;
      }
      &:nth-child(8) {
        width: 125px;
      }
    }
  }
  // 顶部操作栏结束

  ::v-deep {
    // 二级操作栏开始
    .spectrum-analysis-sub-operators {
      flex-shrink: 0;
      margin-bottom: 19px;
      display: flex;
      flex-wrap: nowrap;
      overflow: auto;

      .pop-over-with-icon {
        height: 32px;

        &:not(:last-child) {
          margin-right: 11px;
        }

        &:nth-child(1) {
          width: 256px;
        }
        &:nth-child(2) {
          width: 186px;
        }
        &:nth-child(3) {
          width: 246px;
        }
        &:nth-child(4) {
          width: 246px;
        }
      }

      .peak-info {
        width: 306px;
        height: 32px;
        display: inline-block;
      }
    }
    // 二级操作栏结束
  }

  // 主体部分开始
  &-main {
    margin-top: 15px;
    height: calc(100% - 45px);
    overflow: hidden;
  }
  // 主体部分结束
}
</style>
<style lang="less">
.spectrum-analysis-operators-dropdown-overlay {
  background-color: #03353f;
  .ant-menu {
    background: transparent;
    padding: 0;
    position: relative;
    border-right: 0;

    &-submenu {
      &-active {
        background-color: #055565 !important;
      }

      &-title {
        height: 30px !important;
        line-height: 30px !important;
        color: #fff;
        margin: 0;

        &:active {
          background-color: #055565 !important;
        }

        .ant-menu-submenu-arrow {
          &::before,
          &::after {
            background: #fff !important;
          }
        }
      }
    }

    &-item {
      color: #fff;
      font-family: Arial;
      border: 0;
      background-color: transparent !important;
      padding: 4px 14px;
      height: 30px;
      line-height: 22px;
      margin: 0 !important;

      &:hover {
        background-color: #055565 !important;
      }
      &-selected {
        font-weight: normal;
      }
      &-disabled {
        color: #476d74 !important;
        &:hover {
          background-color: transparent !important;
        }
      }
    }
  }
}

.empty {
  padding-top: 100px;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
}

.figure-chart-option-tooltip {
  background-color: #00aa7f !important;
  border-color: #00aa7f !important;

  .channel {
    color: #fff;
  }

  .energy {
    color: #00d1f0;
  }

  .warning {
    color: yellow;
  }
}
</style>
