import { CoeType, GljType, IRationCoe } from '@sc/types';
import { v1 } from 'uuid';

// 根据人材机类型，获取可含有的组成物类型，空数组即为该人材机不可含有组成物
export const getComponentTypes = (type: GljType): GljType[] => {
  if ([GljType.CONCRETE, GljType.MORTAR, GljType.MIX_RATIO].includes(type)) {
    return [GljType.GENERAL_MATERIAL];
  }
  if ([GljType.GENERAL_MACHINE, GljType.INSTRUMENT].includes(type)) {
    return [
      GljType.MACHINE_COMPOSITION,
      GljType.MACHINE_LABOUR,
      GljType.FUEL_POWER_FEE,
      GljType.DEPRECIATION_FEE,
      GljType.INSPECTION_FEE,
      GljType.MAINTENANCE,
      GljType.DISMANTLING_FREIGHT_FEE,
      GljType.VERIFICATION_FEE,
      GljType.OTHER_FEE,
    ];
  }
  if (GljType.MAIN_MATERIAL === type) {
    return [GljType.MAIN_MATERIAL];
  }
  return [];
};

// 获取自定义系数
export const getCustomerCoe = (): IRationCoe => {
  return {
    ID: v1(),
    stdID: -1,
    name: '自定义系数',
    content: '人工×1，材料×1，机械×1，主材×1，设备×1',
    isAdjust: true,
    coes: [
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.RATION },
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.LABOUR },
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MATERIAL },
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MACHINE },
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MAIN },
      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.EQUIPMENT },
    ],
  };
};
