import { reactive } from 'vue';

/**步骤信息状态类型 */
type StepStateType = {
  /**步骤名称 */
  stepName: string;
  /**是否安装网元 */
  setupNE: boolean;
  /**安装网元步骤信息 */
  neSteps: any[];
  /**安装网元步骤当前选中 */
  neStepsCurrent: number;
};

/**步骤信息状态 */
export const stepState: StepStateType = reactive({
  stepName: 'Start',
  setupNE: false,
  neSteps: [
    {
      title: '网元服务配置',
      description: '设置网元对应的服务终端',
    },
    {
      title: '网元全局参数',
      description: '设置网元基础配置信息',
    },
    {
      title: '网元服务安装',
      description: '将网元服务安装到服务终端',
    },
    {
      title: '网元许可授权',
      description: '获取网元许可激活码进行授权认证',
    },
  ],
  neStepsCurrent: -1,
});

/**步骤信息状态复位 */
export function fnRestStepState(t?: any) {
  stepState.stepName = 'Start';
  stepState.setupNE = false;
  stepState.neStepsCurrent = -1;
  // 多语言翻译
  if (t) {
    stepState.neSteps = [
      {
        title: t('views.system.quickStart.stepNeInfoTitle'),
        description: t('views.system.quickStart.stepNeInfoDesc'),
      },
      {
        title: t('views.system.quickStart.stepPara5GTitle'),
        description: t('views.system.quickStart.stepPara5GDesc'),
      },
      {
        title: t('views.system.quickStart.stepInstallTitle'),
        description: t('views.system.quickStart.stepInstallDesc'),
      },
      {
        title: t('views.system.quickStart.stepLicenseTitle'),
        description: t('views.system.quickStart.stepLicenseDesc'),
      },
    ];
  }
}

/**跳转步骤组件 */
export function fnToStepName(stepName: string) {
  stepState.neStepsCurrent = [
    'NeInfoConfig',
    'NeInfoConfigPara5G',
    'NeInfoSoftwareInstall',
    'NeInfoSoftwareLicense',
  ].indexOf(stepName);

  stepState.stepName = stepName;
}
