2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[354],{12817:function(se,Q,n){var ee=n(24572),I=n(91600),X=n(58733),$=n(99932),K=n(78450),t=n(75782),ne=n(27693),te=n(55585),V=n(31479),F=n(35276),q=n(88648),D=n(18518),w=n(88938),s=n(89839),oe=n(26572),b=n(40870),ae=n(95027),y=n(53068),x=n(38365),h=n(50959),k=n(61643),_=n(11527),N=["onTableChange","maxLength","formItemProps","recordCreatorProps","rowKey","controlled","defaultValue","onChange","editableFormRef"],B=["record","position","creatorButtonText","newRecordType","parentKey","style"],G=h.createContext(void 0);function j(e){var O=e.children,C=e.record,J=e.position,W=e.newRecordType,M=e.parentKey,A=(0,h.useContext)(G);return h.cloneElement(O,(0,t.Z)((0,t.Z)({},O.props),{},{onClick:function(){var p=(0,K.Z)((0,$.Z)().mark(function R(g){var P,Z,o,E;return(0,$.Z)().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,(P=(Z=O.props).onClick)===null||P===void 0?void 0:P.call(Z,g);case 2:if(E=u.sent,E!==!1){u.next=5;break}return u.abrupt("return");case 5:A==null||(o=A.current)===null||o===void 0||o.addEditRecord(C,{position:J,newRecordType:W,parentKey:M});case 6:case"end":return u.stop()}},R)}));function U(R){return p.apply(this,arguments)}return U}()}))}function H(e){var O,C,J=(0,F.YB)(),W=e.onTableChange,M=e.maxLength,A=e.formItemProps,p=e.recordCreatorProps,U=e.rowKey,R=e.controlled,g=e.defaultValue,P=e.onChange,Z=e.editableFormRef,o=(0,X.Z)(e,N),E=(0,q.D)(e.value),v=(0,h.useRef)(),u=(0,h.useRef)();(0,h.useImperativeHandle)(o.actionRef,function(){return v.current});var S=(0,ae.Z)(function(){return e.value||g||[]},{value:e.value,onChange:e.onChange}),le=(0,I.Z)(S,2),d=le[0],ve=le[1],T=h.useMemo(function(){return typeof U=="function"?U:function(f,a){return f[U]||a}},[U]),ce=function(a){if(typeof a=="number"&&!e.name){if(a>=d.length)return a;var l=d&&d[a];return T==null?void 0:T(l,a)}if((typeof a=="string"||a>=d.length)&&e.name){var r=d.findIndex(function(i,c){var m;return(T==null||(m=T(i,c))===null||m===void 0?void 0:m.toString())===(a==null?void 0:a.toString())});return r}return a};(0,h.useImperativeHandle)(Z,function(){var f=function(r){var i,c;if(r==null)throw new Error("rowIndex is required");var m=ce(r),L=[e.name,(i=m==null?void 0:m.toString())!==null&&i!==void 0?i:""].flat(1).filter(Boolean);return(c=u.current)===null||c===void 0?void 0:c.getFieldValue(L)},a=function(){var r,i=[e.name].flat(1).filter(Boolean);if(Array.isArray(i)&&i.length===0){var c,m=(c=u.current)===null||c===void 0?void 0:c.getFieldsValue();return Array.isArray(m)?m:Object.keys(m).map(function(L){return m[L]})}return(r=u.current)===null||r===void 0?void 0:r.getFieldValue(i)};return(0,t.Z)((0,t.Z)({},u.current),{},{getRowData:f,getRowsData:a,setRowData:function(r,i){var c,m,L,ue;if(r==null)throw new Error("rowIndex is required");var de=ce(r),Ce=[e.name,(c=de==null?void 0:de.toString())!==null&&c!==void 0?c:""].flat(1).filter(Boolean),Re=((m=u.current)===null||m===void 0||(L=m.getFieldsValue)===null||L===void 0?void 0:L.call(m))||{},be=(0,x.Z)(Re,Ce,(0,t.Z)((0,t.Z)({},f(r)),i||{}));return(ue=u.current)===null||ue===void 0||ue.setFieldsValue(be),!0}})}),(0,h.useEffect)(function(){e.controlled&&d.forEach(function(f,a){var l;(l=u.current)===null||l===void 0||l.setFieldsValue((0,ee.Z)({},T(f,a),f))},{})},[d,e.controlled]),(0,h.useEffect)(function(){if(e.name){var f;u.current=e==null||(f=e.editable)===null||f===void 0?void 0:f.form}},[(O=e.editable)===null||O===void 0?void 0:O.form,e.name]);var Y=p||{},me=Y.record,ie=Y.position,he=Y.creatorButtonText,Ee=Y.newRecordType,Pe=Y.parentKey,ge=Y.style,De=(0,X.Z)(Y,B),fe=ie==="top",re=(0,h.useMemo)(function(){return typeof M=="number"&&M<=(d==null?void 0:d.length)?!1:p!==!1&&(0,_.jsx)(j,{record:(0,D.h)(me,d==null?void 0:d.length,d)||{},position:ie,parentKey:(0,D.h)(Pe,d==null?void 0:d.length,d),newRecordType:Ee,children:(0,_.jsx)(oe.ZP,(0,t.Z)((0,t.Z)({type:"dashed",style:(0,t.Z)({display:"block",margin:"10px 0",width:"100%"},ge),icon:(0,_.jsx)(ne.Z,{})},De),{},{children:he||J.getMessage("editableTable.action.add","\u6DFB\u52A0\u4E00\u884C\u6570\u636E")}))})},[p,M,d==null?void 0:d.length]),Oe=(0,h.useMemo)(function(){return re?fe?{components:{header:{wrapper:function(a){var l,r=a.className,i=a.children;return(0,_.jsxs)("thead",{className:r,children:[i,(0,_.jsxs)("tr",{style:{position:"relative"},children:[(0,_.jsx)("td",{colSpan:0,style:{visibility:"hidden"},children:re}),(0,_.jsx)("td",{style:{position:"absolute",left:0,width:"100%"},colSpan:(l=o.columns)===null||l===void 0?void 0:l.length,children:re})]})]})}}}}:{tableViewRender:function(a,l){var r,i;return(0,_.jsxs)(_.Fragment,{children:[(r=(i=e.tableViewRender)===null||i===void 0?void 0:i.call(e,a,l))!==null&&r!==void 0?r:l,re]})}}:{}},[fe,re]),_e=(0,t.Z)({},e.editable),Me=(0,w.J)(function(f,a){var l,r,i;if((l=e.editable)===null||l===void 0||(r=l.onValuesChange)===null||r===void 0||r.call(l,f,a),(i=e.onValuesChange)===null||i===void 0||i.call(e,a,f),e.controlled){var c;e==null||(c=e.onChange)===null||c===void 0||c.call(e,a)}});return(e!=null&&e.onValuesChange||(C=e.editable)!==null&&C!==void 0&&C.onValuesChange||e.controlled&&e!==null&&e!==void 0&&e.onChange)&&(_e.onValuesChange=Me),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(G.Provider,{value:v,children:(0,_.jsx)(k.Z,(0,t.Z)((0,t.Z)((0,t.Z)({search:!1,options:!1,pagination:!1,rowKey:U,revalidateOnFocus:!1},o),Oe),{},{tableLayout:"fixed",actionRef:v,onChange:W,editable:(0,t.Z)((0,t.Z)({},_e),{},{formProps:(0,t.Z)({formRef:u},_e.formProps)}),dataSource:d,onDataSourceChange:function(a){if(ve(a),e.name&&ie==="top"){var l,r=(0,x.Z)({},[e.name].flat(1).filter(Boolean),a);(l=u.current)===null||l===void 0||l.setFieldsValue(r)}}}))}),e.name?(0,_.jsx)(te.Z,{name:[e.name],children:function(a){var l,r,i=(0,y.Z)(a,[e.name].flat(1)),c=i==null?void 0:i.find(function(m,L){return!(0,s.A)(m,E==null?void 0:E[L])});return c&&E&&(e==null||(l=e.editable)===null||l===void 0||(r=l.onValuesChange)===null||r===void 0||r.call(l,c,i)),null}}):null]})}function z(e){var O=V.ZP.useFormInstance();return e.name?(0,_.jsx)(b.Z.Item,(0,t.Z)((0,t.Z)({style:{maxWidth:"100%"}},e==null?void 0:e.formItemProps),{},{name:e.name,children:(0,_.jsx)(H,(0,t.Z)((0,t.Z)({},e),{},{editable:(0,t.Z)((0,t.Z)({},e.editable),{},{form:O})}))})):(0,_.jsx)(H,(0,t.Z)({},e))}z.RecordCreator=j,Q.Z=z},91551:function(se,Q,n){n.r(Q);var ee=n(25359),I=n.n(ee),X=n(49811),$=n.n(X),K=n(54306),t=n.n(K),ne=n(12817),te=n(12472),V=n(86195),F=n(21137),q=n(79112),D=n(50959),w=n(87474),s=n(11527),oe=F.Z.Option,b,ae=function(_,N){b&&(clearTimeout(b),b=null);var B=function(){(0,V.request)("/api/storage?search="+_).then(function(j){N(j.data)})};b=setTimeout(B,300)},y=function(_){var N=(0,D.useState)([]),B=t()(N,2),G=B[0],j=B[1],H=_.value.split(".")[0],z=(0,D.useState)(!1),e=t()(z,2),O=e[0],C=e[1],J=(0,D.useState)(""),W=t()(J,2),M=W[0],A=W[1],p=(0,D.useRef)(),U=[{title:"\u5E8F\u53F7",dataIndex:"index",width:"5%",readonly:!0},{title:"\u5B58\u50A8\u6876",dataIndex:"bucket",width:"8%"},{title:"\u952E\u540D",dataIndex:"key"},{title:"\u503C",dataIndex:"value",render:function(g){return g.length>100?(0,s.jsx)("a",{onClick:function(){A(g),C(!0)},children:"".concat(g.slice(0,100),"...")}):g},valueType:"textarea"},{title:"\u64CD\u4F5C",valueType:"option",width:"12%",render:function(g,P,Z,o){return[(0,s.jsx)("a",{onClick:function(){var v;o==null||(v=o.startEditable)===null||v===void 0||v.call(o,P.id)},children:"\u7F16\u8F91"},"editable"),(0,s.jsx)("a",{onClick:function(){var v,u,S={};S[P.id]="",(0,w.Z)(S),(v=p.current)===null||v===void 0||(u=v.reloadAndRest)===null||u===void 0||u.call(v)},children:"\u5220\u9664"},"delete")]}}];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(q.Z,{title:"",open:O,footer:[],onOk:function(){C(!1)},onCancel:function(){C(!1)},children:M}),(0,s.jsx)(ne.Z,{actionRef:p,request:$()(I()().mark(function R(){var g,P=arguments;return I()().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return g=P.length>0&&P[0]!==void 0?P[0]:{},o.abrupt("return",(0,V.request)("/api/storage/list?keys="+[_.value].join(","),{params:g}).then(function(E){return E.data=E.data.map(function(v){return v.id=v.bucket+"."+v.key,v}),E}));case 2:case"end":return o.stop()}},R)})),showSorterTooltip:!0,pagination:{},rowKey:"id",maxLength:100005,scroll:{x:960},recordCreatorProps:{position:"bottom",record:function(){return{id:H,bucket:H}}},loading:!1,columns:U,editable:{type:"multiple",editableKeys:G,onSave:function(){var R=$()(I()().mark(function P(Z,o){var E,v,u,S,le,d;return I()().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:E=Z==o.bucket,v={},E||(u=o.id.split("."),S=t()(u,2),le=S[0],d=S[1],(o.bucket!=le||o.key!=d)&&(v[o.id]="")),v[o.bucket+"."+o.key]=o.value,(0,w.Z)(v);case 5:case"end":return T.stop()}},P)}));function g(P,Z){return R.apply(this,arguments)}return g}(),onChange:j}})]})},x=function(_){var N=(0,D.useState)([]),B=t()(N,2),G=B[0],j=B[1],H=(0,D.useState)(),z=t()(H,2),e=z[0],O=z[1],C=function(A){ae(A,j)},J=function(A){O(A)},W=G.map(function(M){return(0,s.jsx)(oe,{children:M.text},M.value)});return(0,s.jsxs)(te._z,{subTitle:"tips\uFF1A\u5220\u9664\u5B58\u50A8\u6876 empty ?",children:[(0,s.jsx)(F.Z,{showSearch:!0,value:e,placeholder:_.placeholder,style:_.style,defaultActiveFirstOption:!1,showArrow:!1,filterOption:!1,onFocus:function(){C("")},onSearch:C,onChange:J,notFoundContent:null,children:W}),e&&(0,s.jsx)(y,{value:e},e)]})},h=function(){return(0,s.jsx)(x,{placeholder:"\u8BF7\u8F93\u5165\u5173\u952E\u8BCD",style:{width:200,marginBottom:"20px"}})};Q.default=h},87474:function(se,Q,n){var ee=n(25359),I=n.n(ee),X=n(49811),$=n.n(X),K=n(21362),t=n(86195),ne=function(){var te=$()(I()().mark(function V(F){var q,D,w,s=arguments;return I()().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return q=s.length>1&&s[1]!==void 0?s[1]:"\u6B63\u5728\u63D0\u4EA4\u66F4\u6539..",D=s.length>2&&s[2]!==void 0?s[2]:"\u63D0\u4EA4\u6210\u529F\uFF01",w=s.length>3&&s[3]!==void 0?s[3]:"\u63D0\u4EA4\u5931\u8D25",q&&K.ZP.loading("\u6B63\u5728\u63D0\u4EA4\u66F4\u6539..",2e4),b.abrupt("return",new Promise(function(ae){(0,t.request)("/api/storage",{method:"put",data:F}).then(function(y){var x;if(K.ZP.destroy(),(y==null||(x=y.data)===null||x===void 0?void 0:x.isLogin)==!1){K.ZP.warning("\u767B\u5F55\u5931\u6548\uFF01",2);var h=new URL(window.location.href).searchParams,k=h.get("redirect");window.location.pathname!=="/user/login"&&!k&&t.history.replace({pathname:"/user/login"});return}y!=null&&y.success?D&&K.ZP.success(D,1):w&&K.ZP.warning("\u63D0\u4EA4\u5931\u8D25\uFF01",2),ae(y)})}));case 5:case"end":return b.stop()}},V)}));return function(F){return te.apply(this,arguments)}}();Q.Z=ne}}]);
|