zy-react-library 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,6 @@ export interface BasicCascaderProps extends Omit<CascaderProps, "fieldNames"> {
11
11
  idKey?: string;
12
12
  /** 树形数据 children 字段,默认 children */
13
13
  childrenKey?: string;
14
- /** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
15
- onGetNodePathsIsIncludeOneself?: boolean;
16
14
  /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
17
15
  getNodePathsIsIncludeOneself?: boolean;
18
16
  /** 获取父级节点 */
@@ -1 +1 @@
1
- import{Cascader as e}from"antd";import{useMemo as n,useEffect as a}from"react";import{processTreeDataByLevel as t}from"../../../utils/index.js";import{jsx as o}from"react/jsx-runtime";function l(l){const{onGetData:s,onChange:d,onGetNodePaths:r,onGetNodePathsIsIncludeOneself:c,getNodePathsIsIncludeOneself:i=!0,placeholder:h="",data:m=[],nameKey:f="name",idKey:u="id",childrenKey:p="children",level:I,...N}=l;void 0!==c&&console.warn("【BasicCascader】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");const v=void 0!==c?c:i,y=n(()=>I?t({data:m,level:I,childrenKey:p,currentLevel:1}):m,[m,I,p]);return a(()=>{s?.(m,y)},[m,y]),o(e,{options:y,placeholder:`请选择${h}`,onChange:(e,n)=>{if(n&&r){const e=(e=>{let n=e;return!v&&e&&(n=e.slice(0,-1)),n||[]})(n);r?.(e)}d?.(e,n)},onClear:()=>{r?.([])},fieldNames:{label:f,value:u,children:p},...N})}l.displayName="BasicCascader";export{l as default};
1
+ import{Cascader as e}from"antd";import{useMemo as a,useEffect as t}from"react";import{processTreeDataByLevel as n}from"../../../utils/index.js";import{jsx as r}from"react/jsx-runtime";function l(l){const{onGetData:o,onChange:i,onGetNodePaths:d,getNodePathsIsIncludeOneself:c=!0,placeholder:s="",data:m=[],nameKey:h="name",idKey:f="id",childrenKey:p="children",level:u,...y}=l,v=a(()=>u?n({data:m,level:u,childrenKey:p,currentLevel:1}):m,[m,u,p]);return t(()=>{o?.(m,v)},[m,v]),r(e,{options:v,placeholder:`请选择${s}`,onChange:(e,a)=>{if(a&&d){const e=(e=>{let a=e;return!c&&e&&(a=e.slice(0,-1)),a||[]})(a);d?.(e)}i?.(e,a)},onClear:()=>{d?.([])},fieldNames:{label:h,value:f,children:p},...y})}l.displayName="BasicCascader";export{l as default};
@@ -1,9 +1,9 @@
1
+ import type { NamePath } from "@rc-component/form/lib/interface";
1
2
  import type { ColProps } from "antd/es/col";
2
3
  import type { FormItemProps, Rule } from "antd/es/form";
3
4
  import type { FormListFieldData } from "antd/es/form/FormList";
4
5
  import type { Gutter } from "antd/es/grid/row";
5
- import type { NamePath } from "rc-field-form/lib/interface";
6
- import type { ReactElement, ReactNode } from "react";
6
+ import type { CSSProperties, ReactElement, ReactNode } from "react";
7
7
  import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
8
8
  import type { DeepPartial } from "./FormBuilder";
9
9
 
@@ -131,6 +131,10 @@ export interface FormOptionBase<
131
131
  dependencies?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, Dependencies[]>;
132
132
  /** 是否仅用于保存标签,不渲染到页面上,只在表单中保存数据,默认 false */
133
133
  onlyForLabel?: IsOnlyForLabel;
134
+ /** Col 的内联样式,会合并到 Col 的 style 上,支持函数动态计算 */
135
+ colStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, CSSProperties | ((formValues: AllValues) => CSSProperties)>;
136
+ /** Col 内部、Form.Item 之前渲染的标题节点,支持函数动态计算 */
137
+ colTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ReactNode | ((formValues: AllValues) => ReactNode)>;
134
138
  }
135
139
 
136
140
  /**
@@ -157,6 +161,10 @@ export type FormOptionByRender<
157
161
  checkboxCol?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "checkbox" ? number : never>;
158
162
  /** Form.List 独有的属性 */
159
163
  formListUniqueProps?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? FormListUniqueProps | ((formValues: AllValues) => FormListUniqueProps) : never>;
164
+ /** FormList 每行的内联样式,仅 render 为 formList 时可用,支持函数按行计算 */
165
+ rowStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? CSSProperties | ((field: FormListFieldData, fieldIndex: number) => CSSProperties) : never>;
166
+ /** FormList 每行起始位置渲染的标题节点,仅 render 为 formList 时可用,支持函数按行计算 */
167
+ rowTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? ReactNode | ((field: FormListFieldData, fieldIndex: number) => ReactNode) : never>;
160
168
  };
161
169
 
