<script setup lang="ts">
import { traduction, getErrorTranslate } from '@/utils/language';
import { ref, reactive, computed, onMounted, onUnmounted, onBeforeUnmount, watch } from 'vue';
import useStore from '@/stores';
import Dialog from '@/components/Dialog/Dialog.vue';
import FileUpload from '@/components/FileUpload/FileUpload.vue';
import { UploadFile } from 'element-plus/es/components/upload/src/upload';
import { ElNotification as elNotification } from 'element-plus';
import UploadingIcon from '@/components/UploadingIcon/UploadingIcon.vue';
import CustomAlert from '@/components/CustAlert/CustAlert.vue';
import SecondPassword from '@/components/SecondPassword/SecondPassword.vue';
import { SecondAuthorityFail, SystemModel, UserPrivil } from '@/model/base-enum';
import {
  getPowerControl,
  queryTaskProgress,
  getUpgradeInfo,
  importUpgradeFile,
  importFileByConfig,
  reauth
} from '../../upgrade.services';
import Date from '@/utils/date';
import { checkPrivil } from '@/apps/app-bmc/router/routes';
import { getStoreData } from '@/utils/composition';
import { showElMessage, getMessageId, escapeHeader } from '@/utils/utils';
import { IconSuccess, IconRemind } from '@computing/opendesign-icons';
import { UI_REST_FIRMWAREINVENTORY } from '@/api/api';

const store = useStore();
const isSystemLock = computed(() => {
  return store.state.glob.systemLocked;
});
const multihost = computed(() => getStoreData('loct', 'multihost'));
const productLabel = store.state.loct.sn;
const loct: any = localStorage.getItem('loct');
const dialogRef = ref();
const tipRef = ref();
const uploadRef = ref();
const alertInfo = traduction('IBMC_FIMWARE_TIP_INFO', { softwareName: productLabel });
let hpmUpload: any = null;
let formData = ref(); // 表单数据
// 表示进度条的显示状态
const onUpgrade = ref(false);
const submitDisabled = ref(true);
const uploadDisabled = ref(false);
const progress = ref(0);
// 升级进度查询
let taskInterval: any = null;
let taskStateErrorAmount = 0;
// 记录网络失败次数
let networkErrorAmount = 0;
let bmcUpdating = false;
const upgradeResult = reactive({
  result: '',
  msg: '',
});
const uploadError = ref('');
// 是否支持生效分离
const upgradeActiveModeSupported = ref(false);

// CPLD白名单
const CPLDList = ['DPUCpld'];

// 生效分离勾选状态
const activeMode = ref(false);
let fileItem: any = null;

const hasUserConfig = checkPrivil(UserPrivil.userConfig);
// 保留配置
let configSelected = ref('yes');

