<template>
  <div ref="fmeaTable" class="summary-archive-content">
    <a-card>
      <div class="fmeaTable-from">
        <a-form layout="vertical">
          <a-row :gutter="24">
            <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
              <a-form-item :label="$t('summary-Archive.fmea-table.structure')">
                <!-- 勾选模式选择 -->
                <span class="radio-group-class" >
                  <a-radio-group @change="radioChange" :default-value="1" size="small">
                    <a-radio :value="2" class="level-radio">
                      <a-tooltip>
                        <template slot="title">
                          {{ $t('summary-archive.fmea-table.same-level-check') }}
                        </template>
                        {{ $t('summary-archive.fmea-table.same-level-check') }}
                      </a-tooltip>
                    </a-radio>
                    <a-radio :value="3" class="level-radio">
                      <a-tooltip>
                        <template slot="title">
                          {{ $t('summary-archive.fmea-table.check-with-same-superior') }}
                        </template>
                        {{ $t('summary-archive.fmea-table.check-with-same-superior') }}
                      </a-tooltip>
                    </a-radio>
                    <a-radio :value="1" class="level-radio">
                      <a-tooltip>
                        <template slot="title">
                          {{ $t('summary-archive.fmea-table.unlimited') }}
                        </template>
                        {{ $t('summary-archive.fmea-table.unlimited') }}
                      </a-tooltip>
                    </a-radio>
                  </a-radio-group>
                </span>
                <a-tree-select ref="leftTree" v-model="searchParams.struId" treeCheckable treeCheckStrictly
                  :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :placeholder="$t('summary-Archive.fmea-table.please-select-a-structure')
                    " allow-clear show-search :showArrow="true" tree-default-expand-all :replaceFields="replaceFields"
                  :maxTagCount="3" :filterTreeNode="filterTreeNode" :tree-data="treeData" @select="selectBtn" @change="treeSelectChange">
                  <template #title="{ value: val, title }">
                    <template>{{ title }}</template>
                  </template>
                </a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
              <a-form-item :label="$t('summary-Archive.fmea-table.effect')">
                <a-select @change="effectSelectChange" :defaultValue="searchParams.effectDisplayOption">
                  <a-select-option v-for="(item, index) in effectDict" :key="index" :value="item.value">
                    {{ item.name }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <span v-show="advanceExpand">
              <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
                <a-form-item :label="$t('summary-Archive.fmea-table.cause')">
                  <a-select @change="causeSelectChange" :defaultValue="searchParams.causeDisplayOption">
                    <a-select-option v-for="(item, index) in causeDict" :key="index" :value="item.value">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
                <a-form-item :label="$t('summary-Archive.fmea-table.second-language')">
                  <a-select v-model="searchParams.twoLanguage" :placeholder="$t(
                    'summary-Archive.fmea-table.pleae-select-second-language'
                  )
                    " :loading="secondLanguageLoading">
                    <a-select-option v-for="(item, index) in secondLanguages" :key="index" :value="item.lkey">
                      {{ $t("global-dict.select-nls." + item.lkey) }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
                <a-form-item :label="$t('global-btn.export')">
                  <a-select v-model="exportType">
                    <a-select-option v-for="(item, index) in exportTypeList" :key="index" :value="item.value">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
                <a-form-item :label="$t('summary-archive.fmea-table.property.display')">
                  <a-select v-model="searchParams.propertyDisplay" mode="multiple" allowClear>
                    <a-select-option v-for="(item, index) in propertyDisplayList" :key="index" :value="item.value">
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </span>
            <a-col :xl="advanceExpand ? 24 : 8" :lg="advanceExpand ? 24 : 8" :md="24" :sm="24" :xs="24">
              <a-form-item class="tr" :label="'\xa0'">
                <a @click="toggleAdvance">
                  {{
                    advanceExpand ? $t("global.collapse") : $t("global.expand")
                  }}
                  <a-icon :type="advanceExpand ? 'up' : 'down'" />
                </a>
                <a-button class="ml10" @click="search" type="primary">
                  {{ $t("global-btn.search") }}
                </a-button>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card style="border-radius:10px 10px 0px 0px">
      <template slot="extra">
        <a-button @click="toggleFullscreen(valueH)" class="ml_20">
          {{ $t("global-btn.full-screen-display") }}
        </a-button>
        <a-button class="ml10" @click="exportExcel" type="primary">
          {{ $t("global-btn.export") }}
        </a-button>
      </template>
      <div :style="{ height: overflowHeight }">
        <!--  表格  -->
        <div class="ant-table-wrapper" ref="tableContainer">
          <a-spin :spinning="tableLoading">
            <div
              class="ant-table ant-table-fixed-header ant-table-scroll-position-left ant-table-layout-fixed ant-table-small ant-table-bordered">
              <div class="ant-table-content">
                <div class="ant-table-scroll">
                  <div id="table_head" class="ant-table-header"
                    style="margin-bottom: -16px; padding-bottom: 0px; min-width: 0px; overflow: scroll ;"
                    @scroll="handleTableHeadScroll">
                    <table class="">
                      <colgroup>
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col />
                      </colgroup>
                      <thead class="ant-table-thead">
                        <tr>
                          <th colspan="1" class="ant-table-align-center ant-table-row-cell-ellipsis">
                          </th>
                          <th key="improvement" colspan="1" class="ant-table-align-center ant-table-row-cell-ellipsis"
                              style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.continuous.improvement") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th key="step2" colspan="3" class="ant-table-align-center ant-table-row-cell-ellipsis"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.step2") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th key="step3" colspan="3" class="ant-table-align-center ant-table-row-cell-ellipsis"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.step3") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th key="step4" colspan="4" class="ant-table-align-center ant-table-row-cell-ellipsis"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.step4") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th key="step5" colspan="6" class="ant-table-align-center ant-table-row-cell-ellipsis"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.step5") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th key="step6" colspan="16" class="ant-table-align-center ant-table-row-cell-ellipsis"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.step6") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                        </tr>
                        <tr>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                              style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                        "summary-archive.fmea-table.problem"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                              style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                        "summary-archive.fmea-table.Historical-changes-authorizations"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.previous-higher-level"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #B9CAE0 !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.elements-of-concern"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #C4B3CD !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.next-lower-level-or-feature-type"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.higher-level-functions-and-requirements"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #B9CAE0 !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.focus-on-the-function-and-requirements-of-elements"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #C4B3CD !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.next-lower-level-functions-and-requirements-or-features"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.failure-impact-(FE)-on-the-previous-higher-level-element-and/or-end-user"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th id="s_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('s_sort', 'sAsc', 'sDesc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.severity-of-failure-impact-(s)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #B9CAE0 !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.failure-mode-of-focus-element-(FM)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center; background-color: #C4B3CD !important;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.failure-cause-(FC)-of-the-next-lower-level-feature-or-characteristic"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th
                            class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.current-preventive-measures-for-failure-causes-(PC)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th id="o_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('o_sort', 'oAsc', 'oDesc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.frequency-of-failure-cause-(FC)-(o)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th
                            class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.detection-measures-(DC)-of-current-failure-cause-(FC)-or-failure-mode-(FM)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th id="d_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('d_sort', 'dAsc', 'dDesc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.detection-degree-(d)-of-failure-cause-(FC)-or-failure-mode-(FM)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th id="ap_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('ap_sort', 'apAsc', 'apDesc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.dfmea-ap") }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>

                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.filter-code-(optional)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th
                            class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.dfmea-precautions"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th
                            class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.dfmea-detection-measures"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.name-of-responsible-person"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.target-completion-date"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.state") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.take-evidence-based-measures"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t("summary-archive.fmea-table.completion-date")
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th id="s1_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('s1_sort', 's1Asc', 's1Desc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t("summary-archive.fmea-table.severity-(s)")
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th id="o1_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('o1_sort', 'o1Asc', 'o1Desc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t("summary-archive.fmea-table.frequency-(o)")
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th id="d1_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('d1_sort', 'd1Asc', 'd1Desc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.detection-degree-(d)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>
                          <th id="ap1_sort" class="green ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word
                        ant-table-column-has-actions ant-table-column-has-sorters ant-table-column-sort"
                            style="text-align: center;" onclick="handleSort('ap1_sort', 'ap1Asc', 'ap1Desc')">
                            <span class="ant-table-header-column">
                              <div class="ant-table-column-sorters">
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.dfmea-ap") }}
                                </span>
                                <span class="ant-table-column-sorter">
                                  <div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
                                    <i aria-label="图标: caret-up"
                                      class="anticon anticon-caret-up ant-table-column-sorter-up off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-up" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z" />
                                      </svg>
                                    </i>
                                    <i aria-label="图标: caret-down"
                                      class="anticon anticon-caret-down ant-table-column-sorter-down off">
                                      <svg viewBox="0 0 1024 1024" data-icon="caret-down" width="1em" height="1em"
                                        fill="currentColor" aria-hidden="true" focusable="false" class="">
                                        <path
                                          d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z" />
                                      </svg>
                                    </i>
                                  </div>
                                </span>
                              </div>
                            </span>
                          </th>

                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{
                                    $t(
                                      "summary-archive.fmea-table.filter-code-(optional)"
                                    )
                                  }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                          <th class="ant-table-align-center ant-table-row-cell-ellipsis ant-table-row-cell-break-word"
                            style="text-align: center;">
                            <span class="ant-table-header-column">
                              <div>
                                <span class="ant-table-column-title">
                                  {{ $t("summary-archive.fmea-table.remarks") }}
                                </span>
                                <span class="ant-table-column-sorter"> </span>
                              </div>
                            </span>
                          </th>
                        </tr>
                      </thead>
                    </table>
                  </div>
                  <div id="table_body" tabindex="-1" class="ant-table-body" :style="{ height: tableBodyHeight }"
                    style="overflow-y:scroll;" @scroll="handleTableBodyScroll" ref="scrollContainer">
                    <a-list :data-source="[]" v-show="searchParams.toStruIdCount < 1" />
                    <table class="" v-show="searchParams.toStruIdCount > 0">
                      <colgroup>
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col style="width: 150px; min-width: 150px;" />
                        <col />
                      </colgroup>
                      <tbody class="ant-table-tbody"></tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </a-spin>
        </div>
      </div>
    </a-card>
    <div class="summary-archive-content-card"
      style="height:42px;border-radius:0px 0px 10px 10px;margin:0px 1px 0px 1px">
      <a-pagination v-show="pagination.total > 0" class="ant-table-pagination" style="margin:0px;" size="small"
        :total="pagination.total" :show-total="total => getShowTotal(pagination.total)" @change="handlePagination" />
    </div>
    <ModifyMeasure ref="modifyMeasure" @update:modifyCellFlag="handleModifyCellFlag" />
  </div>
</template>
<script>
import { arrayToTree } from "@/utils/tree";
import ModifyMeasure from "./components/ModifyMeasure.vue"

