Newer
Older
KaiFengPC / src / hooks / useDicts.js
@鲁yixuan 鲁yixuan on 14 Jun 1 KB update
export default function useDicts(proxy) {
  const { build_category } = proxy.useDict('build_category');
  const { drainage_partition } = proxy.useDict('drainage_partition');
  const { sponge_engineering_type } = proxy.useDict('sponge_engineering_type');
  const { sponge_land_type } = proxy.useDict('sponge_land_type');
  const { project_content_type } = proxy.useDict('project_content_type');
  const { project_library_type } = proxy.useDict('project_library_type');
  const { task_type } = proxy.useDict('task_type');
  const { project_drainage_zone } = proxy.useDict('project_drainage_zone');
  const { project_operation_pattern } = proxy.useDict('project_operation_pattern');
  const { build_status } = proxy.useDict('build_status');
  const dicts = {
    build_category,
    drainage_partition,
    sponge_engineering_type,
    sponge_land_type,
    project_content_type,
    project_library_type,
    task_type,
    project_operation_pattern,
    build_status,
    project_drainage_zone,
  };
  const findText = (prop, type) => {
    const item = dicts[prop].value.find(it => it.value === type);
    return item?.label || '';
  };

  return {
    ...dicts,
    findText,
  };
}