const tipClose = (val: boolean) => {
  tipRef.value.hide();
  if (val) {
    dialogRef.value.show();
  }
};
// 是否保留配置项按钮禁用
const configRadioDisabled = ref(isSystemLock.value);
const retainedDisabled = ref(isSystemLock.value);
const changeActiveMode = (value: boolean) => {
  if (value) {
    configSelected.value = 'yes';
    configRadioDisabled.value = true;
  } else {
    configRadioDisabled.value = false;
  }
};
// 文件上传
const message = 'insufficient memory capacity for the upload.';
const uploadConfig = reactive({
  action: UI_REST_FIRMWAREINVENTORY,
  headers: {
    'X-CSRF-Token': escapeHeader(loct ? JSON.parse(loct).to : ''),
    From: 'WebUI',
    Accept: '*/*',
  },
  width: 320,
  disabled: isSystemLock.value || uploadDisabled.value,
  method: 'POST',
  name: 'imgfile',
  isAutoUpload: false,
  accept: '.hpm',
  isNeedClearError: false,
  id: 'uploadConfig',
  onAddItem: (file: UploadFile, list: UploadFile[], msg?: any, upload?: any): boolean => {
    hpmUpload = upload;
    uploadError.value = '';
    const subfix = file.name.split('.').reverse()[0];
    const size = file.size;
    // 文件格式错误
    if (subfix !== 'hpm') {
      uploadError.value = traduction('IBMC_UP_FILE_FORMAT_ERROR');
      return false;
    } else if (size && size > 1024 * 1024 * 90) {
      uploadError.value = traduction('IBMC_UPLOAD_FILE_90M_ERROR');
      return false;
    } else {
      fileItem = file;
      submitDisabled.value = false;
      return true;
    }
  },
  onError: (err: any, file: UploadFile, fileList: UploadFile[]) => {
    const errorId = getMessageId(JSON.parse(err.message));
    const errorMsg = getErrorTranslate(errorId[0]?.code as string) || traduction('COMMON_FAILED');
    // 文件名错误不需要提示右上角信息
    if (errorId[0]?.message === message) {
      showElMessage('error', traduction('IBMC_UPGRADE_FIRMWARE_TIP'));
      uploadError.value = traduction('IBMC_UPGRADE_FIRMWARE_TIP');
    } else if (errorId[0]?.code && errorId[0]?.code !== 'FileNameError') {
      showElMessage('error', errorMsg);
      uploadError.value = errorMsg;
    }
    onUpgrade.value = false;
    elNotification.closeAll();
    uploadRef.value.clear();
    retainedDisabled.value = false;
    configRadioDisabled.value = false;
    uploadDisabled.value = false;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
  },
  onBeforeUpload: (file: UploadFile) => {
    // 如果支持生效分离则加上ActiveMode参数
    if (upgradeActiveModeSupported.value) {
      file['formData'] = {
        ActiveMode: activeMode.value ? 'Immediately' : 'ResetBMC',
      };
    }
  },
  onSuccess: (res: any, file: UploadFile, fileList: UploadFile[]) => {
    beginImportUpgradeFile(fileItem.name);
  },
  onProgress: (event: any, file: UploadFile, fileList: UploadFile[]) => {
    uploadDisabled.value = true;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    retainedDisabled.value = true;
    configRadioDisabled.value = true;
    // 设置上传文件进度
    progress.value = Math.floor(event.percent);
    if (!onUpgrade.value) {
      elNotification({
        title: traduction('IBMC_UPGRADE_UPLOADING'),
        message: traduction('IBMC_UPGRADE_UPLOADING_TIP'),
        icon: UploadingIcon as any,
        position: 'bottom-right',
        duration: 0,
        offset: 10,
      });
    }
    onUpgrade.value = true;
    submitDisabled.value = true;
  },
});
// 开始执行升级流程
function beginImportUpgradeFile(name: any) {
  onUpgrade.value = false;
  elNotification.closeAll();
  elNotification({
    title: traduction('IBMC_UPGRADE_UPLOAD_SUCCESS'),
    message: traduction('IBMC_UPGRADE_UPLOAD_COMPLETE'),
    position: 'bottom-right',
    type: 'success',
    offset: 10,
  });

  // 设置导入文件进度，并开始导入文件
  progress.value = 0;
  importUpgradeFile(name, configSelected.value).then(
    (res: any) => {
      const url = res.data.url;
      onUpgrade.value = false;
      elNotification.closeAll();
      elNotification({
        title: traduction('IBMC_UPGRADE_UPLOAD_SUCCESS'),
        message: traduction('IBMC_UPGRADE_UPLOAD_COMPLETE'),
        position: 'bottom-right',
        type: 'success',
        offset: 10,
      });
      queryTask(url);
    },
    err => {
      onUpgrade.value = false;
      elNotification.closeAll();
      uploadRef.value.clear();
      uploadDisabled.value = false;
      retainedDisabled.value = false;
      configRadioDisabled.value = false;
      uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
      const errorId = getMessageId(err.data);
      const errorMsg = getErrorTranslate(errorId[0]?.code as string) || traduction('COMMON_FAILED');
      uploadError.value = errorMsg;
      // 文件名错误不需要提示右上角信息
      if (errorId[0]?.code && errorId[0]?.code !== 'FileNameError') {
        showElMessage('error', errorMsg);
      }
    },
  );
}

