"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[2778],{43261:function(ue,V,n){var J=n(40749),y=n(67654),F=n(87841),M=n(99177),K=n(42700),t=n(88351),j=n(14555),H=n(50788),w=n(40818),ne=n(12883),p=n(993),N=n(8463),z=n(5897),te=n(14649),k=n(84974),re=n(71639),O=n(91929),B=n(61041),C=n(93236),ae=n(50740),le=n(87708),f=n(62086),Z=["onTableChange","maxLength","formItemProps","recordCreatorProps","rowKey","controlled","defaultValue","onChange","editableFormRef"],q=["record","position","creatorButtonText","newRecordType","parentKey","style"],ee=C.createContext(void 0);function Y(e){var R=e.children,A=e.record,U=e.position,x=e.newRecordType,b=e.parentKey,L=(0,C.useContext)(ee);return C.cloneElement(R,(0,t.Z)((0,t.Z)({},R.props),{},{onClick:function(){var W=(0,K.Z)((0,M.Z)().mark(function D(s){var c,u,o,P;return(0,M.Z)().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,(c=(u=R.props).onClick)===null||c===void 0?void 0:c.call(u,s);case 2:if(P=h.sent,P!==!1){h.next=5;break}return h.abrupt("return");case 5:L==null||(o=L.current)===null||o===void 0||o.addEditRecord(A,{position:U,newRecordType:x,parentKey:b});case 6:case"end":return h.stop()}},D)}));function m(D){return W.apply(this,arguments)}return m}()}))}function ie(e){var R,A,U=(0,ne.YB)(),x=e.onTableChange,b=e.maxLength,L=e.formItemProps,W=e.recordCreatorProps,m=e.rowKey,D=e.controlled,s=e.defaultValue,c=e.onChange,u=e.editableFormRef,o=(0,F.Z)(e,Z),P=(0,C.useRef)(void 0),a=(0,C.useRef)(),h=(0,C.useRef)();(0,C.useImperativeHandle)(o.actionRef,function(){return a.current},[a.current]);var I=(0,re.Z)(function(){return e.value||s||[]},{value:e.value,onChange:e.onChange}),de=(0,y.Z)(I,2),d=de[0],ve=de[1],S=C.useMemo(function(){return typeof m=="function"?m:function(E,r){return E[m]||r}},[m]),se=function(r){if(typeof r=="number"&&!e.name){if(r>=d.length)return r;var l=d&&d[r];return S==null?void 0:S(l,r)}if((typeof r=="string"||r>=d.length)&&e.name){var i=d.findIndex(function(_,v){var g;return(S==null||(g=S(_,v))===null||g===void 0?void 0:g.toString())===(r==null?void 0:r.toString())});if(i!==-1)return i}return r};(0,C.useImperativeHandle)(u,function(){var E=function(i){var _,v;if(i==null)throw new Error("rowIndex is required");var g=se(i),T=[e.name,(_=g==null?void 0:g.toString())!==null&&_!==void 0?_:""].flat(1).filter(Boolean);return(v=h.current)===null||v===void 0?void 0:v.getFieldValue(T)},r=function(){var i,_=[e.name].flat(1).filter(Boolean);if(Array.isArray(_)&&_.length===0){var v,g=(v=h.current)===null||v===void 0?void 0:v.getFieldsValue();return Array.isArray(g)?g:Object.keys(g).map(function(T){return g[T]})}return(i=h.current)===null||i===void 0?void 0:i.getFieldValue(_)};return(0,t.Z)((0,t.Z)({},h.current),{},{getRowData:E,getRowsData:r,setRowData:function(i,_){var v,g;if(i==null)throw new Error("rowIndex is required");var T=se(i),X=[e.name,(v=T==null?void 0:T.toString())!==null&&v!==void 0?v:""].flat(1).filter(Boolean),Me=Object.assign({},(0,t.Z)((0,t.Z)({},E(i)),_||{})),Oe=(0,B.Z)({},X,Me);return(g=h.current)===null||g===void 0||g.setFieldsValue(Oe),!0}})},[e.name,h.current]),(0,C.useEffect)(function(){e.controlled&&d.forEach(function(E,r){var l;(l=h.current)===null||l===void 0||l.setFieldsValue((0,J.Z)({},S(E,r),E))},{})},[(0,ae.P)(d),e.controlled]),(0,C.useEffect)(function(){if(e.name){var E;h.current=e==null||(E=e.editable)===null||E===void 0?void 0:E.form}},[(R=e.editable)===null||R===void 0?void 0:R.form,e.name]);var $=W||{},fe=$.record,oe=$.position,me=$.creatorButtonText,he=$.newRecordType,Ee=$.parentKey,De=$.style,Pe=(0,F.Z)($,q),ce=oe==="top",Q=(0,C.useMemo)(function(){return typeof b=="number"&&b<=(d==null?void 0:d.length)?!1:W!==!1&&(0,f.jsx)(Y,{record:(0,p.h)(fe,d==null?void 0:d.length,d)||{},position:oe,parentKey:(0,p.h)(Ee,d==null?void 0:d.length,d),newRecordType:he,children:(0,f.jsx)(te.ZP,(0,t.Z)((0,t.Z)({type:"dashed",style:(0,t.Z)({display:"block",margin:"10px 0",width:"100%"},De),icon:(0,f.jsx)(j.Z,{})},Pe),{},{children:me||U.getMessage("editableTable.action.add","\u6DFB\u52A0\u4E00\u884C\u6570\u636E")}))})},[W,b,d==null?void 0:d.length]),ge=(0,C.useMemo)(function(){return Q?ce?{components:{header:{wrapper:function(r){var l,i=r.className,_=r.children;return(0,f.jsxs)("thead",{className:i,children:[_,(0,f.jsxs)("tr",{style:{position:"relative"},children:[(0,f.jsx)("td",{colSpan:0,style:{visibility:"hidden"},children:Q}),(0,f.jsx)("td",{style:{position:"absolute",left:0,width:"100%"},colSpan:(l=o.columns)===null||l===void 0?void 0:l.length,children:Q})]})]})}}}}:{tableViewRender:function(r,l){var i,_;return(0,f.jsxs)(f.Fragment,{children:[(i=(_=e.tableViewRender)===null||_===void 0?void 0:_.call(e,r,l))!==null&&i!==void 0?i:l,Q]})}}:{}},[ce,Q]),_e=(0,t.Z)({},e.editable),Ce=(0,N.J)(function(E,r){var l,i,_;if((l=e.editable)===null||l===void 0||(i=l.onValuesChange)===null||i===void 0||i.call(l,E,r),(_=e.onValuesChange)===null||_===void 0||_.call(e,r,E),e.controlled){var v;e==null||(v=e.onChange)===null||v===void 0||v.call(e,r)}});return(e!=null&&e.onValuesChange||(A=e.editable)!==null&&A!==void 0&&A.onValuesChange||e.controlled&&e!==null&&e!==void 0&&e.onChange)&&(_e.onValuesChange=Ce),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ee.Provider,{value:a,children:(0,f.jsx)(le.Z,(0,t.Z)((0,t.Z)((0,t.Z)({search:!1,options:!1,pagination:!1,rowKey:m,revalidateOnFocus:!1},o),ge),{},{tableLayout:"fixed",actionRef:a,onChange:x,editable:(0,t.Z)((0,t.Z)({},_e),{},{formProps:(0,t.Z)({formRef:h},_e.formProps)}),dataSource:d,onDataSourceChange:function(r){if(ve(r),e.name&&oe==="top"){var l,i=(0,B.Z)({},[e.name].flat(1).filter(Boolean),r);(l=h.current)===null||l===void 0||l.setFieldsValue(i)}}}))}),e.name?(0,f.jsx)(H.Z,{name:[e.name],children:function(r){var l,i;if(!P.current)return P.current=d,null;var _=(0,O.Z)(r,[e.name].flat(1)),v=_==null?void 0:_.find(function(g,T){var X;return!(0,z.A)(g,(X=P.current)===null||X===void 0?void 0:X[T])});return P.current=d,v&&(e==null||(l=e.editable)===null||l===void 0||(i=l.onValuesChange)===null||i===void 0||i.call(l,v,_)),null}}):null]})}function G(e){var R=w.ZP.useFormInstance();return e.name?(0,f.jsx)(k.Z.Item,(0,t.Z)((0,t.Z)({style:{maxWidth:"100%"}},e==null?void 0:e.formItemProps),{},{name:e.name,shouldUpdate:function(U,x){var b=[e.name].flat(1);try{return JSON.stringify((0,O.Z)(U,b))!==JSON.stringify((0,O.Z)(x,b))}catch(L){return!0}},children:(0,f.jsx)(ie,(0,t.Z)((0,t.Z)({},e),{},{editable:(0,t.Z)((0,t.Z)({},e.editable),{},{form:R})}))})):(0,f.jsx)(ie,(0,t.Z)({},e))}G.RecordCreator=Y,V.Z=G},85968:function(ue,V,n){var J=n(23674),y=n(62086),F=function(K){var t=(0,J.useModel)("@@initialState"),j=t.initialState,H=t.loading,w=t.error,ne=t.refresh,p=t.setInitialState,N=j==null?void 0:j.authPermissionAction;if(!N)return(0,y.jsx)("span",{children:K.children});var z=N.indexOf(K.action);return z>=0?(0,y.jsx)("span",{children:K.children}):(0,y.jsx)(y.Fragment,{})};V.Z=F},38915:function(ue,V,n){n.r(V);var J=n(57213),y=n.n(J),F=n(25359),M=n.n(F),K=n(49811),t=n.n(K),j=n(54306),H=n.n(j),w=n(93236),ne=n(23674),p=n(14649),N=n(51676),z=n(50336),te=n(43261),k=n(85968),re=n(90627),O=n(62086),B=re.Z.ArticleCategoryController,C=B.articleCategoryItems,ae=B.articleCategoryCreate,le=B.articleCategoryDelete,f=B.articleCategoryUpdate;V.default=function(){var Z=(0,w.useRef)(),q={id:"",name:"",sort:100},ee=(0,w.useState)(q),Y=H()(ee,2),ie=Y[0],G=Y[1],e=(0,w.useState)([]),R=H()(e,2),A=R[0],U=R[1],x=function(){var m=t()(M()().mark(function D(s){var c,u,o;return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,le(s);case 2:c=a.sent,u=c.success,u&&(Z.current.clearSelected(),(o=Z.current)===null||o===void 0||o.reload());case 5:case"end":return a.stop()}},D)}));return function(s){return m.apply(this,arguments)}}(),b=function(){var m=t()(M()().mark(function D(s){var c,u,o;return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return G(s),a.next=3,ae(y()({},s));case 3:c=a.sent,u=c.success,u&&(G(q),(o=Z.current)===null||o===void 0||o.reload());case 6:case"end":return a.stop()}},D)}));return function(s){return m.apply(this,arguments)}}(),L=function(){var m=t()(M()().mark(function D(s){var c,u,o;return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,f(y()({},s));case 2:c=a.sent,u=c.success,u&&((o=Z.current)===null||o===void 0||o.reload());case 5:case"end":return a.stop()}},D)}));return function(s){return m.apply(this,arguments)}}(),W=[{title:"\u680F\u76EE\u540D\u79F0",dataIndex:"name",search:!1},{title:"\u6392\u5E8F",dataIndex:"sort",search:!1},{title:"\u521B\u5EFA\u65F6\u95F4",dataIndex:"created_at",search:!1,editable:!1},{title:"\u64CD\u4F5C",dataIndex:"option",valueType:"option",render:function(D,s,c,u){return[(0,O.jsx)(k.Z,{action:"admin/article_category/update",children:(0,O.jsx)(p.ZP,{type:"link",onClick:function(){var P;G(s),u==null||(P=u.startEditable)===null||P===void 0||P.call(u,s.id)},children:"\u7F16\u8F91"},"editable")},"admin/article_category/update"),(0,O.jsx)(k.Z,{action:"admin/article_category/delete",children:(0,O.jsx)(N.Z,{title:"\u786E\u8BA4\u5220\u9664\uFF1F",onConfirm:function(){x({id:[s.id]})},children:(0,O.jsx)(p.ZP,{type:"link",danger:!0,children:"\u5220\u9664"},"delete")})},"admin/article_category/delete")]}}];return(0,O.jsx)(z._z,{ghost:!0,children:(0,O.jsx)(O.Fragment,{children:(0,O.jsx)(te.Z,{actionRef:Z,rowKey:"id",search:!1,request:function(){var m=t()(M()().mark(function D(s,c,u){var o,P,a;return M()().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return I.next=2,C(y()(y()({},s),{},{sorter:c,filter:u}));case 2:return o=I.sent,P=o.data,a=o.success,I.abrupt("return",{data:P||[],total:0,success:a});case 6:case"end":return I.stop()}},D)}));return function(D,s,c){return m.apply(this,arguments)}}(),recordCreatorProps:{position:"top",record:function(){return{id:0}}},editable:{type:"multiple",editableKeys:A,onSave:function(){var m=t()(M()().mark(function s(c,u,o){return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:c?L(u):b(u);case 1:case"end":return a.stop()}},s)}));function D(s,c,u){return m.apply(this,arguments)}return D}(),onChange:U},columns:W,pagination:!1})})})}}}]);