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