// 升级前确认弹窗
const dialogConfig = reactive({
  id: '',
  content: traduction('COMMON_ASK_OK'),
  title: traduction('ALARM_OK'),
});

const tipConfig = {
  id: 'tipConfig',
  content: traduction('COMMON_ASK_OK'),
  title: traduction('ALARM_OK'),
};

const user = {
  loginWithoutPassword: getStoreData('loct', 'nopwd') || false,
};
let minPwdLength: number = 8;
const loginWithoutPassword = ref(user.loginWithoutPassword);

const secondRef = ref();
function resetDialog() {
  if (configSelected.value === 'no') {
    // 不保留配置项升级：三次弹窗，先风险提示弹窗，再确认操作弹窗，再输入密码确认
    tipRef.value.show();
  } else {
    // 保留配置项升级：一次弹窗，直接确认操作弹窗
    dialogRef.value.show();
  }
}
// 二次密码确认弹窗
function confirmReset(param: { reason: boolean; password: string }) {
  if (!param.reason || !param.password) {
    secondRef.value.hide();
    return;
  }
  startToUpload(param.password);
}

function startToUpload(key?: string) {
  // 点击确定后，开始升级，并将进度清0, 升级状态复位, 升级失败次数重置
  progress.value = 10;
  upgradeResult.result = '';
  upgradeResult.msg = '';
  taskStateErrorAmount = 0;
  networkErrorAmount = 0;
  if (key) {
    reauth(key).then(res => {
      secondRef.value.hide();
      hpmUpload.submit();
    }, err => {
      const errorCode = err.data.error[0].code;
      if (
        errorCode === SecondAuthorityFail.REAUTHFAILED ||
        errorCode === SecondAuthorityFail.AUTHORIZATIONFAILED
      ) {
        secondRef.value.setErrorId();
        secondRef.value.clearPassword();
      }
    });
  } else {
    hpmUpload.submit();
  }
}
// 开始升级按钮点击
function submitUpload(reason: any) {
  dialogRef.value.hide();
  if (reason && configSelected.value === 'yes') {
    startToUpload();
    return;
  }
  if (reason && configSelected.value === 'no') {
    if (!loginWithoutPassword.value) {
      secondRef.value.show();
    } else {
      startToUpload();
    }
  }
}

// 升级完成后处理逻辑
function taskCompleted(taskData: any) {
  clearQueryProgress();
  progress.value = 100;
  configSelected.value = 'yes';
  bmcUpdating = false;
  elNotification.closeAll();
  // 2分钟后，才隐藏进度条，以便自动化截图
  setTimeout(() => {
    onUpgrade.value = false;
  }, 120000);
  const fileType = taskData.Name;
  const isBIOS = fileType === 'Bios' || fileType === 'Teeos';
  const isCPLD = fileType?.toLowerCase()?.indexOf('cpld') > -1 && !CPLDList.includes(fileType);
  if ((isBIOS || isCPLD) && !multihost.value) {
    // BIOS,CPLD生效分离
    getPowerControl()
      .then(resData => {
        if (resData['data'].PowerState[0].State !== 'Off') {
          if (isCPLD) {
            upgradeResult.msg = 'IBMC_AFTER_CPLD';
          } else {
            upgradeResult.msg = 'IBMC_AFTER_REBOOT';
          }
        } else {
          upgradeResult.msg = 'IBMC_FIMWARE_UPDATE_FIND';
        }
        upgradeResult.result = 'success';
      })
      .catch(() => {
        upgradeResult.msg = 'IBMC_FIMWARE_UPDATE_FIND';
        upgradeResult.result = 'success';
      });
  } else {
    upgradeResult.msg = 'IBMC_FIMWARE_UPDATE_FIND';
    upgradeResult.result = 'success';
  }
  if (upgradeActiveModeSupported.value) {
    elNotification({
      title: traduction('IBMC_FIMWARE_UPDATE_FIND'),
      message: traduction('IBMC_MANUAL_EFFECTIVE_MODE', { softwareName: productLabel }),
      type: 'success',
      position: 'bottom-right',
      offset: 10,
    });
  } else {
    elNotification({
      title: traduction('IBMC_FIMWARE_UPDATE_FIND'),
      type: 'success',
      position: 'bottom-right',
      offset: 10,
    });
  }
  store.state.glob.setGlobState({ type: 'isUpgrading', value: false });
}
// 正在升级时的处理逻辑
function taskRunning(taskData: any, url: string) {
  if (!bmcUpdating) {
    elNotification({
      title: traduction('IBMC_AUTOMATIC_PROCEED'),
      message: traduction('IBMC_FIMWARE_UPDATE_TIP'),
      icon: UploadingIcon as any,
      position: 'bottom-right',
      duration: 0,
      offset: 10,
    });
  }
  bmcUpdating = true;
  reQueryProgress(url);
}

