Compare commits

..

No commits in common. "2.0" and "master" have entirely different histories.
2.0 ... master

24 changed files with 93 additions and 118 deletions

View File

@ -15,8 +15,4 @@ yarn add zy-react-library
### v1.1.2 (2025-12-25)
- 🎉 优化编译效果
### v2.0.0 (2026-06-22)
- 🎉 升级到antd6
- 🎉 优化编译效果

View File

@ -1,7 +1,7 @@
{
"name": "zy-react-library",
"private": false,
"version": "2.0.6",
"version": "1.3.19",
"type": "module",
"description": "",
"author": "LiuJiaNan",
@ -30,13 +30,13 @@
},
"dependencies": {
"@ahooksjs/use-url-state": "^3.5.1",
"@ant-design/icons": "^6.2.5",
"@ant-design/pro-components": "^3.1.12-0",
"@ant-design/icons": "^5.6.1",
"@ant-design/pro-components": "^2.8.10",
"@cqsjjb/jjb-common-lib": "latest",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-react": "^1.0.6",
"ahooks": "^3.9.5",
"antd": "^6.4.4",
"antd": "^5.27.6",
"dayjs": "^1.11.18",
"lodash-es": "^4.17.21",
"react": "^18.3.1",

View File

@ -11,6 +11,8 @@ export interface BasicCascaderProps extends Omit<CascaderProps, "fieldNames"> {
idKey?: string;
/** 树形数据 children 字段,默认 children */
childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */

View File

@ -10,6 +10,7 @@ function BasicCascader(props) {
onGetData,
onChange,
onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true,
placeholder = "",
data = [],
@ -20,6 +21,14 @@ function BasicCascader(props) {
...restProps
} = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicCascader】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
// 根据 level 处理树数据
const processedData = useMemo(() => {
return level
@ -34,7 +43,7 @@ function BasicCascader(props) {
const getNodePaths = (selectedOptions) => {
let nodePaths = selectedOptions;
if (!getNodePathsIsIncludeOneself && selectedOptions) {
if (!finalGetNodePathsIsIncludeOneself && selectedOptions) {
nodePaths = selectedOptions.slice(0, -1);
}
return nodePaths || [];

View File

@ -44,11 +44,6 @@ export interface FormBuilderProps<Values = any> extends Omit<FormProps, "form" |
form: FormInstance<Values>;
/** 表单提交时的回调函数 */
onFinish?: (values: Values) => void;
/** 历史记录对象,用于返回上一页,默认使用 window.history.back */
history?: {
goBack?: () => void;
[key: string]: any;
};
}
/**

View File

@ -21,7 +21,6 @@ const FormBuilder = (props) => {
showCancelButton = true,
customActionButtons,
extraActionButtons,
history,
loading = false,
...restProps
} = props;
@ -52,7 +51,7 @@ const FormBuilder = (props) => {
}, [showActionButtons]);
const handleCancel = () => {
history?.goBack ? history.goBack() : window.history.back();
window.history.back();
};
return (

View File

@ -1,9 +1,9 @@
import type { NamePath } from "@rc-component/form/lib/interface";
import type { ColProps } from "antd/es/col";
import type { FormItemProps, Rule } from "antd/es/form";
import type { FormListFieldData } from "antd/es/form/FormList";
import type { Gutter } from "antd/es/grid/row";
import type { CSSProperties, ReactElement, ReactNode } from "react";
import type { NamePath } from "rc-field-form/lib/interface";
import type { ReactElement, ReactNode } from "react";
import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
import type { DeepPartial } from "./FormBuilder";
@ -131,10 +131,6 @@ export interface FormOptionBase<
dependencies?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, Dependencies[]>;
/** 是否仅用于保存标签,不渲染到页面上,只在表单中保存数据,默认 false */
onlyForLabel?: IsOnlyForLabel;
/** Col 的内联样式,会合并到 Col 的 style 上,支持函数动态计算 */
colStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, CSSProperties | ((formValues: AllValues) => CSSProperties)>;
/** Col 内部、Form.Item 之前渲染的标题节点,支持函数动态计算 */
colTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ReactNode | ((formValues: AllValues) => ReactNode)>;
}
/**
@ -161,10 +157,6 @@ export type FormOptionByRender<
checkboxCol?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "checkbox" ? number : never>;
/** Form.List 独有的属性 */
formListUniqueProps?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? FormListUniqueProps | ((formValues: AllValues) => FormListUniqueProps) : never>;
/** FormList 每行的内联样式,仅 render 为 formList 时可用,支持函数按行计算 */
rowStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? CSSProperties | ((field: FormListFieldData, fieldIndex: number) => CSSProperties) : never>;
/** FormList 每行起始位置渲染的标题节点,仅 render 为 formList 时可用,支持函数按行计算 */
rowTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? ReactNode | ((field: FormListFieldData, fieldIndex: number) => ReactNode) : never>;
};
/**

View File

@ -84,8 +84,12 @@ const FormItemsRenderer = ({
};
};
// 设置日期组件的属性
const setDateComponentProps = (option, formItemProps) => {
// 获取传给formItem的属性
const getFormItemProps = (option) => {
const formItemProps = typeof option.formItemProps === "function"
? option.formItemProps(getFormValues())
: (option.formItemProps || {});
// 为日期组件添加特殊处理
if ([
FORM_ITEM_RENDER_ENUM.DATE,
@ -113,15 +117,6 @@ const FormItemsRenderer = ({
formItemProps.getValueFromEvent = (_, dateString) => dateString;
formItemProps.getValueProps = value => ({ value: Array.isArray(value) ? value.map(v => v ? dayjs(v) : undefined) : undefined });
}
};
// 获取传给 formItem 的属性
const getFormItemProps = (option) => {
const formItemProps = typeof option.formItemProps === "function"
? option.formItemProps(getFormValues())
: (option.formItemProps || {});
setDateComponentProps(option, formItemProps);
return formItemProps;
};
@ -223,39 +218,6 @@ const FormItemsRenderer = ({
return { span: itemSpan, labelCol: itemLabelCol, wrapperCol: itemWrapperCol };
};
// 获取 col 样式
const getColStyle = (option) => {
return typeof option.colStyle === "function"
? option.colStyle(getFormValues())
: option.colStyle;
};
// 获取 col 标题Col 内部、Form.Item 之后)
const getColTitle = (option) => {
return typeof option.colTitle === "function"
? option.colTitle(getFormValues())
: option.colTitle;
};
// 获取 row 样式FormList 的每一行)
const getRowStyle = (option, field, fieldIndex) => {
return typeof option.rowStyle === "function"
? option.rowStyle(field, fieldIndex)
: option.rowStyle;
};
// 获取 row 标题FormList 每行末尾)
const getRowTitle = (option, field, fieldIndex) => {
return typeof option.rowTitle === "function"
? option.rowTitle(field, fieldIndex)
: option.rowTitle;
};
// 获取是否动态表单项
const getIsDynamicFormItem = (option, formItemProps) => {
return (option.shouldUpdate ?? option.dependencies) || (formItemProps.shouldUpdate ?? formItemProps.dependencies);
};
// 获取 hidden
const getHidden = (hidden) => {
// 支持动态计算 hidden
@ -302,7 +264,7 @@ const FormItemsRenderer = ({
case FORM_ITEM_RENDER_ENUM.SELECT:
return (
<Select placeholder={placeholder} showSearch={{ optionFilterProp: "children" }} allowClear {...componentProps}>
<Select placeholder={placeholder} showSearch allowClear optionFilterProp="children" {...componentProps}>
{(option.items || []).map((item) => {
const { value, label, disabled } = getSelectableItemAttributes(item, itemsFieldKey);
return (
@ -458,12 +420,8 @@ const FormItemsRenderer = ({
delete formItemProps.dependencies;
delete formItemProps.shouldUpdate;
if (getHidden(option.hidden))
return null;
return (
<Col key={getKey(option) || index} span={col.span} style={{ ...style, ...getColStyle(option) }}>
{getColTitle(option)}
<Col key={getKey(option) || index} span={col.span} style={style}>
<Form.Item
name={option.name}
label={renderLabel(option)}
@ -512,7 +470,7 @@ const FormItemsRenderer = ({
if (option.render === FORM_ITEM_RENDER_ENUM.DIVIDER) {
return (
<Col key={getKey(option) || index} span={col.span} style={style}>
<Divider titlePlacement="start" {...componentProps}>{option.label}</Divider>
<Divider orientation="left" {...componentProps}>{option.label}</Divider>
</Col>
);
}
@ -545,19 +503,18 @@ const FormItemsRenderer = ({
const componentProps = getComponentProps(option);
return (
<Col key={getKey(option) || index} span={col.span} style={{ ...style, ...getColStyle(option) }}>
{getColTitle(option)}
<Col key={getKey(option) || index} span={col.span} style={style}>
<Form.List name={option.name} {...componentProps}>
{(fields, { add, remove, move }) => (
<>
{fields.map((field, fieldIndex) => {
const listOptions = getListOptions(formListUniqueProps.options, field, fieldIndex, add, remove, move);
const rowStyle = getRowStyle(option, field, fieldIndex);
const rowTitle = getRowTitle(option, field, fieldIndex);
return (
<Row gutter={gutter} key={field.key} style={rowStyle}>
{rowTitle}
<Row gutter={gutter} key={field.key}>
{listOptions.map((listOption, listIndex) => {
if (getHidden(listOption.hidden))
return null;
const col = getCol(listOption);
const formItemProps = getFormItemProps(listOption);
@ -575,7 +532,7 @@ const FormItemsRenderer = ({
if (listOption.render === FORM_ITEM_RENDER_ENUM.FORM_LIST)
return renderFormList(params);
if (getIsDynamicFormItem(listOption, formItemProps))
if ((listOption.shouldUpdate ?? listOption.dependencies) || (formItemProps.shouldUpdate ?? formItemProps.dependencies))
return renderDynamicFormItem(params);
// 判断一个项是否需要显示按钮(不是 onlyForLabel 且不是隐藏的)
@ -605,10 +562,8 @@ const FormItemsRenderer = ({
if (listIndex === lastShowIndex || isNextNestedFormList || isNextNoShow) {
delete formItemProps.dependencies;
delete formItemProps.shouldUpdate;
return (
<Col key={getKey(listOption) || listIndex} span={col.span} style={{ ...style, ...getColStyle(listOption) }}>
{getColTitle(listOption)}
<Col key={getKey(listOption) || listIndex} span={col.span} style={style}>
<Form.Item
label={renderLabel(listOption)}
labelCol={col.labelCol}
@ -619,7 +574,7 @@ const FormItemsRenderer = ({
{...formItemProps}
>
<div style={{ display: "flex", gap: 10, alignItems: "center", justifyContent: "space-between" }}>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ flex: 1 }}>
<Form.Item
noStyle
rules={getRules(listOption)}
@ -677,6 +632,9 @@ const FormItemsRenderer = ({
return (
<>
{options.map((option, index) => {
if (getHidden(option.hidden))
return null;
const col = getCol(option);
const style = getStyle(index);
const formItemProps = getFormItemProps(option);
@ -699,7 +657,7 @@ const FormItemsRenderer = ({
return renderFormList(params);
// 如果配置了 shouldUpdate 或 dependencies使用 Form.Item 的联动机制
if (getIsDynamicFormItem(option, formItemProps))
if ((option.shouldUpdate ?? option.dependencies) || (formItemProps.shouldUpdate ?? formItemProps.dependencies))
return renderDynamicFormItem(params);
// 普通表单项(静态配置)

View File

@ -17,14 +17,12 @@ function HeaderBack(props) {
<>
<div
className="back"
onClick={() => {
history?.goBack ? history.goBack() : window.history.back();
}}
onClick={() => history?.goBack?.() || window.history.back()}
>
<ArrowLeftOutlined style={{ fontSize: 14 }} />
<span>返回</span>
</div>
<Divider orientation="vertical" style={{ backgroundColor: "#dcdfe6", marginLeft: 15, marginRight: 15 }} />
<Divider type="vertical" style={{ backgroundColor: "#dcdfe6", marginLeft: 15, marginRight: 15 }} />
</>
)
}

View File

@ -131,7 +131,7 @@ function HiddenInfo(props) {
return (
<div>
<Spin spinning={loading || downloadFileLoading}>
<Divider titlePlacement="start">隐患信息</Divider>
<Divider orientation="left">隐患信息</Divider>
<Descriptions
bordered
column={1}
@ -193,7 +193,7 @@ function HiddenInfo(props) {
{
(info.hiddenUserPresetsCO && Object.keys(info.hiddenUserPresetsCO).length > 0) && (
<>
<Divider titlePlacement="start">整改信息发现人预填</Divider>
<Divider orientation="left">整改信息发现人预填</Divider>
<Descriptions
bordered
column={1}
@ -223,7 +223,7 @@ function HiddenInfo(props) {
{
(info.hiddenConfirmUserCO && info.hiddenConfirmUserCO.length > 0) && (
<>
<Divider titlePlacement="start">隐患确认</Divider>
<Divider orientation="left">隐患确认</Divider>
{
info.hiddenConfirmUserCO.map(item => (
<Descriptions
@ -256,7 +256,7 @@ function HiddenInfo(props) {
{
info.hiddenExtensionList && info.hiddenExtensionList.length > 0 && (
<>
<Divider titlePlacement="start">延期信息</Divider>
<Divider orientation="left">延期信息</Divider>
{
info.hiddenExtensionList.map(item => (
<Descriptions
@ -319,7 +319,7 @@ function HiddenInfo(props) {
{
info.hiddenSpecialList && info.hiddenSpecialList.length > 0 && (
<>
<Divider titlePlacement="start">特殊处置审核信息</Divider>
<Divider orientation="left">特殊处置审核信息</Divider>
{
info.hiddenSpecialList.map(item => (
<Descriptions
@ -405,7 +405,7 @@ function HiddenInfo(props) {
{
(info.hiddenRectifyUserCO && info.hiddenRectifyUserCO.length > 0) && (
<>
<Divider titlePlacement="start">整改信息</Divider>
<Divider orientation="left">整改信息</Divider>
{
info.hiddenRectifyUserCO.map((item, index) => (
<Descriptions
@ -454,7 +454,7 @@ function HiddenInfo(props) {
info.hiddenAcceptQualifiedUserCO.length > 0
? (
<>
<Divider titlePlacement="start">验收信息</Divider>
<Divider orientation="left">验收信息</Divider>
{
info.hiddenAcceptQualifiedUserCO.map((item, index) => (
<Descriptions
@ -482,7 +482,7 @@ function HiddenInfo(props) {
info.hiddenAcceptUnqualifiedUserCO.length > 0
? (
<>
<Divider titlePlacement="start">验收打回信息</Divider>
<Divider orientation="left">验收打回信息</Divider>
{
info.hiddenAcceptUnqualifiedUserCO.map(item => (
<Descriptions
@ -507,7 +507,7 @@ function HiddenInfo(props) {
(info.hiddenInspecCO && Object.keys(info.hiddenInspecCO).length > 0)
? (
<>
<Divider titlePlacement="start">安全环保验收信息</Divider>
<Divider orientation="left">安全环保验收信息</Divider>
<Descriptions
bordered
column={1}

View File

@ -53,7 +53,7 @@ const ImportFile = (props) => {
open={visible}
onCancel={handleClose}
width={600}
mask={{ closable: false }}
maskClosable={false}
footer={[
templateUrl && (
<Button key="export" onClick={handleExportTemplate}>

View File

@ -11,6 +11,8 @@ export interface BasicLeftTreeProps extends Omit<TreeProps, "fieldNames"> {
idKey?: string;
/** 树形数据 children 字段,默认 children */
childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */

View File

@ -12,6 +12,7 @@ const BasicLeftTree = (props) => {
onGetData,
onSelect,
onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true,
expandedKeys: externalExpandedKeys,
treeData = [],
@ -21,6 +22,14 @@ const BasicLeftTree = (props) => {
...restProps
} = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicLeftTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState("");
const [autoExpandParent, setAutoExpandParent] = useState(true);
@ -81,7 +90,7 @@ const BasicLeftTree = (props) => {
targetId: selectedNodeId,
idKey,
childrenKey,
isIncludeOneself: getNodePathsIsIncludeOneself,
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
});
onGetNodePaths?.(parentNodes);
}

View File

@ -267,7 +267,7 @@ const MapSelector = (props) => {
onCancel={handleClose}
width={1000}
destroyOnHidden={false}
mask={{ closable: false }}
maskClosable={false}
afterClose={handleAfterClose}
footer={[
<Button key="back" onClick={handleClose}>

View File

@ -61,11 +61,7 @@ function Page(props) {
{customActionButtons || (
<Space>
{extraActionButtons}
<Button
onClick={() => {
history?.goBack ? history.goBack() : window.history.back();
}}
>
<Button onClick={() => history?.goBack?.() || window.history.back()}>
{backButtonText}
</Button>
</Space>

View File

@ -90,7 +90,7 @@ function Pdf(props) {
<Modal
style={{ top: isFullscreen ? 0 : 100, maxWidth: isFullscreen ? "100vw" : "calc(100vw - 32px)", paddingBottom: isFullscreen ? 0 : 24 }}
open={visible}
mask={{ closable: false }}
maskClosable={false}
width={isFullscreen ? "100vw" : pdfWidth + 100}
title={title}
onCancel={() => {

View File

@ -59,7 +59,7 @@ function BasicSelect(props) {
}, [data]);
return (
<Select placeholder={`请选择${placeholder}`} showSearch={{ optionFilterProp: "children" }} allowClear onChange={handleChange} {...restProps}>
<Select placeholder={`请选择${placeholder}`} showSearch allowClear optionFilterProp="children" onChange={handleChange} {...restProps}>
{data.map((item) => {
const value = item[idKey];
const label = labelRender ? labelRender(item) : item[nameKey];

View File

@ -11,6 +11,8 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
idKey?: string;
/** 树形数据 children 字段,默认 children */
childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */

View File

@ -11,6 +11,7 @@ function BasicSelectTree(props) {
onChange,
onGetLabel,
onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true,
placeholder = "",
treeData = [],
@ -22,6 +23,14 @@ function BasicSelectTree(props) {
...restProps
} = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicSelectTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
const processedTreeData = useMemo(() => {
// 根据 level 处理树数据
let result = level
@ -55,7 +64,7 @@ function BasicSelectTree(props) {
targetId,
idKey,
childrenKey,
isIncludeOneself: getNodePathsIsIncludeOneself,
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
});
parentNodes.push(...currentParentNodes);
}
@ -72,7 +81,7 @@ function BasicSelectTree(props) {
targetId,
idKey,
childrenKey,
isIncludeOneself: getNodePathsIsIncludeOneself,
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
});
onGetNodePaths?.(parentNodes);
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);

View File

@ -30,7 +30,6 @@ export interface Params {
inType?: InType[];
/** 企业类型 1-监管 2-企业 3-相关方 */
enterpriseType?: EnterpriseType | EnterpriseType[];
[key: string]: any;
}
/**

View File

@ -60,7 +60,7 @@ function Signature(props) {
title="签字"
width={800}
open={signatureModalOpen}
mask={{ closable: false }}
maskClosable={false}
onCancel={() => setSignatureModalOpen(false)}
footer={[
<Button key="clear" onClick={() => signatureCanvas.current.clear()}>重签</Button>,

View File

@ -92,7 +92,7 @@ const Video = forwardRef(({
关闭
</Button>,
]}
mask={{ closable: false }}
maskClosable={false}
onCancel={() => setVisible(false)}
>
{playerElement}

View File

@ -18,6 +18,8 @@ export interface UseTableOptions<TData extends Data, TParams extends Params> ext
params?: Record<string, any> | (() => Record<string, any>);
/** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */
transform?: (formData: FormValues) => FormValues;
/** @deprecated 已弃用,请使用 onSuccess */
callback?: (list: any[], data: any) => void;
/** 表单实例(通过 Form.useForm() 创建) */
form?: FormInstance;
}

View File

@ -96,6 +96,13 @@ function useTable(service, options) {
},
);
if (restOptions.callback !== undefined) {
console.warn("【useTable】 callback 参数已弃用,请使用 onSuccess 参数");
}
// 执行回调函数
restOptions.callback && restOptions.callback(res?.data?.list || [], res?.data || {});
// 返回结果
return {
...res,