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