<template>
  <div class="dfmea-page-tree-content">
    <!--  顶部按钮 Start  -->
    <!--      加载-->
    <a-spin :tip="spinTip" :delay="delayTime" :spinning="buttonLoading">
      <div class="top-button-bar-func">
        <!-- 变体矩阵 下拉选择 Start -->
        <a style="margin: 1px 0 0 12px;" class="fr mr10">
          <a-select style="width: 150px" allowClear v-model:value="variantSelectValue"
            @change="handleVariantSelectChange">
            <a-select-option v-for="(item, index) in variantSelectInfo" :key="index" :title="item.name"
              :value="item.variantId">
              {{ item.name }}
            </a-select-option>
          </a-select>
        </a>
        <a v-for="item in topBtns" href="javascript:void(0);" :key="item.key"
          v-show="item.key === 'quitViewSideBySide' ? showViewSideBySide : true"
          :class="'fmeaTreeTopBtn ' + (item.active ? 'active ' : '') + (item.floatR ? 'fr' : '')"
          @click="topBtnClick(item)">
          <a-tooltip :placement="item.key === 'quitViewSideBySide' ? 'topRight' : 'topLeft'"
            :title="$t('' + item.label + '')" arrowPointAtCenter>
            <div v-if="!item.children">
              <i :class="getTopIconClass(item)" />
              <!-- 右侧分割线 -->
              <a-divider v-if="item.sepR" type="vertical" />
            </div>
          </a-tooltip>
          <!-- children top Start -->
          <a-tooltip :placement="item.key === 'configure' && !showViewSideBySide ? 'topRight' : 'topLeft'"
            :title="$t('' + item.label + '')" arrowPointAtCenter>
            <div v-if="item.children && item.children.length > 0">
              <a-dropdown :trigger="[item.active ? 'click' : '']">
                <i v-if="item.key === 'completeInspection'" :class="'iconfont ' + item.icon"
                  :style="completeIconColor()" />
                <i v-else :class="'iconfont ' + item.icon" />
                <a-menu slot="overlay">
                  <template v-for="(item, index) in item.children">
                    <a-menu-divider v-if="item.key === 'divider'" />
                    <a-menu-item v-else-if="item.sign === 'completeInspection' && item.key != 'doubleCheck'">
                      {{ $t('' + item.label + '') }}
                      <a-checkbox :checked="item.check" @change="completeInspection(item)" class="fr"
                        style="margin-left: 10px" />
                    </a-menu-item>
                    <a-menu-item v-else-if="item.sign === 'completeInspection' && item.key === 'doubleCheck'">
                      <a-button @click="recheckIntegrity()" :disabled="completeButton" class="mr_10">
                        {{ $t('' + item.label + '') }}
                      </a-button>
                      <a-button @click="checkStatistics()">
                        {{ $t('' + $t("functional-analysis.top-btn.check-statistics") + '') }}
                      </a-button>
                    </a-menu-item>
                    <a-menu-item v-else :key="index" @click="dropDownClick(item)">
                      {{ $t('' + item.label + '') }}
                    </a-menu-item>
                  </template>
                </a-menu>
              </a-dropdown>
            </div>
          </a-tooltip>
          <!-- children top End -->
        </a>
      </div>
    </a-spin>
    <!--  顶部按钮 End  -->

    <!--  主界面 Start  -->
    <div class="functional-analysis-content">
      <SplitPane split="vertical" :min-percent="1" :default-percent="showViewSideBySide ? 50 : 100">
        <template slot="paneL" ref="mainTree">
          <!--  结构树 Start  -->
          <SplitPane class="mainPane" split="vertical" :min-percent="1" :default-percent="28">
            <template slot="paneL" class="leftTree">
              <LeftTree ref="leftTree" :versionDiffCloseFlag="versionDiffCloseFlag" @initRightTree="initRightTree"
                @getRightTreeData="getRightTreeData" @getCurrentNodeMenus="getCurrentNodeMenus"
                @setCheckedNode="setCheckedNode" @setHighLightNode="setHighLightLNode"
                @setMultipleHighLightNode="setMultipleHighLightLNode"
                @clearMultipleHighLightNode="clearMultipleHighLightLNode"
                @setHighLightCopyCutNode="setHighLightCopyCutNode"
                @clearHighLightCopyCutNode="clearHighLightCopyCutLNode"
                @restoreHighLightCopyNode="restoreHighLightCopyNode" @paste="paste" @drop="dropL"
                @deleteNode="deleteNode" @deleteRootNode="deleteRootNode" @moveNode="moveNode" @addParent="addParent"
                @rightUpdateTreeDataNode="rightUpdateTreeDataNode" @refreshBtnStatus="refreshBtnStatus"
                @refreshMoveNodeFlag="refreshMoveLeftNodeFlag" @keyListenerChange="keyListenerChange"
                @cleanVariantSelect="cleanVariantSelect"
                :versionLibraryDiffCloseFlag="versionLibraryDiffCloseFlag" @saveNodeAiInference="saveNodeAiInference"/>
            </template>
            <template slot="paneR">
              <RightTree ref="rightTree" :filterTypeCode="filterTypeCode"
                :functionNetShowHide="funNetInspectionShowHide" :faultNetShowHide="faultNetInspectionShowHide"
                :versionDiffCloseFlag="versionDiffCloseFlag" @initLeftTree="initLeftTree"
                @handleLeftNode="handleLeftNode" @getCurrentNodeMenus="getCurrentNodeMenus"
                @setCheckedNode="setCheckedNode" @setHighLightNode="setHighLightNode"
                @setMultipleHighLightNode="setMultipleHighLightNode"
                @clearMultipleHighLightNode="clearMultipleHighLightNode"
                @setHighLightCopyCutNode="setHighLightCopyCutNode"
                @clearHighLightCopyCutNode="clearHighLightCopyCutNode"
                @restoreHighLightCopyNode="restoreHighLightCopyNode" @paste="paste" @drop="drop"
                @addMeasure="addMeasure" @addGroup="addGroup" @deleteNode="deleteNode" @moveNode="moveNode"
                @convertNode="convertNode" @updateNodeSOD="updateNodeSOD" @updateNodeClassify="updateNodeClassify"
                @updateNode="updateNodeSOD" @leftUpdateTreeDataNode="leftUpdateTreeDataNode"
                @refreshBtnStatus="refreshBtnStatus" @refreshMoveNodeFlag="refreshMoveRightNodeFlag"
                @keyListenerChange="keyListenerChange" @initVariantSelectByVariantId="initVariantSelectByVariantId"
                :versionLibraryDiffCloseFlag="versionLibraryDiffCloseFlag"
                @saveNodeAiInference="saveNodeAiInference" @saveSodAiInference="saveSodAiInference"
                @saveMeasureiAiInference="saveMeasureiAiInference"/>
            </template>
          </SplitPane>
        </template>
        <!--  结构树 End  -->

        <!--  并排查看 Start  -->
        <template slot="paneR">
          <SplitPane class="viewSideBySide" :default-percent='28' :min-percent='15' split='vertical'>
            <template slot="paneL">
              <ViewSideBySideLeftTree ref="viewSideBySideLeftTree" @initRightTree="initViewSideBySideRightTree" />
            </template>
            <template slot="paneR">
              <ViewSideBySideRightTree ref="viewSideBySideRightTree" />
            </template>
          </SplitPane>
        </template>
        <!--  并排查看 End  -->
      </SplitPane>
    </div>
    <!--  主界面 End  -->

    <!-- 顶部按钮/下拉项 Start -->
    <DragModal :title="topBtnTitle" :visible="topBtnModal" :destroyOnClose="true" :maskClosable="false"
      :width="DragModalWidth" :mask="maskFlag" :wrapClassName="wrapClass" @cancel="cancel" :footer="null">
      <!-- 文件导入(四版) -->
      <FourVersion v-if="topBtnActionName === 'fourVersion'" :checkedNode=checkedNode @initLeftTree="initLeftTree"
        @initRightTree="initRightTree" @closeModal="closeTopBtnModal" />
      <!-- 文件导入(四版转新版) -->
      <FourToNewVersion v-if="topBtnActionName === 'fourToNewVersion'" :checkedNode=checkedNode
        @initLeftTree="initLeftTree" @initRightTree="initRightTree" @closeModal="closeTopBtnModal" />
      <!-- 文件导入(新版) -->
      <NewVersion v-if="topBtnActionName === 'newVersion'" :checkedNode=checkedNode @initLeftTree="initLeftTree"
        @initRightTree="initRightTree" @closeModal="closeTopBtnModal" />
      <!-- XML导入 -->
      <XMLImport v-if="topBtnActionName === 'XMLImport'" @initLeftTree="initLeftTree" @initRightTree="initRightTree"
        @initVariantSelect="initVariantSelect" @cleanVariantSelect="cleanVariantSelect"
        @refreshDefaultBtnStatus="refreshDefaultBtnStatus" @closeModal="closeTopBtnModal" />
      <!-- RFMEA文件导入 -->
      <RFMEAImport v-if="topBtnActionName === 'RFMEAImport'" @initLeftTree="initLeftTree" @initRightTree="initRightTree"
        @initVariantSelect="initVariantSelect" @cleanVariantSelect="cleanVariantSelect"
        @refreshDefaultBtnStatus="refreshDefaultBtnStatus" @closeModal="closeTopBtnModal" />
      <!-- 批量替换 -->
      <BatchReplace v-if="topBtnActionName === 'batchReplace'" @initLeftTree="initLeftTree"
        @initRightTree="initRightTree" @handleLeftTreeCss="handleLeftTreeCss" @handleRightTreeCss="handleRightTreeCss"
        @closeModal="closeTopBtnModal" />
      <!-- 并排查看 -->
      <ViewSideBySide v-if="topBtnActionName === 'viewSideBySide'" @closeModal="closeTopBtnModal"
        @openViewSideBySide="openViewSideBySide" />
      <!-- 用户定义的特性 -->
      <UserDefinedProperties v-if="topBtnActionName === 'userDefinedProperties'" />
      <!-- 备注配置 -->
      <NotesConfig v-if="topBtnActionName === 'notesConfig'" />
      <!-- 功能种类 -->
      <FunctionType v-if="topBtnActionName === 'functionType'" @closeModal="closeTopBtnModal" />
      <!-- 特性种类 -->
      <CharacteristicType v-if="topBtnActionName === 'characteristicType'" @closeModal="closeTopBtnModal"
        @initKeyFeature="initKeyFeature" @initRightTree="initRightTree" />
      <!-- 评分标准 -->
      <ScoringCriteria v-if="topBtnActionName === 'scoringCriteria'" @closeModal="closeTopBtnModal" />
      <!-- 行动优先级 -->
      <ActionPriority v-if="topBtnActionName === 'actionPriority'" @initRightTree="initRightTree"
        @closeModal="closeTopBtnModal" />
      <!-- 接口库 -->
      <InterfaceLibrary v-if="topBtnActionName === 'interfaceLibrary'" @closeModal="closeTopBtnModal" />
      <!-- DFMEA库 -->
      <DFMEALibrary v-if="topBtnActionName === 'DFMEALibrary'" @closeModal="closeTopBtnModal" />

      <!-- 特性自动标记-->
      <PropertyTagged v-if="topBtnActionName === 'PropertyTagged'" @closeModal="closeTopBtnModal"
        @initRightTree="initRightTree" />
      <!-- 语言设置 -->
      <LanguageSettings v-if="topBtnActionName === 'languageSettings'" @closeModal="closeTopBtnModal" />
      <!-- 显示语言 -->
      <SelectLanguage v-if="topBtnActionName === 'selectLanguage'" @initLeftTree="initLeftTree"
        @initRightTree="initRightTree" @closeModal="closeTopBtnModal" />
      <!-- 翻译校对 -->
      <CheckTranslation v-if="topBtnActionName === 'checkTranslation'" @closeModal="closeTopBtnModal" />
      <!--DFMEA成熟度评估管理-->
      <DFMEAMaturity v-if="topBtnActionName === 'DFMEAMaturity'" @initRightTree="initRightTree"
        @closeModal="closeTopBtnModal" />
    </DragModal>
    <!-- 顶部按钮/下拉项 End -->
    <!--      刷新-->
    <!-- 回收站 -->
    <RecycleBinModal ref="recycleBinModal" :showRecycleBinModal="showRecycleBinModal"
      @setHighLightNode="getHighLightNode" @initLeftTree="initLeftTree" @initRightTree="initRightTree"
      @closeModal="closeRecycleModal" />
    <!-- 变体矩阵 -->
    <VariantMatrixModal ref="variantMatrixModal" :showVariantMatrixModal="showVariantMatrixModal"
      @initLeftTree="initLeftTree" @initRightTree="initRightTree" @initVariantSelect="initVariantSelect"
      @initVariantSelectByVariantId="initVariantSelectByVariantId" @closeModal="closeVariantMatrixModal" />
    <!-- 接口矩阵 -->
    <InterfaceMatrixModal ref="interfaceMatrixModal" :showInterfaceMatrixModal="showInterfaceMatrixModal"
      @initLeftTree="initLeftTree" @initRightTree="initRightTree" @closeModal="closeInterfaceMatrixModal" />
    <!-- 功能矩阵 -->
    <FunctionMatrixModal ref="functionMatrixModal" :showFunctionMatrixModal="showFunctionMatrixModal"
      @initLeftTree="initLeftTree" @initRightTree="initRightTree" @closeModal="closeFunctionMatrixModal" />
    <!-- 失效矩阵 -->
    <FailureMatrixModal ref="failureMatrixModal" :showFailureMatrixModal="showFailureMatrixModal"
      @initLeftTree="initLeftTree" @initRightTree="initRightTree" @closeModal="closeFailureMatrixModal" />
    <!-- 统计分析 -->
    <StatisticalAnalysisModal ref="statisticalAnalysisModal"
      :showStatisticalAnalysisModal="showStatisticalAnalysisModal" @initLeftTree="initLeftTree"
      @initRightTree="initRightTree" @closeModal="closeStatisticalAnalysisModal" />
    <!-- 结构网 -->
    <StructureNetModal ref="structureNetModal" :showStructureNetModal="showStructureNetModal"
      @closeStructureNetModal="closeStructureNetModal" />
    <!-- P图-->
    <Parameter ref="parameter" />
    <!-- 评分标准 -->
    <ScoringCriteriaDrawer ref="scoringCriteriaDrawer" :showScoringCriteriaDrawer="showScoringCriteriaDrawer"
      @closeDrawer="closeScoringCriteriaDrawer" />
    <!--    刷新-->
    <RefreshSetting v-if="topBtnActionName === 'RefreshSetting'" @closeModal="closeTopBtnModal"
      @refresh="repairFmeaData" />
    <!-- 检查统计 -->
    <CheckStatisticsModal ref="checkStatisticsModal" :showCheckStatisticsModal="showCheckStatisticsModal"
      @closeCheckStatisticsModal="closeCheckStatisticsModal" @ClickSkipStruTree="ClickSkipStruTree" />
  </div>
  <!--  </a-spin>-->