162
170
  /**
@@ -1 +1 @@
1
- import{InfoCircleOutlined as e}from"@ant-design/icons";import{Input as r,DatePicker as n,Form as t,Col as l,Divider as s,Row as a,Button as o,Checkbox as d,Radio as i,Select as u,InputNumber as p,Tooltip as c}from"antd";import m from"dayjs";import{FORM_ITEM_RENDER_ENUM as h}from"../../enum/formItemRender/index.js";import{getDataType as y}from"../../utils/index.js";import{jsx as E,Fragment as f,jsxs as T}from"react/jsx-runtime";const{TextArea:b}=r,{RangePicker:v}=n,I=({options:I,labelCol:A,gutter:R=24,span:Y=12,collapse:D=!1,useAutoGenerateRequired:C=!0,initialValues:N})=>{const w=t.useFormInstance(),M=()=>{const e=w.getFieldsValue();return 0===Object.keys(e).length&&N?N:e},P=e=>"function"==typeof e.componentProps?e.componentProps(M()):e.componentProps||{},U=e=>{const r="function"==typeof e.formItemProps?e.formItemProps(M()):e.formItemProps||{};return((e,r)=>{[h.DATE,h.DATE_MONTH,h.DATE_YEAR,h.DATETIME].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:e?m(e):void 0})),[h.DATE_WEEK].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:e?m(e,"YYYY-wo"):void 0})),[h.DATE_RANGE,h.DATETIME_RANGE].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:Array.isArray(e)?e.map(e=>e?m(e):void 0):void 0}))})(e,r),r},x=e=>"function"==typeof e?e(M()):e??!0,g=e=>{if(e.render===h.DIVIDER)return[];const r=[];switch(e.render||h.INPUT){case h.INPUT:!1!==e.useConstraints&&r.push({max:50,message:"最多输入50字符"});break;case h.TEXTAREA:!1!==e.useConstraints&&r.push({max:500,message:"最多输入500字符"});break;case h.INPUT_NUMBER:case h.NUMBER:!1!==e.useConstraints&&r.push({pattern:/^(\d+)(\.\d{1,2})?$/,message:"请输入正确的数字,最多保留两位小数"}),!1!==e.useConstraints&&r.push({validator:(e,r)=>r&&Math.abs(Number.parseFloat(r))>999999999?Promise.reject("输入数值超出安全范围"):Promise.resolve()});break;case h.INTEGER:!1!==e.useConstraints&&r.push({pattern:/^(\d+)$/,message:"请输入正确的整数"}),!1!==e.useConstraints&&r.push({validator:(e,r)=>r&&Math.abs(Number.parseFloat(r))>999999999?Promise.reject("输入数值超出安全范围"):Promise.resolve()})}if(!C)return e.rules?Array.isArray(e.rules)?[...e.rules,...r]:[e.rules,...r]:r;if(x(e.required)){const n=!e.render||[h.INPUT,h.TEXTAREA,h.INPUT_NUMBER,h.NUMBER,h.INTEGER].includes(e.render);r.push({required:!0,message:`${n?"请输入":"请选择"}${e.label}`})}return e.rules?Array.isArray(e.rules)?[...e.rules,...r]:[e.rules,...r]:r},_=e=>e.key||("Array"===y(e.name)?e.name.join("."):e.name),B=e=>{const r=e.render===h.DIVIDER?24:e.span??Y,n=e.labelCol??(24===r?{span:A.span/2}:A);return{span:r,labelCol:n,wrapperCol:e.wrapperCol??{span:24-n.span}}},F=(e,r)=>(e.shouldUpdate??e.dependencies)||(r.shouldUpdate??r.dependencies),k=e=>"function"==typeof e?e(M()):e??!1,L=(e,r)=>({value:e[r.valueKey],label:"function"==typeof r.labelKey?r.labelKey(e):e[r.labelKey],disabled:e.disabled}),V=e=>{const t=P(e),s=(e=>({valueKey:e?.itemsField?.valueKey||"bianma",labelKey:e?.itemsField?.labelKey||"name"}))(e),o=e.render??h.INPUT,c=e.placeholder??`请${[h.INPUT,h.TEXTAREA,h.INPUT_NUMBER,h.NUMBER,h.INTEGER].includes(o)?"输入":"选择"}${e.label}`;switch(o){case h.INPUT:return E(r,{placeholder:c,maxLength:!1!==e.useConstraints?50:9999,...t});case h.TEXTAREA:return E(b,{placeholder:c,maxLength:!1!==e.useConstraints?500:9999,showCount:!0,rows:3,...t});case h.INPUT_NUMBER:case h.NUMBER:case h.INTEGER:return E(p,{placeholder:c,style:{width:"100%"},...t});case h.SELECT:return E(u,{placeholder:c,showSearch:!0,allowClear:!0,optionFilterProp:"children",...t,children:(e.items||[]).map(e=>{const{value:r,label:n,disabled:t}=L(e,s);return E(u.Option,{value:r,disabled:t,children:n},r)})});case h.RADIO:return E(i.Group,{...t,children:(e.items||[]).map(e=>{const{value:r,label:n,disabled:t}=L(e,s);return E(i,{value:r,disabled:t,children:n},r)})});case h.CHECKBOX:return E(d.Group,{...t,children:e.checkboxCol?E(a,{children:(e.items||[]).map(r=>{const{value:n,label:t,disabled:a}=L(r,s);return E(l,{span:e.checkboxCol,children:E(d,{value:n,disabled:a,children:t})},n)})}):(e.items||[]).map(e=>{const{value:r,label:n,disabled:t}=L(e,s);return E(d,{value:r,disabled:t,children:n},r)})});case h.DATE:return E(n,{placeholder:c,format:"YYYY-MM-DD",style:{width:"100%"},...t});case h.DATE_MONTH:return E(n,{picker:"month",placeholder:c,format:"YYYY-MM",style:{width:"100%"},...t});case h.DATE_YEAR:return E(n,{picker:"year",placeholder:c,format:"YYYY",style:{width:"100%"},...t});case h.DATE_WEEK:return E(n,{picker:"week",placeholder:c,format:"YYYY-wo",style:{width:"100%"},...t});case h.DATE_RANGE:return E(v,{placeholder:[`请选择开始${e.label}`,`请选择结束${e.label}`],format:"YYYY-MM-DD",style:{width:"100%"},...t});case h.DATETIME:return E(n,{showTime:!0,placeholder:c,format:"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},...t});case h.DATETIME_RANGE:return E(v,{showTime:!0,placeholder:[`请选择开始${e.label}`,`请选择结束${e.label}`],format:"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},...t});case h.DIVIDER:return null;default:return o}},$=r=>r.tip?T(f,{children:[r.label,E(c,{title:r.tip,children:E(e,{style:{marginLeft:4,fontSize:12}})})]}):r.label,G=({option:e,style:r,col:n,index:s,preserve:a})=>{const o=U(e);return delete o.dependencies,delete o.shouldUpdate,k(e.hidden)?null:E(l,{span:n.span,style:r,children:E(t.Item,{name:e.name,label:$(e),rules:g(e),labelCol:n.labelCol,wrapperCol:n.wrapperCol,preserve:a,required:!!C&&" "!==$(e)&&x(e.required),colon:" "!==$(e),...o,children:V(e)})},_(e)||s)},K=({option:e,style:r,col:n,index:a,preserve:o})=>{const d=P(e);return e.customizeRender?E(l,{span:n.span,style:r,children:e.render},_(e)||a):e.onlyForLabel?E(t.Item,{name:e.name,noStyle:!0,preserve:o,children:E("input",{type:"hidden"})},_(e)||a):e.render===h.DIVIDER?E(l,{span:n.span,style:r,children:E(s,{orientation:"left",...d,children:e.label})},_(e)||a):null},q=({option:e,index:r,style:n,col:l,preserve:s})=>{const a=U(e);return E(t.Item,{noStyle:!0,preserve:s,shouldUpdate:e.shouldUpdate??a.shouldUpdate,dependencies:e.dependencies??a.dependencies,children:()=>G({option:e,style:n,col:l,index:r,preserve:s})},_(e)||r)},O=({option:e,index:r,col:n,style:s})=>{const d=(e=>{const r={showAddButton:!0,showRemoveButton:!0,addButtonText:"添加",removeButtonText:"删除",options:[],addDefaultValue:{},addInsertIndex:void 0};return"function"==typeof e.formListUniqueProps?{...r,...e.formListUniqueProps(M())}:{...r,...e.formListUniqueProps||{}}})(e),i=P(e);return E(l,{span:n.span,style:s,children:E(t.List,{name:e.name,...i,children:(e,{add:r,remove:n,move:i})=>E(f,{children:e.map((e,u)=>{const p=((e,r,n,t,l,s)=>"function"==typeof e?e(r,n,{field:r,fieldIndex:n,add:t,remove:l,move:s}):e??[])(d.options,e,u,r,n,i);return E(a,{gutter:R,children:p.map((a,i)=>{const c=B(a),m=U(a),y={option:a,style:s,col:c,index:`${u}_${i}`,preserve:!0},f=K(y);if(f)return f;if(a.render===h.FORM_LIST)return O(y);if(F(a,m))return q(y);const b=e=>!k(e.hidden)&&!e.onlyForLabel,v=p[i+1],I=v&&v.render===h.FORM_LIST,A=v&&!b(v);return i===(()=>{for(let e=p.length-1;e>=0;e--){const r=p[e];if(r.render===h.FORM_LIST)return e;if(b(r))return e}return-1})()||I||A?(delete m.dependencies,delete m.shouldUpdate,E(l,{span:c.span,style:s,children:E(t.Item,{label:$(a),labelCol:c.labelCol,wrapperCol:c.wrapperCol,preserve:!1,required:!!C&&" "!==$(a)&&x(a.required),colon:" "!==$(a),...m,children:T("div",{style:{display:"flex",gap:10,alignItems:"center",justifyContent:"space-between"},children:[E("div",{style:{flex:1},children:E(t.Item,{noStyle:!0,rules:g(a),name:a.name,children:V(a)})}),u>=1?d.showRemoveButton&&E(o,{type:"primary",danger:!0,onClick:()=>n(e.name),children:d.removeButtonText}):d.showAddButton&&E(o,{type:"primary",onClick:()=>r(d.addDefaultValue,d.addInsertIndex),children:d.addButtonText})]})})},_(a)||i)):G(y)})},e.key)})})})},_(e)||r)};return E(f,{children:I.map((e,r)=>{const n=B(e),t=(e=>D&&e>=3?{display:"none"}:void 0)(r),l=U(e),s={option:e,style:t,col:n,index:r,preserve:!1};return K(s)||(e.render===h.FORM_LIST?O(s):F(e,l)?q(s):G(s))})})};I.displayName="FormItemsRenderer";export{I as default};
1
+ import{InfoCircleOutlined as e}from"@ant-design/icons";import{Input as r,DatePicker as t,Form as n,Col as l,Divider as o,Row as s,Button as a,Checkbox as i,Radio as d,Select as u,InputNumber as c,Tooltip as p}from"antd";import m from"dayjs";import{FORM_ITEM_RENDER_ENUM as h}from"../../enum/formItemRender/index.js";import{getDataType as y}from"../../utils/index.js";import{jsx as f,Fragment as E,jsxs as T}from"react/jsx-runtime";const{TextArea:b}=r,{RangePicker:v}=t,I=({options:I,labelCol:A,gutter:R=24,span:w=12,collapse:Y=!1,useAutoGenerateRequired:D=!0,initialValues:C})=>{const N=n.useFormInstance(),M=()=>{const e=N.getFieldsValue();return 0===Object.keys(e).length&&C?C:e},P=e=>"function"==typeof e.componentProps?e.componentProps(M()):e.componentProps||{},U=e=>{const r="function"==typeof e.formItemProps?e.formItemProps(M()):e.formItemProps||{};return((e,r)=>{[h.DATE,h.DATE_MONTH,h.DATE_YEAR,h.DATETIME].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:e?m(e):void 0})),[h.DATE_WEEK].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:e?m(e,"YYYY-wo"):void 0})),[h.DATE_RANGE,h.DATETIME_RANGE].includes(e.render)&&(r.getValueFromEvent=(e,r)=>r,r.getValueProps=e=>({value:Array.isArray(e)?e.map(e=>e?m(e):void 0):void 0}))})(e,r),r},x=e=>"function"==typeof e?e(M()):e??!0,g=e=>{if(e.render===h.DIVIDER)return[];const r=[];switch(e.render||h.INPUT){case h.INPUT:!1!==e.useConstraints&&r.push({max:50,message:"最多输入50字符"});break;case h.TEXTAREA:!1!==e.useConstraints&&r.push({max:500,message:"最多输入500字符"});break;case h.INPUT_NUMBER:case h.NUMBER:!1!==e.useConstraints&&r.push({pattern:/^(\d+)(\.\d{1,2})?$/,message:"请输入正确的数字,最多保留两位小数"}),!1!==e.useConstraints&&r.push({validator:(e,r)=>r&&Math.abs(Number.parseFloat(r))>999999999?Promise.reject("输入数值超出安全范围"):Promise.resolve()});break;case h.INTEGER:!1!==e.useConstraints&&r.push({pattern:/^(\d+)$/,message:"请输入正确的整数"}),!1!==e.useConstraints&&r.push({validator:(e,r)=>r&&Math.abs(Number.parseFloat(r))>999999999?Promise.reject("输入数值超出安全范围"):Promise.resolve()})}if(!D)return e.rules?Array.isArray(e.rules)?[...e.rules,...r]:[e.rules,...r]:r;if(x(e.required)){const t=!e.render||[h.INPUT,h.TEXTAREA,h.INPUT_NUMBER,h.NUMBER,h.INTEGER].includes(e.render);r.push({required:!0,message:`${t?"请输入":"请选择"}${e.label}`})}return e.rules?Array.isArray(e.rules)?[...e.rules,...r]:[e.rules,...r]:r},_=e=>e.key||("Array"===y(e.name)?e.name.join("."):e.name),B=e=>{const r=e.render===h.DIVIDER?24:e.span??w,t=e.labelCol??(24===r?{span:A.span/2}:A);return{span:r,labelCol:t,wrapperCol:e.wrapperCol??{span:24-t.span}}},F=e=>"function"==typeof e.colStyle?e.colStyle(M()):e.colStyle,S=e=>"function"==typeof e.colTitle?e.colTitle(M()):e.colTitle,k=(e,r)=>(e.shouldUpdate??e.dependencies)||(r.shouldUpdate??r.dependencies),L=e=>"function"==typeof e?e(M()):e??!1,V=(e,r)=>({value:e[r.valueKey],label:"function"==typeof r.labelKey?r.labelKey(e):e[r.labelKey],disabled:e.disabled}),$=e=>{const n=P(e),o=(e=>({valueKey:e?.itemsField?.valueKey||"bianma",labelKey:e?.itemsField?.labelKey||"name"}))(e),a=e.render??h.INPUT,p=e.placeholder??`请${[h.INPUT,h.TEXTAREA,h.INPUT_NUMBER,h.NUMBER,h.INTEGER].includes(a)?"输入":"选择"}${e.label}`;switch(a){case h.INPUT:return f(r,{placeholder:p,maxLength:!1!==e.useConstraints?50:9999,...n});case h.TEXTAREA:return f(b,{placeholder:p,maxLength:!1!==e.useConstraints?500:9999,showCount:!0,rows:3,...n});case h.INPUT_NUMBER:case h.NUMBER:case h.INTEGER:return f(c,{placeholder:p,style:{width:"100%"},...n});case h.SELECT:return f(u,{placeholder:p,showSearch:!0,allowClear:!0,optionFilterProp:"children",...n,children:(e.items||[]).map(e=>{const{value:r,label:t,disabled:n}=V(e,o);return f(u.Option,{value:r,disabled:n,children:t},r)})});case h.RADIO:return f(d.Group,{...n,children:(e.items||[]).map(e=>{const{value:r,label:t,disabled:n}=V(e,o);return f(d,{value:r,disabled:n,children:t},r)})});case h.CHECKBOX:return f(i.Group,{...n,children:e.checkboxCol?f(s,{children:(e.items||[]).map(r=>{const{value:t,label:n,disabled:s}=V(r,o);return f(l,{span:e.checkboxCol,children:f(i,{value:t,disabled:s,children:n})},t)})}):(e.items||[]).map(e=>{const{value:r,label:t,disabled:n}=V(e,o);return f(i,{value:r,disabled:n,children:t},r)})});case h.DATE:return f(t,{placeholder:p,format:"YYYY-MM-DD",style:{width:"100%"},...n});case h.DATE_MONTH:return f(t,{picker:"month",placeholder:p,format:"YYYY-MM",style:{width:"100%"},...n});case h.DATE_YEAR:return f(t,{picker:"year",placeholder:p,format:"YYYY",style:{width:"100%"},...n});case h.DATE_WEEK:return f(t,{picker:"week",placeholder:p,format:"YYYY-wo",style:{width:"100%"},...n});case h.DATE_RANGE:return f(v,{placeholder:[`请选择开始${e.label}`,`请选择结束${e.label}`],format:"YYYY-MM-DD",style:{width:"100%"},...n});case h.DATETIME:return f(t,{showTime:!0,placeholder:p,format:"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},...n});case h.DATETIME_RANGE:return f(v,{showTime:!0,placeholder:[`请选择开始${e.label}`,`请选择结束${e.label}`],format:"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},...n});case h.DIVIDER:return null;default:return a}},G=r=>r.tip?T(E,{children:[r.label,f(p,{title:r.tip,children:f(e,{style:{marginLeft:4,fontSize:12}})})]}):r.label,K=({option:e,style:r,col:t,index:o,preserve:s})=>{const a=U(e);return delete a.dependencies,delete a.shouldUpdate,L(e.hidden)?null:T(l,{span:t.span,style:{...r,...F(e)},children:[S(e),f(n.Item,{name:e.name,label:G(e),rules:g(e),labelCol:t.labelCol,wrapperCol:t.wrapperCol,preserve:s,required:!!D&&" "!==G(e)&&x(e.required),colon:" "!==G(e),...a,children:$(e)})]},_(e)||o)},q=({option:e,style:r,col:t,index:s,preserve:a})=>{const i=P(e);return e.customizeRender?f(l,{span:t.span,style:r,children:e.render},_(e)||s):e.onlyForLabel?f(n.Item,{name:e.name,noStyle:!0,preserve:a,children:f("input",{type:"hidden"})},_(e)||s):e.render===h.DIVIDER?f(l,{span:t.span,style:r,children:f(o,{orientation:"left",...i,children:e.label})},_(e)||s):null},O=({option:e,index:r,style:t,col:l,preserve:o})=>{const s=U(e);return f(n.Item,{noStyle:!0,preserve:o,shouldUpdate:e.shouldUpdate??s.shouldUpdate,dependencies:e.dependencies??s.dependencies,children:()=>K({option:e,style:t,col:l,index:r,preserve:o})},_(e)||r)},j=({option:e,index:r,col:t,style:o})=>{const i=(e=>{const r={showAddButton:!0,showRemoveButton:!0,addButtonText:"添加",removeButtonText:"删除",options:[],addDefaultValue:{},addInsertIndex:void 0};return"function"==typeof e.formListUniqueProps?{...r,...e.formListUniqueProps(M())}:{...r,...e.formListUniqueProps||{}}})(e),d=P(e);return T(l,{span:t.span,style:{...o,...F(e)},children:[S(e),f(n.List,{name:e.name,...d,children:(r,{add:t,remove:d,move:u})=>f(E,{children:r.map((r,c)=>{const p=((e,r,t,n,l,o)=>"function"==typeof e?e(r,t,{field:r,fieldIndex:t,add:n,remove:l,move:o}):e??[])(i.options,r,c,t,d,u),m=((e,r,t)=>"function"==typeof e.rowStyle?e.rowStyle(r,t):e.rowStyle)(e,r,c),y=((e,r,t)=>"function"==typeof e.rowTitle?e.rowTitle(r,t):e.rowTitle)(e,r,c);return T(s,{gutter:R,style:m,children:[y,p.map((e,s)=>{const u=B(e),m=U(e),y={option:e,style:o,col:u,index:`${c}_${s}`,preserve:!0},E=q(y);if(E)return E;if(e.render===h.FORM_LIST)return j(y);if(k(e,m))return O(y);const b=e=>!L(e.hidden)&&!e.onlyForLabel,v=p[s+1],I=v&&v.render===h.FORM_LIST,A=v&&!b(v);return s===(()=>{for(let e=p.length-1;e>=0;e--){const r=p[e];if(r.render===h.FORM_LIST)return e;if(b(r))return e}return-1})()||I||A?(delete m.dependencies,delete m.shouldUpdate,T(l,{span:u.span,style:{...o,...F(e)},children:[S(e),f(n.Item,{label:G(e),labelCol:u.labelCol,wrapperCol:u.wrapperCol,preserve:!1,required:!!D&&" "!==G(e)&&x(e.required),colon:" "!==G(e),...m,children:T("div",{style:{display:"flex",gap:10,alignItems:"center",justifyContent:"space-between"},children:[f("div",{style:{flex:1},children:f(n.Item,{noStyle:!0,rules:g(e),name:e.name,children:$(e)})}),c>=1?i.showRemoveButton&&f(a,{type:"primary",danger:!0,onClick:()=>d(r.name),children:i.removeButtonText}):i.showAddButton&&f(a,{type:"primary",onClick:()=>t(i.addDefaultValue,i.addInsertIndex),children:i.addButtonText})]})})]},_(e)||s)):K(y)})]},r.key)})})})]},_(e)||r)};return f(E,{children:I.map((e,r)=>{const t=B(e),n=(e=>Y&&e>=3?{display:"none"}:void 0)(r),l=U(e),o={option:e,style:n,col:t,index:r,preserve:!1};return q(o)||(e.render===h.FORM_LIST?j(o):k(e,l)?O(o):K(o))})})};I.displayName="FormItemsRenderer";export{I as default};
@@ -1 +1 @@
1
- import{Form as e,Modal as t,Button as o}from"antd";import{getFileUrl as l}from"../../utils/index.js";import n from"../Upload/index.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const s=s=>{const{visible:a,onCancel:c,onConfirm:m,title:p="导入",templateUrl:d,labelCol:x={span:4},children:f,exportTemplateButtonText:u="导出模板",extraButtons:C,...h}=s,[b]=e.useForm(),k=()=>{b.resetFields(),c()};return r(t,{title:p,open:a,onCancel:k,width:600,maskClosable:!1,footer:[d&&r(o,{onClick:()=>{t.confirm({title:"提示",content:"确定要下载excel模板吗?",okText:"确定",cancelText:"取消",onOk:()=>{const e=l();window.open(e+d)}})},children:u},"export"),...C||[],r(o,{onClick:k,children:"取消"},"cancel"),r(o,{type:"primary",onClick:b.submit,children:"确定"},"submit")],children:i(e,{form:b,labelCol:x,wrapperCol:{span:24-x.span},scrollToFirstError:!0,onFinish:e=>{m(e),k()},...h,children:[f&&"function"==typeof f?f({form:b}):f,r(e.Item,{label:"附件",name:"file",rules:[{required:!0,message:"附件不能为空"}],children:r(n,{accept:".xls,.xlsx",listType:"text",maxCount:1})})]})})};s.displayName="ImportFile";export{s as default};
1
+ import{Form as e,Modal as t,Button as o}from"antd";import{getFileUrl as l}from"../../utils/index.js";import n from"../Upload/index.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const s=s=>{const{visible:a,onCancel:c,onConfirm:m,title:p="导入",templateUrl:d,labelCol:x={span:4},children:f,exportTemplateButtonText:u="导出模板",extraButtons:C,...h}=s,[b]=e.useForm(),k=()=>{b.resetFields(),c()};return r(t,{title:p,open:a,onCancel:k,width:600,mask:{closable:!1},footer:[d&&r(o,{onClick:()=>{t.confirm({title:"提示",content:"确定要下载excel模板吗?",okText:"确定",cancelText:"取消",onOk:()=>{const e=l();window.open(e+d)}})},children:u},"export"),...C||[],r(o,{onClick:k,children:"取消"},"cancel"),r(o,{type:"primary",onClick:b.submit,children:"确定"},"submit")],children:i(e,{form:b,labelCol:x,wrapperCol:{span:24-x.span},scrollToFirstError:!0,onFinish:e=>{m(e),k()},...h,children:[f&&"function"==typeof f?f({form:b}):f,r(e.Item,{label:"附件",name:"file",rules:[{required:!0,message:"附件不能为空"}],children:r(n,{accept:".xls,.xlsx",listType:"text",maxCount:1})})]})})};s.displayName="ImportFile";export{s as default};
@@ -11,8 +11,6 @@ export interface BasicLeftTreeProps extends Omit<TreeProps, "fieldNames"> {
11
11
  idKey?: string;
12
12
  /** 树形数据 children 字段,默认 children */
