import { toMap } from '@/utils/node';
import { ref } from 'vue';
import { CommonStore } from '@/stores/common';
import { nodeTypeList } from '@/utils/enum/node';

const commonStore = CommonStore();

const nodeTypeMap = toMap(nodeTypeList);

const analysisSoftwareOptions = ref([]);
const performanceTypeOptions = ref([]);
const performanceUnitOptions = ref([]);
const capacityOptions = ref([]);
const departmentListOptions = ref([]);
const sectionListOptions = ref([]);
const groupListOptions = ref([]);
const taskPoolDictOptions = ref<any>({});
const poolCategoryTypeOptions = ref([]);
const allNodeTypeMap: any = ref();
const initProjectDicts = () => {
  const analysisSoftware: any = commonStore.getDictData('ANALYSIS_SOFTWARE');
  const performanceType: any = commonStore.getDictData('PERFORMANCE_TYPE');
  const performanceUnit: any = commonStore.getDictData('PERFORMANCE_UNIT');
  const capacityList: any = commonStore.getDictData('SIMULATION_CAPACITY');
  const departmentList: any = commonStore.getDictData('DEPARTMENT_LIST');
  const sectionList: any = commonStore.getDictData('SECTION_LIST');
  const groupList: any = commonStore.getDictData('GROUP_LIST');
  const poolCategoryTypeList: any = commonStore.getDictData('POOL_CATEGORY_TYPE');
  analysisSoftwareOptions.value = analysisSoftware.A;
  performanceTypeOptions.value = performanceType.A;
  performanceUnitOptions.value = performanceUnit.A;
  capacityOptions.value = capacityList.A;
  departmentListOptions.value = departmentList.A;
  sectionListOptions.value = sectionList.A;
  groupListOptions.value = groupList.A;
  poolCategoryTypeOptions.value = poolCategoryTypeList.A;
  taskPoolDictOptions.value = {
    analysisSoftwareOptions,
    performanceTypeOptions,
    performanceUnitOptions,
    capacityOptions,
    departmentListOptions,
    sectionListOptions,
    groupListOptions,
  };
  allNodeTypeMap.value = {
    ...nodeTypeMap,
    ...toMap(poolCategoryTypeOptions.value),
  };
};

export { poolCategoryTypeOptions, taskPoolDictOptions, allNodeTypeMap, initProjectDicts };