</template>

<script>

import "@/styles/fmea.scss";
import { addClass, removeClass } from "@/utils/index";
import SplitPane from "vue-splitpane";
import DragModal from "@/components/DragModal";
import LeftTree from "./components/LeftTree";
import RightTree from "./components/RightTree";
import axios from 'axios';

/** 并排查看 */
import ViewSideBySideLeftTree from "./components/ViewSideBySide/LeftTree/index";
import ViewSideBySideRightTree from "./components/ViewSideBySide/RightTree/index";

/** 顶部Excel导入/下拉栏 */
import FourVersion from "./components/TopBtnModal/excel/FourVersion";
import FourToNewVersion from "./components/TopBtnModal/excel/FourToNewVersion";
import NewVersion from "./components/TopBtnModal/excel/NewVersion";

/** 顶部文件导入导出/下拉栏 */
import XMLImport from "./components/TopBtnModal/XMLImport";
import RFMEAImport from "./components/TopBtnModal/RFMEAImport";

/** 接口矩阵 */
import InterfaceMatrixModal from "./components/TopBtnModal/InterfaceMatrixModal";
/** 功能矩阵 */
import FunctionMatrixModal from "./components/TopBtnModal/FunctionMatrixModal";
/** 失效矩阵 */
import FailureMatrixModal from "./components/TopBtnModal/FailureMatrixModal";
/** 统计分析 */
import StatisticalAnalysisModal from "./components/TopBtnModal/StatisticalAnalysis/index";
/** 结构网 **/
import StructureNetModal from "./components/Net/StructureNetModal";
/** 评分标准 **/
import ScoringCriteriaDrawer from "./components/TopBtnModal/ScoringCriteriaDrawer";
/** 批量替换 **/
import BatchReplace from "./components/TopBtnModal/BatchReplace";
/** 变体矩阵 **/
import VariantMatrixModal from "./components/TopBtnModal/VariantMatrixModal";
/** p图 **/
import Parameter from "../structure/components/TopBtnModal/Parameter/index.vue";

/** 顶部工具/并排查看 */
import ViewSideBySide from "./components/TopBtnModal/ViewSideBySide";

/** 顶部配置/下拉栏 */
import UserDefinedProperties from "./components/TopBtnModal/configuration/UserDefinedProperties";
import NotesConfig from "./components/TopBtnModal/configuration/NotesConfig";
import FunctionType from "./components/TopBtnModal/configuration/FunctionType";
import ScoringCriteria from "./components/TopBtnModal/configuration/ScoringCriteria";
import ActionPriority from "./components/TopBtnModal/configuration/ActionPriority";
import CharacteristicType from "./components/TopBtnModal/configuration/CharacteristicType";
import InterfaceLibrary from "./components/TopBtnModal/configuration/InterfaceLibrary";
import DFMEALibrary from "./components/TopBtnModal/configuration/DFMEALibrary";
import PropertyTagged from "@/views/fmeaTree/components/TopBtnModal/configuration/PropertyTagged";
import RefreshSetting from "@/views/fmeaTree/components/TopBtnModal/configuration/RefreshSetting";
/** 回收站 */
import RecycleBinModal from "./components/TopBtnModal/RecycleBin"

/** 统计检查 */
import CheckStatisticsModal from "./components/CheckStatisticsModal/index"

/** 多语言 */
import LanguageSettings from "./components/TopBtnModal/languages/LanguageSettings";
import SelectLanguage from "./components/TopBtnModal/languages/SelectLanguage";
import CheckTranslation from "./components/TopBtnModal/languages/CheckTranslation";
import AntSpinDot from "@/components/AntSpinDot/index.vue";
import {
  getMoveTargetNode,
  showCurConvertBtn,
  showMergeBtn,
  showMoveDownBtn,
  showMoveUpBtn,
  showPasteBtn
} from "@/utils/treeMenuBtn";
import { getTopStructDeep } from "@/utils/tree";
import $ from "jquery";

/** 成熟度管理 */
import DFMEAMaturity from "./components/TopBtnModal/configuration/DFMEAMaturity";

