export * from './common';
export * from './patrol';
export * from './warehouse';
export * from './warehouseDefinition';

// 字典

//获取字典项
export const useDict = (dict) => {
  if (!dict || !Array.isArray(dict)) {
    console.error('请传入正确的字典');
    return '';
  }
  return (code) => {
    return dict.find((item) => (item && item.code) === code) || {};
  };
};
//获取字典label
export const useDictLabel = (dict) => {
  if (!dict || !Array.isArray(dict)) {
    console.error('请传入正确的字典');
    return '';
  }
  return (code) => {
    // console.log(code, 'label');
    const obj = dict.find((item) => (item && item.code) == code);
    return obj && obj.label;
  };
};
//获取字典label
export const useDictLabelFilter = (code, dict) => {
  if (!dict || !Array.isArray(dict)) {
    console.error('请传入正确的字典');
    return '';
  }
  const obj = dict.find((item) => (item && item.code) === code);
  return obj && obj.label;
};
