import { defineStore } from 'pinia';

export const useSimulationStore = defineStore('simulation', {
  state: () => {
    return {
      layer: {},
      userInfo: localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo') || '') : null,
      projectBaseInfo: null,
      // webSocket: new WebSocket(websocketPrefixPath + localStorage.getItem('jobNumber')),
      dataReviewPath: sessionStorage.getItem('DATA_REVIEW_PATH') || '',
      standardLibPath: sessionStorage.getItem('STANDARD_LIB_PATH') || '',
      mnoduleLibPath: sessionStorage.getItem('MODULE_LIB_PATH') || '',
      customLibPath: sessionStorage.getItem('CUSTOM_LIB_PATH') || '',
      dataPermissionPath: sessionStorage.getItem('DATA_PERMISSION_PATH') || '',
      personalSpacePath: sessionStorage.getItem('PERSONAL_SPACE_PATH') || '',
      isSM: false,
      projectDiaInfo: {
        isEdit: false,
        showDiaKey: '',
        baseInfo: {},
        nodeInfo: [],
        roleInfo: [],
        loadcaseInfo: [],
      },
      automationInfo: {
        discipline: '',
        runPath: '',
        runName: '',
        runType: 0,
        disciplinePath: '',
        moduleLibPath: '',
      },
      // 已经取消的任务队列
      cancelTaskIdList: [],
      // CONFIG：配置数据     LOADING：接口进行中    SUCCESS：成功    ERROR：失败
      modelInfo: {
        isCconfirmStep: false,
        checkModelList: ['1', '3'],
        modelStep: 1,
        splitStatus: 'CONFIG',
        assembleStatus: 'CONFIG',
        // loadingSplit: false,
        // loadingAssemble: false,
        // 拆分的三步的index
        splitStepIndex: 1,
        // 装配的三步的index
        assembleStepIndex: 1,

        // 拆分的数据
        splitBaseInfo: {
          modelFile: [],
          modelSet: [],
        },
        splitPartListInfo: {
          partListFile: '',
          tableData: [],
          selectKeys: [],
          multipleSelection: [],
        },
        splitRenListInfo: {
          csvFile: '',
          tableData: [],
          selectKeys: [],
          multipleSelection: [],
          moduleExportPath: '',
        },
        // 装配的数据
        moduleLibInfo: {
          moduleLibPath: '',
          tableData: [],
          selectKeys: [],
          multipleSelection: [],
        },
        loadcaseSelectInfo: {
          controlCardType: 'standard',
          selectKeys: [],
          multipleSelection: [],
        },
        assembleResultPath: '',
        // 分析项库操作是否保存
      },
      // 模组工具的相关配置
      modelToolInfo: {
        modelZeroInfo: {
          Type1: {
            modelFile: [],
            partListFile: '',
            moduleExportPath: '',
          },
          Type4: {
            modelFile: [],
            partListFile: '',
            moduleExportPath: '',
          },
          Type5: {
            modelFile: [],
            partListFile: '',
            moduleExportPath: '',
            uploadGlobalFile: [],
          },
        },
        modelOneInfo: {
          Type3: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type6: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type7: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type8: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type10: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type11: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type12: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type14: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type15: {
            modelFile: [],
            moduleExportPath: '',
          },
          Type16: {
            modelFile: [],
            attachNodeFile: [],
            moduleExportPath: '',
          },
          Type17: {
            moduleExportPath: '',
          },
          Type18: {
            modelLibPath: '',
            subjoinFile: '',
            moduleExportPath: '',
          },
        },
        modelTwoInfo: {
          Type9: {
            modelFile: [],
            moduleExportPath: '',
          },
        },
        modelThreeInfo: {
          Type13: {
            modelFile: [],
            moduleExportPath: '',
            revolveParam: '',
          },
        },
        modelFourInfo: {
          Type2: {
            modelFile: [],
            moduleExportPath: '',
            deleteFile: [],
            deleteParam: '',
          },
        },
      },
      // 上传的文件list
      uploadFileList: [],
      uploadSpeed: 0,
      showUploadList: false,
      // 全局唯一递增id
      IncrementalId: 1,
      logInfo: {
        modelFirstLog: '',
        modelToolLog: '',
        modelSecondLog0: '',
        submitLog: '',
        reportProcessLog: '',
      },
      sessionId: localStorage.getItem('sessionId') || '',
      hasZipNoDown: false,
      proxy: {},
      loadcaseIsSave: true,
      isCollapse: false, // 菜单是否展开
      fileUtil: {
        dragging: false,
      },
    };
  },
  actions: {
    // SET_USERINFO(state, data) {
    //   state.userInfo = data;
    // },
    // SET_PROJECTINFO(state, data) {
    //   state.projectBaseInfo = data;
    // },
    // SET_DATA_REVIEW_PATH(state, data) {
    //   sessionStorage.setItem('DATA_REVIEW_PATH', data);
    //   state.dataReviewPath = data;
    // },
    // SET_PERSONAL_SPACE_PATH(state, data) {
    //   sessionStorage.setItem('PERSONAL_SPACE_PATH', data);
    //   state.personalSpacePath = data;
    // },
    // SET_STANDARD_LIB_PATH(state, data) {
    //   sessionStorage.setItem('STANDARD_LIB_PATH', data);
    //   state.standardLibPath = data;
    // },
    // SET_MODULE_LIB_PATH(state, data) {
    //   sessionStorage.setItem('MODULE_LIB_PATH', data);
    //   state.mnoduleLibPath = data;
    // },
    // SET_CUSTOM_LIB_PATH(state, data) {
    //   sessionStorage.setItem('CUSTOM_LIB_PATH', data);
    //   state.customLibPath = data;
    // },
    // SET_DATA_PERMISSION_PATH(state, data) {
    //   sessionStorage.setItem('DATA_PERMISSION_PATH', data);
    //   state.dataPermissionPath = data;
    // },
    // RESET_STATE(state) {
    //   state.dataReviewPath = '';
    // },
    // SET_IS_SM(state, data) {
    //   state.isSM = data;
    // },
    // SET_PROJECT_DIA_INFO(state, { data, key }) {
    //   state.projectDiaInfo[key] = data;
    // },
    // SET_AUTOMATION_INFO(state, { data, key }) {
    //   state.automationInfo[key] = data;
    // },
    // SET_MODEL_INFO(state, { data, key }) {
    //   state.modelInfo[key] = data;
    // },
    // SET_LOG_INFO(state, { data, key }) {
    //   state.logInfo[key] = data;
    // },
    // SET_SESSIONID(state, data) {
    //   state.sessionId = data;
    // },
    // SET_UPLOAD_FILE_LIST(state, data) {
    //   state.uploadFileList = data;
    // },
    // SET_UPLOAD_SPEED(state, data) {
    //   state.uploadSpeed = data;
    // },
    // SET_SHOW_UPLOAD_LIST(state, data) {
    //   state.showUploadList = data;
    // },
    // SET_HAS_ZIP_NO_DOWN(state, data) {
    //   state.hasZipNoDown = data;
    // },
    // SET_PROXY(state, data) {
    //   state.proxy = data;
    // },
    // SET_COLLAPSE(state) {
    //   state.isCollapse = !state.isCollapse;
    // },
    // SET_FILE_UTIL(state, data) {
    //   state.fileUtil.dragging = data.dragging;
    // },
  },
});