export default {
  inject: ['reload'],
  components: {
    Parameter,
    AntSpinDot,
    SplitPane,
    DragModal,
    LeftTree,
    RightTree,
    ViewSideBySideLeftTree,
    ViewSideBySideRightTree,
    FourVersion,
    FourToNewVersion,
    NewVersion,
    XMLImport,
    RFMEAImport,
    InterfaceMatrixModal,
    FunctionMatrixModal,
    FailureMatrixModal,
    StatisticalAnalysisModal,
    VariantMatrixModal,
    ScoringCriteriaDrawer,
    BatchReplace,
    ViewSideBySide,
    UserDefinedProperties,
    NotesConfig,
    FunctionType,
    ScoringCriteria,
    ActionPriority,
    CharacteristicType,
    InterfaceLibrary,
    DFMEALibrary,
    PropertyTagged,
    RefreshSetting,
    StructureNetModal,
    LanguageSettings,
    SelectLanguage,
    CheckTranslation,
    RecycleBinModal,
    DFMEAMaturity,
    CheckStatisticsModal,
  },
  data() {
    return {
      /** P图模态框：开关 */
      showParameter: false,
      batchReplaceFlag: false, // 正在批量替换标识
      DragModalWidth: 1000, // 模态框宽度
      maskFlag: true, // 是否遮罩
      wrapClass: 'top-200', // 设置modal框下页面可点击
      selectedRows: undefined,
      /** 顶部按钮 */
      topBtns: JSON.parse(JSON.stringify(this.$store.getters.fmeaTopBtns)),
      /** Excel导入开关 */
      showImportExcelModal: false,
      /** ReliaBench导入开关 */
      showImportReliaBenchModal: false,
      /** 顶部按钮模态框：开关 */
      topBtnModal: false,
      /** 顶部按钮模态框：标题 */
      topBtnTitle: '',
      /** 顶部按钮模态框：key */
      topBtnActionName: '',
      /** 选中节点 */
      checkedNode: {},
      /** 功能显示/隐藏开关 */
      functionShowHide: true,
      /** 特性显示/隐藏开关 */
      featureShowHide: true,
      /** 要求显示/隐藏开关 */
      requireShowHide: true,
      /** 失效显示/隐藏开关 */
      faultShowHide: true,
      /** 措施显示/隐藏开关 */
      measureShowHide: true,
      /** 功能网检查显示/隐藏开关 */
      functionNetShowHide: true,
      /** 失效网检查显示/隐藏开关 */
      faultNetShowHide: true,
      /** 功能网完整性检查显示/隐藏开关 */
      funNetInspectionShowHide: true,
      /** 失效网完整性检查显示/隐藏开关 */
      faultNetInspectionShowHide: true,
      /** 功能完整性检查 */
      funInspectionShowHide: false,
      /** 失效完整性 */
      failInspectionShowHide: false,
      /** 要求完整性检查 */
      requestInspectionShowHide: false,
      /** SOD值完整性检查 */
      sodInspectionShowHide: false,
      /** 高风险项检查 */
      highRiskInspectionShowHide: false,
      /** 过滤节点CODE */
      filterTypeCode: "",
      /** 并排查看 */
      showViewSideBySide: false,
      /** 左侧上下移动节点标识，防止快速移动 */
      moveLeftNodeFlag: true,
      /** 右侧上下移动节点标识，防止快速移动 */
      moveRightNodeFlag: true,
      /** 结构网模态框：开关 */
      showStructureNetModal: false,
      /** 变体矩阵模态框：开关 */
      showVariantMatrixModal: false,
      /** 接口矩阵模态框：开关 */
      showInterfaceMatrixModal: false,
      /** 功能矩阵模态框：开关 */
      showFunctionMatrixModal: false,
      /** 失效矩阵模态框：开关 */
      showFailureMatrixModal: false,
      /** 统计分析模态框：开关 */
      showStatisticalAnalysisModal: false,
      /** 评分标准抽屉：开关 */
      showScoringCriteriaDrawer: false,
      /** 语言设置：开关 */
      showLanguageSettings: false,
      /** 显示语言：开关 */
      showSelectLanguage: false,
      /** 翻译校对：开关 */
      showCheckTranslation: false,
      /** 粘贴后节点ID */
      pasteAfterNodeId: "",
      /** 变体下拉信息 */
      variantSelectInfo: [],
      /** 变体下拉选中Key */
      variantSelectKey: "",
      /** 变体下拉选中值 */
      variantSelectValue: undefined,
      /** button加载中状态 */
      buttonLoading: false,
      /** 延迟显示加载效果的时间（防止闪烁）*/
      delayTime: 300,
      /** 自定义Loading描述文案 */
      // spinTip: "加载中...",
      spinTip: "",
      /** 删除弹出框 */
      deleteModal: undefined,
      /** 加载对象 */
      loader: undefined,
      /** 完整性检查暂存值*/
      completeInspectionObj: {},
      /** 完整性检查loading */
      completeLoading: false,
      /** 回收站：开关 */
      showRecycleBinModal: false,
      /** 统计检查模态框开关 */
      showCheckStatisticsModal: false,
      /** 关联历史失效显示隐藏：开关 */
      historyShowOrHide: false,
      historyComp: [],
    };
  },
  computed: {
    completeButton() {
      if (!this.funNetInspectionShowHide || !this.faultNetInspectionShowHide) {
        return false;
      } else if (this.funInspectionShowHide || this.failInspectionShowHide || this.requestInspectionShowHide || this.sodInspectionShowHide || this.highRiskInspectionShowHide) {
        return false;
      } else {
        return true;
      }
    }
  },
  props: {
    versionDiffCloseFlag: {
      type: Boolean,
      default: undefined
    },
    versionLibraryDiffCloseFlag: {
      type: Boolean,
      default: undefined
    }
  },
  watch: {
    // 监听是否在进行批量替换
    batchReplaceFlag() {
      this.$nextTick(() => {
        if (this.batchReplaceFlag) {
          this.maskFlag = false;
          this.DragModalWidth = 500; // 宽度设置500
        } else {
          this.maskFlag = true;
          this.DragModalWidth = 1000; // 宽度设置500
        }
      })
    },
    // 监听顶部按钮状态
    "$store.getters.lastCheckedNode"(v) {
      this.refreshBtnStatus(v);
    },
    // 完整性按钮监听
    funInspectionShowHide(value) {
      this.$refs.leftTree.funInspectionShowHide = value;
      this.$refs.rightTree.funInspectionShowHide = value;
    },
    failInspectionShowHide(value) {
      this.$refs.leftTree.failInspectionShowHide = value;
      this.$refs.rightTree.failInspectionShowHide = value;
    },
    requestInspectionShowHide(value) {
      this.$refs.leftTree.requestInspectionShowHide = value;
      this.$refs.rightTree.requestInspectionShowHide = value;
    },
    sodInspectionShowHide(value) {
      this.$refs.leftTree.sodInspectionShowHide = value;
      this.$refs.rightTree.sodInspectionShowHide = value;
    },
    highRiskInspectionShowHide(value) {
      this.$refs.leftTree.highRiskInspectionShowHide = value;
      this.$refs.rightTree.highRiskInspectionShowHide = value;
    }
  },
  mounted() {
    window.addEventListener("keydown", this.keyCodeForEvent);
    this.$once('hook:beforeDestroy', () => {
      window.removeEventListener("keydown", this.keyCodeForEvent);
    });
    this.initVariantSelect();
  },
  methods: {
    /**
     * 完整性检查图标颜色变化
     */
    completeIconColor() {
      if (this.funNetInspectionShowHide && this.faultNetInspectionShowHide &&
        !this.funInspectionShowHide && !this.failInspectionShowHide &&
        !this.requestInspectionShowHide && !this.sodInspectionShowHide &&
        !this.highRiskInspectionShowHide) {
        return "padding: 0px 4px 0px 4px;"
      } else {//有完整性检查选中的情况，对图标背景赋颜色
        return "padding: 0px 4px 0px 4px; background-color: #c4c9cb"
      }
    },
    /**
     * 完整性检查前对按钮的判断以及操作
     */
    completeInspection(obj) {
      this.completeLoading = true;
      if (this.completeInspectionObj.key == null) {//如果暂存数据key为空，清除，以防脏数据
        this.completeInspectionObj = null;
      }
      obj.check = !obj.check;//将fmeaTreeData中的这条数据的check反转
      if (!this.completeInspectionObj) {//暂存中无数据，直接赋值
        this.completeInspectionObj = obj;
        this.completeInspectionToTree(this.completeInspectionObj)
      } else {//暂存中有数据
        if (obj.key == this.completeInspectionObj.key) {//点击的数据与暂存数据相同，直接覆盖
          this.completeInspectionObj = obj;
          this.completeInspectionToTree(this.completeInspectionObj)
        } else if (this.completeInspectionObj.check == true) {//暂存中数据为点击状态，先取消再赋值
          this.completeInspectionObj.check = false
          this.completeInspectionToTree(this.completeInspectionObj)
          this.completeInspectionObj = obj;
          this.completeInspectionToTree(this.completeInspectionObj)
        } else {//暂存中数据不为同一条并且是取消状态，直接覆盖
          this.completeInspectionObj = obj;
          this.completeInspectionToTree(this.completeInspectionObj)
        }
      }
    },
    /**
     *完整性检查操作
     * @param obj 完整性检查点击的数据
     */
    completeInspectionToTree(obj) {
      switch (obj.key) {
        case "functionNetShowHide": // 功能网完整性检查显示/隐藏
          this.funNetInspectionShowHide = !this.funNetInspectionShowHide;
          break;
        case "faultNetShowHide": // 失效网完整性检查显示/隐藏
          this.faultNetInspectionShowHide = !this.faultNetInspectionShowHide;
          break;
        case "funInspection": // 功能完整性检查
          this.funInspectionShowHide = !this.funInspectionShowHide;
          break;
        case "requestInspection": // 要求完整性检查
          this.requestInspectionShowHide = !this.requestInspectionShowHide;
          break;
        case "failInspection": // 失效完整性检查
          this.failInspectionShowHide = !this.failInspectionShowHide;
          break;
        case "sodInspection": // SOD值完整性检查
          this.sodInspectionShowHide = !this.sodInspectionShowHide;
          break;
        case "highRiskInspection": // 高风险项(AP=H)检查
          this.highRiskInspectionShowHide = !this.highRiskInspectionShowHide;
          break;
        default:
          break;
      }
      this.integrityCheck();
    },
    /**
     * 检查统计
     */
    checkStatistics() {
      this.showCheckStatisticsModal = true;
      this.$refs.checkStatisticsModal.search();
    },
    /**
     * 关闭统计分析模态框。
     */
    closeCheckStatisticsModal() {
      this.showCheckStatisticsModal = false;
    },
    /**
     * 点击跳转结构树。
     */
    ClickSkipStruTree(nodeType, struId, parentStruId) {
      this.$refs.leftTree.onAsyncSuccessSelectId = parentStruId;
      this.$refs.rightTree.onAsyncSuccessSelectId = nodeType !== '01' ? struId : parentStruId;
      this.$refs.leftTree.selectNode("leftTree");
      this.$refs.rightTree.selectNode("rightTree");
      this.$refs.rightTree.clickRight = struId;
    },
    /**
     * 完整性检查方法
     */
    integrityCheck() {
      let _that = this;
      // 对左侧树和右侧树进行数据显示更新
      _that.$api.integrityCheck({
        rfmeaId: this.$store.getters.rfmeaId
      }).then((res) => {
        if (res.flag) {
          _that.$refs.leftTree.funComp = res.data.funComp;
          _that.$refs.leftTree.reqComp = res.data.reqComp;
          _that.$refs.leftTree.faiComp = res.data.faiComp;
          _that.$refs.leftTree.sodComp = res.data.sodComp;
          _that.$refs.leftTree.riskComp = res.data.riskComp;
          _that.$refs.rightTree.funComp = res.data.funComp;
          _that.$refs.rightTree.reqComp = res.data.reqComp;
          _that.$refs.rightTree.faiComp = res.data.faiComp;
          _that.$refs.rightTree.sodComp = res.data.sodComp;
          _that.$refs.rightTree.riskComp = res.data.riskComp;
        }
        _that.$refs.leftTree.changeCheckNodes();
        _that.$refs.rightTree.changeCheckNodes();
      });
      _that.completeLoading = false;
    },
    /**
     * 完整性检查（重新检查）
     */
    recheckIntegrity() {
      this.completeLoading = true;
      this.integrityCheck();
      this.completeLoading = false;
    },
    /**
     * 关联历史失效完整性检查
     */
    integrityFailureCheck() {
      let _that = this;
      // 对左侧树和右侧树进行数据显示更新
      _that.$api.integrityFailureCheck({
        fmeaId: this.$store.getters.fmeaId,
        rfmeaId: this.$store.getters.rfmeaId,
      }).then((res) => {
        if (res.flag) {
          _that.$refs.leftTree.historyComp = res.data.historyComp;
          _that.$refs.rightTree.historyComp = res.data.historyComp;
          _that.$refs.leftTree.changeCheckNodes();
          _that.$refs.rightTree.changeCheckNodes();
        }
      });
      _that.completeLoading = false;
    },
    /**
     * 初始化变体下拉
     */
    initVariantSelect() {
      let _that = this;
      _that.$api.getVariantMatrixSelect({
        fmeaId: _that.$store.getters.rfmeaId,
      }).then(res => {
        if (res.flag) {
          _that.variantSelectInfo = res.data.rdfmVariantManagerList || [];
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      });
    },
    /**
     * 清空变体下拉选中值
     */
    cleanVariantSelect() {
      this.variantSelectKey = undefined;
      this.variantSelectValue = undefined;
    },
    /**
     * 初始化变体下拉中，某个单独变体数据
     */
    initVariantSelectByVariantId() {
      let _that = this;
      if (!_that.variantSelectKey) return;
      _that.$api.getVariantMatrixByVariantId({
        fmeaId: _that.$store.getters.rfmeaId,
        variantId: _that.variantSelectKey,
      }).then(res => {
        if (res.flag) {
          _that.setVariantFilterNode(res.data.variantStruIds)
          // 处理变体节点显示或隐藏
          _that.handleVariantNodeShowHide();
          // 显示/隐藏，右侧树节点
        } else {
          _that.$message.error(res.message, 1);
        }
      });
    },
    /**
     * 缓存变体过滤节点
     * @param filterNodes 过滤节点
     */
    setVariantFilterNode(filterNodes) {
      this.$store.dispatch("fmeaTree/set", {
        key: "variantFilterNodes",
        value: filterNodes
      });
    },
    /**
     * 处理变体下拉改变事件
     * @param val
     */
    handleVariantSelectChange(val) {
      let _that = this;
      _that.variantSelectKey = val;
      // 默认主体数据时
      if (!val) {
        _that.setVariantFilterNode([]);
        // 处理变体节点显示或隐藏
        _that.handleVariantNodeShowHide();
        return;
      }
      _that.initVariantSelectByVariantId();
    },
    /**
     * 处理变体节点显示或隐藏
     */
    handleVariantNodeShowHide() {
      this.$refs.leftTree.handleShowHideNodes();
      this.$refs.rightTree.handleShowHideNodes();
    },
    /**
     * 取得顶部图标样式
     */
    getTopIconClass(btnInfo) {
      let color = " ";
      if (btnInfo.active) {
        color += btnInfo.key;
      }
      return 'iconfont ' + btnInfo.icon + color;
    },
    /**
     * 刷新默认顶部按钮区状态
     */
    refreshDefaultBtnStatus() {
      this.topBtns = JSON.parse(JSON.stringify(this.$store.getters.fmeaTopBtns));
      //刷新后判断完整性的按钮是否有选中状态，不正常进行重新赋值操作
      if (this.completeInspectionObj.check === true) {
        this.topBtns.map(item => {
          if (item.key === 'completeInspection') {
            item.children.map(itemChild => {
              if (this.completeInspectionObj && this.completeInspectionObj.key === itemChild.key) {
                itemChild.check = true
                this.completeInspectionObj = itemChild
              }
            })
          }
        })
      }
    },
    /**
     * 更新顶部按钮区状态
     */
    refreshBtnStatus() {
      // 处理非选中节点顶部按钮区状态
      this.handleNoCheckNodeBtnStatus();
      // 处理选中节点顶部按钮区状态
      this.handleCheckNodeBtnStatus();
      // 刷新节点显示/隐藏，按钮状态
      this.handleNodeShowHideBtnStatus();
    },
    /**
     * 刷新移动左侧节点标识状态
     */
    refreshMoveLeftNodeFlag() {
      this.moveLeftNodeFlag = true;
    },
    /**
     * 刷新移动左侧节点标识状态
     */
    refreshMoveRightNodeFlag() {
      this.moveRightNodeFlag = true;
    },
    /**
     * 处理非选中节点顶部按钮区状态
     */
    handleNoCheckNodeBtnStatus() {
      // 1：只读，2：编制
      let readOnly = this.$api.isLook !== '1';
      this.topBtns.forEach((btn) => {
        switch (btn.key) {
          case "fileImportExport": // 文件导入导出
            btn.active = readOnly;
            break;
          case "viewSideBySide": // 并排查看
            btn.active = readOnly;
            break;
          case "batchReplace": // 批量替换
            btn.active = readOnly;
            break;
          case "RecycleBin": // 回收站
            btn.active = readOnly;
            break;
          default:
            break;
        }
      });
    },
    /**
     * 处理选中节点顶部按钮区状态
     */
    handleCheckNodeBtnStatus() {
      // 选中节点
      let checkedNode = this.$store.getters.lastCheckedNode;
      if (!checkedNode) return;
      // 选中节点的树标识位：leftTree、rightTree
      let checkedLRTreeFlag = this.$store.getters.lastCheckedLRTreeFlag;
      // 复制剪切的节点
      let lastCopyOrCutNode = this.$store.getters.lastCopyOrCutNode;
      // 复制剪切的标识位：copy、cut
      let lastCopyOrCut = this.$store.getters.lastCopyOrCut;
      // 取得子组件（左/右）
      let lrTree = checkedLRTreeFlag === 'leftTree' ? this.$refs.leftTree : this.$refs.rightTree
      // 选中节点过滤掉外部结构后的的子节点
      let checkedNodeChildren = [];
      if (checkedNode.children && checkedNode.children.length > 0) {
        checkedNodeChildren = checkedNode.children.filter(item => {
          return item.struTypeCode !== '99';
        })
      }
      // 选中节点的右键菜单
      let cNodeMenus;
      this.getCurrentNodeMenus(checkedNode, checkedLRTreeFlag, val => {
        cNodeMenus = val;
      });
      // 1：只读，2：编制
      let readOnlyTopBtns = this.$api.isLook === '1' ? this.$store.getters.fmeaReadOnlyTopBtns : [];
      let topBtns = this.topBtns;
      for (let i = 0, len = topBtns.length; i < len; i++) {
        let btn = topBtns[i];
        if (readOnlyTopBtns && readOnlyTopBtns.length > 0
          && readOnlyTopBtns.indexOf(btn.key) === -1) continue;
        switch (btn.key) {
          case "excelImport": // Excel导入
            btn.active = checkedLRTreeFlag === 'leftTree';
            if (btn.active && btn.icon.indexOf(btn.key) === -1) btn.icon += (" " + btn.key);
            break;
          case "functionNet": // 功能网
            btn.active = "02,04,05".indexOf(checkedNode.struTypeCode) !== -1;
            if (btn.active && btn.icon.indexOf(btn.key) === -1) btn.icon += (" " + btn.key);
            break;
          case "faultNet": // 失效网
            btn.active = "06".indexOf(checkedNode.struTypeCode) !== -1;
            if (btn.active && btn.icon.indexOf(btn.key) === -1) btn.icon += (" " + btn.key);
            break;
          case "copy": // 复制
            btn.active = cNodeMenus.indexOf(btn.key) !== -1;
            break;
          case "cut": // 剪切
            btn.active = (cNodeMenus.indexOf(btn.key) !== -1 && checkedNode.deep !== 1); // 根节点不能剪切
            break;
          case "paste": // 粘贴
            btn.active = cNodeMenus.indexOf(btn.key) !== -1;
            if (!lastCopyOrCut) btn.active = false; // 没有复制或剪切，不允许粘贴
            // 剪切的节点不能粘贴在它的子节点下(包含自己)
            if (showPasteBtn(checkedLRTreeFlag, this.$store.getters.nodeTypeDict.paste,
              lastCopyOrCutNode, checkedNode, lastCopyOrCut) === 1) btn.active = false
            break;
          case "delete": // 删除
            // 非根节点或根节点下孩子节点中struTypeCode为01的节点数为1
            btn.active = (cNodeMenus.indexOf(btn.key) !== -1 && checkedNode.deep === 1 &&
                    checkedNodeChildren && checkedNodeChildren.length === 1)
              || (cNodeMenus.indexOf(btn.key) !== -1 && checkedNode.deep !== 1);
            break;
          case "convert": // 转换
            btn.active = (cNodeMenus.indexOf(btn.key) !== -1
              && showCurConvertBtn(checkedLRTreeFlag, checkedNode));
            break;
          case "moveUp": // 上移
            btn.active = (cNodeMenus.indexOf(btn.key) !== -1
              && showMoveUpBtn(checkedLRTreeFlag, checkedNode));
            break;
          case "moveDown": // 下移
            btn.active = (cNodeMenus.indexOf(btn.key) !== -1
              && showMoveDownBtn(checkedLRTreeFlag, checkedNode));
            break;
          case "collapseExpand": // 单级折叠/展开
            btn.active = true;
            break;
          case "collapseExpandAll": // 同级折叠/展开
            btn.active = true;
            break;
          default:
            break;
        }
      }
    },
    /**
     * 重置选中节点顶部按钮区状态
     */
    resetCheckNodeBtnStatus() {
      this.topBtns.forEach(btn => {
        switch (btn.key) {
          case "excelImport": // Excel导入
            btn.active = false;
            break;
          case "functionNet": // 功能网
            btn.active = false;
            break;
          case "faultNet": // 失效网
            btn.active = false;
            break;
          case "copy": // 复制
            btn.active = false;
            break;
          case "cut": // 剪切
            // 根节点不能剪切
            btn.active = false;
            break;
          case "paste": // 粘贴
            btn.active = false;
            break;
          case "delete": // 删除
            btn.active = false;
            break;
          case "convert": // 转换
            btn.active = false;
            break;
          case "moveUp": // 上移
            btn.active = false;
            break;
          case "moveDown": // 下移
            btn.active = false;
            break;
          case "collapseExpand": // 单级折叠/展开
            btn.active = false;
            break;
          case "collapseExpandAll": // 同级折叠/展开
            btn.active = false;
            break;
          default:
            break;
        }
      });
    },
    /**
     * 刷新节点显示/隐藏，按钮状态
     */
    handleNodeShowHideBtnStatus() {
      this.topBtns.forEach((btn) => {
        switch (btn.key) {
          case "functionShowHide": // 功能显示/隐藏
            btn.active = this.functionShowHide;
            break;
          case "featureShowHide": // 特性显示/隐藏
            btn.active = this.featureShowHide;
            break;
          case "requireShowHide": // 要求显示/隐藏
            btn.active = this.requireShowHide;
            break;
          case "faultShowHide": // 失效显示/隐藏
            btn.active = this.faultShowHide;
            break;
          case "measureShowHide": // 措施显示/隐藏
            btn.active = this.measureShowHide;
            break;
          case "functionNetShowHide": // 功能网完整性检查显示/隐藏
            btn.active = this.funNetInspectionShowHide;
            break;
          case "faultNetShowHide": // 失效网完整性检查显示/隐藏
            btn.active = this.faultNetInspectionShowHide;
            break;
          case "fileImportExport":// 文件导入导出
            if (this.batchReplaceFlag) { // 批量替换时
              btn.active = this.funInspectionShowHide; // 禁用
            }
            break;
          case "viewSideBySide": // 并排查看
            if (this.batchReplaceFlag) { // 批量替换时
              btn.active = this.funInspectionShowHide; // 禁用
            }
            break;
          case "historyShowOrHide": // 关联历史失效显示/隐藏
            btn.active = this.historyShowOrHide;
            break;
          default:
            break;
        }
      });
    },
    // DragModal的关闭方法
    cancel(item) {
      if (this.batchReplaceFlag) { // 从批量替换状态退出
        // 恢复按钮可选中
        this.topBtns.forEach((btn) => {
          switch (btn.key) {
            case "configure": // 配置按钮
              btn.active = true;
              break;
            case "languages": // 多语言
              btn.active = true;
              break;
            case "matrixList": // 矩阵
              btn.active = true;
              break;
            case "fileImportExport": // 矩阵
              btn.active = true;
              break;
            case "viewSideBySide": // 并排查看
              btn.active = true;
              break;
            case "completeInspection": // 并排查看
              btn.active = true;
              break;
            case "structureNet": // 结构网
              btn.active = true;
              break;
          }
        });
        this.batchReplaceFlag = false;
      }
      this.topBtnModal = false
    },
    /**
     * 按钮区，点击按钮事件
     */
    topBtnClick(item) {
      // 顶部节点显示/隐藏，按钮点击事件
      if (item.key !== "moveDown" && item.key !== "moveUp") {
        this.topNodeShowHideBtnClick(item);
      }
      if (!item.active) return; // 置灰按钮，点击无效
      // 并排查看、批量替换、功能矩阵、结构网、回收站
      if (item.key === 'viewSideBySide'
        || item.key === 'batchReplace'
        || item.key === 'functionMatrix'
        || item.key === 'interfaceMatrix'
        || item.key === 'statisticalAnalysis'
        || item.key === 'variantMatrix'
        || item.key === 'structureNet'
        || item.key === 'parameter'
        || item.key === 'scoringCriteriaDrawer'
        || item.key === 'RecycleBin') {
        // 正在进行批量替换
        if (item.key === 'batchReplace') {
          this.batchReplaceFlag = true;
          // 禁用按钮
          this.topBtns.forEach((btn) => {
            switch (btn.key) {
              case "configure": // 配置按钮
                btn.active = false;
                break;
              case "languages": // 多语言
                btn.active = false;
                break;
              case "matrixList": // 矩阵
                btn.active = false;
                break;
              case "fileImportExport": // 文件导入导出
                btn.active = false;
                break;
              case "viewSideBySide": // 并排查看
                btn.active = false;
                break;
              case "completeInspection": // 完整性检查
                btn.active = false;
                break;
              case "scoringCriteria": // 评分标准
                btn.active = false;
                break;
              case "structureNet": // 结构网
                btn.active = false;
                break;
            }
          });
        }
        this.dropDownClick(item);
        return;
      } else if (item.key === 'quitViewSideBySide') { // 退出并排查看
        this.closeViewSideBySide();
        // } else if (item.key === 'repairDfmea') {
        //   this.repairFmeaData();
      }
      // 恢复初始modal设置值
      // 选中节点
      let checkedNode = this.$store.getters.lastCheckedNode;
      if (!checkedNode) return;
      // 选中节点的树标识位：leftTree、rightTree
      let checkedLRTreeFlag = this.$store.getters.lastCheckedLRTreeFlag;
      // 取得子组件（左/右）
      let lrTree = checkedLRTreeFlag === 'leftTree' ? this.$refs.leftTree : this.$refs.rightTree;
      // 取得左右侧菜单信息
      let lrTreeMenus = checkedLRTreeFlag === 'leftTree' ?
        this.$store.getters.leftTreeMenus : this.$store.getters.rightTreeMenus;
      // 当前节点菜单项
      let cNodeMenus;
      this.getCurrentNodeMenus(checkedNode, checkedLRTreeFlag, val => {
        cNodeMenus = val;
      });
      let actionInfo;
      switch (item.key) {
        case "functionNet": // 功能网
          this.clearHighLightCopyCutNode();
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "showFunctionNet");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case "faultNet": // 失效网
          this.clearHighLightCopyCutNode();
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "showFaultNet");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case "copy": // 复制
          this.setHighLightCopyCutNode("copy", checkedLRTreeFlag);
          this.refreshBtnStatus();
          break;
        case "cut": // 剪切
          this.setHighLightCopyCutNode("cut", checkedLRTreeFlag);
          this.refreshBtnStatus();
          break;
        case "paste": // 粘贴
          this.paste();
          break;
        case "delete": // 删除
          this.clearHighLightCopyCutNode();
          if (checkedNode.deep === 1) {
            this.deleteRootNode(checkedNode);
          } else {
            this.deleteNode(checkedNode);
          }
          break;
        case "convert": // 转换
          this.clearHighLightCopyCutNode();
          this.convertNode(checkedNode);
          break;
        case "moveUp": // 上移
          this.clearHighLightCopyCutNode();
          this.moveNode(checkedNode, -1);
          break;
        case "moveDown": // 下移
          this.clearHighLightCopyCutNode();
          this.moveNode(checkedNode, 1);
          break;
        case "collapseExpand": // 单级折叠/展开
          this.clearHighLightCopyCutNode();
          lrTree.collapseExpand();
          break;
        case "collapseExpandAll": // 同级折叠/展开
          this.clearHighLightCopyCutNode();
          lrTree.collapseExpandAll();
          break;
        default:
          break;
      }
    },
    /**
     * 顶部节点显示/隐藏，按钮点击事件
     */
    topNodeShowHideBtnClick(item) {
      // this.cleanCheckedNode()
      switch (item.key) {
        case "functionShowHide": // 功能显示/隐藏
          // 修改：过滤节点类型
          this.updateFilterTypeCode(this.functionShowHide, ",02");
          this.functionShowHide = !this.functionShowHide;
          break;
        case "featureShowHide": // 特性显示/隐藏
          // 修改：过滤节点类型
          this.updateFilterTypeCode(this.featureShowHide, ",04");
          this.featureShowHide = !this.featureShowHide;
          break;
        case "requireShowHide": // 要求显示/隐藏
          // 修改：过滤节点类型
          this.updateFilterTypeCode(this.requireShowHide, ",05");
          this.requireShowHide = !this.requireShowHide;
          break;
        case "faultShowHide": // 失效显示/隐藏
          // 修改：过滤节点类型
          this.updateFilterTypeCode(this.faultShowHide, ",06");
          this.faultShowHide = !this.faultShowHide;
          break;
        case "measureShowHide": // 措施显示/隐藏
          // 修改：过滤节点类型
          this.updateFilterTypeCode(this.measureShowHide, ",07,14,08,09,10");
          this.measureShowHide = !this.measureShowHide;
          break;
        case "functionNetShowHide": // 功能网完整性检查显示/隐藏
          this.funNetInspectionShowHide = !this.funNetInspectionShowHide;
          break;
        case "faultNetShowHide": // 失效网完整性检查显示/隐藏
          this.faultNetInspectionShowHide = !this.faultNetInspectionShowHide;
          break;
        case "historyShowOrHide": // 关联历史问题显示/隐藏
          this.updateFilterTypeCode(!this.historyShowOrHide, null);
          this.$refs.rightTree.historyShowOrHide = !this.historyShowOrHide;
          this.$refs.leftTree.historyShowOrHide = !this.historyShowOrHide;
          this.historyShowOrHide = !this.historyShowOrHide;
          this.integrityFailureCheck();
          break;
        default:
          return;
      }
      // 刷新默认显示/隐藏状态
      this.refreshDefaultShowHideStatus(item.key);
      // 刷新节点显示/隐藏，按钮状态
      this.handleNodeShowHideBtnStatus();
      // 显示/隐藏，右侧树节点
      // this.$refs.rightTree.handleShowHideNodes();
    },
    /**
     * 刷新默认显示/隐藏状态
     * @param showHideFlag
     */
    refreshDefaultShowHideStatus(showHideFlag) {
      if (showHideFlag === 'functionNetShowHide' || showHideFlag === 'faultNetShowHide') {
        this.filterTypeCode = '';
        this.functionShowHide = true;
        this.featureShowHide = true;
        this.requireShowHide = true;
        this.faultShowHide = true;
        this.measureShowHide = true;
      }
      if (showHideFlag === 'functionNetShowHide') {
        this.faultNetShowHide = true;
      } else if (showHideFlag === 'faultNetShowHide') {
        this.functionNetShowHide = true;
      } else {
        this.faultNetShowHide = true;
        this.functionNetShowHide = true;
      }
    },
    /**
     * 修改：过滤节点类型
     * @param showHideFlag
     * @param typeCode
     */
    updateFilterTypeCode(showHideFlag, typeCode) {
      if (showHideFlag) {
        this.filterTypeCode += typeCode;
      } else {
        this.filterTypeCode = this.filterTypeCode.replace(typeCode, "");
      }
    },
    /**
     * 监听键盘，快捷键
     */
    keyListenerChange(v) {
      if (v) {
        window.removeEventListener("keydown", this.keyCodeForEvent);
      } else {
        window.addEventListener("keydown", this.keyCodeForEvent);
      }
    },
    /**
     * 监听键盘，触发事件
     */
    keyCodeForEvent(e) {
      // 选中节点
      let checkedNode = this.$store.getters.lastCheckedNode;
      if (!checkedNode) return;
      // 复制剪切的节点
      let lastCopyOrCutNode = this.$store.getters.lastCopyOrCutNode;
      // 复制剪切的标识位：copy、cut
      let lastCopyOrCut = this.$store.getters.lastCopyOrCut;
      // 选中节点的树标识位：leftTree、rightTree
      let checkedLRTreeFlag = this.$store.getters.lastCheckedLRTreeFlag;
      // 取得子组件（左/右）
      let lrTree = checkedLRTreeFlag === 'leftTree' ? this.$refs.leftTree : this.$refs.rightTree;
      // 取得左右侧菜单信息
      let lrTreeMenus = checkedLRTreeFlag === 'leftTree' ?
        this.$store.getters.leftTreeMenus : this.$store.getters.rightTreeMenus;
      // 当前节点菜单项
      let cNodeMenus;
      this.getCurrentNodeMenus(checkedNode, checkedLRTreeFlag, val => {
        cNodeMenus = val;
      });
      let actionInfo;
      switch (e.keyCode) {
        case 88: // 剪切(Ctrl+X)
          if (!e.ctrlKey) return false;
          if (checkedNode.deep === 1) return false; // 根节点不能剪切
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "cut");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 67: // 复制(Ctrl+C)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "copy");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 86: // 粘贴(Ctrl+V)
          if (!e.ctrlKey) return false;
          if (!lastCopyOrCut) return false; // 没有复制或剪切，不允许粘贴
          // 剪切的节点不能粘贴在它的子节点下(包含自己)
          if (showPasteBtn(checkedLRTreeFlag, this.$store.getters.nodeTypeDict.paste,
            lastCopyOrCutNode, checkedNode, lastCopyOrCut) === 1) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "paste");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 65: // 结构(Ctrl+A)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addStructure");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 83: // 功能(Shift+S)
          if (!e.shiftKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addFunction");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 87: // 产品特性(Shift+W)
          if (!e.shiftKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addProductFeature");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 69: // 要求(Ctrl+E)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addRequire");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 68: // 失效(Shift+D)
          if (!e.shiftKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addFault");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 71: // 当前预防控制(Ctrl+G)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addCurrentPreventionMeasure");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 66: // 当前探测控制(Ctrl+B)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addCurrentProbeMeasure");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 82: // 功能网(Shift+R)
          if (!e.shiftKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "showFunctionNet");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 77: // 合并(Alt+M)
          if (!e.altKey) return false;
          if (checkedNode.deep === 1) return false; // 根节点不能合并
          else if (showMergeBtn(checkedLRTreeFlag, checkedNode) === 1) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "merge");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 46: // Delete
          if (checkedNode.deep === 1) return false; // 根节点不能删除
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "delete");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 38: // 同级上移(Ctrl+↑)
          if (!e.ctrlKey) return false;
          if (checkedNode.deep === 1) return false;  // 根节点不能移动
          else if (!showMoveUpBtn(checkedLRTreeFlag, checkedNode)) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "moveUp");
          if (actionInfo) {
            lrTree.menuAction(actionInfo);
          }
          break;
        case 40: // 同级下移(Ctrl+↓)
          if (!e.ctrlKey) return false;
          if (checkedNode.deep === 1) return false;  // 根节点不能移动
          else if (!showMoveDownBtn(checkedLRTreeFlag, checkedNode)) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "moveDown");
          if (actionInfo) {
            lrTree.menuAction(actionInfo);
          }
          break;
        case 81: // 属性(Ctrl+Q)
          if (!e.ctrlKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "property");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        case 78: // 评审意见(Shift+N)
          if (!e.shiftKey) return false;
          actionInfo = this.getNodeActionInfo(lrTreeMenus, cNodeMenus, "addReviewComments");
          if (actionInfo) lrTree.menuAction(actionInfo);
          break;
        default:
          break;
      }
    },
    /**
     * 取得当前节点的右键菜单项
     * @param checkNode 选中节点
     * @param treeFlag 树标识（leftTree、rightTree）
     * @param callback 回调方法
     */
    getCurrentNodeMenus(checkNode, treeFlag, callback) {
      let nodeTypeDict = Object.values(this.$store.getters.nodeTypeDict.functionAnalysis).filter((item) => {
        return item.key === checkNode.struTypeCode;
      })[0];
      let nodeMenus = {};
      // 1：只读，2：编制
      let readOnly = this.$api.isLook;
      // 只读
      if (readOnly === '1') {
        if (treeFlag === 'leftTree') nodeMenus = nodeTypeDict.leftMenuReadOnly;
        else nodeMenus = nodeTypeDict.rightMenuReadOnly;
        return callback(nodeMenus);
      }
      // 编制
      if (treeFlag === 'leftTree') {
        nodeMenus = JSON.parse(JSON.stringify(nodeTypeDict.leftMenu));
        // 只有根结构时，不能删除根节点
        nodeMenus = this.onlyTheRootNode(nodeMenus);
      } else {
        nodeMenus = JSON.parse(JSON.stringify(nodeTypeDict.rightMenu));
      }
      // 特殊'连线结构'，过滤掉'结构、多级添加'
      if (checkNode.struTypeCode === '01' && checkNode.connectId) {
        nodeMenus = this.handleLineStructureMenu(nodeMenus);
      }
      return callback(nodeMenus);
    },
    /**
     * 只有根结构时，不能删除根节点
     * 右键菜单，不显示【删除根节点】
     * @param nodeMenus 节点菜单
     */
    onlyTheRootNode(nodeMenus) {
      let treeObj = $.fn.zTree.getZTreeObj('leftTree');
      let nodes = treeObj.getNodes();
      if (nodes && nodes[0] && !nodes[0].children) {
        let filterMenus = ['deleteRoot'];
        for (let i = nodeMenus.length - 1; i >= 0; i--) {
          if (filterMenus.filter(item => item === nodeMenus[i])[0])
            nodeMenus.splice(i, 1);
        }
      }
      return nodeMenus;
    },
    /**
     * 处理连线结构
     * 右键菜单，不显示【结构、多级添加、复制、剪切、粘贴、合并】
     * @param nodeMenus 节点菜单
     */
    handleLineStructureMenu(nodeMenus) {
      let filterMenus = ['addStructure', 'addMultistageStructure', 'copy', 'cut', 'paste', 'merge', 'property'];
      for (let i = nodeMenus.length - 1; i >= 0; i--) {
        if (filterMenus.filter(item => item === nodeMenus[i])[0])
          nodeMenus.splice(i, 1);
      }
      return nodeMenus;
    },
    /**
     * 取得节点对应的菜单信息
     * @param lrTreeMenus 左右树总菜单
     * @param nodeMens 该节点菜单
     * @param menuKey 菜单标识
     */
    getNodeActionInfo(lrTreeMenus, nodeMens, menuKey) {
      let actionInfo;
      if (nodeMens.indexOf(menuKey) === -1) return;
      lrTreeMenus.forEach((item) => {
        if (item.key === menuKey) actionInfo = item;
      });
      return actionInfo;
    },
    /**
     * 选中节点时，存储当前节点信息
     */
    setCheckedNode(node, treeFlag) {
      if (treeFlag === 'leftTree') {
        this.$store.dispatch("fmeaTree/set", {
          key: "checkedLeftNode",
          value: node
        });
        this.$store.dispatch("fmeaTree/set", {
          key: "checkedRightNode",
          value: undefined
        });
      } else {
        this.$store.dispatch("fmeaTree/set", {
          key: "checkedRightNode",
          value: node
        });
      }
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCheckedNode",
        value: node
      });
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCheckedLRTreeFlag",
        value: treeFlag
      });
    },
    /**
     * 选中节点时，清除当前节点信息
     */
    cleanCheckedNode() {
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCheckedNode",
        value: undefined
      });
      this.$store.dispatch("fmeaTree/set", {
        key: "checkedRightNode",
        value: undefined
      });
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCheckedLRTreeFlag",
        value: undefined
      });
    },
    /**
     * 清除：缓存左侧节点
     */
    cleanCheckedLeftNode() {
      this.$store.dispatch("fmeaTree/set", {
        key: "checkedLeftNode",
        value: undefined
      });
    },
    /**
     * 高亮节点
     */
    setHighLightNode(node, treeFlag) {
      let className = treeFlag + "-node-selected";
      let treeEleId = treeFlag + "Node";
      let multiSelectedNode = this.$store.getters.multiSelectedNode;
      if (!multiSelectedNode || multiSelectedNode.length === 0) {
        let arr = document.getElementsByClassName(className);
        // 清除其他高亮节点
        if (arr) {
          for (let i = 0; i < arr.length; i++) {
            removeClass(arr[i], className);
          }
        }
      }
      addClass(
        document.getElementById(treeEleId + node.id),
        className
      );
    },
    /**
     * 左侧树高亮节点
     */
    setHighLightLNode(node, treeFlag) {
      let className = treeFlag + "-node-selected";
      let treeEleId = treeFlag + "Node";
      let multiSelectedNode = this.$store.getters.multiSelectedLNode;
      if (!multiSelectedNode || multiSelectedNode.length === 0) {
        let arr = document.getElementsByClassName(className);
        // 清除其他高亮节点
        if (arr) {
          for (let i = 0; i < arr.length; i++) {
            removeClass(arr[i], className);
          }
        }
      }
      addClass(
        document.getElementById(treeEleId + node.id),
        className
      );
    },
    clearMultipleHighLightNode(treeFlag) {
      let className = treeFlag + "-node-selected";
      let arr = document.getElementsByClassName(className);
      let multiSelectedNode = this.$store.getters.multiSelectedNode;
      if (arr && multiSelectedNode && multiSelectedNode.length > 0) {
        for (let i = 0; i < arr.length; i++) {
          removeClass(arr[i], className);
        }
      }
    },
    setMultipleHighLightNode(node, treeFlag) {
      let className = treeFlag + "-node-selected";
      let treeEleId = treeFlag + "Node";
      let mulNode = this.$store.getters.multiSelectedNode;
      let arr = document.getElementsByClassName(className);
      if (arr) {
        let docArr = Array.from(arr);
        docArr.forEach(item => {
          removeClass(document.getElementById(item.id), className);
        });
      }
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCutNode",
        value: this.$store.getters.lastCheckedNode
      });
      mulNode.forEach(item => {
        addClass(document.getElementById(treeEleId + item.id), className);
      });
    },
    clearMultipleHighLightLNode(treeFlag) {
      let className = treeFlag + "-node-selected";
      let arr = document.getElementsByClassName(className);
      let multiSelectedNode = this.$store.getters.multiSelectedLNode;
      if (arr && multiSelectedNode && multiSelectedNode.length > 0) {
        for (let i = 0; i < arr.length; i++) {
          removeClass(arr[i], className);
        }
      }
    },
    setMultipleHighLightLNode(node, treeFlag) {
      let className = treeFlag + "-node-selected";
      let treeEleId = treeFlag + "Node";
      let mulNode = this.$store.getters.multiSelectedLNode;
      let arr = document.getElementsByClassName(className);
      if (arr) {
        let docArr = Array.from(arr);
        docArr.forEach(item => {
          removeClass(document.getElementById(item.id), className);
        });
      }
      mulNode.forEach(item => {
        addClass(document.getElementById(treeEleId + item.id), className);
      });
    },
    /**
     * 设置：复制/剪切时，节点高亮
     */
    async setHighLightCopyCutLNode(cutCopy, treeFlag) {
      let treeEleId = treeFlag + "Node";
      this.clearHighLightCopyCutNode();
      let multiSelectedNode = this.$store.getters.multiSelectedLNode;
      if (multiSelectedNode && multiSelectedNode.length > 0) {
        multiSelectedNode.forEach(item => {
          addClass(document.getElementById(treeEleId + item.id), "curCopyCutNode");
          removeClass(document.getElementById(treeEleId + item.id), treeFlag + "-node-selected");
        });
      } else {
        addClass(
          document.getElementById(treeEleId + this.$store.getters.lastCheckedNode.id),
          "curCopyCutNode"
        );
      }
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCutNode",
        value: this.$store.getters.lastCheckedNode
      });
      // 存储操作树标识位：leftTree or rightTree
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCutLRTreeFlag",
        value: treeEleId
      });
      // 存储操作类型标识位：复制=copy or 剪切=cut
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCut",
        value: cutCopy
      });
      // addClass(
      //     document.getElementById(treeEleId + this.$store.getters.lastCheckedNode.id),
      //     "curCopyCutNode"
      // );
    },
    /**
     * 清除：复制/剪切时，节点高亮
     */
    clearHighLightCopyCutLNode() {
      if (!this.$store.getters.lastCopyOrCutNode) return;
      let multiCopyNode = this.$store.getters.multiCopyNode;
      let cls = "curCopyCutNode";
      if (multiCopyNode && multiCopyNode.length > 0) {
        this.clearMultipleHighLightNode("rightTree");
        multiCopyNode.forEach(item => {
          let el = document.getElementById(this.$store.getters.lastCopyOrCutLRTreeFlag + item.id);
          if (el) removeClass(el, cls);
        });
      } else {
        let ele = document.getElementById(this.$store.getters.lastCopyOrCutLRTreeFlag
          + this.$store.getters.lastCopyOrCutNode.id);
        if (ele) removeClass(ele, cls);
      }
      this.$store.dispatch("fmeaTree/clearCopyOrCut");
      this.refreshBtnStatus();
    },
    /**
     * 设置：复制/剪切时，节点高亮
     * @param cutCopy copy、cut
     * @param treeFlag leftTree、rightTree
     */
    setHighLightCopyCutNode(cutCopy, treeFlag) {
      let lastCheckedNode = this.$store.getters.lastCheckedNode;
      if (!lastCheckedNode) return;
      this.clearHighLightCopyCutNode();
      addClass(document.getElementById(lastCheckedNode.tId + '_a'), "curCopyCutNode");
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCutNode",
        value: lastCheckedNode
      });
      // 存储操作树标识位：leftTree or rightTree
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCutLRTreeFlag",
        value: treeFlag
      });
      // 存储操作类型标识位：复制=copy or 剪切=cut
      this.$store.dispatch("fmeaTree/set", {
        key: "lastCopyOrCut",
        value: cutCopy
      });
    },
    /**
     * 清除：复制/剪切时，节点高亮
     */
    clearHighLightCopyCutNode() {
      let lastCopyOrCutNode = this.$store.getters.lastCopyOrCutNode;
      let treeId = lastCopyOrCutNode?.tId.split('_')[0];
      if (lastCopyOrCutNode && treeId) {
        let treeObj = $.fn.zTree.getZTreeObj(treeId);
        let node = treeObj.getNodeByParam("id", lastCopyOrCutNode?.id, null);
        if (node) {
          removeClass(document.getElementById(node.tId + '_a'), "curCopyCutNode");
        }
        this.$store.dispatch("fmeaTree/clearCopyOrCut");
      }
    },
    /**
     * 恢复高亮复制节点,目的：允许一次复制多次粘贴
     * @param treeId
     */
    restoreHighLightCopyNode(treeId) {
      let lastCopyOrCutNode = this.$store.getters.lastCopyOrCutNode;
      let lastCopyOrCut = this.$store.getters.lastCopyOrCut;
      if (lastCopyOrCutNode && lastCopyOrCut === 'copy') {
        let treeObj = $.fn.zTree.getZTreeObj(treeId);
        let node = treeObj.getNodeByParam("id", lastCopyOrCutNode?.id, null);
        if (node) {
          addClass(document.getElementById(node.tId + '_a'), "curCopyCutNode");
        }
      }
    },
    /**
     * 粘贴
     */
    paste() {
      let _that = this;
      let copyOrCutLRTreeFlag = this.$store.getters.lastCopyOrCutLRTreeFlag;
      // 区分并排查看
      if (copyOrCutLRTreeFlag === 'sideLeftTree' || copyOrCutLRTreeFlag === 'sideRightTree') {
        _that.viewSideBySidePasteNode();
      } else {
        _that.pasteNode();
      }
    },
    /**
     * 并排查看粘贴节点
     */
    viewSideBySidePasteNode() {
      let _that = this;
      // 开启加载...
      _that.showHideLoading(true);
      _that.$api.pasteNodeFromOtherFMEA({
        parentFmeaId: _that.$store.getters.rfmeaId, // 目标fmeaId
        parentStruId: _that.$store.getters.lastCheckedNode.id, // 目标节点ID
        selectFmeaId: _that.$store.getters.sideRfmeaId, // 并排查看fmeaId
        selectStruId: _that.$store.getters.lastCopyOrCutNode.id, // 被复制节点ID
        importingWay: 'all', // 所有节点
      }).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          // 粘贴后节点ID
          _that.pasteAfterNodeId = res.data.newStruId;
          // 粘贴回调方法设置目标选中节点id(设置焦点时使用)
          _that.$refs.leftTree.setPasteCompletedNodeId(_that.pasteAfterNodeId);
          _that.$refs.rightTree.setPasteCompletedNodeId(_that.pasteAfterNodeId);
          let struTypeCode = _that.$store.getters.lastCopyOrCutNode.struTypeCode;
          // 刷新树
          if ("01,99".indexOf(struTypeCode) !== -1) {
            _that.initLeftTree();
          } else {
            _that.initRightTree();
          }
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      }).finally(() => {
        // 关闭加载...
        _that.showHideLoading(false);
      });
    },
    // 拖拽左侧树
    dropL(data) {
      let paramObj = {};
      let multipleNode = this.$store.getters.multiSelectedLNode
      if (multipleNode && multipleNode.length > 1) {
        multipleNode.sort((a, b) => {
          return a.leftNo - b.leftNo
        })
        let struIdList = multipleNode.map(item => item.id)
        paramObj.srcStruIdList = struIdList;
      } else if (data.sourceStru.pid == data.targetStruId) {
        return
      } else {
        multipleNode.push(data.sourceStru)
      }
      paramObj.struId = data.targetStru.id;
      paramObj.fmeaId = this.$store.getters.rfmeaId;
      paramObj.source = multipleNode;
      paramObj.target = data.targetStru;
      paramObj.pos = data.pos;
      this.dropNode(paramObj);
    },
    // 拖拽右侧树
    drop(data) {
      let paramObj = {};
      let multipleNode = this.$store.getters.multiSelectedNode
      if (multipleNode && multipleNode.length > 1) {
        multipleNode.sort((a, b) => {
          return a.leftNo - b.leftNo
        })
        let struIdList = multipleNode.map(item => item.id)
        paramObj.srcStruIdList = struIdList;
      } else if (data.sourceStru.pid == data.targetStru.id) {
        this.$refs.rightTree.treeLoadings(false)
        // 拖拽至父级不做处理
        return
      } else {
        this.$store.dispatch("fmeaTree/set", {
          key: "lastCopyOrCutNode",
          value: this.$store.getters.lastCheckedNode
        });
        multipleNode.push(data.sourceStru)
      }
      if (!data.targetStru) return
      // 复制剪切的节点
      let lastCopyOrCutNode = this.$store.getters.lastCopyOrCutNode;
      if (this.judgeCutOrSort(multipleNode[0].struTypeCode, data.targetStru.struTypeCode)) {
        let poses = data.targetStru.pos.split('-')
        if ((poses[poses.length - 1] == data.pos && multipleNode[0].struTypeCode != '06' && data.targetStru.struTypeCode != '05') || (poses[poses.length - 1] == data.pos && multipleNode[0].struTypeCode == '06' && data.targetStru.struTypeCode == '06')) {
          this.$refs.rightTree.treeLoadings(false);
          this.clearMultipleHighLightNode("rightTree");
          this.$refs.rightTree.selectedNode = [];
          return;
        }
        paramObj.struId = data.targetStru.id;
        paramObj.fmeaId = this.$store.getters.rfmeaId;
        paramObj.source = multipleNode;
        paramObj.target = data.targetStru;
        paramObj.pos = data.pos;
        this.dropNode(paramObj);
      } else {
        // 剪切的节点不能粘贴在它的子节点下(包含自己)
        if (showPasteBtn(this.$store.getters.nodeTypeDict.paste, lastCopyOrCutNode, data.targetStru, 'cut') === 1) {
          this.$refs.rightTree.treeLoadings(false);
          this.clearMultipleHighLightNode("rightTree");
          this.$refs.rightTree.selectedNode = [];
          return
        }
        paramObj.struId = data.targetStru.id;
        paramObj.fmeaId = this.$store.getters.rfmeaId;
        paramObj.srcStruId = data.sourceStru.id;
        paramObj.optType = 2;
        this.$api.pasteNode(paramObj).then((res) => {
          if (res.flag) {
            this.$message.success(res.message, 1);
            // 粘贴后节点ID
            this.pasteAfterNodeId = res.data.pasteStruId;
            // 刷新树
            this.initLeftTree();
            this.initRightTree();
          } else {
            this.$message.error(res.message, 1);
          }
        }).catch((error) => {
          this.$message.error(error.response.data.message, 1);
        })
      }
    },
    /**
     * 判断是剪切还是排序
     */
    judgeCutOrSort(struTypeCode1, struTypeCode2) {
      // 第一段判断是否是功能、产品特性、过程特性，第二段判断将失效拖拽至要求拖拽至要求，第三段判断其余节点不同的操作
      return ('02,03,04'.indexOf(struTypeCode1) != -1 && '02,03,04'.indexOf(struTypeCode2) != -1) || ('06' == struTypeCode1 && '05' == struTypeCode2) || ('05' == struTypeCode1 && '06' == struTypeCode2) || ('09,10'.indexOf(struTypeCode1) != -1 && '09,10'.indexOf(struTypeCode2) != -1) || struTypeCode1 == struTypeCode2;
    },
    /**
     * 调用拖拽接口
     */
    dropNode(data) {
      this.$api.dropNode(data).then((res) => {
        if (res.flag) {
          this.$message.success(res.message, 1);
          // 粘贴后节点ID
          this.pasteAfterNodeId = res.data.pasteStruId;
          // 刷新树
          this.initLeftTree();
          this.initRightTree();
        } else {
          this.$message.error(res.message, 1);
        }
      }).catch((error) => {
        this.$message.error(error.response.data.message, 1);
      })

    },

    /**
     * 粘贴节点
     */
    pasteNode() {
      let _that = this;
      // 粘贴是否携带上级功能网、失效网关系变量 0：不携带；1：携带
      var pastePormpt = 0;
      if (_that.$store.getters.lastCopyOrCut === 'copy'
        && (_that.$store.getters.lastCopyOrCutNode.struTypeCode === '01'
          || _that.$store.getters.lastCopyOrCutNode.struTypeCode === '99')) {
        _that.$confirm({
          title: this.$t('global-message.remind'),
          content: this.$t('global-message.paste.prompt'),
          icon: "aaoopqa", //图标，不想用就随便写一个
          okText: this.$t('global-btn.yes'),
          cancelText: this.$t('global-btn.no'),
          onCancel() {
            pastePormpt = 0;
            _that.pasteJump(pastePormpt);
          },
          onOk() {
            pastePormpt = 1;
            _that.pasteJump(pastePormpt)
          },
        });
      } else {
        _that.pasteJump(pastePormpt);
      }
    },
    /**
     * 粘贴跳转
     */
    pasteJump(pastePormpt) {
      let _that = this;
      let multipleNode = _that.$store.getters.multiCopyNode;
      let paramObj = {};
      paramObj.optType = _that.$store.getters.lastCopyOrCut === "copy" ? 1 : 2;
      paramObj.struId = _that.$store.getters.lastCheckedNode.id;
      paramObj.fmeaId = _that.$store.getters.rfmeaId;
      paramObj.pastePormpt = pastePormpt;
      if (multipleNode && multipleNode.length > 0) {
        let struIdList = multipleNode.map(item => item.id)
        paramObj.srcStruIdList = struIdList;
      } else {
        paramObj.srcStruId = _that.$store.getters.lastCopyOrCutNode.id;
      }
      // 开启加载...
      _that.showHideLoading(true);
      _that.$api.pasteNode(paramObj).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          // 粘贴后节点ID
          _that.pasteAfterNodeId = res.data.pasteStruId;
          // 粘贴回调方法设置目标选中节点id(设置焦点时使用)
          _that.$refs.leftTree.setPasteCompletedNodeId(_that.pasteAfterNodeId);
          _that.$refs.rightTree.setPasteCompletedNodeId(_that.pasteAfterNodeId);
          let struTypeCode = _that.$store.getters.lastCopyOrCutNode.struTypeCode;
          // 刷新树
          if ("01,99".indexOf(struTypeCode) !== -1) {
            _that.initLeftTree();
          } else {
            _that.initRightTree();
          }
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      }).finally(() => {
        // 清除：剪切时，节点高亮
        if (this.$store.getters.lastCopyOrCut === 'cut')
          _that.clearHighLightCopyCutNode();
        // 关闭加载...
        _that.showHideLoading(false);
      });
    },
    // 粘贴回调方法设置目标选中节点id(设置焦点时使用)
    pasteNodeSelection(pasteStruId) {
      this.$refs.leftTree.setPasteCompletedNodeId(pasteStruId);
      this.$refs.rightTree.setPasteCompletedNodeId(pasteStruId);
    },
    /**
     * 添加措施状态
     * @param node 节点
     * @param label 内容
     * @param struTypeCode 14：当前措施，07：优化措施
     */
    addMeasure(node, label, struTypeCode) {
      let content = this.$t('global-message.remind.append.measure', [label]);
      let _that = this;
      _that.$confirm({
        title: this.$t('global-message.remind'),
        content: content,
        icon: "aaoopqa", //图标，不想用就随便写一个
        okText: this.$t('global-btn.ok'),
        cancelText: this.$t('global-btn.cancel'),
        onOk() {
          _that.$api.saveMeasure({
            fmeaId: _that.$store.getters.rfmeaId,
            struId: node.id,
            struTypeCode: struTypeCode,
          }).then((res) => {
            if (res.flag) {
              _that.$message.success(res.message, 1);
              // 刷新右侧树
              _that.initRightTree();
            } else {
              _that.$message.error(res.message, 1);
            }
          }).catch((error) => {
            _that.$message.error(error.response.data.message, 1);
          })
        },
        onCancel() {
        }
      });
    },
    /**
     * 添加措施组
     */
    addGroup(node) {
      let content = this.$t('global-message.remind.append.group');
      let _that = this;
      _that.$confirm({
        title: this.$t('global-message.remind'),
        content: content,
        icon: "aaoopqa", //图标，不想用就随便写一个
        okText: this.$t('global-btn.ok'),
        cancelText: this.$t('global-btn.cancel'),
        onOk() {
          _that.$api.saveGroup({
            fmeaId: _that.$store.getters.rfmeaId,
            struId: node.id,
          }).then((res) => {
            if (res.flag) {
              _that.$message.success(res.message, 1);
              // 刷新右侧树
              _that.initRightTree();
            } else {
              _that.$message.error(res.message, 1);
            }
          }).catch((error) => {
            _that.$message.error(error.response.data.message, 1);
          })
        },
        onCancel() {
        }
      });
    },
    /**
     * 删除节点
     */
    deleteNode(node) {
      let _that = this;
      // 确保唯一
      if (_that.deleteModal) {
        // 销毁
        _that.deleteModal.destroy();
      }
      let multipleNode = _that.$store.getters.multiSelectedNode;
      let deleteContent = undefined;
      let deleteNumber = undefined;
      let data = {
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: node.id
      };
      // 发送请求，统计删除的节点数量
      _that.$api.getDeleteNodeNumber(data).then(res => {
        if (res.flag) {
          deleteNumber = res.data;
          // 根据删除的节点类型，设置不同的删除提示语
          switch (node.struTypeCode) {
            // 结构
            case '01':
              deleteContent = _that.$t('global-message.warn.structural.analysis.node.delete', [deleteNumber]);
              break;
            // 接口
            case '99':
              deleteContent = _that.$t('global-message.warn.functiones.interfaces.delete', [deleteNumber]);
              break;
            //  功能
            case '02':
              deleteContent = _that.$t('global-message.warn.function.delete', [deleteNumber]);
              break;
            // 产品特性
            case '04':
              deleteContent = _that.$t('global-message.warn.product.features.delete', [deleteNumber]);
              break;
            //  要求
            case '05':
              deleteContent = _that.$t('global-message.warn.requirement.delete', [deleteNumber]);
              break;
            //  失效
            case '06':
              deleteContent = _that.$t('global-message.warn.validity.delete', [deleteNumber]);
              break;
            //  优化措施
            case '07':
              deleteContent = _that.$t('global-message.warn.optimizationes.delete', [deleteNumber]);
              break;
            //  当前措施
            case '14':
              deleteContent = _that.$t('global-message.warn.current.measures.delete', [deleteNumber]);
              break;
            //  措施组
            case '08':
              deleteContent = _that.$t('global-message.warn.action.group.delete', [deleteNumber]);
              break;
            //  预防
            case '09':
              deleteContent = _that.$t('global-message.warn.mensura.preventiva.delete', [deleteNumber]);
              break;
            //  探测
            case '10':
              deleteContent = _that.$t('global-message.warn.detection.measures.delete', [deleteNumber]);
              break;
            default:
              break;
          }
          _that.deleteModal = _that.$confirm({
            title: _that.$t('global-message.warn'),
            content: deleteContent,
            okText: _that.$t('global-btn.ok'),
            cancelText: _that.$t('global-btn.cancel'),
            onCancel() { },
            onOk() {
              let paramObj = {};
              paramObj.fmeaId = _that.$store.getters.rfmeaId;
              if (multipleNode && multipleNode.length > 0) {
                paramObj.struIdList = multipleNode.map(item => item.id);
              } else {
                paramObj.struId = node.id;
              }
              // 开启加载...
              _that.showHideLoading(true);
              _that.$api.deleteNode(paramObj).then((res) => {
                if (res.flag) {
                  _that.$message.success(res.message, 1);
                  _that.cleanCheckedNode();
                  if ("01,99".indexOf(node.struTypeCode) !== -1) {
                    _that.cleanCheckedLeftNode();
                    _that.initLeftTree();
                    _that.$refs.rightTree.selectedNode = [];
                  }
                  _that.initRightTree();
                } else {
                  _that.$message.error(res.message, 1);
                }
              }).catch((error) => {
                _that.$message.error(error.response.data.message, 1);
              }).finally(() => {
                _that.resetCheckNodeBtnStatus();
                // 关闭加载...
                _that.showHideLoading(false);
              })
            },
          });
        }
      });
    },
    /**
     * 删除根节点
     * @param node 节点
     */
    deleteRootNode(node) {
      let _that = this;
      let deleteContent = undefined;
      let deleteNumber = undefined;
      let data = {
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: node.id
      };
      _that.$api.getDeleteNodeNumber(data).then(res => {
        if (res.flag) {
          deleteNumber = res.data;
          deleteContent = _that.$t('global-message.warn.nodo.radice.delete', [deleteNumber]);
          _that.$confirm({
            title: _that.$t('global-message.warn'),
            content: deleteContent,
            okText: _that.$t('global-btn.ok'),
            cancelText: _that.$t('global-btn.cancel'),
            onCancel() { },
            onOk() {
              _that.$api.deleteRootNode({
                fmeaId: _that.$store.getters.rfmeaId,
                struId: node.id
              }).then((res) => {
                if (res.flag) {
                  _that.$message.success(res.message, 1);
                  _that.cleanCheckedNode();
                  _that.cleanCheckedLeftNode();
                  _that.initLeftTree();
                  _that.initRightTree();
                } else {
                  _that.$message.error(res.message, 1);
                }
              }).catch((error) => {
                _that.$message.error(error.response.data.message, 1);
              }).finally(() => {
                _that.resetCheckNodeBtnStatus();
              })
            }
          });
        }
      });
    },
    /**
     * 转换节点
     */
    convertNode(node) {
      let _that = this;
      if ('07,14'.indexOf(node.struTypeCode) !== -1) { // 措施状态（当前/优化）
        _that.$api.convertMeasure({
          fmeaId: _that.$store.getters.rfmeaId,
          struId: node.id,
          parentStruId: node.pid,
          measureState: node.struTypeCode,
        }).then((res) => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            _that.initRightTree();
          } else {
            _that.$message.error(res.message, 1);
          }
        }).catch((error) => {
          _that.$message.error(error.response.data.message, 1);
        });
      } else {
        _that.$api.convertNode({
          fmeaId: _that.$store.getters.rfmeaId,
          struId: node.id
        }).then((res) => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            _that.initRightTree();
          } else {
            _that.$message.error(res.message, 1);
          }
        }).catch((error) => {
          _that.$message.error(error.response.data.message, 1);
        });
      }
    },
    /**
     * 上移/下移
     * @param node 节点
     * @param optType -1上移，1下移
     */
    async moveNode(node, optType) {
      let _that = this;
      // 选中节点的树标识位：leftTree、rightTree
      let checkedLRTreeFlag = this.$store.getters.lastCheckedLRTreeFlag;
      let targetNode = getMoveTargetNode(checkedLRTreeFlag, node, optType);
      if (checkedLRTreeFlag === 'leftTree') {
        if (!_that.moveLeftNodeFlag) return;
        _that.moveLeftNodeFlag = false;
      } else if (checkedLRTreeFlag === 'rightTree') {
        if (!_that.moveRightNodeFlag) return;
        _that.moveRightNodeFlag = false;
      }
      await _that.$api.moveNode({
        fmeaId: _that.$store.getters.rfmeaId,
        optType: optType,
        struId: node.id,
        targetStruId: targetNode.id,
      }).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          // 回调方法设置目标选中节点id(设置焦点时使用)
          if (checkedLRTreeFlag === 'leftTree') {
            _that.$refs.leftTree.setPasteCompletedNodeId(node.id);
          } else {
            _that.$refs.rightTree.setPasteCompletedNodeId(node.id);
          }
          if ("01,99".indexOf(node.struTypeCode) !== -1) {
            _that.initLeftTree();
          } else {
            _that.initRightTree();
          }
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      });
    },
    /**
     * 添加上级
     */
    addParent(node) {
      let _that = this;
      this.$confirm({
        title: this.$t('global-message.warn'),
        content: this.$t('global-message.warn.add-parent'),
        icon: "aaoopqa", //图标，不想用就随便写一个
        okText: this.$t('global-btn.ok'),
        cancelText: this.$t('global-btn.cancel'),
        onOk() {
          _that.$api.saveParentStructure({
            fmeaId: _that.$store.getters.rfmeaId,
            struId: node.id
          }).then((res) => {
            if (res.flag) {
              _that.$message.success(res.message, 1);
              _that.cleanCheckedLeftNode();
              _that.initLeftTree();
              _that.initRightTree();
            } else {
              _that.$message.error(res.message, 1);
            }
          }).catch((error) => {
            _that.$message.error(error.response.data.message, 1);
          });
        },
        onCancel() {
        }
      });
    },
    /**
     * 修改节点SOD值
     * @param nodeId 节点ID
     * @param val sod值
     * @param sodFlag 1:S、2:O、3:D
     */
    updateNodeSOD(nodeId, val, sodFlag) {
      let _that = this;
      _that.$api.updateNodeSOD({
        fmeaId: _that.$store.getters.fmeaId,
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: nodeId,
        levelId: val,
        sodFlag: sodFlag,
      }).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          _that.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      });
    },
    /**
     * 修改节点潜在关键特性
     * @param node 节点
     * @param classify 特性标识
     */
    updateNodeClassify(node, classify) {
      let _that = this;
      _that.$api.updateNodeClassify({
        fmeaId: _that.$store.getters.fmeaId,
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: node.id,
        struTypeCode: node.struTypeCode,
        classify: classify,
      }).then((res) => {
        if (res.flag) {
          _that.$message.success(res.message, 1);
          _that.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).catch((error) => {
        _that.$message.error(error.response.data.message, 1);
      });
    },
    /**
     * RFMEA文件导出
     */
    RFMEAExport() {
      let rfmeaId = this.$store.getters.rfmeaId;
      let url = this.$api.baseUrl + "/DFMEA/rdfmImport/Rb0426191/exportJson?fmeaId=" + rfmeaId;
      window.open(url);
    },
    /**
     * XML文件导出
     */
    XMLExport() {
      let rfmeaId = this.$store.getters.rfmeaId;
      let url = this.$api.baseUrl + "/DFMEA/rdfmImport/Rb0426195/exportXML?fmeaId=" + rfmeaId;
      window.open(url);
    },
    /**
     * 显示、隐藏主界面 -- 加载Loading
     * @param flag
     */
    showHideLoading(flag) {
      if (flag) {
        if (this.loader) this.loader.hide();
        this.loader = this.$loading.show({
          container: this.$refs.mainTree,
          color: '#1890FF',
        }, {
          // 自定义加载动画组件
          default: this.$createElement('ant-spin-dot'),
        });
      } else {
        this.loader.hide();
      }
    },
    /**
     * 顶部按钮下拉单击
     * @param obj 下拉对象
     */
    dropDownClick(obj) {
      this.clearHighLightCopyCutNode();
      if (obj.key === 'RFMEAExport') { // RFMEA文件导出
        this.RFMEAExport();
        return;
      } else if (obj.key === 'XMLExport') { // XML文件导出
        this.XMLExport();
        return;
      } else if (obj.key === 'variantMatrix') { // 变体矩阵
        this.$refs.variantMatrixModal.getTableData();
        this.showVariantMatrixModal = true;
        return;
      } else if (obj.key === 'interfaceMatrix') { // 接口矩阵
        // this.$refs.interfaceMatrixModal.getLeftSelect();
        // 默认根节点ID
        // let rootNodeId = this.$refs.leftTree.treeData[0].id;
        this.$refs.interfaceMatrixModal.list();
        this.showInterfaceMatrixModal = true;
        return;
      } else if (obj.key === 'functionMatrix') { // 功能矩阵
        this.$refs.functionMatrixModal.getLeftSelect();
        // 默认根节点ID
        let rootNodeId = this.$refs.leftTree.initData[0].id;
        this.$refs.functionMatrixModal.list(rootNodeId);
        this.showFunctionMatrixModal = true;
        return;
      } else if (obj.key === 'failureMatrix') { // 失效矩阵
        this.$refs.failureMatrixModal.getLeftSelect();
        // 默认根节点ID
        let rootNodeId = this.$refs.leftTree.initData[0].id;
        this.$refs.failureMatrixModal.list(rootNodeId);
        this.showFailureMatrixModal = true;
        return;
      } else if (obj.key === 'statisticalAnalysis') {
        this.$refs.statisticalAnalysisModal.getLeftSelectTree();
        this.showStatisticalAnalysisModal = true;
        return;
      } else if (obj.key === 'structureNet') { // 结构网
        this.$refs.structureNetModal.initStructureNetData();
        this.showStructureNetModal = true;
        return;
      } else if (obj.key === 'scoringCriteriaDrawer') { // 评分标准抽屉
        this.$refs.scoringCriteriaDrawer.initScoringCriteria();
        this.showScoringCriteriaDrawer = true;
        return;
      } else if (obj.key === 'parameter') { // P图
        this.$refs.parameter.parameterVisible = true;
        return;
      } else if (obj.key === 'RecycleBin') { // 回收站
        this.$refs.recycleBinModal.handleResize();
        this.$refs.recycleBinModal.initData();
        this.$nextTick(() => {
          this.$refs.recycleBinModal.initTableColumns();
        });
        this.showRecycleBinModal = true;
        return;
      }
      this.topBtnTitle = this.$t('' + obj.label + '');
      this.topBtnActionName = obj.key;
      this.checkedNode = this.$store.getters.lastCheckedNode;
      this.topBtnModal = true;
    },
    /**
     * 关闭P图模态框。
     */
    closeParameter() {
      this.showParameter = false;
    },
    /**
     * 关闭回收站模态框。
     */
    closeRecycleModal() {
      this.showRecycleBinModal = false;
    },
    /**
     * 设置回收站恢复数据高亮显示
     */
    getHighLightNode(node) {
      // 恢复节点数据
      let nodeData = {
        id: node[0].struId,
        pid: node[0].parentStruId, // 上一级节点
        fmeaId: node[0].fmeaId,
        name: node[0].name,
        struTypeCode: node[0].struTypeCode,
      }
      let parentData = {
        fmeaId: node[1].fmeaId,
        parentStruId: node[1].struId, // 第一级节点
      }
      // 设置恢复节点高亮显示
      if (nodeData !== null) {
        if (nodeData.struTypeCode === '01' || nodeData.struTypeCode === '99') {
          // 当恢复的节点为左树的结构节点时，设置恢复节点高亮和默认选中
          this.setCheckedNode(nodeData, 'leftTree');
          // 同步高亮右侧树节点
          this.setCheckedNode(nodeData, 'rightTree');
          // 刷新左侧树
          this.initLeftTree();
          // 刷新右侧树
          this.initRightTree();
        } else {
          // 当右侧树不处于恢复的节点结构下时，恢复节点后需要将右侧树的结构调整到恢复的节点结构下
          // 获取右侧树节点信息
          let rightTree = $.fn.zTree.getZTreeObj('rightTree');
          let nodeRight = rightTree.getNodeByParam("id", nodeData.id);
          this.$refs.rightTree.handleBeforeClick("rightTree", nodeRight, 1);
          // 获取左侧树节点信息
          let leftTree = $.fn.zTree.getZTreeObj('leftTree');
          let nodeLeft = leftTree.getNodeByParam("id", parentData.parentStruId);
          this.$refs.leftTree.handleBeforeClick("leftTree", nodeLeft, 1);
          // 当恢复的节点为右树的节点时，设置恢复节点高亮和默认选中
          this.setCheckedNode(nodeData, 'rightTree');
        }
      }
    },
    /**
    /**
     * 打开并排查看
     */
    openViewSideBySide() {
      this.$refs.viewSideBySideLeftTree.initLeftTree();
      this.$refs.viewSideBySideRightTree.initRightTree();
      this.showViewSideBySide = true;
    },
    /**
     * 关闭并排查看
     */
    closeViewSideBySide() {
      this.showViewSideBySide = false;
    },
    /**
     * 关闭顶部按钮模态框。
     */
    closeTopBtnModal() {
      if (this.topBtnActionName == 'actionPriority') {
        this.initRightTree();
      }
      this.topBtnActionName = "";
      this.topBtnModal = false;
    },
    /**
     * 初始化潜在关键特性。
     */
    initKeyFeature() {
      this.$refs.rightTree.initKeyFeature();
    },
    /**
     * 关闭变体矩阵模态框。
     */
    closeVariantMatrixModal() {
      this.showVariantMatrixModal = false;
    },
    /**
     * 关闭接口矩阵模态框。
     */
    closeInterfaceMatrixModal() {
      this.showInterfaceMatrixModal = false;
    },
    /**
     * 关闭功能矩阵模态框。
     */
    closeFunctionMatrixModal() {
      this.showFunctionMatrixModal = false;
    },
    /**
     * 关闭失效矩阵模态框。
     */
    closeFailureMatrixModal() {
      this.showFailureMatrixModal = false;
    },
    /**
     * 关闭统计分析模态框。
     */
    closeStatisticalAnalysisModal() {
      this.showStatisticalAnalysisModal = false;
    },
    /**
     * 关闭结构网模态框。
     */
    closeStructureNetModal() {
      this.showStructureNetModal = false;
    },
    /**
     * 关闭评分标准模态框。
     */
    closeScoringCriteriaDrawer() {
      this.showScoringCriteriaDrawer = false;
    },
    /**
     * 刷新左侧树
     */
    initLeftTree() {
      this.$refs.leftTree.initLeftTree();
    },
    /**
     * 刷新右侧树
     */
    initRightTree() {
      this.$refs.rightTree.initRightTree();
    },
    /**
     * 获取右侧树 -- 数据
     */
    getRightTreeData(callback) {
      return callback(this.$refs.rightTree.initData)
    },
    /**
     * 刷新并排查看右侧树右侧树
     */
    initViewSideBySideRightTree() {
      this.$refs.viewSideBySideRightTree.initRightTree();
    },
    /**
     * 获取并排查看右侧树 -- 数据
     */
    getViewSideBySideRightTreeData(callback) {
      return callback(this.$refs.viewSideBySideRightTree.treeData)
    },
    /**
     * 修改左侧treeData节点数据（名称）
     * @param node 节点
     */
    leftUpdateTreeDataNode(node) {
      this.$refs.leftTree.updateTreeDataNode(this.$refs.leftTree.treeData, node);
    },
    /**
     * 修改右侧treeData节点数据（名称）
     * @param node 节点
     */
    rightUpdateTreeDataNode(node) {
      this.$refs.rightTree.updateTreeDataNode(this.$refs.rightTree.treeData, node);
    },
    /**
     * 关闭Excel导入
     */
    closeImportExcelModal() {
      this.showImportExcelModal = false;
    },
    /**
     * 关闭Reliabench导入
     */
    closeImportReliaBenchModal() {
      this.showImportReliaBenchModal = false;
    },
    /**
     * 修复fmea数据
     */
    repairFmeaData() {
      this.buttonLoading = true;
      this.$api.repairFmeaData(this.$store.getters.rfmeaId).then(res => {
        if (res.flag) {
          this.$message.success(res.message, 1);
          this.initRightTree();
          this.initLeftTree();
          this.buttonLoading = false;
          // this.reload();
        } else {
          this.$message.error(res.message, 1);
          this.buttonLoading = false;
          // this.reload();
        }
      });
    },
    // 改变左树查找内容颜色
    handleLeftTreeCss(selectedRows, charToFind) {
      this.$refs.leftTree.changeSelectNodesColor(selectedRows, charToFind);
    },
    // 改变右树查找内容颜色
    handleRightTreeCss(selectedRows, charToFind) {
      this.$refs.rightTree.changeSelectNodesColor(selectedRows, charToFind);
    },
    // 通过右树节点定位到左树
    handleLeftNode(leftNode) {
      this.$refs.leftTree.handleBeforeClick("leftTree", leftNode, 1);
    },
    /**
     * 功能/失效 ai推理
     */
    saveNodeAiInference(node, struTypeCode) {
      let _that = this;
      _that.showHideLoading(true);
      let data = {
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: node.id,
        struTypeCode: struTypeCode,
        name: node.description,
      };
      _that.$api.saveNodeAiInference(data).then(res => {
        if (res.flag) {
          this.$message.success(res.message, 1);
          this.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).finally(() => {
        _that.showHideLoading(false);
      });
    },
    /**
     * 严重度(S) ai推理
     */
    saveSodAiInference(node, sodFlag) {
      let _that = this;
      _that.showHideLoading(true);
      let data = {
        fmeaId: _that.$store.getters.fmeaId,
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: node.id,
        name: node.description,
        sodFlag: sodFlag
      };
      _that.$api.saveSodAiInference(data).then(res => {
        if (res.flag) {
          this.$message.success(res.message, 1);
          this.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).finally(() => {
        _that.showHideLoading(false);
      });
    },
    /**
     * 预防/探测措施AI推理
     */
    saveMeasureiAiInference(nodeId, struTypeCode, measureCode) {
      let _that = this;
      _that.showHideLoading(true);
      let data = {
        rfmeaId: _that.$store.getters.rfmeaId,
        struId: nodeId,
        struTypeCode: struTypeCode,
        measureCode: measureCode,
      };
      _that.$api.saveMeasureiAiInference(data).then(res => {
        if (res.flag) {
          this.$message.success(res.message, 1);
          this.initRightTree();
        } else {
          _that.$message.error(res.message, 1);
        }
      }).finally(() => {
        _that.showHideLoading(false);
      });
    },
  },
  // 销毁
  destroyed() {
    $.contextMenu('destroy'); // 销毁所有菜单。
    this.$store.dispatch("fmeaTree/clear");
  }
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.a-tree {
  height: 400px !important;
  overflow: auto !important;
}
.top-button-bar-func {
  // overflow-x: auto; // 放开会导致颜色选择控件被遮盖
  // overflow-y: hidden;
  width: 100% !important;
  height: 36px;
  border-bottom: 1px solid #ccc;
  border-top: 1px solid #ccc;

  &::-webkit-scrollbar {
    width: 2px;
    height: 2px;
  }

  &::-webkit-scrollbar-thumb {
    background: #1890ff;
    border-radius: 5px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 5px;
  }

  // 功能分析
  .fmeaTreeTopBtn {
    margin: 0px 0px 0px 12px;
    display: block;
    float: left;
    width: 30px;
    height: 26px;
    position: relative;
    cursor: pointer;

    // 不知道是干什么的，先注释掉
    // &.toBtn {
    //   margin: 0 0 0 12px;
    //   width: 40px;
    //   height: 51px;
    //   background-color: #e6eef3;
    //   font-weight: bold;
    //   line-height: 50px;
    //   padding: 0 10px;
    //   border-bottom: 2px solid $gkBlue;

    //   i {
    //     color: $gkBlue;
    //   }
    // }

    img {
      width: 30px;
      height: 26px;
      line-height: 26px;
    }

    i {
      font-size: 22px;
      position: absolute;
      top: 2px;
      color: #dbdbdb;
    }

    &.fr {
      float: right !important;
    }

    &.active {
      i {
        color: #515151;
        font-weight: 550;

        &.excelImport {
          color: green !important;
        }

        &.functionNet {
          color: green !important;
        }

        &.faultNet {
          color: #c84d3c !important;
        }

        &.functionShowHide {
          color: #42a75e !important;
        }

        &.featureShowHide {
          color: #5b9bd5 !important;
        }

        &.requireShowHide {
          color: #5b9bd5 !important;
        }

        &.faultShowHide {
          color: #c84d3c !important;
        }

        &.measureShowHide {}

        &.functionNetShowHide {
          color: #42a75e !important;
        }

        &.faultNetShowHide {
          color: #c84d3c !important;
        }
      }
    }
  }
}
</style>

<style lang="less" scoped>
/deep/ .top-200 {
  pointer-events: none !important;
}

/deep/ .ant-divider,
.ant-divider-vertical {
  left: 1.6em;
  width: 1px;
  height: 1.5em;
  top: 0.5em;
  background: #ccc;
}
</style>
