Newer
Older
KaiFengPC / src / hooks / useDicts.js
@zhangdeliang zhangdeliang on 23 May 1 KB 初始化项目
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_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,
  };
  const findText = (prop, type) => {
    const item = dicts[prop].value.find(it => it.value === type);
    return item?.label || '';
  };

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