import { getDisciplineByRole } from '@/utils/roleDiscipline';
import { getUserRoleCodes } from '@/utils/user';

export const getDemandHideKeys = (key: string) => {
  const allKeys = [
    'simulationPurpose',
    'animationPurpose',
    'robotBrand',
    'axis',
    'beatDemand',
    'useType',
    'styleRequirements',
    'viewRequirements',
    'referenceData',
    'deviceMessage',
    'materialAndCraftsmanship',
    'robotNum',
    'colorRequirements',
  ];
  let keys: string[] = [];
  if (key.indexOf('有限元') !== -1 || key.indexOf('DISCIPLINE_TYPE') !== -1) {
    const finiteElementKeys = ['simulationPurpose'];
    keys = allKeys.filter((item) => !finiteElementKeys.includes(item));
  } else if (key.indexOf('动画') !== -1) {
    const animationKeys = ['animationPurpose', 'robotBrand', 'axis', 'beatDemand'];
    keys = allKeys.filter((item) => !animationKeys.includes(item));
  } else if (key.indexOf('工业') !== -1) {
    const industrialKeys = [
      'useType',
      'styleRequirements',
      'viewRequirements',
      'referenceData',
      'deviceMessage',
      'colorRequirements',
      'materialAndCraftsmanship',
    ];
    keys = allKeys.filter((item) => !industrialKeys.includes(item));
  } else if (key.indexOf('机器人') !== -1) {
    const robotKeys = ['robotBrand', 'axis', 'robotNum'];
    keys = allKeys.filter((item) => !robotKeys.includes(item));
  } else if (key.indexOf('公差') !== -1) {
    const toleranceKeys = [''];
    keys = allKeys.filter((item) => !toleranceKeys.includes(item));
  }
  return keys;
};

/** 获取当前用户所属仿真类型 */
export const getUserSimulationType = () => {
  // const disciplines = await getDisciplineByRole('ROLE_ADMIN, GENERAL_USER');
  // console.log('disciplines', disciplines);
  const roleSimulationInfo: any = getDisciplineByRole(getUserRoleCodes());
  return roleSimulationInfo.simulationType ? roleSimulationInfo.simulationType[0] : '';
  // return '动画';
  // return '工业';
};

/** 获取当前用户能看到的学科 */
export const getSeeDisciplines = () => {
  const roleSimulationInfo: any = getDisciplineByRole(getUserRoleCodes());
  return roleSimulationInfo.discipline;
  // return ['结构'];
};