export default {
  name: "FMEATable",
  components: {
    ModifyMeasure
  },
  data() {
    return {
      deepCurrent: '', // 当前选中的层级
      checkIdShow: false, // 同级勾选是否启动
      sameSuperCheckFlag: false, // 同父级勾选是否启动
      checkedEvet: false, // 判断是勾选还是删除
      currentChecked: [], // 完全受控数据
      struNodeList: [], // 节点下拉选原始数据
      /** 树数据 */
      treeData: [],
      /** 替换 treeNode 中 title,key,children,value 字段为 treeData 中对应的字段 */
      replaceFields: {
        children: "children",
        label: "name",
        key: "id",
        value: "id"
      },
      /** 表格加载中状态 */
      tableLoading: false,
      /** 影响字典 */
      effectDict: [
        { name: this.$t("global-dict.direct.effect"), value: "3" },
        { name: this.$t("global-dict.final-effect"), value: "4" },
        { name: this.$t("global-dict.direct-and-final-effect"), value: "5" },
        { name: this.$t("global-dict.max-s-effect"), value: "6" },
        { name: this.$t("global-dict.all"), value: "1" }
      ],
      /** 原因字典 */
      causeDict: [
        { name: this.$t("global-dict.direct.cause"), value: "1" },
        { name: this.$t("global-dict.root.cause"), value: "4" },
        { name: this.$t("global-dict.direct-root-causes"), value: "3" },
        { name: this.$t("global-dict.all"), value: "2" }
      ],
      /** 导出类型 */
      exportTypeList: [
        { name: this.$t("global-btn.vad4.2-export"), value: "0" },
        { name: this.$t("global-btn.aiagd-export"), value: "1" },
        { name: this.$t("global-btn.aiag-vda-export"), value: "2" },
        { name: this.$t("global-btn.aiag-vda-export-new"), value: "3" },
        // { name: this.$t("global-btn.gm-export"), value: "4" }, // GM导出
        // { name: this.$t("global-btn.vad4.2-PDF-export"), value: "5" }, // VDA4.2导出PDF
        // { name: this.$t("global-btn.aiagd-PDF-export"), value: "6" }, //AIAG D导出PDF
        // { name: this.$t("global-btn.aiag-vda-PDF-export"), value: "7" }, // AIAG-VDA导出PDF
        // { name: this.$t("global-btn.aiag-vda-PDF-export-new"), value: "8" }, // 新版AIAG-VDA导出PDF
        // { name: this.$t("global-btn.gm-PDF-export"), value: "9" }, // GM导出PDF
      ],
      /** 检索条件 */
      searchParams: {
        /** FMEA标识 */
        fmeaId: this.$store.getters.rfmeaId,
        /** 结构字符串 */
        struId: undefined,
        /** 第二语言 */
        twoLanguage: undefined,
        /** 1 显示所有后果 此项不用做 2 显示全部后果，但不显示重复后果 3 只显示直接后果
         * 4 只显示最终后果 5 只显示直接和最终后果 6 只显示严重度分值最高的后果 */
        effectDisplayOption: "3",
        /** 1 只显示直接原因 2 全部原因 3 只显示直接原因和根本原因 4 只显示根本原因 */
        causeDisplayOption: "1",
        /** 输出特性符号（1：失效后果 2：失效模式 3：失效原因 4：失效后果的功能 5：失效模式的功能 6：失效原因 的功能） */
        propertyDisplay: [5],
        /** 分页 */
        pageCurrent: 1,
        pageSize: 10,
        /** 上次加载的数据包含多少结构(分页加载使用) */
        toStruIdCount: 0,
        /** 排序 */
        sort: {
          /** 严重度：升序 */
          sAsc: false,
          /** 严重度：降序 */
          sDesc: false,
          /** O：升序 */
          oAsc: false,
          /** O：降序 */
          oDesc: false,
          /** D：升序 */
          dAsc: false,
          /** D：降序 */
          dDesc: false,
          /** AP：升序 */
          apAsc: false,
          /** AP：降序 */
          apDesc: false,
          /** 严重度：升序 */
          s1Asc: false,
          /** 严重度：降序 */
          s1Desc: false,
          /** O：升序 */
          o1Asc: false,
          /** O：降序 */
          o1Desc: false,
          /** D：升序 */
          d1Asc: false,
          /** D：降序 */
          d1Desc: false,
          /** AP：升序 */
          ap1Asc: false,
          /** AP：降序 */
          ap1Desc: false
        }
      },
      /** 第二语言 */
      secondLanguages: [],
      /** 第二语言Loading */
      secondLanguageLoading: false,
      /**导出类型 */
      exportType: "3",
      /** 表格分页 */
      pagination: {
        current: 1, // 当前页数
        pageSize: 10, // 每页条数
        showTotal: this.getShowTotal, // 用于显示数据总量和当前数据顺序
        showSizeChanger: false, // 是否可以改变 pageSize
        pageSizeOptions: ["10", "20", "50", "100", "200"], // 指定每页可以显示多少条
        onShowSizeChange: (current, pageSize) => (this.pageSize = pageSize), // pageSize 变化的回调
        total: 0 // 总条数
      },

      /** 上次加载的数据包含多少结构(分页加载使用) */
      toStruIdCount: 0,
      advanceExpand: false,
      /** 输出特性符号的节点类型 */
      propertyDisplayList: [
        { name: this.$t('summary-archive.fmea-table.failure.effect'), value: 1 },
        { name: this.$t('summary-archive.fmea-table.failure.mode'), value: 2 },
        { name: this.$t('summary-archive.fmea-table.failure.cause'), value: 3 },
        { name: this.$t('summary-archive.fmea-table.parent.of.failure.effect'), value: 4 },
        { name: this.$t('summary-archive.fmea-table.parent.of.failure.mode'), value: 5 },
        { name: this.$t('summary-archive.fmea-table.parent.of.failure.cause'), value: 6 },
      ],
      valueH: 115,
      heightFlag: false,
      scrollPosition: { top: 0, left: 0 }, // 保存滚动位置
      modifyCellFlag: false, // 单元格修改标识
      overflowHeight: window.innerHeight - 410 + 'px',
      tableBodyHeight: window.innerHeight - 495 + 'px',
    };
  },
  mounted() {
    this.getTreeSelect();
    this.list();
    this.getLanguageList();
    window.addEventListener("resize", this.watchWindowSize);
    this.$once("hook:beforeDestroy", () => {
      window.removeEventListener("resize", this.watchWindowSize);
    });
    window.handleInputFocusCheck = this.handleInputFocusCheck;
    window.handleSeverityChange = this.handleSeverityChange;
    window.handleOccurrenceChange = this.handleOccurrenceChange;
    window.handleDetectionChange = this.handleDetectionChange;
    window.handleOptOccurrenceChange = this.handleOptOccurrenceChange;
    window.handleOptDetectionChange = this.handleOptDetectionChange;
    window.handleSort = this.handleSort;
    window.onresize = () => {
      this.overflowHeight = window.innerHeight - 410 + 'px';
      this.tableBodyHeight = window.innerHeight - 495 + 'px';
    };
  },

  methods: {
    // 收起/展开
    toggleAdvance() {
      this.advanceExpand = !this.advanceExpand;
      if (this.advanceExpand) {
        this.overflowHeight = window.innerHeight - 480 + 'px';
        this.tableBodyHeight = window.innerHeight - 565 + 'px';
      } else {
        this.overflowHeight = window.innerHeight - 410 + 'px';
        this.tableBodyHeight = window.innerHeight - 495 + 'px';
      }
    },

    /**
     * 获取第二语言
     */
    getLanguageList() {
      let _that = this;
      _that.secondLanguages = true;
      let data = {};
      Object.assign(data, { fmeaId: _that.$store.getters.rfmeaId });
      data.mfmeaFmeaTableDisplayCtrl = {
        effectDisplayOption: _that.effectDisplayOption
          ? _that.effectDisplayOption
          : "3",
        causeDisplayOption: _that.causeDisplayOption
          ? _that.causeDisplayOption
          : "1"
      };
      _that.$api.getFmeaTable(data).then(res => {
          if (res.flag) {
            _that.searchParams.twoLanguage = res.data.display_nls;
            _that.secondLanguages = res.data.mfmeaCurrentNls || [];
          } else {
            _that.$message.error(res.message, 1);
          }
        })
        .catch(error => {
          _that.$message.error(error.response.data.message, 1);
        })
        .finally(() => {
          _that.secondLanguageLoading = false;
        });
    },
    /**
     * 列表
     */
    list() {
      let _that = this;
      _that.tableLoading = true;
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let data = {
        fmeaId: _that.$store.getters.rfmeaId,
        struIds: struIds || undefined,
        twoLanguage: _that.searchParams.twoLanguage,
        toStruIdCount: _that.searchParams.toStruIdCount,
        mergeCell: _that.searchParams.mergeCell,
        fileFormat: _that.searchParams.fileFormat,
        sAsc: _that.searchParams.sort.sAsc,
        sDesc: _that.searchParams.sort.sDesc,
        oAsc: _that.searchParams.sort.oAsc,
        oDesc: _that.searchParams.sort.oDesc,
        dAsc: _that.searchParams.sort.dAsc,
        dDesc: _that.searchParams.sort.dDesc,
        apAsc: _that.searchParams.sort.apAsc,
        apDesc: _that.searchParams.sort.apDesc,
        s1Asc: _that.searchParams.sort.s1Asc,
        s1Desc: _that.searchParams.sort.s1Desc,
        o1Asc: _that.searchParams.sort.o1Asc,
        o1Desc: _that.searchParams.sort.o1Desc,
        d1Asc: _that.searchParams.sort.d1Asc,
        d1Desc: _that.searchParams.sort.d1Desc,
        ap1Asc: _that.searchParams.sort.ap1Asc,
        ap1Desc: _that.searchParams.sort.ap1Desc
      };
      data.mfmeaFmeaTableDisplayCtrl = {
        effectDisplayOption: _that.searchParams.effectDisplayOption,
        causeDisplayOption: _that.searchParams.causeDisplayOption
      };
      data.pagination = {
        pageCurrent: _that.searchParams.pageCurrent
      };
      _that.$api
        .getFmeaVdanTable(data)
        .then(res => {
          if (res.flag) {
            let dfmeaList = res.data.dfmeaList;
            if (dfmeaList && dfmeaList.length > 0) {
              // 语言标识
              _that.searchParams.twoLanguage = res.data.display_nls;
              // 分页
              let pagination = res.inputData.pagination;
              _that.pagination.current = pagination.pageCurrent;
              _that.pagination.pageSize = pagination.pageSize;
              _that.pagination.total = pagination.rowTotal;
              // 结构数量
              let toStruIdCount = _that.searchParams.toStruIdCount;
              _that.searchParams.toStruIdCount =
                toStruIdCount > 0
                  ? toStruIdCount + dfmeaList.length
                  : dfmeaList.length;
              // 绘画表格
              _that.drawTable(res.data);
              _that.searchFlag = false;
            }
            if (_that.modifyCellFlag === true) {
              // 恢复滚动条位置
              _that.$nextTick(() => {
                _that.$refs.scrollContainer.scrollTop = _that.scrollPosition.top;
                _that.$refs.scrollContainer.scrollLeft = _that.scrollPosition.left;
                _that.modifyCellFlag = false;
              });
            }
          } else {
            _that.$message.error(res.message, 1);
          }
        })
        .finally(() => {
          _that.secondLanguageLoading = false;
          _that.tableLoading = false;
        });
    },
    /**
     * 获取分页，显示总数
     * @param total 总数
     */
    getShowTotal(total) {
      return this.$t("global-constant.table.show-total", [total]);
    },
    /**
     * 输入项筛选
     * @param inputValue
     * @param treeNode
     */
    filterTreeNode(inputValue, treeNode) {
      return treeNode.data.props.name.includes(inputValue);
    },
    /**
     * 获取Tree下拉
     */
    getTreeSelect() {
      let _that = this;
      _that.$api
        .getLeftTree({
          fmeaId: _that.$store.getters.rfmeaId
        })
        .then(res => {
          if (res.flag) {
            _that.struNodeList = res.data.mfmeaStruTreeModels;
            let targetNode = res.data.mfmeaStruTreeModels.filter(item => {
              return item.pid === "00000000000000000000000000000000";
            })[0];
            // 数组转Tree
            _that.treeData = arrayToTree(
              targetNode,
              res.data.mfmeaStruTreeModels
            );
          } else {
            _that.$message.error(res.message, 1);
          }
        })
        .catch(error => {
          _that.$message.error(error.response.data.message, 1);
        });
    },
    // 监听全屏状态的变化
    exitHandler() {
      if (!document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement) {
        // 如果当前不处于全屏状态，则移除事件监听器
        window.removeEventListener('fullscreenchange', this.exitHandler);
        window.removeEventListener('webkitfullscreenchange', this.exitHandler);
        window.removeEventListener('mozfullscreenchange', this.exitHandler);
        window.removeEventListener('MSFullscreenChange', this.exitHandler);
        window.onresize = null;
        this.overflowHeight = window.innerHeight - 410 + 'px';
        this.tableBodyHeight = window.innerHeight - 495 + 'px';
        this.advanceExpand = false;
      } else {
        this.overflowHeight = window.innerHeight - 115 + 'px';
        this.tableBodyHeight = window.innerHeight - 115 + 'px';
      }
    },
    /**
     * 表格全屏显示
     */
    toggleFullscreen(valueH) {
      let _that = this;
      // 获取表格容器的引用
      const tableContainer = _that.$refs.tableContainer;
      // 如果当前没有处于全屏状态
      if (!tableContainer.fullscreenElement) {
        window.addEventListener('fullscreenchange', this.exitHandler);
        window.addEventListener('webkitfullscreenchange', this.exitHandler);
        window.addEventListener('mozfullscreenchange', this.exitHandler);
        window.addEventListener('MSFullscreenChange', this.exitHandler);

        // 根据浏览器的不同 进入全屏模式的方法也不同
        if (tableContainer.requestFullscreen) { // 判断浏览器是否支持requestFullscreen方法进入全屏模式
          tableContainer.requestFullscreen();
        } else if (tableContainer.mozRequestFullScreen) { // Firefox浏览器使用mozRequestFullScreen方法进入全屏模式
          tableContainer.mozRequestFullScreen();
        } else if (tableContainer.webkitRequestFullscreen) { // Chrome浏览器使用webkitRequestFullscreen方法进入全屏模式
          tableContainer.webkitRequestFullscreen();
        } else if (tableContainer.msRequestFullscreen) { // IE浏览器使用msRequestFullscreen方法进入全屏模式
          tableContainer.msRequestFullscreen();
        } else if (tableContainer.webkitEnterFullscreen) { // Safari浏览器使用webkitEnterFullscreen方法进入全屏模式
          tableContainer.webkitEnterFullscreen();
        } else if (tableContainer.mozEnterFullScreen) { // Firefox浏览器使用mozEnterFullScreen方法进入全屏模式
          tableContainer.mozEnterFullScreen();
        }
      }
    },
    /**
     * 导出按钮
     */
    exportExcel() {
      //判断是哪种导出方式
      let _that = this;
      if (_that.exportType == "0") {
        _that.VDA42ExcelExport();
      } else if (_that.exportType == "1") {
        _that.AIAGDExcelExport();
      } else if (_that.exportType == "2") {
        _that.AIAGVDAExcelExport();
      } else if (_that.exportType == "3") {
        _that.AIAGVDAExcelExportNew();
      } else if (_that.exportType == "4") {
        _that.GMExport();
      } else if (_that.exportType == "5") {
        _that.VDA42ExportPDF();
      } else if (_that.exportType == "6") {
        _that.AIAGDExportPDF();
      } else if (_that.exportType == "7") {
        _that.AIAGVDAExportPDF();
      } else if (_that.exportType == "8") {
        _that.NewAIAGVDAExportPDF();
      } else if (_that.exportType == "9") {
        _that.GMExportPDF();
      }
    },
    /**
     * VDA4.2 Excel导出
     */
    VDA42ExcelExport() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || "";
      let effectDisplayOption = this.searchParams.effectDisplayOption || "";
      let causeDisplayOption = this.searchParams.causeDisplayOption || "";
      let twoLanguage = this.searchParams.twoLanguage || "";
      let url =
        this.$api.baseUrl +
        "/DFMEA/MfmeaFmeaTable/Rb04263A1/exportvda42?fmeaId=" +
        rfmeaId +
        "&struIds=" +
        struId +
        "&effectDisplayOption=" +
        effectDisplayOption +
        "&causeDisplayOption=" +
        causeDisplayOption +
        "&twoLanguage=" +
        twoLanguage;
      window.open(url);
    },
    /**
     * AIAG D Excel导出
     */
    AIAGDExcelExport() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || "";
      let effectDisplayOption = this.searchParams.effectDisplayOption || "";
      let causeDisplayOption = this.searchParams.causeDisplayOption || "";
      let twoLanguage = this.searchParams.twoLanguage || "";
      let url =
        this.$api.baseUrl +
        "/DFMEA/MfmeaFmeaTable/Rb04263A1/exportaiagd?fmeaId=" +
        rfmeaId +
        "&struIds=" +
        struId +
        "&effectDisplayOption=" +
        effectDisplayOption +
        "&causeDisplayOption=" +
        causeDisplayOption +
        "&twoLanguage=" +
        twoLanguage;
      window.open(url);
    },
    /**
     * AIAG-VDA Excel导出
     */
    AIAGVDAExcelExport() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let exportFrom = this.$com.getCookie("from");
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || "";
      let effectDisplayOption = this.searchParams.effectDisplayOption || "";
      let causeDisplayOption = this.searchParams.causeDisplayOption || "";
      let twoLanguage = this.searchParams.twoLanguage || "";
      let propertyDisplay = this.searchParams.propertyDisplay || "";
      let url =
        this.$api.baseUrl +
        "/DFMEA/MfmeaFmeaTable/Rb04263A1/exportvdan?fmeaId=" +
        rfmeaId +
        "&struIds=" +
        struId +
        "&effectDisplayOption=" +
        effectDisplayOption +
        "&causeDisplayOption=" +
        causeDisplayOption +
        "&twoLanguage=" +
        twoLanguage +
        "&mergeCell=" +
        0 +
        "&infoFmeaId=" +
        fmeaId +
        "&propertyDisplay=" +
        propertyDisplay +
        "&exportFrom=" +
        exportFrom;
      window.open(url);
    },

    /**
     * AIAG-VDA Excel导出  新版
     */
    AIAGVDAExcelExportNew() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let exportFrom = this.$com.getCookie("from");
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || "";
      let effectDisplayOption = this.searchParams.effectDisplayOption || "";
      let causeDisplayOption = this.searchParams.causeDisplayOption || "";
      let twoLanguage = this.searchParams.twoLanguage || "";
      let propertyDisplay = this.searchParams.propertyDisplay || "";
      let url =
        this.$api.baseUrl +
        "/DFMEA/MfmeaFmeaTable/Rb04263A1/exportvdanNew?fmeaId=" +
        rfmeaId +
        "&struIds=" +
        struId +
        "&effectDisplayOption=" +
        effectDisplayOption +
        "&causeDisplayOption=" +
        causeDisplayOption +
        "&twoLanguage=" +
        twoLanguage +
        "&mergeCell=" +
        0 +
        "&infoFmeaId=" +
        fmeaId +
        "&propertyDisplay=" +
        propertyDisplay +
        "&exportFrom=" +
        exportFrom;
      window.open(url);
    },

    /**
     * GM Excel导出
     */
    GMExport() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let propertyDisplay = this.searchParams.propertyDisplay || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let mergeCell = this.searchParams.nodeMerge || '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb04263A1/exportgm?fmeaId=" + fmeaId
        + "&rfmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&propertyDisplay=" + propertyDisplay
        + "&twoLanguage=" + twoLanguage
        + "&mergeCell=" + mergeCell
      window.open(url);
    },

    // ----------------pdf导出-----------------------
    /**
     * VDA4.2 PDF导出
     */
    VDA42ExportPDF() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb04263A1/pdfExportvda42?fmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&twoLanguage=" + twoLanguage
      window.open(url);
    },
    /**
     * AIAG D PDF导出
     */
    AIAGDExportPDF() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb04263A1/pdfExportaiagd?fmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&twoLanguage=" + twoLanguage
      window.open(url);
    },
    /**
     * AIAG-VDA PDF导出,节点合并
     */
    AIAGVDAExportPDF() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let propertyDisplay = this.searchParams.propertyDisplay || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let mergeCell = this.searchParams.nodeMerge || '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb04263A1/pdfExportvdan?fmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&propertyDisplay=" + propertyDisplay
        + "&twoLanguage=" + twoLanguage
        + "&mergeCell=" + mergeCell
      window.open(url);
    },
    /**
     * AIAG-VDA PDF导出,节点不合并
     */
    NewAIAGVDAExportPDF() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let propertyDisplay = this.searchParams.propertyDisplay || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let mergeCell = this.searchParams.nodeMerge || '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb0426302/pdfExportvdan?fmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&propertyDisplay=" + propertyDisplay
        + "&twoLanguage=" + twoLanguage
        + "&mergeCell=" + mergeCell
      window.open(url);
    },
    /**
     * GM PDF导出
     */
    GMExportPDF() {
      let struIds = [];
      if (this.searchParams.struId && this.searchParams.struId.length > 0) {
        this.searchParams.struId.forEach(item => {
          struIds.push(item.value);
        })
      }
      let fmeaId = this.$store.getters.fmeaId;
      let rfmeaId = this.$store.getters.rfmeaId;
      let struId = struIds || '';
      let effectDisplayOption = this.searchParams.effectDisplayOption || '';
      let causeDisplayOption = this.searchParams.causeDisplayOption || '';
      let propertyDisplay = this.searchParams.propertyDisplay || '';
      let twoLanguage = this.searchParams.twoLanguage || '';
      let mergeCell = this.searchParams.nodeMerge || '';
      let variableUrl = '';
      let url = this.$api.baseUrl + "/DFMEA/MfmeaFmeaTable/Rb04263A1/pdfExportgm?fmeaId=" + fmeaId
        + "&rfmeaId=" + rfmeaId
        + "&struIds=" + struId
        + "&effectDisplayOption=" + effectDisplayOption
        + "&causeDisplayOption=" + causeDisplayOption
        + "&propertyDisplay=" + propertyDisplay
        + "&twoLanguage=" + twoLanguage
        + "&mergeCell=" + mergeCell
      window.open(url);
    },

    /**查询列表 */
    search() {
      // 记录滚动条位置
      this.scrollPosition = {
        top: this.$refs.scrollContainer.scrollTop,
        left: this.$refs.scrollContainer.scrollLeft,
      };
      this.clearTableData();
      this.list();
    },
    /**
     * 单选框改变事件
     */
    radioChange(e) {
      let redioFlag = e.target.value;
      if (redioFlag === 1) {
        this.checkIdShow = false;
        this.sameSuperCheckFlag = false;
      } else if (redioFlag === 2) {
        this.checkIdShow = true;
        this.sameSuperCheckFlag = false;
      } else if (redioFlag === 3) {
        this.checkIdShow = false;
        this.sameSuperCheckFlag = true;
      }
    },
    /**
     * tree 完全受控  选中
     * @param even
     * @param evenT
     * @param evenTR
     */
    selectBtn(even, evenT, evenTR) {
      this.checkedEvet = true; //判断是勾选添加还是删除
      this.currentChecked = evenTR.checkedNodes;
      let i = evenTR.checkedNodes.length - 1;
      this.deepCurrent = evenTR.checkedNodes[i].data.props.deep; // 设置当前选择节点的深度
      this.currentPid = evenTR.checkedNodes[i].data.props.pid; // 设置当前选择节点的父级ID
    },

    /**
     * Tree下拉选择事件时
     * @param value
     * @param option
     */
    treeSelectChange(value, option) {
      this.searchParams.struId = value;
      let checkList = [];
      let checkIds = [];
      if (this.sameSuperCheckFlag == true) {
        //当同父级勾选按钮打开，并且是勾选添加时
        if (this.checkedEvet == true) {
          this.struNodeList.forEach(item => {
            if (item.deep == this.deepCurrent && item.pid == this.currentPid) checkList.push(item);
          });
          checkList.forEach(item => {
            let ids = {
              lable: item.name,
              value: item.id,
            }
            checkIds.push(ids);
          });
          let result = checkIds.concat(this.searchParams.struId);
          let arrayResult = result.filter((currentValue, currentIndex, selfArr) => {
            return selfArr.findIndex(item => item.value === currentValue.value) === currentIndex;
          });
          this.searchParams.struId = arrayResult;
          // 暂存选中数据，取消勾选时使用
          this.currentChecked = arrayResult;
        } else {
          //当同父级勾选按钮打开，并且是勾选取消时
          // 对比数组，找到当前勾选的层级
          let arr1 = this.currentChecked.filter(item => {
            return !this.searchParams.struId.find(prop => {
              return prop.value == item.value
            })
          });
          let currentUnCheckedNode = this.struNodeList.filter(item => {
            return item.id === arr1[0].value;
          })
          this.deepCurrent = currentUnCheckedNode[0] ? currentUnCheckedNode[0].deep : undefined;
          this.currentPid = currentUnCheckedNode[0] ? (currentUnCheckedNode[0].pid ? currentUnCheckedNode[0].pid : undefined) : undefined;
          //根据当前勾选的层级，找到所有相同的层级
          this.struNodeList.forEach(item => {
            if (item.deep == this.deepCurrent && item.pid == this.currentPid) checkList.push(item);
          });
          checkList.forEach(item => {
            let ids = {
              lable: item.name,
              value: item.id,
            }
            checkIds.push(ids);
          });
          //把找到相同数据的层级从勾选的数据中删除
          const result = this.searchParams.struId.filter((itemA) => {
            return !checkIds.some((itemB) => itemA.value == itemB.value);
          })
          this.searchParams.struId = result;
          this.currentChecked = result;
        }
      } else if (this.checkIdShow == true) {
        //当同级勾选按钮打开，并且是勾选添加时
        if (this.checkedEvet == true) {
          this.struNodeList.forEach(item => {
            if (item.deep == this.deepCurrent) checkList.push(item);
          });
          checkList.forEach(item => {
            let ids = {
              lable: item.name,
              value: item.id,
            }
            checkIds.push(ids);
          });
          let result = checkIds.concat(this.searchParams.struId);
          let arrayResult = result.filter((currentValue, currentIndex, selfArr) => {
            return selfArr.findIndex(item => item.value === currentValue.value) === currentIndex;
          });
          this.searchParams.struId = arrayResult;
          // 暂存选中数据，取消勾选时使用
          this.currentChecked = arrayResult;
        } else {
          //当同级勾选按钮打开，并且是勾选取消时
          // 对比数组，找到当前勾选的层级
          let arr1 = this.currentChecked.filter(item => {
            return !this.searchParams.struId.find(prop => {
              return prop.value == item.value
            })
          });
          let currentUnCheckedNode = this.struNodeList.filter(item => {
            return item.id === arr1[0].value;
          })
          this.deepCurrent = currentUnCheckedNode[0] ? currentUnCheckedNode[0].deep : undefined;
          //根据当前勾选的层级，找到所有相同的层级
          this.struNodeList.forEach(item => {
            if (item.deep == this.deepCurrent) checkList.push(item);
          });
          checkList.forEach(item => {
            let ids = {
              lable: item.name,
              value: item.id,
            }
            checkIds.push(ids);
          });
          //把找到相同数据的层级从勾选的数据中删除
          const result = this.searchParams.struId.filter((itemA) => {
            return !checkIds.some((itemB) => itemA.value == itemB.value);
          })
          this.searchParams.struId = result;
          this.currentChecked = result;
        }
      } else {
        this.searchParams.struId = value;
      }
      this.checkedEvet = false;
    },
    /**
     * 影响下拉选择事件时
     * @param value
     * @param option
     */
    effectSelectChange(value, option) {
      this.searchParams.effectDisplayOption = value;
    },
    /**
     * 原因下拉选择事件时
     * @param value
     * @param option
     */
    causeSelectChange(value, option) {
      this.searchParams.causeDisplayOption = value;
    },
    /**
     * 处理表格头部滚动条
     */
    handleTableHeadScroll() {
      // 表格头部与表格体，X滚动条保持一直
      let headEle = document.querySelector("#table_head");
      let bodyEle = document.querySelector("#table_body");
      bodyEle.scrollLeft = headEle.scrollLeft;
    },
    /**
     * 处理表格体滚动条
     * @param e
     */
    handleTableBodyScroll(e) {
      let _that = this;
      // 表格头部与表格体，X滚动条保持一直
      let headEle = document.querySelector("#table_head");
      let bodyEle = document.querySelector("#table_body");
      headEle.scrollLeft = bodyEle.scrollLeft;

      // 触发滚动加载
      // 滚动条高度
      let scrollH = e.srcElement.scrollHeight;
      // 滚动条当前位置高度
      let scrollCurrentH = e.srcElement.scrollTop + e.srcElement.clientHeight;
      if (e.srcElement.scrollTop > 0 && scrollH - scrollCurrentH <= 50) {
        if (!_that.searchFlag) {
          _that.searchFlag = true;
          let toStruIdCount = _that.searchParams.toStruIdCount;
          let pageSize = _that.pagination.pageSize;
          let rowTotal = _that.pagination.total;
          let pageCurrent = _that.pagination.current;
          let lastPageSize = rowTotal % pageSize;
          let pageNumber = Math.ceil(rowTotal / pageSize);
          let pageTotal = pageCurrent >= pageNumber ? lastPageSize : pageSize;
          if (pageTotal > toStruIdCount) {
            _that.list();
          }
        }
      }
    },
    /**
     * 处理分页
     * @param page 页码
     * @param pageSize 条数
     */
    handlePagination(page, pageSize) {
      let _that = this;
      _that.searchParams.pageCurrent = page;
      _that.clearTableData();
      _that.list();
    },
    /**
     * 清除表格数据
     */
    clearTableData() {
      $("#table_body .ant-table-tbody")
        .find("tr")
        .remove();
      this.searchParams.toStruIdCount = 0;
      this.severitys = [];
      this.occurrences = [];
      this.detections = [];
      this.optOccurrences = [];
      this.optDetections = [];
    },
    /**
     * 处理输入框获取焦点时，SOD值保存到临时变量中
     * @param obj
     */
    handleInputFocusCheck(obj) {
      let _that = this;
      _that.tempVal = obj.value.trim();
    },
    /**
     * 处理输入框校验
     * @param obj
     */
    handleInputBlurCheck(obj) {
      let _that = this;
      let val = obj.value.trim();
      if (val && (val.indexOf("(") === -1 || val.indexOf(")") === -1)) {
        // 请输入整数
        if (isNaN(val)) {
          _that.$notification.warning({
            message: _that.$t("global-message.sod.input-value"),
            duration: 1 // 默认(4.5)自动关闭延时，单位秒
          });
          return false;
        }
        // 请输入1-10之间的整数
        if (val <= 0 || val > 10) {
          _that.$notification.warning({
            message: _that.$t("global-message.sod.input-value"),
            duration: 1 // 默认(4.5)自动关闭延时，单位秒
          });
          return false;
        }
      }
      return true;
    },
    /**
     * 处理SOD数据
     * @param arr
     * @param obj
     */
    handleSODData(arr, obj) {
      let flag = true;
      for (let i = arr.length - 1; i >= 0; i--) {
        if (obj.id === arr[i].id) {
          arr[i].value = obj.value;
          flag = false;
          break;
        }
      }
      if (flag) {
        arr.push({ id: obj.id, value: obj.value });
      }
    },
    /**
     * 处理S修改
     * @param obj
     */
    handleSeverityChange(obj, struId, severityName) {
      let _that = this;
      let checkResult = _that.handleInputBlurCheck(obj);
      if (checkResult) {
        // _that.handleSODData(_that.severitys, obj);
        // 更新S值
        let data = {
          fmeaId: _that.$store.getters.rfmeaId,
          struId: struId,
          signific: severityName
        };
        _that.$api.updateFaultSignific(data).then(res => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            _that.modifyCellFlag = true;
            _that.search();
            return true;
          } else {
            _that.$message.error(res.message, 1);
          }
        });
      } else {
        return false;
      }
    },
    /**
     * 处理O值修改
     * @param obj
     */
    handleOccurrenceChange(obj, struId, occurrences) {
      let _that = this;
      let checkResult = _that.handleInputBlurCheck(obj);
      if (checkResult) {
        // _that.handleSODData(_that.occurrences, obj);
        // 更新O值
        let data = {
          fmeaId: _that.$store.getters.rfmeaId,
          struId: struId,
          occurrences: occurrences
        };
        _that.$api.updateGroupByODCount(data).then(res => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            _that.modifyCellFlag = true;
            _that.search();
            return true;
          } else {
            _that.$message.error(res.message, 1);
          }
        });
      } else {
        return false;
      }
    },
    /**
     * 处理D值修改
     * @param obj
     */
    handleDetectionChange(obj, struId, detection) {
      let _that = this;
      let checkResult = _that.handleInputBlurCheck(obj);
      if (checkResult) {
        // _that.handleSODData(_that.detections, obj);
        // 更新D值
        let data = {
          fmeaId: _that.$store.getters.rfmeaId,
          struId: struId,
          detection: detection
        };
        _that.$api.updateGroupByODCount(data).then(res => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            _that.modifyCellFlag = true;
            _that.search();
            return true;
          } else {
            _that.$message.error(res.message, 1);
          }
        });
      } else {
        return false;
      }
    },
    /**
     * 处理优化O值修改
     * @param obj
     */
    handleOptOccurrenceChange(obj) {
      let _that = this;
      let checkResult = _that.handleInputBlurCheck(obj);
      if (checkResult) {
        _that.handleSODData(_that.optOccurrences, obj);
      }
    },
    /**
     * 处理优化D值修改
     * @param obj
     */
    handleOptDetectionChange(obj) {
      let _that = this;
      let checkResult = _that.handleInputBlurCheck(obj);
      if (checkResult) {
        _that.handleSODData(_that.optDetections, obj);
      }
    },
    /**
     * 处理排序
     * @param id
     * @param asc
     * @param desc
     */
    handleSort(id, asc, desc) {
      let _that = this;
      let elUp = $("#" + id + " .ant-table-column-sorter-up");
      let elDown = $("#" + id + " .ant-table-column-sorter-down");
      let clsUp = elUp.attr("class");
      let clsDown = elDown.attr("class");
      // 升序（若上关闭，下关闭，则打开）
      if (clsUp.indexOf("off") !== -1 && clsDown.indexOf("off") !== -1) {
        _that.closeOtherSortStatus();
        _that.searchParams.sort[asc] = true;
        _that.handleEleClass(elUp, "off", "on");
        _that.clearTableData();
        _that.list();
        return;
      } else if (clsUp.indexOf("on") !== -1) {
        _that.searchParams.sort[asc] = false;
        _that.handleEleClass(elUp, "on", "off");
      }
      // 降序（若上打开，下关闭，则打开）
      if (clsUp.indexOf("on") !== -1 && clsDown.indexOf("off") !== -1) {
        _that.searchParams.sort[desc] = true;
        _that.handleEleClass(elDown, "off", "on");
      } else if (clsDown.indexOf("on") !== -1) {
        _that.searchParams.sort[desc] = false;
        _that.handleEleClass(elDown, "on", "off");
      }
      _that.clearTableData();
      _that.list();
    },
    /**
     * 关闭其他排序状态
     */
    closeOtherSortStatus() {
      let _that = this;
      // 升序。设置off
      $(".ant-table-column-sorter-up").each(function () {
        let cls = $(this).attr("class");
        if (cls.indexOf("on") !== -1) {
          _that.handleEleClass($(this), "on", "off");
        }
      });
      // 降序。设置off
      $(".ant-table-column-sorter-down").each(function () {
        let cls = $(this).attr("class");
        if (cls.indexOf("on") !== -1) {
          _that.handleEleClass($(this), "on", "off");
        }
      });
      // 设置参数。false
      let sort = _that.searchParams.sort;
      for (let key in sort) {
        sort[key] = false;
      }
    },
    /**
     * 处理元素Class
     * @param el 元素
     * @param remove 移除
     * @param add 添加
     */
    handleEleClass(el, remove, add) {
      el.removeClass(remove).addClass(add);
    },
    /**
     * 描绘表格
     * @param output
     */
    drawTable(output) {
      let _that = this;
      let dfmeaList = output.dfmeaList;
      let apMap = output.apMap;
      // 把后台传递的完整数据转换成map
      let struMap = _that.convertListToMap(output.structList);
      let functionMap = _that.convertListToMap(output.functionList);
      let faultMap = _that.convertListToMap(output.faultList);
      let groupMap = _that.convertListToMap(output.groupList);
      let actionMap = _that.convertListToMap(output.actionList);

      // 循环结构
      if (!_that.$utils.isNull(dfmeaList) && dfmeaList.length > 0) {
        for (const i in dfmeaList) {
          _that.startRow = $("#table_body .ant-table-tbody tr").length;
          let structDto = dfmeaList[i];
          let functionVo = structDto.functionDtos;
          // 循环功能
          if (!_that.$utils.isNull(functionVo) && functionVo.length > 0) {
            for (const j in functionVo) {
              let functionDto = functionVo[j];
              let requireVo = functionDto.requireDtos;
              // 循环要求
              if (!_that.$utils.isNull(requireVo)) {
                for (const k in requireVo) {
                  // 创建一个合并失模式的map集合。（key：合并起始行；value：合并的行数）用于合并聚焦功能和聚焦结构
                  let mergeModelMap = new Map();
                  // 创建一个合并失效后果的map集合。（key：合并起始行；value：合并的行数）
                  let mergeEffectMap = new Map();
                  // 创建一个合并失效后果上级功能的map集合。（key：合并起始行；value：合并的行数）
                  let mergeEffectFuncMap = new Map();
                  // 创建一个合并失效后果上级结构的map集合。（key：合并起始行；value：合并的行数）
                  let mergeEffectStruMap = new Map();
                  // 创建一个合并失效原因的map集合。（key：合并起始行；value：合并的行数）
                  let mergeCauseMap = new Map();
                  // 创建一个合并失效原因上级功能和结构的map集合。（key：合并起始行；value：合并的行数）
                  let mergeCauseFuncMap = new Map();
                  // 创建一个合并失效原因上级结构和结构的map集合。（key：合并起始行；value：合并的行数）
                  let mergeCauseStruMap = new Map();
                  let frModeVo = requireVo[k].faultDtos;
                  // 失效模式
                  if (!_that.$utils.isNull(frModeVo) && frModeVo.length > 0) {
                    for (const l in frModeVo) {
                      // 取得数据关系
                      let modeFaultDto = frModeVo[l];
                      // 通过关系获取失效模式数据
                      let faultModeShowDto = faultMap.get(modeFaultDto.id);
                      let fmeaHistoryFailLibModels = faultModeShowDto.mfmeaHistoryFailLibModels;
                      // 失效模式的起始行
                      let modelFaultStartRow = _that.startRow;
                      // 获取表格体行Html
                      let modelHtml = _that.getTableBodyTrHtml(_that.startRow);
                      $("#table_body .ant-table-tbody").append(modelHtml);
                      _that.startRow++;
                      // 描画失效模式
                      _that.drawFaultMode(faultModeShowDto, fmeaHistoryFailLibModels);
                      // 获取失效模式的当前措施
                      let modelFaultDcNameMap = _that.getFaultModelCurrentMeasure(
                        modeFaultDto,
                        actionMap
                      );
                      // 获取失效模式的优化措施
                      let modelFaultOptNameMap = _that.getFaultModelOptMeasure(modeFaultDto, actionMap);

                      // -----------------------------------------------------------失效原因start---------------------------------------------
                      // 失效原因变量
                      let faultCauseVariable = _that.getFaultCauseVariable(
                        modelFaultStartRow
                      );
                      // 循环失效原因
                      let frCauseVo = modeFaultDto.causeDtos;
                      if (!_that.$utils.isNull(frCauseVo)) {
                        for (const p in frCauseVo) {
                          let causeFaultDto = frCauseVo[p];
                          let faultCauseShowDto = faultMap.get(
                            causeFaultDto.id
                          );
                          if (faultCauseShowDto == null) continue;
                          faultCauseVariable.causeStartRow =
                            faultCauseVariable.failCauseStartRow +
                            faultCauseVariable.frCauseVoRowIndex;
                          if (p != 0) {
                            // 获取表格体行Html
                            let html = _that.getTableBodyTrHtml(_that.startRow);
                            $("#table_body .ant-table-tbody").append(html);
                            faultCauseVariable.causeStartRow = _that.startRow;
                            _that.startRow++;
                          }
                          // 失效原因合并数据做成
                          _that.handleFaultCauseMergeData(
                            causeFaultDto,
                            modeFaultDto,
                            faultCauseVariable,
                            mergeCauseMap,
                            mergeCauseFuncMap,
                            mergeCauseStruMap,
                            faultMap
                          );
                          // 描画失效原因
                          _that.drawFaultCause(
                            causeFaultDto,
                            faultCauseVariable,
                            faultMap
                          );
                          //--------------------DFMEA风险分析（步骤5）赋值start-----
                          // 循环失效模式的当前措施状态措施组
                          // 失效原因当前措施组的变量
                          let faultCauseCurrentVar = {
                            modelFaultDcNameCount: 0
                          };
                          let frGroupVo = causeFaultDto.curGroupDtos;
                          let causeCurrentGroupCount = 0;
                          // 循环失效原因的当前措施组
                          if (
                            !_that.$utils.isNull(frGroupVo) &&
                            frGroupVo.length > 0
                          ) {
                            for (const q in frGroupVo) {
                              let causeInitGroupDto = frGroupVo[q];
                              if (q != 0) {
                                // 获取表格体行Html
                                let html = _that.getTableBodyTrHtml(
                                  _that.startRow
                                );
                                $("#table_body .ant-table-tbody").append(html);
                                _that.startRow++;
                              }
                              // 失效原因当前措施
                              _that.drawCauseCurrentMeasures(
                                causeInitGroupDto,
                                faultMap.get(modeFaultDto.id),
                                faultCauseCurrentVar,
                                causeCurrentGroupCount,
                                faultCauseVariable.causeStartRow,
                                actionMap,
                                groupMap,
                                apMap,
                                modelFaultDcNameMap
                              );
                              causeCurrentGroupCount++;
                            }
                          }
                          //--------------------DFMEA风险分析（步骤5）赋值end-----
                          //--------------------优化（步骤6）赋值start-----
                          let frGroupModify = causeFaultDto.optGroupDtos;
                          let causeOtpGroupCount = 0;
                          let tempCount = 0;
                          if (!_that.$utils.isNull(frGroupModify)) {
                            for (const t in frGroupModify) {
                              let causeOtpGroupDto = frGroupModify[t];
                              if (t > causeCurrentGroupCount) {
                                // 获取表格体行Html
                                let html = _that.getTableBodyTrHtml(
                                  _that.startRow
                                );
                                $("#table_body .ant-table-tbody").append(html);
                                _that.startRow++;
                              }
                              _that.drawCauseOptMeasures(
                                causeOtpGroupDto,
                                faultMap.get(modeFaultDto.id),
                                faultCauseCurrentVar,
                                faultCauseVariable.causeStartRow,
                                actionMap,
                                groupMap,
                                apMap,
                                causeOtpGroupCount
                              );
                              tempCount = causeOtpGroupCount;
                              causeOtpGroupCount++;
                            }
                          }
                          // 失效模式优化探测措施
                          _that.drawModeOptMeasures(
                            faultCauseVariable.causeStartRow,
                            tempCount,
                            modelFaultOptNameMap);
                          let groupCount =
                            causeCurrentGroupCount > causeOtpGroupCount
                              ? causeCurrentGroupCount
                              : causeOtpGroupCount;
                          groupCount = groupCount > 0 ? groupCount : 1;
                          faultCauseVariable.frCauseVoRowIndex =
                            faultCauseVariable.frCauseVoRowIndex + groupCount;
                          faultCauseVariable.causeFaultIndex++;
                        }
                      }
                      // -----------------------------------------------------------失效原因end-------------------------------------------------
                      // --------------------------------------------失效后果statr--------------------------------------------------------------
                      // 失效后果变量
                      let faultEffectVariable = _that.getFaultEffectVariable(
                        modelFaultStartRow
                      );
                      // 失效后果
                      let frEffectVo = modeFaultDto.effectDtos;
                      let frEffectRow = modelFaultStartRow;
                      if (!_that.$utils.isNull(frEffectVo)) {
                        for (const o in frEffectVo) {
                          let effectFaultDto = frEffectVo[o];
                          let effectFaultShowDto = faultMap.get(
                            effectFaultDto.id
                          );
                          if (effectFaultShowDto == null) continue;
                          if (
                            o >= faultCauseVariable.frCauseVoRowIndex &&
                            faultCauseVariable.frCauseVoRowIndex != 0
                          ) {
                            // 获取表格体行Html
                            let effectHtml = _that.getTableBodyTrHtml(
                              _that.startRow
                            );
                            $("#table_body .ant-table-tbody").append(
                              effectHtml
                            );
                            frEffectRow = _that.startRow;
                            _that.startRow++;
                          }
                          if (
                            o > 0 &&
                            faultCauseVariable.frCauseVoRowIndex == 0
                          ) {
                            // 获取表格体行Html
                            let effectHtml = _that.getTableBodyTrHtml(
                              frEffectRow
                            );
                            $("#table_body .ant-table-tbody").append(
                              effectHtml
                            );
                            _that.startRow++;
                          }
                          // 失效后果合并数据做成
                          _that.handleFaultEffectMergeData(
                            effectFaultDto,
                            modeFaultDto,
                            faultEffectVariable,
                            mergeEffectMap,
                            mergeEffectFuncMap,
                            mergeEffectStruMap,
                            faultMap
                          );

                          // 描画失效后果
                          _that.drawFaultEffect(
                            effectFaultDto,
                            frEffectRow,
                            faultMap
                          );

                          frEffectRow++;
                          faultEffectVariable.effectFaultIndex++;
                          faultEffectVariable.frEffectVoIndex++;
                        }
                      }
                      // 处理失效后果行数与失效原因行数不一致的情况
                      _that.handleCauseAndEffectDifferent(
                        faultEffectVariable,
                        faultCauseVariable,
                        mergeCauseMap,
                        mergeCauseFuncMap,
                        mergeCauseStruMap
                      );
                      // 处理失效模式合并数据
                      _that.handleFaultModeMergeData(
                        faultCauseVariable,
                        faultEffectVariable,
                        mergeModelMap,
                        modelFaultStartRow
                      );
                      // 合并所有数据
                      _that.mergeAllData(
                        mergeCauseMap,
                        mergeModelMap,
                        mergeEffectMap,
                        mergeCauseFuncMap,
                        mergeEffectFuncMap,
                        mergeCauseStruMap,
                        mergeEffectStruMap
                      );
                    }
                  } else {
                    // 失效模式为空 描画功能
                    _that.drawFunction(
                      struMap.get(structDto.id),
                      functionMap.get(functionDto.id)
                    );
                  }
                }
              } else {
                // 要求为空 描画功能
                _that.drawFunction(
                  struMap.get(structDto.id),
                  functionMap.get(functionDto.id)
                );
              }
            }
          } else {
            // 功能为空
            // 获取表格体行Html
            let struHtml = _that.getTableBodyTrHtml(_that.startRow);
            $("#table_body .ant-table-tbody").append(struHtml);
            _that.startRow++;
            let struDto = struMap.get(structDto.id);
            // 聚焦结构赋值
            $("#tableRow" + (_that.startRow - 1))
              .find("td:eq(3)")
              .append(struDto.name);
          }
        }
      }
    },
    /**
     * 获取表格体，行Html
     * @param startRow 开始行
     */
    getTableBodyTrHtml(startRow) {
      let html = '<tr id="tableRow' + startRow + '">';
      html +=
        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
        "<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>" +
        "<td></td><td></td><td></tr>";
      return html;
    },
    /**
     * 获取失效原因变量
     * @param modelFaultStartRow 失效模式的起始行
     */
    getFaultCauseVariable(modelFaultStartRow) {
      return {
        // 失效原因的行合并的起始行(下级功能)
        mergeCauseFunStartRow: modelFaultStartRow,
        // 失效原因的行合并(下级功能)
        mergeCauseFunCount: 0,
        // 失效原因的行合并的起始行(下级结构)
        mergeCauseStruStartRow: modelFaultStartRow,
        // 失效原因的行合并(下级结构)
        mergeCauseStruCount: 0,
        // 失效原因的行合并的起始行
        mergeCauseStartRow: modelFaultStartRow,
        // 失效原因的合并行数
        mergeCauseCount: 0,
        // 失效原因id
        causeId: "",
        // 失效原因上级要求id
        causeReqId: "",
        // 失效原因上级功能id
        causeFuncId: "",
        // 失效原因上级结构id
        causeStruId: "",
        // 用于记录失效原因的总行数
        frCauseVoRowIndex: 0,
        // 失效原因的循环次数
        causeFaultIndex: 1,
        // 失效原因起始行
        failCauseStartRow: modelFaultStartRow,
        // 失效原因行号
        causeStartRow: 0
      };
    },
    /**
     * 获取失效后果变量
     * @param modelFaultStartRow 失效模式的起始行
     */
    getFaultEffectVariable(modelFaultStartRow) {
      return {
        // 失效后果的行合并的起始行
        mergeEffectStartRow: modelFaultStartRow,
        // 失效后果的行合并的起始行(上级功能)
        mergeEffectFunStartRow: modelFaultStartRow,
        // 失效后果的行合并的起始行(上级结构)
        mergeEffectStruStartRow: modelFaultStartRow,
        // 失效后果的行合并
        mergeEffectCount: 1,
        // 失效后果的行合并(上级功能)
        mergeEffectFunCount: 1,
        // 失效后果的行合并(上级结构)
        mergeEffectStruCount: 1,
        // 失效后果合并id
        effectMergeId: "",
        // 失效后果上级要求id
        effectReqId: "",
        // 失效后果上级功能id
        effectFuncId: "",
        // 失效后果上级结构id
        effectStruId: "",
        // 用于记录失效后果的循环次数
        effectFaultIndex: 1,
        // 用于记录失效后果的上级功能的数量
        effectFuncIndex: 1,
        // 用于记录失效后果的上级功能的结构数量
        effectStruIndex: 1,
        // 失效后果的数量
        frEffectVoIndex: 0
      };
    },
    /**
     * 获取图片Html标签
     * @param fileName 文件名称
     */
    getImgHtml(fileName) {
      let url = this.$api.baseUrl + "/DFMEA/file/" + fileName;
      return '<img style="width:26px;height:26px;" src="' + url + '"/>';
    },
    /**
     * 描画失效模式
     * @param modeFaultDto
     * @returns {Map<any, any>}
     */
    drawFaultMode(modeFaultDto, fmeaHistoryFailLibModels) {
      let _that = this;
      let propertyDisplay = _that.searchParams.propertyDisplay;
      let row = $("#tableRow" + (_that.startRow - 1));
      // 结构名称+拼接零件号
      let struFirstName = modeFaultDto.struName + modeFaultDto.struNameAppend;
      let struLanguageName = "";
      if (modeFaultDto.struLanguageName && modeFaultDto.struLanguageName !== modeFaultDto.struName) {
        // 第二语言名称+拼接零件号
        struLanguageName = modeFaultDto.struLanguageName + modeFaultDto.struNameAppend;
      }
      // 聚焦结构赋值
      row.find("td:eq(3)").append(struFirstName + '<br>' + struLanguageName);
      // 修改单元格内容
      let oneSingleColumn = "td:eq(3)";
      let struName = modeFaultDto.struName;
      let struId = modeFaultDto.struId;
      _that.modifyCellContent(row, oneSingleColumn, struName, struId, struFirstName, struLanguageName);


      // 聚焦功能赋值
      if (modeFaultDto.funcType == "02") {
        row.find("td:eq(6)").css("color", "#52be68");
      } else {
        row.find("td:eq(6)").css("color", "#5b9bd5");
      }
      // 功能名称+拼接要求及规格值
      let funcFirstName = modeFaultDto.funcName + modeFaultDto.funcNameAppend;
      let funcLanguageName = "";
      if (modeFaultDto.funLanguageName && modeFaultDto.funLanguageName !== modeFaultDto.funcName) {
        // 第二语言名称+拼接要求及规格值
        funcLanguageName = modeFaultDto.funLanguageName + modeFaultDto.funcNameAppend;
      }
      row.find("td:eq(6)").append(funcFirstName + '<br>' + funcLanguageName);
      // 修改单元格内容
      let fourSingleColumn = "td:eq(6)";
      let funcName = modeFaultDto.funcName;
      let funcId = modeFaultDto.funcId;
      _that.modifyCellContent(row, fourSingleColumn, funcName, funcId, funcFirstName, funcLanguageName);

      // 失效名称及其第二语言名称
      let faultFirstName = modeFaultDto.name;
      let faultLanguageName = "";
      if (modeFaultDto.languageName && modeFaultDto.languageName !== faultFirstName) {
        faultLanguageName = modeFaultDto.languageName;
      }
      let issueNo = "";
      let issueTitle = "";
      if (!_that.$utils.isNull(fmeaHistoryFailLibModels)) {
        fmeaHistoryFailLibModels.forEach(f => {
          issueNo = issueNo + f.issueNo + "<br>";
          issueTitle = issueTitle + f.issueTitle + "<br>";
        })
      }
      row.find("td:eq(10)").append(faultFirstName + '<br>' + faultLanguageName).css("color", "#ff3636");
      // 修改单元格内容
      row.find("td:eq(0)").append(issueNo);
      row.find("td:eq(1)").append(issueTitle);
      let eightSingleColumn = "td:eq(10)";
      let fautName = modeFaultDto.name;
      let fautId = modeFaultDto.id;
      _that.modifyCellContent(row, eightSingleColumn, fautName, fautId, faultFirstName, faultLanguageName);

      // SC图标(失效模式)
      if (propertyDisplay.includes(2)) {
        let sc = "";
        if (modeFaultDto.classifyModel) {
          if ("1" == modeFaultDto.classifyModel.classifyType) {
            sc = _that.getImgHtml(modeFaultDto.classifyModel.fileName) + " (FM)<br>";
          } else if ("2" == modeFaultDto.classifyModel.classifyType) {
            sc = modeFaultDto.classifyModel.lexplain + " (FM)<br>";
          }
        }
        row.find("td:eq(17)").append(sc).css('text-align', 'center');
        row.find("td:eq(29)").append(sc).css('text-align', 'center');
      }
      // SC图标(失效模式的功能/产品特性/过程特性)
      if (propertyDisplay.includes(5)) {
        let sc = "";
        if (modeFaultDto.funcClassifyModel) {
          if ("1" == modeFaultDto.funcClassifyModel.classifyType) {
            sc = _that.getImgHtml(modeFaultDto.funcClassifyModel.fileName) + " (Fn-FM)<br>";
          } else if ("2" == modeFaultDto.funcClassifyModel.classifyType) {
            sc = modeFaultDto.funcClassifyModel.lexplain + " (Fn-FM)<br>";
          }
        }
        row.find("td:eq(17)").append(sc).css('text-align', 'center');
        row.find("td:eq(29)").append(sc).css('text-align', 'center');
      }
    },
    /**
     * 获取失效模式的当前措施的探测措施
     * @returns {Map<any, any>}
     */
    getFaultModelCurrentMeasure(modeFaultDto, actionMap) {
      let _that = this;
      // 失效模式的当前措施的探测
      let modelFaultDcNameMap = new Map();
      let modelFaultDcCount = 0;
      let failureModeVo = modeFaultDto.curGroupDtos;
      if (!_that.$utils.isNull(failureModeVo)) {
        for (const m in failureModeVo) {
          let faultModeDActionVo = failureModeVo[m].rdfmActionDtos;
          // 失效模式的当前措施的探测
          if (!_that.$utils.isNull(faultModeDActionVo)) {
            for (const n in faultModeDActionVo) {
              let faultModeDAction = faultModeDActionVo[n];
              let actionDto = actionMap.get(faultModeDAction.id);
              if (actionDto != null) {
                let index = parseInt(n) + 1;
                let actionName = actionDto.actionName;
                if (actionName) {
                  modelFaultDcNameMap.set(
                    modelFaultDcCount,
                    {
                      id: failureModeVo[m].id,
                      name: "D" + index + ":" + actionDto.actionName + "(FM)<br>"
                    }

                  );
                  modelFaultDcCount++;
                }
              }
            }
          }
        }
      }
      return modelFaultDcNameMap;
    },
    /**
     * 获取失效模式的优化措施的探测措施
     * @returns {Map<any, any>}
     */
    getFaultModelOptMeasure(modeFaultDto, actionMap) {
      let _that = this;
      // 失效模式的优化措施的探测
      let modelFaultOptNameMap = new Map();
      let modelFaultDcCount = 0;
      let optModeVo = modeFaultDto.optGroupDtos;
      if (!_that.$utils.isNull(optModeVo)) {
        for (const m in optModeVo) {
          let faultModeDActionVo = optModeVo[m].rdfmActionDtos;
          // 失效模式的优化措施的探测
          if (!_that.$utils.isNull(faultModeDActionVo)) {
            for (const n in faultModeDActionVo) {
              let faultModeDAction = faultModeDActionVo[n];
              let actionDto = actionMap.get(faultModeDAction.id);
              if (actionDto != null) {
                let index = parseInt(n) + 1;
                let actionName = actionDto.actionName;
                if (actionName) {
                  modelFaultOptNameMap.set(
                    modelFaultDcCount,
                    {
                      id: optModeVo[m].id,
                      name: "D" + index + ":" + actionDto.actionName + '(FM)<br>'
                    }
                  );
                  modelFaultDcCount++;
                }
              }
            }
          }
        }
      }
      return modelFaultOptNameMap;
    },
    /**
     * 处理失效原因合并数据， 将合并的结果放到map中
     * @param causeFaultDto
     * @param modeFaultDto
     * @param faultVar
     * @param mergeCauseMap
     * @param mergeCauseFuncMap
     * @param mergeCauseStruMap
     * @param faultMap
     */
    handleFaultCauseMergeData(
      causeFaultDto,
      modeFaultDto,
      faultVar,
      mergeCauseMap,
      mergeCauseFuncMap,
      mergeCauseStruMap,
      faultMap
    ) {
      let _that = this;
      let causeFault = faultMap.get(causeFaultDto.id);
      // 失效原因当前措施组数量
      let curGroupCount =
        causeFaultDto.curGroupDtos != null
          ? causeFaultDto.curGroupDtos.length
          : 0;
      // 失效模式当前措施组数量
      let curModelGroupCount =
        modeFaultDto.curGroupDtos != null
          ? modeFaultDto.curGroupDtos.length
          : 0;
      curGroupCount =
        curGroupCount > curModelGroupCount ? curGroupCount : curModelGroupCount;
      // 失效原因优化措施组数量
      let otpGroupCount =
        causeFaultDto.optGroupDtos != null
          ? causeFaultDto.optGroupDtos.length
          : 0;
      // 失效原因的措施总行数
      let causeRowspan =
        curGroupCount >= otpGroupCount ? curGroupCount : otpGroupCount;
      /*===========================失效原因合并的数据构建start========*/
      // 判断当前失效原因是否相同
      if (faultVar.causeId == "") {
        faultVar.causeId = causeFault.id;
        faultVar.mergeCauseCount = causeRowspan;
      } else if (faultVar.causeId == causeFault.id) {
        // 相同
        faultVar.mergeCauseCount += causeRowspan;
      } else {
        // 不相同
        mergeCauseMap.set(
          faultVar.mergeCauseStartRow,
          faultVar.mergeCauseCount != 0
            ? faultVar.mergeCauseCount
            : causeRowspan
        );
        faultVar.causeId = causeFault.id;
        faultVar.mergeCauseStartRow =
          faultVar.mergeCauseStartRow + faultVar.mergeCauseCount;
        faultVar.mergeCauseCount = causeRowspan;
      }
      // 把最后一个失效原因放入map中
      if (
        faultVar.causeFaultIndex >=
        (modeFaultDto.causeDtos != null ? modeFaultDto.causeDtos.length : 0)
      ) {
        mergeCauseMap.set(
          faultVar.mergeCauseStartRow,
          faultVar.mergeCauseCount != 0
            ? faultVar.mergeCauseCount
            : causeRowspan
        );
      }
      /*===========================失效原因合并的数据构建end========*/
      /*===========================失效原因合并上级功能的数据构建start========*/
      // 判断当前失效原因是否相同
      if (faultVar.causeFuncId == "") {
        _that.drawFaultCauseFuncClassify(causeFault, faultVar.causeStartRow);
        faultVar.causeFuncId = causeFault.funcId;
        faultVar.causeReqId = causeFault.reqId;
        faultVar.mergeCauseFunCount = causeRowspan;
      } else if (
        faultVar.causeFuncId == causeFault.funcId &&
        faultVar.causeReqId == causeFault.reqId
      ) {
        // 相同
        faultVar.mergeCauseFunCount += causeRowspan;
      } else {
        // 不相同
        _that.drawFaultCauseFuncClassify(causeFault, faultVar.causeStartRow);
        mergeCauseFuncMap.set(
          faultVar.mergeCauseFunStartRow,
          faultVar.mergeCauseFunCount != 0
            ? faultVar.mergeCauseFunCount
            : causeRowspan
        );
        faultVar.causeFuncId = causeFault.funcId;
        faultVar.mergeCauseFunStartRow =
          faultVar.mergeCauseFunStartRow + faultVar.mergeCauseFunCount;
        faultVar.mergeCauseFunCount = causeRowspan;
      }
      // 把最后一个失效原因放入map中
      if (
        faultVar.causeFaultIndex >=
        (modeFaultDto.causeDtos != null ? modeFaultDto.causeDtos.length : 0)
      ) {
        mergeCauseFuncMap.set(
          faultVar.mergeCauseFunStartRow,
          faultVar.mergeCauseFunCount != 0
            ? faultVar.mergeCauseFunCount
            : causeRowspan
        );
      }
      /*===========================失效原因合并上级功能的数据构建end========*/
      /*===========================失效原因合并上级结构的数据构建start========*/
      // 判断当前失效原因的上级功能的上级结构是否相同
      if (faultVar.causeStruId == "") {
        faultVar.causeStruId = causeFault.struId;
        faultVar.mergeCauseStruCount = causeRowspan;
      } else if (faultVar.causeStruId == causeFault.struId) {
        // 相同，
        faultVar.mergeCauseStruCount += causeRowspan;
      } else {
        // 不相同
        mergeCauseStruMap.set(
          faultVar.mergeCauseStruStartRow,
          faultVar.mergeCauseStruCount != 0
            ? faultVar.mergeCauseStruCount
            : causeRowspan
        );
        faultVar.causeStruId = causeFault.struId;
        faultVar.mergeCauseStruStartRow =
          faultVar.mergeCauseStruStartRow + faultVar.mergeCauseStruCount;
        faultVar.mergeCauseStruCount = causeRowspan;
      }
      // 把最后一个失效原因放入map中
      if (
        faultVar.causeFaultIndex >=
        (modeFaultDto.causeDtos != null ? modeFaultDto.causeDtos.length : 0)
      ) {
        mergeCauseStruMap.set(
          faultVar.mergeCauseStruStartRow,
          faultVar.mergeCauseStruCount != 0
            ? faultVar.mergeCauseStruCount
            : causeRowspan
        );
      }
      /*===========================失效原因合并上级结构的数据构建end========*/
    },

    /**
     * 描画失效原因的上级功能的特性图标
     * @param causeFaultDto
     * @param startRow
     */
    drawFaultCauseFuncClassify(causeFaultDto, startRow) {
      let _that = this;
      let row = $("#tableRow" + startRow);
      let propertyDisplay = _that.searchParams.propertyDisplay;
      // sc图标，(失效原因的功能)
      if (propertyDisplay.includes(6)) {
        let sc = "";
        if (causeFaultDto.funcClassifyModel) {
          if ("1" == causeFaultDto.funcClassifyModel.classifyType) {
            sc = _that.getImgHtml(causeFaultDto.funcClassifyModel.fileName) + " (Fn-FC)<br>";
          } else if ("2" == causeFaultDto.funcClassifyModel.classifyType) {
            sc = causeFaultDto.funcClassifyModel.lexplain + " (Fn-FC)<br>";
          }
        }
        row.find("td:eq(17)").append(sc).css('text-align', 'center');
        row.find("td:eq(29)").append(sc).css('text-align', 'center');
      }
    },
    /**
     * 描画失效原因
     * @param causeFaultDto
     * @param faultVar
     * @param faultMap
     */
    drawFaultCause(causeFaultDto, faultVar, faultMap) {
      let _that = this;
      let faultCauseShowDto = faultMap.get(causeFaultDto.id);
      let row = $("#tableRow" + faultVar.causeStartRow);
      // 结构名称+拼接零件号
      let struFirstName = faultCauseShowDto.struName + faultCauseShowDto.struNameAppend;
      let struLanguageName = "";
      if (faultCauseShowDto.struLanguageName && faultCauseShowDto.struLanguageName !== faultCauseShowDto.struName) {
        // 第二语言名称+拼接零件号
        struLanguageName = faultCauseShowDto.struLanguageName + faultCauseShowDto.struNameAppend;
      }
      row.find("td:eq(4)").append(struFirstName + '<br>' + struLanguageName);
      // 修改单元格内容
      let twoSingleColumn = "td:eq(4)";
      let struName = faultCauseShowDto.struName;
      let struId = faultCauseShowDto.struId;
      _that.modifyCellContent(row, twoSingleColumn, struName, struId, struFirstName, struLanguageName);

      // 下级功能赋值
      if (faultCauseShowDto.funcType == "02") {
        row.find("td:eq(7)").css("color", "#52be68");
      } else {
        row.find("td:eq(7)").css("color", "#5b9bd5");
      }
      // 功能名称+拼接要求及规格值
      let funcFirstName = faultCauseShowDto.funcName + faultCauseShowDto.funcNameAppend;
      let funcLanguageName = "";
      if (faultCauseShowDto.funLanguageName && faultCauseShowDto.funLanguageName !== faultCauseShowDto.funcName) {
        // 第二语言名称+拼接要求及规格值
        funcLanguageName = faultCauseShowDto.funLanguageName + faultCauseShowDto.funcNameAppend;
      }
      row.find("td:eq(7)").append(funcFirstName + '<br>' + funcLanguageName);
      // 修改单元格内容
      let fiveSingleColumn = "td:eq(7)";
      let funcName = faultCauseShowDto.funcName;
      let funcId = faultCauseShowDto.funcId;
      _that.modifyCellContent(row, fiveSingleColumn, funcName, funcId, funcFirstName, funcLanguageName);

      row.find("td:eq(11)").css("color", "#ff3636");
      // 失效原因赋值
      let causeDeep = causeFaultDto.causeDeep;
      let name = faultCauseShowDto.name;
      if (causeDeep == "1") {
        name = ">" + name;
      } else if (causeDeep == "2") {
        name = ">>" + name;
      }
      // 失效名称及其第二语言名称
      let faultFirstName = faultCauseShowDto.name;
      let faultLanguageName = "";
      if (faultCauseShowDto.languageName && faultCauseShowDto.languageName !== faultFirstName) {
        faultLanguageName = faultCauseShowDto.languageName;
      }
      row.find("td:eq(11)").append(faultFirstName + '<br>' + faultLanguageName);
      // 修改单元格内容
      let nineSingleColumn = "td:eq(11)";
      let faultName = name;
      let faultId = faultCauseShowDto.id;
      _that.modifyCellContent(row, nineSingleColumn, faultName, faultId, faultFirstName, faultLanguageName);

      let propertyDisplay = _that.searchParams.propertyDisplay;
      // SC图标 (失效原因)
      if (propertyDisplay.includes(3)) {
        let sc = "";
        if (faultCauseShowDto.classifyModel) {
          if ("1" == faultCauseShowDto.classifyModel.classifyType) {
            sc = _that.getImgHtml(faultCauseShowDto.classifyModel.fileName) + " (FC)<br>";
          } else if ("2" == faultCauseShowDto.classifyModel.classifyType) {
            sc = faultCauseShowDto.classifyModel.lexplain + " (FC)<br>";
          }
        }
        row.find("td:eq(17)").append(sc).css('text-align', 'center');
        row.find("td:eq(29)").append(sc).css('text-align', 'center');
      }
    },
    /**
     * 描画失效原因的当前措施信息
     * @param causeInitGroupDto
     * @param modeFaultDto
     * @param currentVar
     * @param causeCurrentGroupCount
     * @param causeStartRow
     * @param actionMap
     * @param groupMap
     * @param apMap
     * @param modelFaultDcNameMap
     */
    drawCauseCurrentMeasures(
      causeInitGroupDto,
      modeFaultDto,
      currentVar,
      causeCurrentGroupCount,
      causeStartRow,
      actionMap,
      groupMap,
      apMap,
      modelFaultDcNameMap
    ) {
      let _that = this;
      let currentGroupDto = groupMap.get(causeInitGroupDto.id);
      // 失效原因的当前措施的探测
      let causeFaultDcName = "";
      let occurrence = "";
      let row = $("#tableRow" + (causeStartRow + causeCurrentGroupCount));
      if (currentGroupDto != null) {
        // 预防措施名称
        let causeInitPcName = "";
        let pActionVo = causeInitGroupDto.rdfmActionPtos;
        // 循环措施的预防
        if (!_that.$utils.isNull(pActionVo)) {
          for (const r in pActionVo) {
            let index = parseInt(r) + 1;
            let causeInitGroupPDto = actionMap.get(pActionVo[r].id);
            if (causeInitGroupPDto) {
              causeInitPcName +=
                "P" + index + ":" + causeInitGroupPDto.actionName + "<br>";
              if (causeInitGroupPDto.actionLanguageName && causeInitGroupPDto.actionLanguageName !== causeInitGroupPDto.actionName) {
                causeInitPcName +=
                  "P" + index + ":" + causeInitGroupPDto.actionLanguageName + "<br>";
              }
            }
          }
        }
        let dActionVo = causeInitGroupDto.rdfmActionDtos;
        // 循环措施的探测
        if (!_that.$utils.isNull(dActionVo)) {
          for (const s in dActionVo) {
            let index = parseInt(s) + 1;
            let causeInitGroupDDto = actionMap.get(dActionVo[s].id);
            if (causeInitGroupDDto) {
              causeFaultDcName +=
                "D" + index + ":" + causeInitGroupDDto.actionName + "(FC)<br>";
              if (causeInitGroupDDto.actionLanguageName && causeInitGroupDDto.actionLanguageName !== causeInitGroupDDto.actionName) {
                causeFaultDcName +=
                  "D" + index + ":" + causeInitGroupDDto.actionLanguageName + "(FC)<br>";
              }
            }
          }
        }
        // 当前的对失效原因的预防措施（PC）赋值
        row.find("td:eq(12)").append(causeInitPcName);
        // 双击单元格 弹出模态框
        row.find("td:eq(12)").on('dblclick', function () {
          _that.$refs.modifyMeasure.measureVisible = true;
          _that.$refs.modifyMeasure.measureTitleFlag = 1;
          _that.$refs.modifyMeasure.measureType = 1;
          _that.$refs.modifyMeasure.groupId = causeInitGroupDto.id;
          _that.$refs.modifyMeasure.struTypeCode = '09'; // 预防措施
          _that.$refs.modifyMeasure.displayElemnt = _that.$refs.tableContainer; // 指定弹窗挂载元素
          _that.$refs.modifyMeasure.list();
        });
        // 失效原因（FC）的发生频度(O)赋值
        occurrence = currentGroupDto != null ? currentGroupDto.occurrence : "";
        // let occurrenceInput = "";
        // if (occurrence) {
        //   occurrenceInput +=
        //     '<input type="text" class="ant-input" name="occurrence" value="' +
        //     occurrence +
        //     '" id="' +
        //     currentGroupDto.id +
        //     '" style="width: 50px; text-align: center;" maxlength="2"' +
        //     ' autoComplete="off" onfocus="handleInputFocusCheck(this)" onchange="handleOccurrenceChange(this)"/>';
        // }
        row.find("td:eq(13)").append(occurrence).css("text-align", "center");
        // 修改O值
        row.find("td:eq(13)").on('dblclick', function () {
          // 获取当前单元格的内容
          let originalContent = $(this).text();
          // 创建一个新的input元素
          let newInput = $('<input type="text" class="ant-input" style="width: 50px; text-align: center;" maxlength="2" autocomplete="off" />');
          // 设置input的初始值
          newInput.val(originalContent);
          // 绑定input的失去焦点事件
          newInput.on('blur', function () {
            // 获取用户输入的内容
            let newContent = $(this).val().trim();
            if ("" === newContent) {
              $(this).parent().text(originalContent);
              return false;
            }
            // 更新O值
            if (newContent === originalContent) {
              $(this).parent().text(originalContent);
              return false;
            } else {
              // 调用handleOccurrenceChange方法
              let isValid = handleOccurrenceChange(this, currentGroupDto.id, newContent);
              if (!isValid) {
                // 如果校验失败，恢复原始内容
                $(this).parent().text(originalContent);
                return;
              }
            }
            // 更新单元格的内容
            $(this).parent().text(newContent);
            // 移除 input
            $(this).remove();
          });
          // 将input添加到单元格中，并清空原有的内容
          $(this).empty().append(newInput);
          // 聚焦到input上
          newInput.focus();
        });
      }
      // 当前的失效原因(FC)或失效模式（FM）的探测措施（DC）赋值
      let modelFaultDcName = "";
      let failureModeDroupId = ""; // 失效模式（FM）的探测措施的上级ID
      if (modelFaultDcNameMap) {
        for (let value of modelFaultDcNameMap.values()) {
          modelFaultDcName += value.name;
          failureModeDroupId = value.id;
          currentVar.modelFaultDcNameCount++;
          // modelFaultDcName = modelFaultDcName != undefined ? modelFaultDcName : "";
        }
      }
      row.find("td:eq(14)").append(modelFaultDcName + causeFaultDcName);
      // 双击单元格 弹出模态框
      row.find("td:eq(14)").on('dblclick', function () {
        _that.$refs.modifyMeasure.measureVisible = true;
        _that.$refs.modifyMeasure.measureTitleFlag = 2;
        _that.$refs.modifyMeasure.measureType = 1;
        _that.$refs.modifyMeasure.groupId = causeInitGroupDto.id; // 失效原因
        _that.$refs.modifyMeasure.groupDetectionId = failureModeDroupId; // 失效模式
        _that.$refs.modifyMeasure.struTypeCode = '10'; // 探测措施
        _that.$refs.modifyMeasure.displayElemnt = _that.$refs.tableContainer; // 指定弹窗挂载元素
        _that.$refs.modifyMeasure.list();
      });
      if (currentGroupDto != null) {
        // 失效原因(FC)或失效模式（FM）的探测度（D）赋值
        let detection =
          currentGroupDto != null ? currentGroupDto.detection : "";
        // let detectionInput = "";
        // if (detection) {
        //   detectionInput +=
        //     '<input type="text" class="ant-input" name="occurrence" value="' +
        //     detection +
        //     '" id="' +
        //     currentGroupDto.id +
        //     '" style="width: 50px; text-align: center;" maxlength="2"' +
        //     ' autoComplete="off" onfocus="handleInputFocusCheck(this)" onchange="handleDetectionChange(this)"/>';
        // }
        row.find("td:eq(15)").append(detection).css("text-align", "center");
        // 修改D值
        row.find("td:eq(15)").on('dblclick', function () {
          // 获取当前单元格的内容
          let originalContent = $(this).text();
          // 创建一个新的input元素
          let newInput = $('<input type="text" class="ant-input" style="width: 50px; text-align: center;" maxlength="2" autocomplete="off" />');
          // 设置input的初始值
          newInput.val(originalContent);
          // 绑定input的失去焦点事件
          newInput.on('blur', function () {
            // 获取用户输入的内容
            let newContent = $(this).val();
            if ("" === newContent) {
              $(this).parent().text(originalContent);
              return false;
            }
            // 更新D值
            if (newContent === originalContent) {
              $(this).parent().text(originalContent);
              return false;
            } else {
              // 调用handleDetectionChange方法
              let isValid = handleDetectionChange(this, currentGroupDto.id, newContent);
              if (!isValid) {
                // 如果校验失败，恢复原始内容
                $(this).parent().text(originalContent);
                return;
              }
            }
            // 更新单元格的内容
            $(this).parent().text(newContent).trim();
            // 移除 input
            $(this).remove();
          });
          // 将input添加到单元格中，并清空原有的内容
          $(this).empty().append(newInput);
          // 聚焦到input上
          newInput.focus();
        });
        let ap = apMap["" + modeFaultDto.maxS + occurrence + detection];
        if (ap === "H") {
          row.find("td:eq(16)").css("background-color", "#FFC7CE");
        } else if (ap === "M") {
          row.find("td:eq(16)").css("background-color", "#FFEB9C");
        } else if (ap === "L") {
          row.find("td:eq(16)").css("background-color", "#C6EFCE");
        }
        row
          .find("td:eq(16)")
          .append(ap)
          .css("text-align", "center");
      }
    },
    /**
     * 描画失效原因的优化措施
     * @param causeOtpGroupDto
     * @param modeFaultDto
     * @param currentVar
     * @param causeStartRow
     * @param actionMap
     * @param groupMap
     * @param apMap
     * @param causeOtpGroupCount
     */
    drawCauseOptMeasures(
      causeOtpGroupDto,
      modeFaultDto,
      currentVar,
      causeStartRow,
      actionMap,
      groupMap,
      apMap,
      causeOtpGroupCount
    ) {
      let _that = this;
      let optGroupDto = groupMap.get(causeOtpGroupDto.id);
      if (optGroupDto == null) return;
      let row = $("#tableRow" + (causeStartRow + causeOtpGroupCount));
      // 预防措施名称
      let causeOptPcName = "";
      // 探测措施
      let causeOptDcName = "";
      // 责任人
      let causeOptResponsible = "";
      // 目标完成日期
      let causeOptPlanDateStr = "";
      // 状态
      let causeOptStatus = "";
      // 采取基于证据的措施
      let measureEffect = "";
      // 完成日期
      let causeOptEndDateStr = "";
      // 预防措施
      let otpPAction = causeOtpGroupDto.rdfmActionPtos;
      if (!_that.$utils.isNull(otpPAction) && otpPAction.length > 0) {
        for (const u in otpPAction) {
          let index = parseInt(u) + 1;
          let otpPDto = actionMap.get(otpPAction[u].id);
          if (otpPDto) {
            // 措施名称
            causeOptPcName += "P" + index + ":" + otpPDto.actionName + "<br>";
            if (otpPDto.actionLanguageName && otpPDto.actionLanguageName !== otpPDto.actionName) {
              causeOptPcName += "P" + index + ":" + otpPDto.actionLanguageName + "<br>";
            }
            // 责任人
            causeOptResponsible +=
              otpPDto.responsible != null ? otpPDto.responsible + "<br>" : "";
            // 计划日期
            causeOptPlanDateStr +=
              otpPDto.planDateStr != null ? otpPDto.planDateStr + "<br>" : "";
            // 状态
            causeOptStatus +=
              otpPDto.lifeState != null ? otpPDto.lifeState + "<br>" : "";
            // 采取基于证据的措施
            measureEffect +=
              otpPDto.measureEffect != null
                ? otpPDto.measureEffect + "<br>"
                : "";
            // 完成日期
            causeOptEndDateStr +=
              otpPDto.endDateStr != null ? otpPDto.endDateStr + "<br>" : "";
          }
        }
      }
      // 探测措施
      let otpDAction = causeOtpGroupDto.rdfmActionDtos;
      if (!_that.$utils.isNull(otpDAction) && otpDAction.length > 0) {
        for (const u in otpDAction) {
          let otpDDto = actionMap.get(otpDAction[u].id);
          let index = parseInt(u) + 1;
          if (otpDDto) {
            // 措施名称
            causeOptDcName += "D" + index + ":" + otpDDto.actionName + '(FC)<br>';
            if (otpDDto.actionLanguageName && otpDDto.actionLanguageName !== otpDDto.actionName) {
              causeOptDcName += "D" + index + ":" + otpDDto.actionLanguageName + '(FC)<br>';
            }
            // 责任人
            causeOptResponsible +=
              otpDDto.responsible != null ? otpDDto.responsible + "<br>" : "";
            // 计划日期
            causeOptPlanDateStr +=
              otpDDto.planDateStr != null ? otpDDto.planDateStr + "<br>" : "";
            // 状态
            causeOptStatus +=
              otpDDto.lifeState != null ? otpDDto.lifeState + "<br>" : "";
            // 采取基于证据的措施
            measureEffect +=
              otpDDto.measureEffect != null
                ? otpDDto.measureEffect + "<br>"
                : "";
            // 完成日期
            causeOptEndDateStr +=
              otpDDto.endDateStr != null ? otpDDto.endDateStr + "<br>" : "";
          }
        }
      }
      // DFMEA预防措施
      row.find("td:eq(18)").append(causeOptPcName);
      row.find("td:eq(18)").on('dblclick', function () {
        _that.$refs.modifyMeasure.measureVisible = true;
        _that.$refs.modifyMeasure.measureTitleFlag = 1;
        _that.$refs.modifyMeasure.measureType = 2;
        _that.$refs.modifyMeasure.groupId = causeOtpGroupDto.id;
        _that.$refs.modifyMeasure.struTypeCode = '09'; // 预防措施
        _that.$refs.modifyMeasure.displayElemnt = _that.$refs.tableContainer; // 指定弹窗挂载元素
        _that.$refs.modifyMeasure.list();
      });
      // DFMEA探测措施
      row.find("td:eq(19)").append(causeOptDcName);
      row.find("td:eq(19)").on('dblclick', function () {
        _that.$refs.modifyMeasure.measureVisible = true;
        _that.$refs.modifyMeasure.measureTitleFlag = 2;
        _that.$refs.modifyMeasure.measureType = 2;
        _that.$refs.modifyMeasure.groupId = causeOtpGroupDto.id; // 失效原因
        _that.$refs.modifyMeasure.struTypeCode = '10'; // 探测措施
        _that.$refs.modifyMeasure.displayElemnt = _that.$refs.tableContainer; // 指定弹窗挂载元素
        _that.$refs.modifyMeasure.list();
      });
      // 责任人姓名
      row.find("td:eq(20)").append(causeOptResponsible);
      // 目标完成日期，居中
      row
        .find("td:eq(21)")
        .append(causeOptPlanDateStr)
        .css("text-align", "center");
      // 状态，居中
      row
        .find("td:eq(22)")
        .append(causeOptStatus)
        .css("text-align", "center");
      // 采取基于证据的措施
      row.find("td:eq(23)").append(measureEffect);
      // 完成日期
      row.find("td:eq(24)").append(causeOptEndDateStr);
      // 严重度(S)，居中
      let maxS = modeFaultDto != null ? modeFaultDto.maxS : "";
      row
        .find("td:eq(25)")
        .append(maxS)
        .css("text-align", "center");
      // 频度(O)
      let causeOptO = optGroupDto != null ? optGroupDto.occurrence : "";
      let causeOptOInput = "";
      if (causeOptO) {
        causeOptOInput +=
          '<input type="text" class="ant-input" name="opOccurrence" value="' +
          causeOptO +
          '" id="' +
          optGroupDto.id +
          '" style="width: 50px; text-align: center;" maxlength="2"' +
          ' autoComplete="off" onfocus="handleInputFocusCheck(this)" onchange="handleOptOccurrenceChange(this)"/>';
      }
      row
        .find("td:eq(26)")
        .append(causeOptOInput)
        .css("text-align", "center");
      // 探测度(D)
      let causeOptD = optGroupDto != null ? optGroupDto.detection : "";
      let causeOptDInput = "";
      if (causeOptD) {
        causeOptDInput +=
          '<input type="text" class="ant-input" name="opDetection" value="' +
          causeOptD +
          '" id="' +
          causeOtpGroupDto.id +
          '" style="width: 50px; text-align: center;" maxlength="2"' +
          ' autoComplete="off" onfocus="handleInputFocusCheck(this)" onchange="handleOptDetectionChange(this)"/>';
      }
      row
        .find("td:eq(27)")
        .append(causeOptDInput)
        .css("text-align", "center");
      // DFMEA AP
      let ap = apMap["" + maxS + causeOptO + causeOptD];
      if (ap == "H") {
        row.find("td:eq(28)").css("background-color", "#FFC7CE");
      } else if (ap == "M") {
        row.find("td:eq(28)").css("background-color", "#FFEB9C");
      } else if (ap == "L") {
        row.find("td:eq(28)").css("background-color", "#C6EFCE");
      }
      row
        .find("td:eq(28)")
        .append(ap)
        .css("text-align", "center");
      // 筛选代码(可选)
      // 备注
    },
    /**
     * @param causeCurrentGroupCount
     * @param causeOtpGroupCount
     * @param modelFaultOptNameMap
     */
    drawModeOptMeasures(causeStartRow, causeOtpGroupCount, modelFaultOptNameMap) {
      let _that = this;
      let row = $("#tableRow" + (causeStartRow + causeOtpGroupCount));
      // 失效模式（FM）的探测措施赋值
      let modelFaultOptName = ""; // 失效模式优化探测措施名称
      let modelFaultOptId = ""; // 失效模式优化探测措施组Id
      if (modelFaultOptNameMap.size > 0) {
        for (let value of modelFaultOptNameMap.values()) {
          modelFaultOptName += value.name;
          modelFaultOptId = value.id;
        }
      }
      // DFMEA探测措施
      if (modelFaultOptName !== "") {
        row.find("td:eq(19)").append(modelFaultOptName);
        row.find("td:eq(19)").on('dblclick', function () {
          _that.$refs.modifyMeasure.measureVisible = true;
          _that.$refs.modifyMeasure.measureTitleFlag = 2;
          _that.$refs.modifyMeasure.measureType = 2;
          _that.$refs.modifyMeasure.groupDetectionId = modelFaultOptId; // 失效模式
          _that.$refs.modifyMeasure.struTypeCode = '10'; // 探测措施
          _that.$refs.modifyMeasure.displayElemnt = _that.$refs.tableContainer; // 指定弹窗挂载元素
          _that.$refs.modifyMeasure.list();
        });
      }
    },
    /**
     * 失效后果合并数据做成
     * @param effectFaultDto
     * @param modeFaultDto
     * @param effectVar
     * @param mergeEffectMap
     * @param mergeEffectFuncMap
     * @param mergeEffectStruMap
     * @param faultMap
     */
    handleFaultEffectMergeData(
      effectFaultDto,
      modeFaultDto,
      effectVar,
      mergeEffectMap,
      mergeEffectFuncMap,
      mergeEffectStruMap,
      faultMap
    ) {
      let faultModel = faultMap.get(modeFaultDto.id);
      let effectFaultShowDto = faultMap.get(effectFaultDto.id);
      if (faultModel == null) return;
      // 获取失效模式措施组和失效原因措施组的总行数
      let rowspan = modeFaultDto.totalRow;
      /*===========================失效后果合并的数据构建start========*/
      // 判断当前失效后果是否相同
      if (effectVar.effectMergeId == "") {
        effectVar.effectMergeId = effectFaultShowDto.id;
      } else if (effectVar.effectMergeId == effectFaultShowDto.id) {
        // 相同
        effectVar.mergeEffectCount += 1;
      } else {
        // 不相同
        mergeEffectMap.set(
          effectVar.mergeEffectStartRow,
          effectVar.mergeEffectCount != null ? effectVar.mergeEffectCount : 1
        );
        effectVar.effectMergeId = effectFaultShowDto.id;
        effectVar.mergeEffectStartRow =
          effectVar.mergeEffectStartRow + effectVar.mergeEffectCount;
        effectVar.mergeEffectCount = 1;
      }
      // 把最后一个失效后果放入map中
      if (
        effectVar.effectFaultIndex >=
        (modeFaultDto.effectDtos != null ? modeFaultDto.effectDtos.length : 0)
      ) {
        let effectFaultMergeCount =
          effectVar.effectFaultIndex > rowspan
            ? effectVar.mergeEffectCount
            : rowspan - effectVar.effectFaultIndex + 1;
        mergeEffectMap.set(
          effectVar.mergeEffectStartRow,
          effectFaultMergeCount
        );
      }
      /*===========================失效后果合并上级功能的数据构建start========*/
      // 判断当前失效后果的上级功能是否是相同功能
      if (effectVar.effectFuncId == "") {
        effectVar.effectFuncId = effectFaultShowDto.funcId;
        effectVar.effectReqId = effectFaultShowDto.reqId;
      } else if (
        effectVar.effectFuncId == effectFaultShowDto.funcId &&
        effectVar.effectReqId == effectFaultShowDto.reqId
      ) {
        // 相同
        effectVar.mergeEffectFunCount += 1;
      } else {
        // 不相同
        mergeEffectFuncMap.set(
          effectVar.mergeEffectFunStartRow,
          effectVar.mergeEffectFunCount != null
            ? effectVar.mergeEffectFunCount
            : 1
        );
        effectVar.effectFuncId = effectFaultShowDto.funcId;
        effectVar.mergeEffectFunStartRow =
          effectVar.mergeEffectFunStartRow + effectVar.mergeEffectFunCount;
        effectVar.effectFuncIndex += effectVar.mergeEffectFunCount;
        effectVar.mergeEffectFunCount = 1;
      }
      // 把最后一个失效后果放入map中
      if (
        effectVar.effectFaultIndex >=
        (modeFaultDto.effectDtos != null ? modeFaultDto.effectDtos.length : 0)
      ) {
        let effectFuncMergeCount =
          effectVar.effectFaultIndex > rowspan
            ? effectVar.mergeEffectFunCount
            : rowspan - effectVar.effectFuncIndex + 1;
        mergeEffectFuncMap.set(
          effectVar.mergeEffectFunStartRow,
          effectFuncMergeCount
        );
      }
      /*===========================失效后果合并上级功能的数据构建end========*/
      /*===========================失效后果合并上级结构的数据构建start========*/
      // 判断当前失效后果的上级功能的上级结构是否相同
      if (effectVar.effectStruId == "") {
        effectVar.effectStruId = effectFaultShowDto.struId;
      } else if (effectVar.effectStruId == effectFaultShowDto.struId) {
        // 相同
        effectVar.mergeEffectStruCount += 1;
      } else {
        // 不相同
        mergeEffectStruMap.set(
          effectVar.mergeEffectStruStartRow,
          effectVar.mergeEffectStruCount != null
            ? effectVar.mergeEffectStruCount
            : rowspan
        );
        effectVar.effectStruId = effectFaultShowDto.struId;
        effectVar.mergeEffectStruStartRow =
          effectVar.mergeEffectStruStartRow + effectVar.mergeEffectStruCount;
        effectVar.effectStruIndex += effectVar.mergeEffectStruCount;
        effectVar.mergeEffectStruCount = 1;
      }
      // 把最后一个失效后果放入map中
      if (
        effectVar.effectFaultIndex >=
        (modeFaultDto.effectDtos != null ? modeFaultDto.effectDtos.length : 0)
      ) {
        let effectFuncMergeCount =
          effectVar.effectFaultIndex > rowspan
            ? effectVar.mergeEffectStruCount
            : rowspan - effectVar.effectStruIndex + 1;
        mergeEffectStruMap.set(
          effectVar.mergeEffectStruStartRow,
          effectFuncMergeCount
        );
      }
      /*===========================失效后果合并上级结构的数据构建end========*/
    },
    /**
     * 描画失效后果
     * @param effectFaultDto
     * @param frEffectRow
     * @param faultMap
     */
    drawFaultEffect(effectFaultDto, frEffectRow, faultMap) {
      let _that = this;
      let effectFaultShowDto = faultMap.get(effectFaultDto.id);
      let row = $("#tableRow" + frEffectRow);
      if (effectFaultShowDto.id) {
        // 结构名称+拼接零件号
        let struFirstName = effectFaultShowDto.struName + effectFaultShowDto.struNameAppend;
        let struLanguageName = "";
        if (effectFaultShowDto.struLanguageName && effectFaultShowDto.struLanguageName !== effectFaultShowDto.struName) {
          // 第二语言名称+拼接零件号
          struLanguageName = effectFaultShowDto.struLanguageName + effectFaultShowDto.struNameAppend;
        }
        row.find("td:eq(2)").append(struFirstName + '<br/>' + struLanguageName);

        // 修改单元格内容
        let zeroSingleColumn = "td:eq(2)";
        let struName = effectFaultShowDto.struName;
        let struId = effectFaultShowDto.struId;
        _that.modifyCellContent(row, zeroSingleColumn, struName, struId, struFirstName, struLanguageName);
        // 上级功能赋值
        if (effectFaultShowDto.funcType == "02") {
          row.find("td:eq(5)").css("color", "#52be68");
        } else {
          row.find("td:eq(5)").css("color", "#5b9bd5");
        }
        // 功能名称+拼接要求及规格值
        let funcFirstName = effectFaultShowDto.funcName + effectFaultShowDto.funcNameAppend;
        let funcLanguageName = "";
        if (effectFaultShowDto.funLanguageName && effectFaultShowDto.funLanguageName !== effectFaultShowDto.funcName) {
          // 第二语言名称+拼接要求及规格值
          funcLanguageName = effectFaultShowDto.funLanguageName + effectFaultShowDto.funcNameAppend;
        }
        row.find("td:eq(5)").append(funcFirstName + '<br>' + funcLanguageName);
        // 修改单元格内容
        let threeSingleColumn = "td:eq(5)";
        let funcName = effectFaultShowDto.funcName;
        let funcId = effectFaultShowDto.funcId;
        _that.modifyCellContent(row, threeSingleColumn, funcName, funcId, funcFirstName, funcLanguageName);
        // 失效后果赋值
        row.find("td:eq(8)").css("color", "#ff3636");

        let effectDeep = effectFaultDto.effectDeep;
        let name = effectFaultShowDto.name;
        if (effectDeep == "1") {
          name = ">" + name;
        } else if (effectDeep == "2") {
          name = ">>" + name;
        }

        // 失效名称及其第二语言名称
        let faultFirstName = effectFaultShowDto.name;
        let faultLanguageName = "";
        if (effectFaultShowDto.languageName && effectFaultShowDto.languageName !== faultFirstName) {
          faultLanguageName = effectFaultShowDto.languageName;
        }
        row.find("td:eq(8)").append(faultFirstName + '<br>' + faultLanguageName);
        // 修改单元格内容
        let sixSingleColumn = "td:eq(8)";
        let fautName = name;
        let fautId = effectFaultShowDto.id;
        _that.modifyCellContent(row, sixSingleColumn, fautName, fautId, faultFirstName, faultLanguageName);
        // 严重度赋值
        // let effectS = "";
        // if (effectFaultShowDto.maxSShadow) {
        //   effectS = '<input type="text" class="ant-input" name="significs" value="' + effectFaultShowDto.maxSShadow
        //       + '" id="' + effectFaultShowDto.id + '" style="width: 50px; text-align: center;" maxlength="2" '
        //       + ' autoComplete="off" onfocus="handleInputFocusCheck(this)" onchange="handleSeverityChange(this)"/>';
        // }
        // row.find("td:eq(9)").append(effectS).css("text-align", "center");
        row.find("td:eq(9)").append(effectFaultShowDto.maxSShadow).css("text-align", "center");
        // 修改S值
        row.find("td:eq(9)").on('dblclick', function () {
          // 获取当前单元格的内容
          let originalContent = $(this).text();
          // 去除括号内容
          let contentWithoutParens = originalContent.replace(/^\(.*\)$/, function (match) {
            return match.slice(1, -1); // 去除开头和结尾的括号
          });
          // 创建一个新的input元素
          let newInput = $('<input type="text" class="ant-input" style="width: 50px; text-align: center;" maxlength="2" autocomplete="off" />');
          // 设置input的初始值
          newInput.val(contentWithoutParens);
          // 绑定input的失去焦点事件
          newInput.on('blur', function () {
            // 获取用户输入的内容
            let newContent = $(this).val().trim();
            if ("" === newContent) {
              $(this).parent().text(originalContent);
              return false;
            }
            // 检查是否与包含括号的原始内容相同
            if (newContent === contentWithoutParens && newContent !== originalContent) {
              // 如果不同，则恢复包含括号的原始内容
              newContent = originalContent;
            }
            // 更新S值
            if (newContent === originalContent) {
              $(this).parent().text(originalContent);
              return false;
            } else {
              // 调用handleSeverityChange方法
              let isValid = handleSeverityChange(this, effectFaultShowDto.id, newContent);
              if (!isValid) {
                // 如果校验失败，恢复原始内容
                $(this).parent().text(originalContent);
                return;
              }
            }
            // 更新单元格的内容
            $(this).parent().text(newContent);
            // 移除 input
            $(this).remove();
          });
          // 将input添加到单元格中，并清空原有的内容
          $(this).empty().append(newInput);
          // 聚焦到input上
          newInput.focus();
        });

        // SC图标（失效后果）
        let propertyDisplay = _that.searchParams.propertyDisplay;
        if (propertyDisplay.includes(1)) {
          let sc = "";
          if (effectFaultShowDto.classifyModel) {
            if ("1" == effectFaultShowDto.classifyModel.classifyType) {
              sc = _that.getImgHtml(effectFaultShowDto.classifyModel.fileName) + " (FE)<br>";
            } else if ("2" == effectFaultShowDto.classifyModel.classifyType) {
              sc = effectFaultShowDto.classifyModel.lexplain + " (FE)<br>";
            }
            row.find("td:eq(17)").append(sc).css('text-align', 'center');
            row.find("td:eq(29)").append(sc).css('text-align', 'center');
          }
        }
        if (propertyDisplay.includes(4)) { // SC图标（失效后果的功能）
          let sc = "";
          if (effectFaultShowDto.funcClassifyModel) {
            if ("1" == effectFaultShowDto.funcClassifyModel.classifyType) {
              sc = _that.getImgHtml(effectFaultShowDto.funcClassifyModel.fileName) + " (Fn-FC)<br>";
            } else if ("2" == effectFaultShowDto.funcClassifyModel.classifyType) {
              sc = effectFaultShowDto.funcClassifyModel.lexplain + " (Fn-FC)<br>";
            }
            row.find("td:eq(17)").append(sc).css('text-align', 'center');
            row.find("td:eq(29)").append(sc).css('text-align', 'center');
          }
        }
      }
    },
    /**
     * 处理失效原因行数与失效后果行数不一致的情况
     * @param faultEffectVariable
     * @param faultCauseVariable
     * @param mergeCauseMap
     * @param mergeCauseFuncMap
     * @param mergeCauseStruMap
     */
    handleCauseAndEffectDifferent(
      faultEffectVariable,
      faultCauseVariable,
      mergeCauseMap,
      mergeCauseFuncMap,
      mergeCauseStruMap
    ) {
      // 判断失效后果的数量是否大于失效原因的总行数
      if (
        faultEffectVariable.frEffectVoIndex >
        faultCauseVariable.frCauseVoRowIndex
      ) {
        // 大于,将失效原因的最后一个合并行数改变
        let lastCauseKey = [...mergeCauseMap.keys()].pop();
        let lastCauseFuncKey = [...mergeCauseFuncMap.keys()].pop();
        let lastCauseStruKey = [...mergeCauseStruMap.keys()].pop();
        mergeCauseMap.set(
          lastCauseKey,
          faultEffectVariable.frEffectVoIndex -
          faultCauseVariable.frCauseVoRowIndex +
          mergeCauseMap.get(lastCauseKey)
        );
        mergeCauseFuncMap.set(
          lastCauseFuncKey,
          faultEffectVariable.frEffectVoIndex -
          faultCauseVariable.frCauseVoRowIndex +
          mergeCauseFuncMap.get(lastCauseFuncKey)
        );
        mergeCauseStruMap.set(
          lastCauseStruKey,
          faultEffectVariable.frEffectVoIndex -
          faultCauseVariable.frCauseVoRowIndex +
          mergeCauseStruMap.get(lastCauseStruKey)
        );
      }
    },
    /**
     * 处理失效模式合并数据
     * @param faultCauseVariable
     * @param faultEffectVariable
     * @param mergeModelMap
     * @param modelFaultStartRow
     */
    handleFaultModeMergeData(
      faultCauseVariable,
      faultEffectVariable,
      mergeModelMap,
      modelFaultStartRow
    ) {
      /*===========================失效模式合并的数据构建start========*/
      let mergeModelIndex =
        faultCauseVariable.frCauseVoRowIndex >
          faultEffectVariable.frEffectVoIndex
          ? faultCauseVariable.frCauseVoRowIndex
          : faultEffectVariable.frEffectVoIndex;
      mergeModelIndex = mergeModelIndex > 0 ? mergeModelIndex : 1;
      // 把失效模式放入map中
      mergeModelMap.set(modelFaultStartRow, mergeModelIndex);
      /*===========================失效模式合并上级功能的数据构建start========*/
      // -----------------------------------------------------------失效后果end
    },
    /**
     * 合并所有数据
     * @param mergeCauseMap
     * @param mergeModelMap
     * @param mergeEffectMap
     * @param mergeCauseFuncMap
     * @param mergeEffectFuncMap
     * @param mergeCauseStruMap
     * @param mergeEffectStruMap
     */
    mergeAllData(
      mergeCauseMap,
      mergeModelMap,
      mergeEffectMap,
      mergeCauseFuncMap,
      mergeEffectFuncMap,
      mergeCauseStruMap,
      mergeEffectStruMap
    ) {
      // 合并失效原因
      if (mergeCauseMap.size > 0) {
        mergeCauseMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(11)")
              .remove();
          }
          // 合并失效原因
          $("#tableRow" + key)
            .find("td:eq(11)")
            .attr("rowspan", value);
        });
        mergeCauseMap.clear();
      }
      // 合并失效模式
      if (mergeModelMap.size > 0) {
        mergeModelMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(10)")
              .remove();
          }
          // 合并失效模式
          $("#tableRow" + key)
            .find("td:eq(10)")
            .attr("rowspan", value);
        });
      }
      // 合并失效后果
      if (mergeEffectMap.size > 0) {
        mergeEffectMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(9)")
              .remove();
            $("#tableRow" + (key + i))
              .find("td:eq(8)")
              .remove();
          }
          // 合并失效原因的上级功能
          $("#tableRow" + key)
            .find("td:eq(9)")
            .attr("rowspan", value);
          $("#tableRow" + key)
            .find("td:eq(8)")
            .attr("rowspan", value);
        });
        mergeEffectMap.clear();
      }
      // 合并失效原因的上级功能
      if (mergeCauseFuncMap.size > 0) {
        mergeCauseFuncMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(7)")
              .remove();
          }
          // 合并失效后果的上级功能
          $("#tableRow" + key)
            .find("td:eq(7)")
            .attr("rowspan", value);
        });
        mergeCauseFuncMap.clear();
      }
      // 合并失效模式的上级功能
      if (mergeModelMap.size > 0) {
        mergeModelMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(6)")
              .remove();
          }
          // 合并失效模式
          $("#tableRow" + key)
            .find("td:eq(6)")
            .attr("rowspan", value);
        });
      }
      // 合并失效后果的上级功能
      if (mergeEffectFuncMap.size > 0) {
        mergeEffectFuncMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(5)")
              .remove();
          }
          // 合并失效后果的上级功能
          $("#tableRow" + key)
            .find("td:eq(5)")
            .attr("rowspan", value);
        });
        mergeEffectFuncMap.clear();
      }
      // 合并失效原因的上级结构
      if (mergeCauseStruMap.size > 0) {
        mergeCauseStruMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(4)")
              .remove();
          }
          // 合并失效后果的上级功能
          $("#tableRow" + key)
            .find("td:eq(4)")
            .attr("rowspan", value);
        });
        mergeCauseStruMap.clear();
      }
      // 合并失效模式的上级结构
      if (mergeModelMap.size > 0) {
        mergeModelMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(3)")
              .remove();
          }
          // 合并失效模式
          $("#tableRow" + key)
            .find("td:eq(3)")
            .attr("rowspan", value);
        });
      }
      // 合并失效后果的上级结构
      if (mergeEffectStruMap.size > 0) {
        mergeEffectStruMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
              .find("td:eq(2)")
              .remove();
          }
          // 合并失效后果的上级结构
          $("#tableRow" + key)
            .find("td:eq(2)")
            .attr("rowspan", value);
        });
        mergeEffectStruMap.clear();
      }
      if (mergeModelMap.size > 0) {
        mergeModelMap.forEach(function (value, key) {
          for (let i = 1; i < value; i++) {
            $("#tableRow" + (key + i))
                .find("td:eq(1)")
                .remove();
            $("#tableRow" + (key + i))
                .find("td:eq(0)")
                .remove();
          }
          // 合并失效模式
          $("#tableRow" + key)
              .find("td:eq(1)")
              .attr("rowspan", value);
          $("#tableRow" + key)
              .find("td:eq(0)")
              .attr("rowspan", value);
        });
        mergeModelMap.clear();
      }
    },
    /**
     * 失效模式为空时描画功能
     * @param structDto
     * @param functionDto
     */
    drawFunction(structDto, functionDto) {
      let _that = this;
      // 获取表格体行Html
      let modelHtml = _that.getTableBodyTrHtml(_that.startRow);
      $("#table_body .ant-table-tbody").append(modelHtml);
      _that.startRow++;
      let row = $("#tableRow" + (_that.startRow - 1));
      // 聚焦结构赋值
      // 结构名称+拼接零件号
      let struFirstName = structDto.name + structDto.nameAppend;
      let struLanguageName = "";
      if (structDto.languageName && structDto.languageName !== structDto.name) {
        // 第二语言名称+拼接零件号
        struLanguageName = structDto.languageName + structDto.nameAppend;
      }
      row.find("td:eq(3)").append(struFirstName + '<br>' + struLanguageName);
      // 修改单元格内容
      let oneSingleColumn = "td:eq(3)";
      let struName = structDto.name;
      let struId = structDto.id;
      _that.modifyCellContent(row, oneSingleColumn, struName, struId, struFirstName, struLanguageName);
      // 聚焦功能赋值
      // 聚焦功能赋值
      if (functionDto.type == "02") {
        row.find("td:eq(6)").css("color", "#52be68");
      } else {
        row.find("td:eq(6)").css("color", "#5b9bd5");
      }
      // 功能名称+拼接要求及规格值
      let funcFirstName = functionDto.name + functionDto.nameAppend;
      let funcLanguageName = "";
      if (functionDto.name && functionDto.languageName !== functionDto.name) {
        // 第二语言名称+拼接零件号
        funcLanguageName = functionDto.languageName + functionDto.nameAppend;
      }
      row.find("td:eq(6)").append(funcFirstName + '<br>' + funcLanguageName);
      // 修改单元格内容
      let fourSingleColumn = "td:eq(6)";
      let funcName = functionDto.name;
      let funcId = functionDto.id;
      _that.modifyCellContent(row, fourSingleColumn, funcName, funcId, funcFirstName, funcLanguageName);
    },
    /**
     * 将list转换为map
     * @param list
     * @returns {{}}
     */
    convertListToMap(list) {
      let map = new Map();
      for (const i in list) {
        let dto = list[i];
        map.set(dto.id, dto);
      }
      return map;
    },
    /**
     * 保存SOD修改后的值
     */
    save() {
      let _that = this;
      _that.saveLoading = true;
      _that.$api
        .saveFmeaVdanTable({
          fmeaId: _that.$store.getters.rfmeaId,
          hiddenSignificsId: _that.severitys.map(item => item.id).toString(),
          hiddenSignifics: _that.severitys.map(item => item.value).toString(),
          hiddenOccurrenceId: _that.occurrences.map(item => item.id).toString(),
          hiddenOccurrence: _that.occurrences
            .map(item => item.value)
            .toString(),
          hiddenDetectionId: _that.detections.map(item => item.id).toString(),
          hiddenDetection: _that.detections.map(item => item.value).toString(),
          hiddenOpOccurrenceId: _that.optOccurrences
            .map(item => item.id)
            .toString(),
          hiddenOpOccurrence: _that.optOccurrences
            .map(item => item.value)
            .toString(),
          hiddenOpDetectionId: _that.optDetections
            .map(item => item.id)
            .toString(),
          hiddenOpDetection: _that.optDetections
            .map(item => item.value)
            .toString(),
          pageCurrent: _that.searchParams.pageCurrent
        })
        .then(res => {
          if (res.flag) {
            _that.$message.success(res.message, 1);
            // 表格清空
            _that.clearTableData();
            _that.list();
          } else {
            _that.$message.error(res.message, 1);
          }
        })
        .catch(error => {
          _that.$message.error(error.response.data.message, 1);
        })
        .finally(() => {
          _that.saveLoading = false;
        });
    },
    /**
     * 双击修改单元格内容(结构、功能、失效)
     * @param row 行数据
     * @param singleColumn 单元格
     * @param struName 节点名称
     * @param struId 节点ID
     * @param struFirstName 节点名称+拼接值
     * @param struLanguageName 第二语言名称+拼接值
     */
    modifyCellContent(row, singleColumn, struName, struId, struFirstName, struLanguageName) {
      let _that = this;
      row.find(singleColumn).on('dblclick', function () {
        // 获取当前单元格的内容（可能存在节点名称以外的拼接信息）
        let originalContent = struFirstName + '<br>' + struLanguageName;
        // 创建一个新的input元素
        let input = $('<input type="text" class="ant-input" style="width: 100%;" maxlength="50" autocomplete="off" />');
        // 设置input的初始值（无拼接内容的节点名称）
        input.val(struName);
        // 绑定input的失去焦点事件
        input.on('blur', function () {
          // 获取用户输入的内容
          let newContent = $(this).val().trim();
          // 输入内容为空：还原点击前的文字显示
          if ("" === newContent) {
            $(this).parent().html(originalContent);
            return false;
          }
          // 更改前后未作更改则：还原点击前的文字显示
          if (newContent === struName) {
            // 更新单元格的内容
            $(this).parent().html(originalContent);
            return false;
          } else {
            // 更新结构、功能、失效名称
            let data = {
              fmeaId: _that.$store.getters.rfmeaId,
              struId: struId,
              struName: newContent
            };
            _that.$api.updateNodeName(data).then(res => {
              if (res.flag) {
                _that.$message.success(res.message, 1);
                _that.modifyCellFlag = true;
                _that.search();
              } else {
                _that.$message.error(res.message, 1);
              }
            });
          }
          // 移除 input
          $(this).remove();
        });
        // 将input添加到单元格中
        $(this).empty().append(input);
        // 聚焦到input上
        input.focus();
      });
    },
    // 子组件模态框关闭，修改单元格标识，调用查询方法
    handleModifyCellFlag(newValue) {
      this.modifyCellFlag = newValue;
      this.search();
    },
  }
};
</script>

<style lang="less" scoped>
/** 表格头部自动换行 */
/deep/ .ant-table-thead {
  .ant-table-row-cell-ellipsis .ant-table-column-title {
    white-space: normal;
  }
}

/deep/ .ant-table-wrapper .ant-table-thead tr th.green {
  background-color: #79b841 !important;
}

/deep/ .radio-group-class {
  float: right;
  margin-top: -30px;
}

/deep/ .ant-card {
  border-radius: 0px;
}
</style>