13
13
  childrenKey?: string;
14
- /** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
15
- onGetNodePathsIsIncludeOneself?: boolean;
16
14
  /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
17
15
  getNodePathsIsIncludeOneself?: boolean;
18
16
  /** 获取父级节点 */
@@ -1 +1 @@
1
- import{Input as e,Tree as n}from"antd";import{useState as t,useEffect as s}from"react";import{getTreeNodePaths as r}from"../../../utils/index.js";import{jsxs as d,jsx as o}from"react/jsx-runtime";const{Search:a}=e,i=e=>{const{onGetData:i,onSelect:c,onGetNodePaths:l,onGetNodePathsIsIncludeOneself:h,getNodePathsIsIncludeOneself:u=!0,expandedKeys:f,treeData:m=[],nameKey:p="name",idKey:y="id",childrenKey:g="children",...I}=e;void 0!==h&&console.warn("【BasicLeftTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");const x=void 0!==h?h:u,[K,N]=t([]),[v,O]=t(""),[P,G]=t(!0);s(()=>{N(f)},[f]);const S=(e,n,t=[])=>(e.forEach(e=>{e[g]&&((e[p].includes(n)||e[g].some(e=>e[p].includes(n)))&&t.push(e[y]),S(e[g],n,t))}),t),B=(e,n)=>n?e.reduce((e,t)=>{const s=t[p].includes(n),r=t[g]?B(t[g],n):[];return(s||r.length>0)&&e.push({...t,[g]:r.length>0?r:void 0}),e},[]):e,D=e=>{if(!v)return e;const n=e.indexOf(v);if(-1===n)return e;const t=e.substring(0,n),s=e.substring(n+v.length);return d("span",{children:[t,o("span",{style:{color:"#f50"},children:v}),s]})},E=e=>e.map(e=>({...e,[p]:D(e[p]),[g]:e[g]?E(e[g]):void 0})),b=B(m,v),j=E(b);return s(()=>{i?.(m)},[m]),d("div",{style:{width:300},children:[o(a,{style:{marginBottom:8},placeholder:"输入关键字进行过滤",onSearch:async e=>{e!==v&&(e=>{if(O(e),G(!0),!e)return void N([]);const n=S(m,e);N(n)})(e)}}),o(n,{onExpand:e=>{N(e),G(!1)},onSelect:(e,n)=>{if(e.length>0&&l){const n=e[0],t=r({data:m,targetId:n,idKey:y,childrenKey:g,isIncludeOneself:x});l?.(t)}c?.(e,n)},autoExpandParent:P,expandedKeys:K,treeData:j,fieldNames:{title:p,key:y,children:g},...I})]})};i.displayName="BasicLeftTree";export{i as default};
1
+ import{Input as e,Tree as t}from"antd";import{useState as n,useEffect as r}from"react";import{getTreeNodePaths as s}from"../../../utils/index.js";import{jsxs as d,jsx as i}from"react/jsx-runtime";const{Search:a}=e,o=e=>{const{onGetData:o,onSelect:c,onGetNodePaths:l,getNodePathsIsIncludeOneself:h=!0,expandedKeys:u,treeData:m=[],nameKey:f="name",idKey:p="id",childrenKey:y="children",...g}=e,[x,K]=n([]),[v,I]=n(""),[N,S]=n(!0);r(()=>{K(u)},[u]);const D=(e,t,n=[])=>(e.forEach(e=>{e[y]&&((e[f].includes(t)||e[y].some(e=>e[f].includes(t)))&&n.push(e[p]),D(e[y],t,n))}),n),E=(e,t)=>t?e.reduce((e,n)=>{const r=n[f].includes(t),s=n[y]?E(n[y],t):[];return(r||s.length>0)&&e.push({...n,[y]:s.length>0?s:void 0}),e},[]):e,O=e=>{if(!v)return e;const t=e.indexOf(v);if(-1===t)return e;const n=e.substring(0,t),r=e.substring(t+v.length);return d("span",{children:[n,i("span",{style:{color:"#f50"},children:v}),r]})},P=e=>e.map(e=>({...e,[f]:O(e[f]),[y]:e[y]?P(e[y]):void 0})),b=E(m,v),j=P(b);return r(()=>{o?.(m)},[m]),d("div",{style:{width:300},children:[i(a,{style:{marginBottom:8},placeholder:"输入关键字进行过滤",onSearch:async e=>{e!==v&&(e=>{if(I(e),S(!0),!e)return void K([]);const t=D(m,e);K(t)})(e)}}),i(t,{onExpand:e=>{K(e),S(!1)},onSelect:(e,t)=>{if(e.length>0&&l){const t=e[0],n=s({data:m,targetId:t,idKey:p,childrenKey:y,isIncludeOneself:h});l?.(n)}c?.(e,t)},autoExpandParent:N,expandedKeys:x,treeData:j,fieldNames:{title:f,key:p,children:y},...g})]})};o.displayName="BasicLeftTree";export{o as default};
@@ -1 +1 @@
1
- import{Modal as e,Form as i,Row as t,Col as n,Select as a,Input as r,Button as l,Spin as o}from"antd";import{useRef as d,useState as s,useEffect as c}from"react";import{dynamicLoadJs as u,dynamicLoadCss as p}from"../../utils/index.js";import w from"./CesiumMap.js";import"./index.less";import{jsxs as m,jsx as h}from"react/jsx-runtime";const g=g=>{const{visible:y,onClose:b,longitude:v,latitude:C,onConfirm:f,area:L="",showArea:M=!1,disable:B=!1,type:k="baidu"}=g,j=d(null),x=d(null),D=d(null),[G,O]=s(!1),[I,A]=s(v||""),[R,z]=s(C||""),[K,P]=s(""),[T,S]=s("");c(()=>{A(v||""),z(C||""),S(L||"")},[v,C,L]);const W=()=>{if(!window?.BMapGL?.Map)return void setTimeout(()=>{W()},50);const e=new window.BMapGL.Map(j.current);if(x.current=e,e.centerAndZoom(new window.BMapGL.Point(v||window.mapLongitude,C||window.mapLatitude),16),e.enableScrollWheelZoom(!0),v&&C){const i=new window.BMapGL.Point(v,C),t=new window.BMapGL.Marker(i);e.addOverlay(t)}B||e.addEventListener("click",i=>{e.clearOverlays();const t=new window.BMapGL.Point(i.latlng.lng,i.latlng.lat),n=new window.BMapGL.Marker(t);e.addOverlay(n),z(i.latlng.lat),A(i.latlng.lng)})},E=()=>{if(O(!0),j.current){if(!x.current){if("baidu"===k)return void W();"cesium"===k&&(()=>{const{init:e,flyTo:i,addMarkPoint:t,getLongitudeAndLatitude:n}=new w,{viewer:a}=e();x.current=a,i({longitude:v||window.mapLongitude,latitude:C||window.mapLatitude,height:9e5}),v&&C&&t({longitude:v,latitude:C}),B||n((e,i)=>{if(e)return;const{longitude:t,latitude:n}=i;z(n),A(t)})})()}O(!1)}},Z=()=>{P(""),x.current&&(x.current.destroy(),x.current=null),b&&b()};c(()=>{let e;return y&&(e=setTimeout(()=>{(()=>{if(window.mapLongitude||window.mapLatitude)return"baidu"===k?window.mapBaiDuKey?void(async()=>{window.BMapGL?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`,type:"script",attr:{type:"text/javascript"}}),E()):(await u(`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`),E())})():void console.error("【Map】 请在window设置变量 mapBaiDuKey,以供地图初始化加载使用"):void("cesium"===k&&(async()=>{window.Cesium?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js",type:"script",attr:{type:"text/javascript"}}),await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css",type:"link",attr:{rel:"stylesheet",type:"text/css"}}),E()):(await u("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js"),await p("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css"),E())})());console.error("【Map】 请在window设置变量 mapLongitude 和 mapLatitude,以供地图初始化坐标使用")})()},100)),()=>{e&&clearTimeout(e)}},[y]);const $=()=>{if(x.current){try{x.current.clearOverlays(),x.current.destroy(),x.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}x.current=null}};return c(()=>()=>{$()},[]),m(e,{open:y,title:"坐标",onCancel:Z,width:1e3,destroyOnHidden:!1,maskClosable:!1,afterClose:$,footer:[h(l,{onClick:Z,children:"取消"},"back"),!B&&h(l,{type:"primary",onClick:()=>{f&&f(I,R,{area:T}),Z()},children:"确定"},"submit")],children:[m(i,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[M&&h(t,{gutter:24,children:h(n,{span:12,children:h(i.Item,{label:"所属区域",children:m(a,{value:T,onChange:e=>S(e),allowClear:!0,children:[h(a.Option,{value:"1",children:"东港区"}),h(a.Option,{value:"2",children:"西港区"})]})})})}),!B&&"baidu"===k&&m(t,{gutter:24,children:[h(n,{span:12,children:h(i.Item,{label:"关键字搜索",children:h(r,{value:K,onChange:e=>P(e.target.value),allowClear:!0})})}),h(n,{span:12,children:m(i.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(l,{type:"primary",onClick:()=>{K&&x.current&&(D.current=new window.BMapGL.LocalSearch(x.current,{renderOptions:{map:x.current}}),D.current.search(K))},children:"搜索"}),h(l,{onClick:()=>{P(""),x.current&&D.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),m(t,{gutter:24,children:[h(n,{span:12,children:h(i.Item,{label:"经度",children:h(r,{disabled:!0,value:I})})}),h(n,{span:12,children:h(i.Item,{label:"纬度",children:h(r,{disabled:!0,value:R})})})]})]}),h("div",{ref:j,id:"map_container",style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",tip:"地图正在加载中...",spinning:G,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};g.displayName="MapSelector";export{g as default};
1
+ import{Modal as e,Form as i,Row as t,Col as n,Select as a,Input as r,Button as l,Spin as o}from"antd";import{useRef as d,useState as s,useEffect as c}from"react";import{dynamicLoadJs as u,dynamicLoadCss as p}from"../../utils/index.js";import w from"./CesiumMap.js";import"./index.less";import{jsxs as m,jsx as h}from"react/jsx-runtime";const g=g=>{const{visible:y,onClose:b,longitude:v,latitude:C,onConfirm:f,area:L="",showArea:M=!1,disable:B=!1,type:k="baidu"}=g,j=d(null),x=d(null),D=d(null),[G,O]=s(!1),[I,A]=s(v||""),[R,z]=s(C||""),[K,P]=s(""),[T,S]=s("");c(()=>{A(v||""),z(C||""),S(L||"")},[v,C,L]);const W=()=>{if(!window?.BMapGL?.Map)return void setTimeout(()=>{W()},50);const e=new window.BMapGL.Map(j.current);if(x.current=e,e.centerAndZoom(new window.BMapGL.Point(v||window.mapLongitude,C||window.mapLatitude),16),e.enableScrollWheelZoom(!0),v&&C){const i=new window.BMapGL.Point(v,C),t=new window.BMapGL.Marker(i);e.addOverlay(t)}B||e.addEventListener("click",i=>{e.clearOverlays();const t=new window.BMapGL.Point(i.latlng.lng,i.latlng.lat),n=new window.BMapGL.Marker(t);e.addOverlay(n),z(i.latlng.lat),A(i.latlng.lng)})},E=()=>{if(O(!0),j.current){if(!x.current){if("baidu"===k)return void W();"cesium"===k&&(()=>{const{init:e,flyTo:i,addMarkPoint:t,getLongitudeAndLatitude:n}=new w,{viewer:a}=e();x.current=a,i({longitude:v||window.mapLongitude,latitude:C||window.mapLatitude,height:9e5}),v&&C&&t({longitude:v,latitude:C}),B||n((e,i)=>{if(e)return;const{longitude:t,latitude:n}=i;z(n),A(t)})})()}O(!1)}},Z=()=>{P(""),x.current&&(x.current.destroy(),x.current=null),b&&b()};c(()=>{let e;return y&&(e=setTimeout(()=>{(()=>{if(window.mapLongitude||window.mapLatitude)return"baidu"===k?window.mapBaiDuKey?void(async()=>{window.BMapGL?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`,type:"script",attr:{type:"text/javascript"}}),E()):(await u(`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`),E())})():void console.error("【Map】 请在window设置变量 mapBaiDuKey,以供地图初始化加载使用"):void("cesium"===k&&(async()=>{window.Cesium?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js",type:"script",attr:{type:"text/javascript"}}),await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css",type:"link",attr:{rel:"stylesheet",type:"text/css"}}),E()):(await u("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js"),await p("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css"),E())})());console.error("【Map】 请在window设置变量 mapLongitude 和 mapLatitude,以供地图初始化坐标使用")})()},100)),()=>{e&&clearTimeout(e)}},[y]);const $=()=>{if(x.current){try{x.current.clearOverlays(),x.current.destroy(),x.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}x.current=null}};return c(()=>()=>{$()},[]),m(e,{open:y,title:"坐标",onCancel:Z,width:1e3,destroyOnHidden:!1,mask:{closable:!1},afterClose:$,footer:[h(l,{onClick:Z,children:"取消"},"back"),!B&&h(l,{type:"primary",onClick:()=>{f&&f(I,R,{area:T}),Z()},children:"确定"},"submit")],children:[m(i,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[M&&h(t,{gutter:24,children:h(n,{span:12,children:h(i.Item,{label:"所属区域",children:m(a,{value:T,onChange:e=>S(e),allowClear:!0,children:[h(a.Option,{value:"1",children:"东港区"}),h(a.Option,{value:"2",children:"西港区"})]})})})}),!B&&"baidu"===k&&m(t,{gutter:24,children:[h(n,{span:12,children:h(i.Item,{label:"关键字搜索",children:h(r,{value:K,onChange:e=>P(e.target.value),allowClear:!0})})}),h(n,{span:12,children:m(i.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(l,{type:"primary",onClick:()=>{K&&x.current&&(D.current=new window.BMapGL.LocalSearch(x.current,{renderOptions:{map:x.current}}),D.current.search(K))},children:"搜索"}),h(l,{onClick:()=>{P(""),x.current&&D.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),m(t,{gutter:24,children:[h(n,{span:12,children:h(i.Item,{label:"经度",children:h(r,{disabled:!0,value:I})})}),h(n,{span:12,children:h(i.Item,{label:"纬度",children:h(r,{disabled:!0,value:R})})})]})]}),h("div",{ref:j,id:"map_container",style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",tip:"地图正在加载中...",spinning:G,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};g.displayName="MapSelector";export{g as default};
@@ -1 +1 @@
1
- import{useFullscreen as e}from"ahooks";import{Modal as r,Button as o,Spin as i,message as n}from"antd";import{useState as t,useRef as l}from"react";import{pdfjs as a,Document as d,Page as s}from"react-pdf";import c from"../../hooks/useDownloadFile/index.js";import{getFileUrl as p}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{jsx as m,Fragment as f}from"react/jsx-runtime";function h(h){const{visible:u=!1,onCancel:x,file:g,name:v,inline:y=!1,title:w="PDF预览",style:k={}}=h,C=p(),[j,F]=t(0),[P,b]=t(600),L=l(null),[S,{enterFullscreen:D,exitFullscreen:A}]=e(L),{downloadFile:N}=c();a.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${a.version}/build/pdf.worker.min.mjs`;const W=({numPages:e})=>{F(e)},$=()=>{n.error("加载 PDF 文件失败"),x&&x()},z=({width:e})=>{b(e)},B=()=>m(f,{children:m("div",{style:{height:S?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...k},children:m(d,{file:g.includes(C)?g:C+g,onLoadSuccess:W,onLoadError:$,loading:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"65vh"},children:m(i,{size:"large"})}),children:Array.from({length:j}).map((e,r)=>m(s,{pageNumber:r+1,onLoadSuccess:z},`page_${r+1}`))})})});return y?B():m("div",{ref:L,children:m(r,{style:{top:S?0:100,maxWidth:S?"100vw":"calc(100vw - 32px)",paddingBottom:S?0:24},open:u,maskClosable:!1,width:S?"100vw":P+100,title:w,onCancel:()=>{S&&A(),x()},getContainer:!1,footer:[m(o,{onClick:()=>{S&&A(),x()},children:"关闭"},"cancel"),m(o,{onClick:()=>{S?A():D()},children:S?"退出全屏":"全屏"},"fullScreen"),m(o,{type:"primary",onClick:()=>{S&&A(),N({url:g,name:v})},children:"下载"},"download")],children:B()})})}h.displayName="Pdf";export{h as default};
1
+ import{useFullscreen as e}from"ahooks";import{Modal as r,Button as o,Spin as i,message as n}from"antd";import{useState as t,useRef as l}from"react";import{pdfjs as a,Document as d,Page as c}from"react-pdf";import s from"../../hooks/useDownloadFile/index.js";import{getFileUrl as p}from"../../utils/index.js";import"react-pdf/dist/Page/AnnotationLayer.css";import"react-pdf/dist/Page/TextLayer.css";import"./index.less";import{jsx as m,Fragment as f}from"react/jsx-runtime";function h(h){const{visible:u=!1,onCancel:x,file:g,name:v,inline:y=!1,title:w="PDF预览",style:k={}}=h,C=p(),[j,F]=t(0),[P,b]=t(600),L=l(null),[S,{enterFullscreen:D,exitFullscreen:A}]=e(L),{downloadFile:N}=s();a.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${a.version}/build/pdf.worker.min.mjs`;const W=({numPages:e})=>{F(e)},$=()=>{n.error("加载 PDF 文件失败"),x&&x()},z=({width:e})=>{b(e)},B=()=>m(f,{children:m("div",{style:{height:S?"calc(100vh - 40px - 24px - 8px - 32px - 12px)":"72vh",overflowY:"auto",padding:"24px",...k},children:m(d,{file:g.includes(C)?g:C+g,onLoadSuccess:W,onLoadError:$,loading:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"65vh"},children:m(i,{size:"large"})}),children:Array.from({length:j}).map((e,r)=>m(c,{pageNumber:r+1,onLoadSuccess:z},`page_${r+1}`))})})});return y?B():m("div",{ref:L,children:m(r,{style:{top:S?0:100,maxWidth:S?"100vw":"calc(100vw - 32px)",paddingBottom:S?0:24},open:u,mask:{closable:!1},width:S?"100vw":P+100,title:w,onCancel:()=>{S&&A(),x()},getContainer:!1,footer:[m(o,{onClick:()=>{S&&A(),x()},children:"关闭"},"cancel"),m(o,{onClick:()=>{S?A():D()},children:S?"退出全屏":"全屏"},"fullScreen"),m(o,{type:"primary",onClick:()=>{S&&A(),N({url:g,name:v})},children:"下载"},"download")],children:B()})})}h.displayName="Pdf";export{h as default};
@@ -11,8 +11,6 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
11
11
  idKey?: string;
12
12
  /** 树形数据 children 字段,默认 children */
13
13
  childrenKey?: string;
14
- /** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
15
- onGetNodePathsIsIncludeOneself?: boolean;
16
14
  /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
17
15
  getNodePathsIsIncludeOneself?: boolean;
18
16
  /** 获取父级节点 */
@@ -1 +1 @@
1
- import{TreeSelect as e}from"antd";import{useMemo as l,useEffect as t}from"react";import{processTreeDataByLevel as a,processTreeDataForOnlyLastLevel as n,getDataType as r,getTreeNodePaths as o,arrayObjectDeduplication as s}from"../../../utils/index.js";import{jsx as c}from"react/jsx-runtime";function d(d){const{onGetData:i,onChange:h,onGetLabel:u,onGetNodePaths:y,onGetNodePathsIsIncludeOneself:f,getNodePathsIsIncludeOneself:m=!0,placeholder:I="",treeData:p=[],nameKey:v="name",idKey:g="id",childrenKey:K="children",level:S,onlyLastLevel:C=!1,...L}=d;void 0!==f&&console.warn("【BasicSelectTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");const N=void 0!==f?f:m,b=l(()=>{let e=S?a({data:p,level:S,childrenKey:K,currentLevel:1}):p;return e=n({data:e,childrenKey:K,onlyLastLevel:C}),e},[p,S,K,C]);return t(()=>{i?.(p,b)},[p,b]),c(e,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:`请选择${I}`,onChange:(e,l,t)=>{if(e){if("Array"===r(e)){if(y){const l=[];for(let t=0;t<e.length;t++){const a=L.labelInValue||L.treeCheckStrictly?e[t].value:e[t],n=o({data:p,targetId:a,idKey:g,childrenKey:K,isIncludeOneself:N});l.push(...n)}const t=s(l,g);y?.(t)}u?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.label):l)}else if(y||u){const l=L.labelInValue||L.treeCheckStrictly?e.value:e,t=o({data:p,targetId:l,idKey:g,childrenKey:K,isIncludeOneself:N});y?.(t),u?.(t[t.length-1][v])}}else y?.([]),u?.("");h?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.value):e,l,t)},allowClear:!0,treeData:b,fieldNames:{label:v,value:g,children:K},treeNodeFilterProp:v,showCheckedStrategy:e.SHOW_ALL,...L})}d.displayName="BasicSelectTree";export{d as default};
1
+ import{TreeSelect as e}from"antd";import{useMemo as l,useEffect as t}from"react";import{processTreeDataByLevel as a,processTreeDataForOnlyLastLevel as r,getDataType as n,getTreeNodePaths as o,arrayObjectDeduplication as i}from"../../../utils/index.js";import{jsx as c}from"react/jsx-runtime";function d(d){const{onGetData:s,onChange:h,onGetLabel:u,onGetNodePaths:y,getNodePathsIsIncludeOneself:f=!0,placeholder:m="",treeData:p=[],nameKey:v="name",idKey:I="id",childrenKey:g="children",level:K,onlyLastLevel:C=!1,...L}=d,S=l(()=>{let e=K?a({data:p,level:K,childrenKey:g,currentLevel:1}):p;return e=r({data:e,childrenKey:g,onlyLastLevel:C}),e},[p,K,g,C]);return t(()=>{s?.(p,S)},[p,S]),c(e,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:`请选择${m}`,onChange:(e,l,t)=>{if(e){if("Array"===n(e)){if(y){const l=[];for(let t=0;t<e.length;t++){const a=L.labelInValue||L.treeCheckStrictly?e[t].value:e[t],r=o({data:p,targetId:a,idKey:I,childrenKey:g,isIncludeOneself:f});l.push(...r)}const t=i(l,I);y?.(t)}u?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.label):l)}else if(y||u){const l=L.labelInValue||L.treeCheckStrictly?e.value:e,t=o({data:p,targetId:l,idKey:I,childrenKey:g,isIncludeOneself:f});y?.(t),u?.(t[t.length-1][v])}}else y?.([]),u?.("");h?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.value):e,l,t)},allowClear:!0,treeData:S,fieldNames:{label:v,value:I,children:g},treeNodeFilterProp:v,showCheckedStrategy:e.SHOW_ALL,...L})}d.displayName="BasicSelectTree";export{d as default};
@@ -1 +1 @@
1
- import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:g=300,url:y="",...C}=p,[b,k]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(y)},[y]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{k(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:"100%",height:g,marginTop:16},children:s(e,{src:w,style:{width:"100%",height:g,objectFit:"contain"}})}),s(i,{title:"签字",width:800,open:b,maskClosable:!1,onCancel:()=>k(!1),footer:[s(r,{onClick:()=>v.current.clear(),children:"重签"},"clear"),s(r,{onClick:()=>{k(!1),v.current.clear()},children:"取消"},"cancel"),s(r,{type:"primary",onClick:()=>{if(v.current.isEmpty())return void t.warning("请签名");const r=v.current.toDataURL();x(r),u({time:n().format("YYYY-MM-DD HH:mm:ss"),base64:r,file:l(r)}),v.current.clear(),k(!1)},children:"确定"},"ok")],children:s("div",{style:{border:"1px dashed #d9d9d9"},children:s(d,{ref:v,penColor:"black",canvasProps:{width:f,height:g},backgroundColor:"rgb(255,255,255)",...C})})})]})}p.displayName="Signature";export{p as default};
1
+ import{Button as r,Image as e,Modal as i,message as t}from"antd";import n from"dayjs";import{useState as o,useRef as c,useEffect as a}from"react";import d from"react-signature-canvas";import{base642File as l}from"../../utils/index.js";import{jsxs as h,Fragment as m,jsx as s}from"react/jsx-runtime";function p(p){const{onConfirm:u,width:f=752,height:g=300,url:y="",...b}=p,[k,C]=o(!1),v=c(null),[w,x]=o("");return a(()=>{x(y)},[y]),h(m,{children:[s("div",{children:s(r,{type:"primary",onClick:()=>{C(!0)},children:w?"重新签字":"手写签字"})}),w&&s("div",{style:{border:"1px dashed #d9d9d9",width:"100%",height:g,marginTop:16},children:s(e,{src:w,style:{width:"100%",height:g,objectFit:"contain"}})}),s(i,{title:"签字",width:800,open:k,mask:{closable:!1},onCancel:()=>C(!1),footer:[s(r,{onClick:()=>v.current.clear(),children:"重签"},"clear"),s(r,{onClick:()=>{C(!1),v.current.clear()},children:"取消"},"cancel"),s(r,{type:"primary",onClick:()=>{if(v.current.isEmpty())return void t.warning("请签名");const r=v.current.toDataURL();x(r),u({time:n().format("YYYY-MM-DD HH:mm:ss"),base64:r,file:l(r)}),v.current.clear(),C(!1)},children:"确定"},"ok")],children:s("div",{style:{border:"1px dashed #d9d9d9"},children:s(d,{ref:v,penColor:"black",canvasProps:{width:f,height:g},backgroundColor:"rgb(255,255,255)",...b})})})]})}p.displayName="Signature";export{p as default};
@@ -1 +1 @@
1
- import{Modal as e,Button as r}from"antd";import{forwardRef as t,useState as n,useRef as a,useImperativeHandle as o,useEffect as i}from"react";import{getFileUrl as l}from"../../utils/index.js";import s from"./AliPlayer.js";import{jsx as c}from"react/jsx-runtime";const u=t(({source:t="",vid:u="",playAuth:p="",cover:d="",autoplay:m=!0,showProgress:y=!0,playTime:h=0,inline:P=!1,isLive:f=!1,width:v="100%",height:g="600px",title:w="视频",visible:x=!1,onCancel:C,onEnded:I,onTimeupdate:T,onGetPlayerInstance:j,aliPlayerProps:A={}},b)=>{const[k,E]=n(!1),G=a(null);o(b,()=>({play:()=>{G.current&&G.current.play()},pause:()=>{G.current&&G.current.pause()},getPlayerInstance:()=>G.current&&G.current.getPlayerInstance()}));const L=C?x:k,N=C||E;i(()=>{P||(L?G.current&&G.current.play():G.current&&G.current.pause())},[L,P]);const V=c(s,{ref:G,source:(()=>{if(t)return t.includes("http")||t.includes("https")?t:l()+t})(),vid:u,playAuth:p,cover:d,autoplay:m,showProgress:y,playTime:h,isLive:f,width:v,height:g,aliPlayerProps:A,onEnded:I,onTimeupdate:T,onGetPlayerInstance:j});return P?V:c(e,{open:L,width:800,title:w,footer:[c(r,{onClick:()=>N(!1),children:"关闭"},"cancel")],maskClosable:!1,onCancel:()=>N(!1),children:V})});u.displayName="Video";export{u as default};
1
+ import{Modal as e,Button as r}from"antd";import{forwardRef as t,useState as n,useRef as a,useImperativeHandle as o,useEffect as i}from"react";import{getFileUrl as l}from"../../utils/index.js";import s from"./AliPlayer.js";import{jsx as c}from"react/jsx-runtime";const u=t(({source:t="",vid:u="",playAuth:p="",cover:d="",autoplay:m=!0,showProgress:y=!0,playTime:h=0,inline:P=!1,isLive:f=!1,width:v="100%",height:g="600px",title:w="视频",visible:x=!1,onCancel:I,onEnded:T,onTimeupdate:j,onGetPlayerInstance:A,aliPlayerProps:C={}},b)=>{const[k,E]=n(!1),G=a(null);o(b,()=>({play:()=>{G.current&&G.current.play()},pause:()=>{G.current&&G.current.pause()},getPlayerInstance:()=>G.current&&G.current.getPlayerInstance()}));const L=I?x:k,N=I||E;i(()=>{P||(L?G.current&&G.current.play():G.current&&G.current.pause())},[L,P]);const V=c(s,{ref:G,source:(()=>{if(t)return t.includes("http")||t.includes("https")?t:l()+t})(),vid:u,playAuth:p,cover:d,autoplay:m,showProgress:y,playTime:h,isLive:f,width:v,height:g,aliPlayerProps:C,onEnded:T,onTimeupdate:j,onGetPlayerInstance:A});return P?V:c(e,{open:L,width:800,title:w,footer:[c(r,{onClick:()=>N(!1),children:"关闭"},"cancel")],mask:{closable:!1},onCancel:()=>N(!1),children:V})});u.displayName="Video";export{u as default};
@@ -18,8 +18,6 @@ export interface UseTableOptions<TData extends Data, TParams extends Params> ext
18
18
  params?: Record<string, any> | (() => Record<string, any>);
