From 26249d828d68429560134dc3545186bc3628697c Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Sat, 8 Nov 2025 12:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E5=AD=97?= =?UTF-8?q?=E5=85=B8Cascader=E3=80=81LeftTree=E3=80=81Select=E3=80=81Selec?= =?UTF-8?q?tTree=E3=80=81Hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Cascader/Area/index.d.ts | 2 +- components/Cascader/Area/index.js | 9 +--- components/Cascader/Basic/index.d.ts | 4 +- components/Cascader/Basic/index.js | 2 +- components/Cascader/Dictionary/index.d.ts | 23 +++++++++ components/Cascader/Dictionary/index.js | 40 +++++++++++++++ components/LeftTree/Area/index.d.ts | 16 ++++++ components/LeftTree/Area/index.js | 15 ++++++ components/LeftTree/Basic/index.d.ts | 4 +- components/LeftTree/Basic/index.js | 2 +- components/LeftTree/Department/Gwj/index.d.ts | 2 +- components/LeftTree/Department/Gwj/index.js | 2 +- components/LeftTree/Dictionary/index.d.ts | 23 +++++++++ components/LeftTree/Dictionary/index.js | 40 +++++++++++++++ components/Select/Dictionary/index.d.ts | 23 +++++++++ components/Select/Dictionary/index.js | 40 +++++++++++++++ components/Select/Personnel/Gwj/index.d.ts | 2 +- components/SelectTree/Area/index.d.ts | 2 +- components/SelectTree/Area/index.js | 1 - components/SelectTree/Basic/index.d.ts | 4 +- components/SelectTree/Basic/index.js | 12 ++--- .../SelectTree/Department/Gwj/index.d.ts | 2 +- components/SelectTree/Department/Gwj/index.js | 2 +- components/SelectTree/Dictionary/index.d.ts | 23 +++++++++ components/SelectTree/Dictionary/index.js | 40 +++++++++++++++ enum/dictionary/index.js | 7 +++ enum/uploadFile/gwj/index.js | 2 + hooks/useDictionary/index.d.ts | 24 +++++++++ hooks/useDictionary/index.js | 50 +++++++++++++++++++ 29 files changed, 388 insertions(+), 30 deletions(-) create mode 100644 components/Cascader/Dictionary/index.d.ts create mode 100644 components/Cascader/Dictionary/index.js create mode 100644 components/LeftTree/Area/index.d.ts create mode 100644 components/LeftTree/Area/index.js create mode 100644 components/LeftTree/Dictionary/index.d.ts create mode 100644 components/LeftTree/Dictionary/index.js create mode 100644 components/Select/Dictionary/index.d.ts create mode 100644 components/Select/Dictionary/index.js create mode 100644 components/SelectTree/Dictionary/index.d.ts create mode 100644 components/SelectTree/Dictionary/index.js create mode 100644 enum/dictionary/index.js create mode 100644 hooks/useDictionary/index.d.ts create mode 100644 hooks/useDictionary/index.js diff --git a/components/Cascader/Area/index.d.ts b/components/Cascader/Area/index.d.ts index 5d40413..65af4fd 100644 --- a/components/Cascader/Area/index.d.ts +++ b/components/Cascader/Area/index.d.ts @@ -4,7 +4,7 @@ import type { BasicCascaderProps } from "../Basic"; /** * 组件属性 */ -export interface AreaCascaderProps extends Omit { +export interface AreaCascaderProps extends Omit { /** 占位符,默认为"属地" */ placeholder?: string; } diff --git a/components/Cascader/Area/index.js b/components/Cascader/Area/index.js index 9e5d91d..6501c3d 100644 --- a/components/Cascader/Area/index.js +++ b/components/Cascader/Area/index.js @@ -11,14 +11,7 @@ function AreaCascader(props) { } = props; return ( - + ); } diff --git a/components/Cascader/Basic/index.d.ts b/components/Cascader/Basic/index.d.ts index d39a608..e5d248e 100644 --- a/components/Cascader/Basic/index.d.ts +++ b/components/Cascader/Basic/index.d.ts @@ -4,12 +4,12 @@ import type { FC } from "react"; /** * 组件属性 */ -export interface BasicCascaderProps extends CascaderProps { +export interface BasicCascaderProps extends Omit { /** 树形数据 label 字段,默认 name */ nameKey?: string; /** 树形数据 value 字段,默认 id */ idKey?: string; - /** 树形数据 children 字段,默认 childrenList */ + /** 树形数据 children 字段,默认 children */ childrenKey?: string; /** 决定 onGetNodePaths 是否包含自身节点,默认 true */ onGetNodePathsIsIncludeOneself?: boolean; diff --git a/components/Cascader/Basic/index.js b/components/Cascader/Basic/index.js index 8abdb06..7316602 100644 --- a/components/Cascader/Basic/index.js +++ b/components/Cascader/Basic/index.js @@ -15,7 +15,7 @@ function BasicCascader(props) { data = [], nameKey = "name", idKey = "id", - childrenKey = "childrenList", + childrenKey = "children", level, ...restProps } = props; diff --git a/components/Cascader/Dictionary/index.d.ts b/components/Cascader/Dictionary/index.d.ts new file mode 100644 index 0000000..4b1ea24 --- /dev/null +++ b/components/Cascader/Dictionary/index.d.ts @@ -0,0 +1,23 @@ +import type { FC } from "react"; +import type { BasicCascaderProps } from "../Basic"; + +/** + * 组件属性 + */ +export interface DictionarySelectTreeProps extends Omit { + /** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */ + appKey?: string; + /** 要获取的字典 */ + dictValue: string; + /** 树形数据 label 字段,默认 dictLabel */ + nameKey?: string; + /** 树形数据 value 字段,默认 dictValue */ + idKey?: string; +} + +/** + * 数据字典级联组件 + */ +declare const DictionarySelectTree: FC; + +export default DictionarySelectTree; diff --git a/components/Cascader/Dictionary/index.js b/components/Cascader/Dictionary/index.js new file mode 100644 index 0000000..6076f32 --- /dev/null +++ b/components/Cascader/Dictionary/index.js @@ -0,0 +1,40 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useEffect, useState } from "react"; +import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary"; +import BasicCascader from "../Basic"; + +/** + * 数据字典级联组件 + */ +function DictionarySelectTree(props) { + const { + appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, + dictValue = "", + nameKey = "dictLabel", + idKey = "dictValue", + ...restProps + } = props; + + const [treeData, setTreeData] = useState([]); + + const getData = async () => { + if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) + throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中"); + + setTreeData([]); + const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue }); + setTreeData(data); + }; + + useEffect(() => { + dictValue && getData(); + }, [dictValue]); + + return ( + + ); +} + +DictionarySelectTree.displayName = "DictionarySelectTree"; + +export default DictionarySelectTree; diff --git a/components/LeftTree/Area/index.d.ts b/components/LeftTree/Area/index.d.ts new file mode 100644 index 0000000..f45a93e --- /dev/null +++ b/components/LeftTree/Area/index.d.ts @@ -0,0 +1,16 @@ +import type { FC } from "react"; +import type { BasicLeftTreeProps } from "../Basic"; + +/** + * 组件属性 + */ +export interface AreaLeftTreeProps extends Omit { + +} + +/** + * 属地左侧树组件 + */ +declare const AreaLeftTree: FC; + +export default AreaLeftTree; diff --git a/components/LeftTree/Area/index.js b/components/LeftTree/Area/index.js new file mode 100644 index 0000000..6efe666 --- /dev/null +++ b/components/LeftTree/Area/index.js @@ -0,0 +1,15 @@ +import Area from "../../../json/area.json"; +import BasicLeftTree from "../Basic"; + +/** + * 属地左侧树组件 + */ +function AreaLeftTree(props) { + return ( + + ); +} + +AreaLeftTree.displayName = "AreaLeftTree"; + +export default AreaLeftTree; diff --git a/components/LeftTree/Basic/index.d.ts b/components/LeftTree/Basic/index.d.ts index 909b2c0..f43a033 100644 --- a/components/LeftTree/Basic/index.d.ts +++ b/components/LeftTree/Basic/index.d.ts @@ -4,12 +4,12 @@ import type { FC } from "react"; /** * 组件属性 */ -export interface BasicLeftTreeProps extends TreeProps { +export interface BasicLeftTreeProps extends Omit { /** 树形数据 title 字段,默认 name */ nameKey?: string; /** 树形数据 key 字段,默认 id */ idKey?: string; - /** 树形数据 children 字段,默认 childrenList */ + /** 树形数据 children 字段,默认 children */ childrenKey?: string; /** 决定 onGetNodePaths 是否包含自身节点,默认 true */ onGetNodePathsIsIncludeOneself?: boolean; diff --git a/components/LeftTree/Basic/index.js b/components/LeftTree/Basic/index.js index 3b9f418..5d7bc04 100644 --- a/components/LeftTree/Basic/index.js +++ b/components/LeftTree/Basic/index.js @@ -17,7 +17,7 @@ const BasicLeftTree = (props) => { treeData = [], nameKey = "name", idKey = "id", - childrenKey = "childrenList", + childrenKey = "children", ...restProps } = props; diff --git a/components/LeftTree/Department/Gwj/index.d.ts b/components/LeftTree/Department/Gwj/index.d.ts index b9c8f08..bec6d89 100644 --- a/components/LeftTree/Department/Gwj/index.d.ts +++ b/components/LeftTree/Department/Gwj/index.d.ts @@ -14,7 +14,7 @@ export interface Params { /** * 组件属性 */ -export interface DepartmentLeftTreeProps extends Omit { +export interface DepartmentLeftTreeProps extends Omit { /** 请求参数 */ params?: Params; } diff --git a/components/LeftTree/Department/Gwj/index.js b/components/LeftTree/Department/Gwj/index.js index aae5925..69255b5 100644 --- a/components/LeftTree/Department/Gwj/index.js +++ b/components/LeftTree/Department/Gwj/index.js @@ -23,7 +23,7 @@ function DepartmentLeftTree(props) { }, []); return ( - + ); } diff --git a/components/LeftTree/Dictionary/index.d.ts b/components/LeftTree/Dictionary/index.d.ts new file mode 100644 index 0000000..f5388b4 --- /dev/null +++ b/components/LeftTree/Dictionary/index.d.ts @@ -0,0 +1,23 @@ +import type { FC } from "react"; +import type { BasicLeftTreeProps } from "../Basic"; + +/** + * 组件属性 + */ +export interface DictionaryLeftTreeProps extends Omit { + /** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */ + appKey?: string; + /** 要获取的字典 */ + dictValue: string; + /** 树形数据 label 字段,默认 dictLabel */ + nameKey?: string; + /** 树形数据 value 字段,默认 dictValue */ + idKey?: string; +} + +/** + * 数据字典左侧树组件 + */ +declare const DictionaryLeftTree: FC; + +export default DictionaryLeftTree; diff --git a/components/LeftTree/Dictionary/index.js b/components/LeftTree/Dictionary/index.js new file mode 100644 index 0000000..91720e5 --- /dev/null +++ b/components/LeftTree/Dictionary/index.js @@ -0,0 +1,40 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useEffect, useState } from "react"; +import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary"; +import BasicLeftTree from "../Basic"; + +/** + * 数据字典左侧树组件 + */ +function DictionaryLeftTree(props) { + const { + appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, + dictValue = "", + nameKey = "dictLabel", + idKey = "dictValue", + ...restProps + } = props; + + const [treeData, setTreeData] = useState([]); + + const getData = async () => { + if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) + throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中"); + + setTreeData([]); + const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue }); + setTreeData(data); + }; + + useEffect(() => { + dictValue && getData(); + }, [dictValue]); + + return ( + + ); +} + +DictionaryLeftTree.displayName = "DictionaryLeftTree"; + +export default DictionaryLeftTree; diff --git a/components/Select/Dictionary/index.d.ts b/components/Select/Dictionary/index.d.ts new file mode 100644 index 0000000..501ff2c --- /dev/null +++ b/components/Select/Dictionary/index.d.ts @@ -0,0 +1,23 @@ +import type { FC } from "react"; +import type { BasicSelectProps } from "../Basic"; + +/** + * 组件属性 + */ +export interface DictionarySelectProps extends Omit { + /** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */ + appKey?: string; + /** 要获取的字典 */ + dictValue: string; + /** 树形数据 label 字段,默认 dictLabel */ + nameKey?: string; + /** 树形数据 value 字段,默认 dictValue */ + idKey?: string; +} + +/** + * 数据字典下拉组件 + */ +declare const DictionarySelect: FC; + +export default DictionarySelect; diff --git a/components/Select/Dictionary/index.js b/components/Select/Dictionary/index.js new file mode 100644 index 0000000..1716c6a --- /dev/null +++ b/components/Select/Dictionary/index.js @@ -0,0 +1,40 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useEffect, useState } from "react"; +import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary"; +import BasicSelect from "../Basic"; + +/** + * 数据字典下拉组件 + */ +function DictionarySelect(props) { + const { + appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, + dictValue = "", + nameKey = "dictLabel", + idKey = "dictValue", + ...restProps + } = props; + + const [data, setData] = useState([]); + + const getData = async () => { + if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) + throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中"); + + setData([]); + const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue }); + setData(data); + }; + + useEffect(() => { + dictValue && getData(); + }, [dictValue]); + + return ( + + ); +} + +DictionarySelect.displayName = "DictionarySelect"; + +export default DictionarySelect; diff --git a/components/Select/Personnel/Gwj/index.d.ts b/components/Select/Personnel/Gwj/index.d.ts index dc6f721..9e1bacc 100644 --- a/components/Select/Personnel/Gwj/index.d.ts +++ b/components/Select/Personnel/Gwj/index.d.ts @@ -16,7 +16,7 @@ export interface Params { /** * 组件属性 */ -export interface PersonnelSelectProps extends Omit { +export interface PersonnelSelectProps extends Omit { /** 请求参数 */ params?: Params; /** 占位符,默认"人员" */ diff --git a/components/SelectTree/Area/index.d.ts b/components/SelectTree/Area/index.d.ts index edfac82..71b5a19 100644 --- a/components/SelectTree/Area/index.d.ts +++ b/components/SelectTree/Area/index.d.ts @@ -4,7 +4,7 @@ import type { BasicSelectTreeProps } from "../Basic"; /** * 组件属性 */ -export interface AreaSelectTreeProps extends Omit { +export interface AreaSelectTreeProps extends Omit { /** 占位符,默认"属地" */ placeholder?: string; } diff --git a/components/SelectTree/Area/index.js b/components/SelectTree/Area/index.js index aa0682a..6d01e16 100644 --- a/components/SelectTree/Area/index.js +++ b/components/SelectTree/Area/index.js @@ -16,7 +16,6 @@ function AreaSelectTree(props) { placeholder={placeholder} nameKey="label" idKey="value" - childrenKey="children" {...restProps} /> ); diff --git a/components/SelectTree/Basic/index.d.ts b/components/SelectTree/Basic/index.d.ts index 04aea87..dc89c83 100644 --- a/components/SelectTree/Basic/index.d.ts +++ b/components/SelectTree/Basic/index.d.ts @@ -4,12 +4,12 @@ import type { FC } from "react"; /** * 组件属性 */ -export interface BasicSelectTreeProps extends TreeSelectProps { +export interface BasicSelectTreeProps extends Omit { /** 树形数据 label 字段,默认 name */ nameKey?: string; /** 树形数据 value 字段,默认 id */ idKey?: string; - /** 树形数据 children 字段,默认 childrenList */ + /** 树形数据 children 字段,默认 children */ childrenKey?: string; /** 决定 onGetNodePaths 是否包含自身节点,默认 true */ onGetNodePathsIsIncludeOneself?: boolean; diff --git a/components/SelectTree/Basic/index.js b/components/SelectTree/Basic/index.js index 2b5036f..44e13d2 100644 --- a/components/SelectTree/Basic/index.js +++ b/components/SelectTree/Basic/index.js @@ -16,7 +16,7 @@ function BasicSelectTree(props) { treeData = [], nameKey = "name", idKey = "id", - childrenKey = "childrenList", + childrenKey = "children", level, ...restProps } = props; @@ -24,11 +24,11 @@ function BasicSelectTree(props) { // 根据 level 处理树数据 const processedTreeData = level ? processTreeDataByLevel({ - data: treeData, - level, - childrenKey, - currentLevel: 1, - }) + data: treeData, + level, + childrenKey, + currentLevel: 1, + }) : treeData; const handleChange = (value, label, extra) => { diff --git a/components/SelectTree/Department/Gwj/index.d.ts b/components/SelectTree/Department/Gwj/index.d.ts index 5b794ac..d8a0689 100644 --- a/components/SelectTree/Department/Gwj/index.d.ts +++ b/components/SelectTree/Department/Gwj/index.d.ts @@ -5,7 +5,7 @@ import type { BasicSelectTreeProps } from "../../Basic"; /** * 组件属性 */ -export interface DepartmentSelectTreeProps extends Omit { +export interface DepartmentSelectTreeProps extends Omit { /** 请求参数 */ params?: Params; /** 占位符,默认"部门" */ diff --git a/components/SelectTree/Department/Gwj/index.js b/components/SelectTree/Department/Gwj/index.js index 0360000..adfccf3 100644 --- a/components/SelectTree/Department/Gwj/index.js +++ b/components/SelectTree/Department/Gwj/index.js @@ -34,7 +34,7 @@ function DepartmentSelectTree(props) { }, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]); return ( - + ); } diff --git a/components/SelectTree/Dictionary/index.d.ts b/components/SelectTree/Dictionary/index.d.ts new file mode 100644 index 0000000..592742c --- /dev/null +++ b/components/SelectTree/Dictionary/index.d.ts @@ -0,0 +1,23 @@ +import type { FC } from "react"; +import type { BasicSelectTreeProps } from "../Basic"; + +/** + * 组件属性 + */ +export interface DictionarySelectTreeProps extends Omit { + /** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */ + appKey?: string; + /** 要获取的字典 */ + dictValue: string; + /** 树形数据 label 字段,默认 dictLabel */ + nameKey?: string; + /** 树形数据 value 字段,默认 dictValue */ + idKey?: string; +} + +/** + * 数据字典下拉树组件 + */ +declare const DictionarySelectTree: FC; + +export default DictionarySelectTree; diff --git a/components/SelectTree/Dictionary/index.js b/components/SelectTree/Dictionary/index.js new file mode 100644 index 0000000..289c11a --- /dev/null +++ b/components/SelectTree/Dictionary/index.js @@ -0,0 +1,40 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useEffect, useState } from "react"; +import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary"; +import BasicSelectTree from "../Basic"; + +/** + * 数据字典下拉树组件 + */ +function DictionarySelectTree(props) { + const { + appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, + dictValue = "", + nameKey = "dictLabel", + idKey = "dictValue", + ...restProps + } = props; + + const [treeData, setTreeData] = useState([]); + + const getData = async () => { + if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) + throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中"); + + setTreeData([]); + const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue }); + setTreeData(data); + }; + + useEffect(() => { + dictValue && getData(); + }, [dictValue]); + + return ( + + ); +} + +DictionarySelectTree.displayName = "DictionarySelectTree"; + +export default DictionarySelectTree; diff --git a/enum/dictionary/index.js b/enum/dictionary/index.js new file mode 100644 index 0000000..f5145cb --- /dev/null +++ b/enum/dictionary/index.js @@ -0,0 +1,7 @@ +/** + * 数据字典 appKey 枚举 + */ +export const DICTIONARY_APP_KEY_ENUM = { + DEFAULT: "0bb989ecada5470c87635018ece9f327", + GWJ: "0bb989ecada5470c87635018ece9f327", +} diff --git a/enum/uploadFile/gwj/index.js b/enum/uploadFile/gwj/index.js index e950dce..514d1b1 100644 --- a/enum/uploadFile/gwj/index.js +++ b/enum/uploadFile/gwj/index.js @@ -62,6 +62,7 @@ export const UPLOAD_FILE_TYPE_ENUM = { 133: 133, 134: 134, 135: 135, + 136: 136, }; /** @@ -128,4 +129,5 @@ export const UPLOAD_FILE_PATH_ENUM = { 133: "branch_safety_director_approval", 134: "project_authority_review_signature", 135: "branch_manager_approval_signature", + 136: "accident_incident", }; diff --git a/hooks/useDictionary/index.d.ts b/hooks/useDictionary/index.d.ts new file mode 100644 index 0000000..2defd26 --- /dev/null +++ b/hooks/useDictionary/index.d.ts @@ -0,0 +1,24 @@ +export interface getDictionaryOptions { + /** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */ + appKey?: string; + /** 要获取的字典 */ + dictValue: string; +} + +export interface DictionaryItem { + /** label */ + dictLabel: string; + /** value */ + dictValue: string; + /** 子级 */ + children: DictionaryItem[]; + [key: string]: any; +} + +export type getDictionaryFunction = (options: getDictionaryOptions) => Promise; + +/** + * 获取数据字典 + */ +export default function useDictionary(returnType: "array"): [boolean, getDictionaryFunction]; +export default function useDictionary(returnType?: "object"): { loading: boolean; getDictionary: getDictionaryFunction }; diff --git a/hooks/useDictionary/index.js b/hooks/useDictionary/index.js new file mode 100644 index 0000000..4dd102d --- /dev/null +++ b/hooks/useDictionary/index.js @@ -0,0 +1,50 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useState } from "react"; +import { DICTIONARY_APP_KEY_ENUM } from "../../enum/dictionary"; + +/** + * 获取数据字典 + */ +function useDictionary(returnType = "object") { + // loading状态 + const [loading, setLoading] = useState(false); + + // 获取数据字典 + const getDictionary = (options) => { + if (!options) + throw new Error("请传入 options"); + + setLoading(true); + + return new Promise((resolve, reject) => { + const { appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, dictValue } = options; + + if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) + throw new Error("传入的 options.appKey 不在 DICTIONARY_APP_KEY_ENUM 中"); + if (!dictValue) + throw new Error("请传入 options.dictValue"); + + // 发送请求 + request( + "/config/dict-trees/list/by/dictValues", + "get", + { appKey, dictValue }, + ) + .then((res) => { + resolve(res.data); + }) + .catch((err) => { + reject(err); + }) + .finally(() => { + setLoading(false); + }); + }); + }; + + if (returnType === "array") + return [loading, getDictionary]; + return { loading, getDictionary }; +} + +export default useDictionary;