// 进度查询时，其他state状态处理
function taskOtherCases(taskData: any, url: string) {
  taskStateErrorAmount++;
  // 出现状态不对时, 重试次数为10次
  if (taskStateErrorAmount > 10) {
    const state = taskData?.TaskState || 'TaskState is not valid.';
    const errorMsg = 'type error, the current task state value is ：' + state;
    recordUpgradeErrorLogs(errorMsg);
    // 执行升级失败流程
    executeUpgradeFailed(taskData.ErrorCode);
    store.state.glob.setGlobState({ type: 'isUpgrading', value: false });
    bmcUpdating = false;
    return;
  }
  reQueryProgress(url);
}

// 升级状态异常处理(表示升级失败)
function exceptionHandler(taskData: any) {
  resetUploadState();
  if (taskData.ErrorCode) {
    executeUpgradeFailed(taskData.ErrorCode);
  } else {
    executeUpgradeFailedById(taskData.message_id);
  }
}

// 查进度时，接口错误处理（表示接口查询失败）
function errorHandler(error: Error, url: string) {
  // 当接口查询进度报错时，考虑正常升级时间预计是3分钟左右，设置为30次
  if (networkErrorAmount > 30) {
    const errorMsg = 'network connect error!';
    recordUpgradeErrorLogs(errorMsg);
    resetUploadState();
    elNotification.closeAll();
    showElMessage('error', errorMsg);
    uploadError.value = errorMsg;
  } else {
    reQueryProgress(url);
  }
}

// 恢复Upload的状态参数
function resetUploadState() {
  uploadDisabled.value = false;
  retainedDisabled.value = false;
  configRadioDisabled.value = false;
  uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
  onUpgrade.value = false;
  bmcUpdating = false;
  store.state.glob.setGlobState({ type: 'isUpgrading', value: false });
}

// 固件升级进度
function queryTask(url: string) {
  store.state.glob.setGlobState({ type: 'isUpgrading', value: true });
  onUpgrade.value = true;
  queryTaskProgress(url).then(
    res => {
      const taskData = res.data;
      uploadDisabled.value = true;
      retainedDisabled.value = true;
      configRadioDisabled.value = true;
      uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
      // 场景描述：前端固件上传时，存在state，cli后台升级是不存在state
      if (taskData.state) {
        getProgress(url, taskData);
      } else {
        getInitProgress(url, taskData);
      }
    },
    error => { },
  );
}
// 固件升级进度函数拆分
function getProgress(url: string, taskData: any): void {
  if (taskData.state === 'Completed' && taskData.prepare_progress === 100) {
    uploadDisabled.value = false;
    retainedDisabled.value = false;
    configRadioDisabled.value = false;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    taskCompleted(taskData);
  } else if (taskData.state === 'Running' || taskData.state === 'Starting' || taskData.state === 'New') {
    progress.value = taskData.prepare_progress;
    taskRunning(taskData, url);
  } else if (taskData.state === 'Exception') {
    exceptionHandler(taskData);
  } else {
    uploadDisabled.value = false;
    retainedDisabled.value = false;
    configRadioDisabled.value = false;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    taskOtherCases(taskData, url);
  }
}