19
19
  /** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */
20
20
  transform?: (formData: FormValues) => FormValues;
21
- /** @deprecated 已弃用,请使用 onSuccess */
22
- callback?: (list: any[], data: any) => void;
23
21
  /** 表单实例(通过 Form.useForm() 创建) */
24
22
  form?: FormInstance;
25
23
  }
@@ -1 +1 @@
1
- import{useAntdTable as e}from"ahooks";import a from"../useUrlQueryCriteria/index.js";function t(t,r){if(!t)return void console.error("【useTable】 缺少 service 参数");const{params:n,transform:o,...i}=r||{},{useStorageQueryCriteria:s=!0,usePagination:c=!0,usePermission:u=!0,defaultType:l="advance",defaultCurrent:p=1,defaultPageSize:g=20,defaultPagination:f={current:p,pageSize:g},...d}=i,{setUrlCriteriaQuery:b,getUrlCriteriaQuery:m}=a(),y=s?m("searchFormKeys","searchFormValues"):{},S=s&&c?m("paginationKeys","paginationValues"):{},h=Object.keys(y).length>0?y:{},P=c?Object.keys(S).length>0?S:f:{},k=e(function(e,a={},t,r){const n=("function"==typeof a?a():a)||{};return async({current:a,pageSize:o},i={})=>{let s=i;if("function"==typeof t){const e=t(i);e&&"object"==typeof e&&(s={...i,...e})}const c={pageIndex:a,pageSize:o,...s,...n};r&&(c.menuPath=window.location.pathname);const u=await e(c);return{list:u.data||[],total:u.totalCount||0,...u}}}(t,n,o,u),{...d,defaultParams:[P,h],defaultType:l,onSuccess:(e,a)=>{i.onSuccess&&i.onSuccess(e,a),s&&b(a[1]??{},c?{current:k.tableProps.pagination.current,pageSize:k.tableProps.pagination.pageSize}:{})}});return void 0!==i.callback&&console.warn("【useTable】 callback 参数已弃用,请使用 onSuccess 参数"),i.callback&&i.callback(k?.data?.list||[],k?.data||{}),{...k,tableProps:{...k.tableProps,pagination:!!c&&{...k.tableProps.pagination,showQuickJumper:!0,showSizeChanger:!0}},getData:k.search.submit}}export{t as default};
1
+ import{useAntdTable as e}from"ahooks";import t from"../useUrlQueryCriteria/index.js";function a(a,r){if(!a)return void console.error("【useTable】 缺少 service 参数");const{params:n,transform:o,...i}=r||{},{useStorageQueryCriteria:s=!0,usePagination:u=!0,usePermission:c=!0,defaultType:p="advance",defaultCurrent:l=1,defaultPageSize:g=20,defaultPagination:f={current:l,pageSize:g},...m}=i,{setUrlCriteriaQuery:y,getUrlCriteriaQuery:d}=t(),h=s?d("searchFormKeys","searchFormValues"):{},P=s&&u?d("paginationKeys","paginationValues"):{},S=Object.keys(h).length>0?h:{},b=u?Object.keys(P).length>0?P:f:{},z=e(function(e,t={},a,r){const n=("function"==typeof t?t():t)||{};return async({current:t,pageSize:o},i={})=>{let s=i;if("function"==typeof a){const e=a(i);e&&"object"==typeof e&&(s={...i,...e})}const u={pageIndex:t,pageSize:o,...s,...n};r&&(u.menuPath=window.location.pathname);const c=await e(u);return{list:c.data||[],total:c.totalCount||0,...c}}}(a,n,o,c),{...m,defaultParams:[b,S],defaultType:p,onSuccess:(e,t)=>{i.onSuccess&&i.onSuccess(e,t),s&&y(t[1]??{},u?{current:z.tableProps.pagination.current,pageSize:z.tableProps.pagination.pageSize}:{})}});return{...z,tableProps:{...z.tableProps,pagination:!!u&&{...z.tableProps.pagination,showQuickJumper:!0,showSizeChanger:!0}},getData:z.search.submit}}export{a as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",