zy-react-library 2.0.0 → 2.0.2

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.
@@ -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},U=e=>"function"==typeof e.componentProps?e.componentProps(M()):e.componentProps||{},P=e=>{const r="function"==typeof e.formItemProps?e.formItemProps(M()):e.formItemProps||{};return[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})),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=>"function"==typeof e?e(M()):e??!1,k=(e,r)=>({value:e[r.valueKey],label:"function"==typeof r.labelKey?r.labelKey(e):e[r.labelKey],disabled:e.disabled}),L=e=>{const t=U(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}=k(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}=k(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}=k(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}=k(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}},V=r=>r.tip?T(f,{children:[r.label,E(c,{title:r.tip,children:E(e,{style:{marginLeft:4,fontSize:12}})})]}):r.label,$=({option:e,style:r,col:n,index:s,preserve:a})=>{const o=P(e);return delete o.dependencies,delete o.shouldUpdate,E(l,{span:n.span,style:r,children:E(t.Item,{name:e.name,label:V(e),rules:g(e),labelCol:n.labelCol,wrapperCol:n.wrapperCol,preserve:a,required:!!C&&" "!==V(e)&&x(e.required),colon:" "!==V(e),...o,children:L(e)})},_(e)||s)},G=({option:e,style:r,col:n,index:a,preserve:o})=>{const d=U(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},K=({option:e,index:r,style:n,col:l,preserve:s})=>{const a=P(e);return E(t.Item,{noStyle:!0,preserve:s,shouldUpdate:e.shouldUpdate??a.shouldUpdate,dependencies:e.dependencies??a.dependencies,children:()=>$({option:e,style:n,col:l,index:r,preserve:s})},_(e)||r)},q=({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=U(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)=>{if(F(a.hidden))return null;const c=B(a),m=P(a),y={option:a,style:s,col:c,index:`${u}_${i}`,preserve:!0},f=G(y);if(f)return f;if(a.render===h.FORM_LIST)return q(y);if((a.shouldUpdate??a.dependencies)||(m.shouldUpdate??m.dependencies))return K(y);const b=e=>!F(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:V(a),labelCol:c.labelCol,wrapperCol:c.wrapperCol,preserve:!1,required:!!C&&" "!==V(a)&&x(a.required),colon:" "!==V(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:L(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)):$(y)})},e.key)})})})},_(e)||r)};return E(f,{children:I.map((e,r)=>{if(F(e.hidden))return null;const n=B(e),t=(e=>D&&e>=3?{display:"none"}:void 0)(r),l=P(e),s={option:e,style:t,col:n,index:r,preserve:!1};return G(s)||(e.render===h.FORM_LIST?q(s):(e.shouldUpdate??e.dependencies)||(l.shouldUpdate??l.dependencies)?K(s):$(s))})})};I.displayName="FormItemsRenderer";export{I as default};
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 +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};
@@ -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};
@@ -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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",