function getInitProgress(url: string, taskData: any): void {
  if (taskData.TaskState === 'Completed' && taskData.Percentage === '100%') {
    uploadDisabled.value = false;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    retainedDisabled.value = false;
    configRadioDisabled.value = false;
    taskCompleted(taskData);
  } else if (taskData.TaskState === 'Running' || taskData.TaskState === 'Starting' || taskData.TaskState === 'New') {
    if (taskData.Percentage === null) {
      taskData.Percentage = 0;
    } else {
      taskData.Percentage = Number(taskData.Percentage.split('%')[0]);
    }
    progress.value = taskData.Percentage;
    taskRunning(taskData, url);
  } else if (taskData.TaskState === 'Exception') {
    exceptionHandler(taskData);
  } else {
    uploadDisabled.value = false;
    retainedDisabled.value = false;
    configRadioDisabled.value = false;
    uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    taskOtherCases(taskData, url);
  }
}

// 记录升级失败日志
function recordUpgradeErrorLogs(errorMsg: string) {
  const upgradeError = JSON.parse(localStorage.getItem('upgradeError') as string) || {};
  const curTime = new Date().pattern('yyyy-MM-dd HH:mm:ss');
  upgradeError[curTime] = errorMsg;
  localStorage.setItem('upgradeError', JSON.stringify(upgradeError));
}

/**
 * 重新触发进度查询
 * 为了能在OS下电状态下升级CPLD时查到升级完成的状态（升级完成到环境AC下电大概2秒左右），查询间隔设置为2秒
 */
function reQueryProgress(url: string) {
  taskInterval = window.setTimeout(() => {
    queryTask(url);
  }, 2000);
}

// 清除定时查询任务
function clearQueryProgress() {
  if (taskInterval) {
    clearTimeout(taskInterval);
    taskInterval = null;
  }
}

// 升级失败状态码处理
function executeUpgradeFailed(errorCode: number) {
  uploadRef.value?.clear();
  onUpgrade.value = false;
  let msg = traduction('IBMC_FIMWARE_FAILED');
  switch (errorCode) {
    case 2:
      msg = traduction('IBMC_UP_FILE_NOT_EXIST');
      break;
    case 3:
      msg = traduction('IBMC_UP_COMM_FILE_ERROR');
      break;
    case 4:
      msg = traduction('IBMC_UP_COMM_LITTLE_MEM');
      break;
    case 8:
      msg = traduction('IBMC_UP_OS_POWER_ERROR');
      break;
    case 9:
      msg = traduction('IBMC_UP_FIRMWARE_MISMATCH');
      break;
    case 12:
      msg = traduction('IBMC_UP_FIRMWARE_FILE_MISMATCH');
      break;
    case 13:
      msg = traduction('IBMC_UP_FIRMWARE_ERR_WRONG_ME_STATUS');
      break;
    case 27:
      msg = traduction('IBMC_UP_WHITEBRAND_FILE_MISMATCH');
      break;
    case 28:
      msg = traduction('IBMC_UP_FIRMWARE_ERR_RETRY');
      break;
    case 33:
      msg = traduction('IBMC_UP_COMM_FILE_TOO_EARLY');
      break;
    case 34:
      msg = traduction('IBMC_UP_OS_POWER_MCU_ERROR');
      break;
    case 35:
      msg = traduction('IBMC_UP_FIRMWARE_REVOKED');
      break;
    case 70:
      msg = traduction('IBMC_UP_COMM_FILE_TOO_EARLY');
      break;
    case 205:
      msg = traduction('IBMC_UP_POWER_SUPPLY_INSUFFICIENT');
      break;
    case 248:
      msg = traduction('IBMC_UP_VRD_UPGRADE_IS_IN_PROGRESS');
      break;
    default:
      msg = traduction('IBMC_FIMWARE_FAILED');
      break;
  }
  displayUpgradeState('failed', msg);
}

