From 70e11b921e1866ac5ed995b7cf9801b71877b4c3 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 6 Nov 2025 09:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EPersonnelSelect=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/LeftTree/Department/Gwj/index.d.ts | 4 +- components/Select/Basic/index.d.ts | 23 ++++++++++ components/Select/Basic/index.js | 32 +++++++++++++ components/Select/Personnel/Gwj/index.d.ts | 37 +++++++++++++++ components/Select/Personnel/Gwj/index.js | 45 +++++++++++++++++++ components/SelectTree/Basic/index.d.ts | 2 + .../SelectTree/Department/Gwj/index.d.ts | 10 ++++- components/SelectTree/Department/Gwj/index.js | 17 +++++-- 8 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 components/Select/Basic/index.d.ts create mode 100644 components/Select/Basic/index.js create mode 100644 components/Select/Personnel/Gwj/index.d.ts create mode 100644 components/Select/Personnel/Gwj/index.js diff --git a/components/LeftTree/Department/Gwj/index.d.ts b/components/LeftTree/Department/Gwj/index.d.ts index 6ef64b9..b9c8f08 100644 --- a/components/LeftTree/Department/Gwj/index.d.ts +++ b/components/LeftTree/Department/Gwj/index.d.ts @@ -1,12 +1,14 @@ import type { FC } from "react"; import type { BasicLeftTreeProps } from "../../Basic"; +/** + * 请求参数 + */ export interface Params { /** 企业id */ eqCorpinfoId?: string; /** 父级部门id */ eqParentId?: string; - [key: string]: any; } /** diff --git a/components/Select/Basic/index.d.ts b/components/Select/Basic/index.d.ts new file mode 100644 index 0000000..0ca87a5 --- /dev/null +++ b/components/Select/Basic/index.d.ts @@ -0,0 +1,23 @@ +import type { SelectProps } from "antd/es/select"; +import type { FC } from "react"; + +/** + * 组件属性 + */ +export interface BasicSelectProps extends SelectProps { + /** 数据源 */ + data: Record[]; + /** 数据 label 字段,默认 name */ + nameKey?: string; + /** 数据 value 字段,默认 id */ + idKey?: string; + /** 占位符 */ + placeholder?: string; +} + +/** + * 基础下拉组件(不建议直接使用此组件,二次继承使用) + */ +declare const BasicSelectTree: FC; + +export default BasicSelectTree; diff --git a/components/Select/Basic/index.js b/components/Select/Basic/index.js new file mode 100644 index 0000000..183e8b0 --- /dev/null +++ b/components/Select/Basic/index.js @@ -0,0 +1,32 @@ +import { Select } from "antd"; + +/** + * 基础下拉组件(不建议直接使用此组件,二次继承使用) + */ +function BasicSelect(props) { + const { + placeholder = "", + data = [], + nameKey = "name", + idKey = "id", + ...restProps + } = props; + + return ( + + ); +} + +BasicSelect.displayName = "BasicSelect"; + +export default BasicSelect; diff --git a/components/Select/Personnel/Gwj/index.d.ts b/components/Select/Personnel/Gwj/index.d.ts new file mode 100644 index 0000000..9d910d9 --- /dev/null +++ b/components/Select/Personnel/Gwj/index.d.ts @@ -0,0 +1,37 @@ +import type { FC } from "react"; +import type { BasicSelectProps } from "../../Basic"; + +/** + * 请求参数 + */ +export interface Params { + /** 企业id */ + corpinfoId?: string; + /** 岗位id */ + postId?: string; + /** 部门id */ + departmentId?: string; +} + +/** + * 组件属性 + */ +export interface DepartmentSelectProps extends Omit { + /** 请求参数 */ + params?: Params; + /** 占位符,默认"人员" */ + placeholder?: string; + /** 是否需要企业id,默认 false */ + isNeedCorpInfoId?: boolean; + /** 是否需要岗位id,默认 false */ + isNeedPostId?: boolean; + /** 是否需要部门id,默认 true */ + isNeedDepartmentId?: boolean; +} + +/** + * 基础下拉组件(港务局版本) + */ +declare const DepartmentSelect: FC; + +export default DepartmentSelect; diff --git a/components/Select/Personnel/Gwj/index.js b/components/Select/Personnel/Gwj/index.js new file mode 100644 index 0000000..99a30c9 --- /dev/null +++ b/components/Select/Personnel/Gwj/index.js @@ -0,0 +1,45 @@ +import { request } from "@cqsjjb/jjb-common-lib/http"; +import { useEffect, useState } from "react"; +import BasicSelect from "~/components/Select/Basic"; + +/** + * 基础下拉组件(港务局版本) + */ +function PersonnelSelect(props) { + const { + params = {}, + placeholder = "人员", + isNeedCorpInfoId = false, + isNeedDepartmentId = true, + isNeedPostId = false, + ...restProps + } = props; + + const [data, setData] = useState([]); + + const getData = async () => { + setData([]); + // 根据参数决定是否发送请求 + if (isNeedCorpInfoId && !params.corpinfoId) + return; + if (isNeedDepartmentId && !params.departmentId) + return; + if (isNeedPostId && !params.postId) + return; + + const { data } = await request("/basic-info/user/listAll", "get", params); + setData(data); + }; + + useEffect(() => { + getData(); + }, [JSON.stringify(params), isNeedCorpInfoId, isNeedDepartmentId, isNeedPostId]); + + return ( + + ); +} + +PersonnelSelect.displayName = "PersonnelSelect"; + +export default PersonnelSelect; diff --git a/components/SelectTree/Basic/index.d.ts b/components/SelectTree/Basic/index.d.ts index 57c8ce9..eb6db5d 100644 --- a/components/SelectTree/Basic/index.d.ts +++ b/components/SelectTree/Basic/index.d.ts @@ -15,6 +15,8 @@ export interface BasicSelectTreeProps extends TreeSelectProps { onGetNodePathsIsIncludeOneself?: boolean; /** 获取父级节点 */ onGetNodePaths?: (nodes: Record[]) => void; + /** 占位符 */ + placeholder?: string; } /** diff --git a/components/SelectTree/Department/Gwj/index.d.ts b/components/SelectTree/Department/Gwj/index.d.ts index 9575f7d..d33cc43 100644 --- a/components/SelectTree/Department/Gwj/index.d.ts +++ b/components/SelectTree/Department/Gwj/index.d.ts @@ -5,13 +5,19 @@ import { Params } from "../../../LeftTree/Department/Gwj"; /** * 组件属性 */ -export interface DepartmentSelectTreeProps extends Omit { +export interface DepartmentSelectTreeProps extends Omit { /** 请求参数 */ params?: Params; + /** 占位符,默认"部门“ */ + placeholder?: string; + /** 是否需要企业id,默认 false */ + isNeedCorpInfoId?: boolean; + /** 是否需要父级部门id,默认 false */ + isNeedParentId?: boolean; } /** - * 部门下拉树组件(港务局版本) + * 基础下拉树组件(港务局版本) */ declare const DepartmentSelectTree: FC; diff --git a/components/SelectTree/Department/Gwj/index.js b/components/SelectTree/Department/Gwj/index.js index cc03b45..be022f0 100644 --- a/components/SelectTree/Department/Gwj/index.js +++ b/components/SelectTree/Department/Gwj/index.js @@ -3,27 +3,38 @@ import { useEffect, useState } from "react"; import BasicLeftTree from "../../Basic"; /** - * 部门左侧树组件(港务局版本) + * 基础下拉树组件(港务局版本) */ function DepartmentSelectTree(props) { const { params = {}, + placeholder = "部门", + isNeedCorpInfoId = false, + isNeedParentId = false, ...restProps } = props; const [treeData, setTreeData] = useState([]); const getData = async () => { + setTreeData([]); + + // 根据参数决定是否发送请求 + if (isNeedCorpInfoId && !params.eqCorpinfoId) + return; + if (isNeedParentId && !params.eqParentId) + return; + const { data } = await request("/basic-info/department/listTree", "post", params); setTreeData(data); }; useEffect(() => { getData(); - }, []); + }, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]); return ( - + ); }