function executeUpgradeFailedById(message_id: string) {
  uploadRef.value?.clear();
  onUpgrade.value = false;
  let msg = traduction('IBMC_FIMWARE_FAILED');
  switch (message_id) {
    case 'FirmwareRevoked':
      msg = traduction('IBMC_UP_FIRMWARE_REVOKED');
      break;
    default:
      msg = traduction('IBMC_FIMWARE_FAILED');
      break;
  }
  displayUpgradeState('failed', msg);
}

// 固件升级状态提示
function displayUpgradeState(state: 'success' | 'failed' | 'clear', msg: string) {
  elNotification.closeAll();
  if (state === 'failed') {
    uploadError.value = msg;
    showElMessage('error', msg);
  } else if (state === 'success') {
    showElMessage('success', traduction('IBMC_FIMWARE_UPDATE_FIND'));
  }
}
function init(isInit?: boolean) {
  getUpgradeInfo().then(res => {
    activeMode.value = res.data.ActiveMode === 'Immediately' ? true : false;
    if (upgradeActiveModeSupported.value && activeMode.value) {
      configRadioDisabled.value = true;
    } else {
      configSelected.value = 'yes';
      configRadioDisabled.value = isSystemLock.value;
    }
    // 进入页面时查询一次升级进度
    const upgradeUrl = res.data?.UpgradeUrl;
    if (res.data.UpdatingFlag && isInit && Boolean(upgradeUrl)) {
      elNotification.closeAll();
      queryTask(upgradeUrl);
      uploadDisabled.value = true;
      retainedDisabled.value = true;
      configRadioDisabled.value = true;
      uploadConfig.disabled = isSystemLock.value || uploadDisabled.value;
    }
  });
}

onMounted(() => {
  init(true);
});
onBeforeUnmount(() => {
  if (hpmUpload) {
    hpmUpload.abort();
  }
});
onUnmounted(() => {
  clearQueryProgress();
  elNotification.closeAll();
});
</script>
<template>
  <div id="locationView" v-privil.base.baseConfig class="location-container">
    <CustomAlert id="alertType" :content="alertInfo" />
    <el-form label-width="auto" label-position="left">
      <el-form-item class="upload-item" :error="uploadError" :label="$t('IBMC_MANUAL_UPDATE')">
        <div class="upload-and-res">
          <FileUpload
            ref="uploadRef"
            class="upload-style"
            :data="uploadConfig"
            @set-error="displayUpgradeState"
          ></FileUpload>
          <div v-if="upgradeResult.result === 'success'" id="upgradeResult" class="upload-res">
            <el-icon v-if="upgradeResult.result === 'success'" :size="16">
              <IconSuccess />
            </el-icon>
            <span class="res-msg">{{ $t(upgradeResult.msg) }}</span>
          </div>
        </div>
        <el-progress v-if="onUpgrade" id="proUpdate" stroke-width="4" :percentage="progress" />
      </el-form-item>
      <!-- 生效分离 -->
      <el-form-item
        v-if="upgradeActiveModeSupported"
        id="activeModeSupported"
        class="active-mode-item"
        :label="$t('IBMC_MANUAL_SEPARATION')"
        size="default"
      >
        <el-checkbox
          v-model="activeMode"
          v-addId.checkbox="'activeMode'"
          :label="$t('IBMC_MANUAL_EFFECTIVE_MODE')"
          :disabled="isSystemLock"
          @change="changeActiveMode"
        />
        <span id="manualTip" class="manualTip">{{ $t('IBMC_MANUAL_TIP') }}</span>
      </el-form-item>
      <el-form-item :label="$t('CONFIG_SAVED_LABLE')" v-if="hasUserConfig">
        <!-- 是否保留配置升级 -->
        <div id="configSavedInfo">
          <el-radio
            v-model="configSelected"
            v-addId.radio="'configSave'"
            size="middle"
            label="yes"
            :disabled="retainedDisabled"
          >
            {{ $t('CONFIG_SAVED_YES') }}
          </el-radio>
          <el-radio
            v-model="configSelected"
            v-addId.radio="'configChange'"
            size="middle"
            label="no"
            :disabled="configRadioDisabled"
          >
            {{ $t('CONFIG_SAVED_NO') }}
          </el-radio>
          <!-- 是否保留配置升级说明Tip -->
          <span id="configSavedTip">{{ $t('CONFIG_SAVED_TIP') }}</span>
        </div>
      </el-form-item>
      <el-form-item class="submit-item" label=" ">
        <el-button
          id="modeButton"
          :disabled="submitDisabled || (onUpgrade && progress !== 100)"
          type="primary"
          @click="resetDialog"
        >
          {{ $t('IBMC_UPGRADE_CONGIF_BTN') }}
        </el-button>
        <Dialog ref="dialogRef" :config="dialogConfig" @close="submitUpload"></Dialog>
        <!-- 不保留配置项提示弹窗 -->
        <Dialog ref="tipRef" :config="tipConfig" @close="tipClose" class="config-dialog">
          <div slot="other">
            <div class="tip-title">
              <div class="d-icon">
                <el-icon :size="16">
                  <IconRemind />
                </el-icon>
              </div>
              <div class="d-container">
                <div>{{ $t('CONFIG_SAVED_IBMC_RISK') }}</div>
                <div>{{ $t('CONFIG_SAVED_BIOS_RISK') }}</div>
              </div>
            </div>
            <div class="tip-word">{{ $t('COMMON_ASK_OK') }}</div>
          </div>
        </Dialog>
      </el-form-item>
    </el-form>
    <SecondPassword ref="secondRef" @close="confirmReset" />
  </div>
</template>
<style lang="scss" scoped>
.location-container {
  .el-form {
    margin-top: 16px;

    :deep(.el-input) {
      max-width: 320px;
    }
  }

  .upload-item {
    :deep(.el-form-item__content) {
      display: block;

      .upload-and-res {
        display: flex;
        align-items: center;

        .upload-res {
          margin-left: 8px;
          display: flex;
          align-items: center;

          .res-msg {
            margin-left: 4px;
          }
        }
      }
    }
  }

  :deep(.active-mode-item) {
    .el-form-item__label {
      padding-top: 0;
      padding-bottom: 0;
    }

    .el-checkbox {
      height: auto;
    }
  }

  .submit-item {
    margin-bottom: 0;
  }

  .el-progress {
    margin-top: 8px;
    width: 320px;
  }

  .manualTip {
    margin-left: 8px;
    color: var(--o-text-color-tertiary);
  }
}
</style>
<style lang="scss">
.el-notification .el-notification__closeBtn {
  top: 18px;
  right: 15px;
}
#tipAlert {
  background-color: #e2f1fc;
  border: 1px solid var(--o-color-state-primary);
}
#tipAler :deep(.bc-content) {
  color: #6c7280;
}
.tip-word {
  margin-top: 20px;
  color: #6c7280;
}
.tip-title {
  display: flex;
  background-color: #e2f1fc;
  padding: 8px 16px;
  border-radius: 2px;
  border: 1px solid var(--o-color-state-primary);
}
.tip-title .d-icon {
  height: 16px;
  margin-right: 8px;
}
.tip-title .d-container {
  font-size: 12px;
  color: var(--o-text-color-primary);
  overflow: hidden;
  transition: all 0.2s;
  white-space: pre-wrap;
  &.active {
    margin-top: 8px;
    height: auto;
  }
}
.config-dialog {
  .c-modal {
    width: 532px;
  }
}
#configSavedTip {
  vertical-align: top;
}
</style>
