2 lines
9.9 KiB
JavaScript
2 lines
9.9 KiB
JavaScript
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[8238],{43261:function(_e,V,n){var J=n(40749),y=n(67654),F=n(87841),M=n(99177),A=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),oe=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,I=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,A.Z)((0,M.Z)().mark(function g(s){var c,_,i,D;return(0,M.Z)().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,(c=(_=R.props).onClick)===null||c===void 0?void 0:c.call(_,s);case 2:if(D=h.sent,D!==!1){h.next=5;break}return h.abrupt("return");case 5:L==null||(i=L.current)===null||i===void 0||i.addEditRecord(I,{position:U,newRecordType:x,parentKey:b});case 6:case"end":return h.stop()}},g)}));function m(g){return W.apply(this,arguments)}return m}()}))}function le(e){var R,I,U=(0,ne.YB)(),x=e.onTableChange,b=e.maxLength,L=e.formItemProps,W=e.recordCreatorProps,m=e.rowKey,g=e.controlled,s=e.defaultValue,c=e.onChange,_=e.editableFormRef,i=(0,F.Z)(e,Z),D=(0,C.useRef)(void 0),a=(0,C.useRef)(),h=(0,C.useRef)();(0,C.useImperativeHandle)(i.actionRef,function(){return a.current},[a.current]);var K=(0,re.Z)(function(){return e.value||s||[]},{value:e.value,onChange:e.onChange}),ue=(0,y.Z)(K,2),u=ue[0],ve=ue[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>=u.length)return r;var o=u&&u[r];return S==null?void 0:S(o,r)}if((typeof r=="string"||r>=u.length)&&e.name){var l=u.findIndex(function(d,v){var P;return(S==null||(P=S(d,v))===null||P===void 0?void 0:P.toString())===(r==null?void 0:r.toString())});if(l!==-1)return l}return r};(0,C.useImperativeHandle)(_,function(){var E=function(l){var d,v;if(l==null)throw new Error("rowIndex is required");var P=se(l),T=[e.name,(d=P==null?void 0:P.toString())!==null&&d!==void 0?d:""].flat(1).filter(Boolean);return(v=h.current)===null||v===void 0?void 0:v.getFieldValue(T)},r=function(){var l,d=[e.name].flat(1).filter(Boolean);if(Array.isArray(d)&&d.length===0){var v,P=(v=h.current)===null||v===void 0?void 0:v.getFieldsValue();return Array.isArray(P)?P:Object.keys(P).map(function(T){return P[T]})}return(l=h.current)===null||l===void 0?void 0:l.getFieldValue(d)};return(0,t.Z)((0,t.Z)({},h.current),{},{getRowData:E,getRowsData:r,setRowData:function(l,d){var v,P;if(l==null)throw new Error("rowIndex is required");var T=se(l),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(l)),d||{})),Oe=(0,B.Z)({},X,Me);return(P=h.current)===null||P===void 0||P.setFieldsValue(Oe),!0}})},[e.name,h.current]),(0,C.useEffect)(function(){e.controlled&&u.forEach(function(E,r){var o;(o=h.current)===null||o===void 0||o.setFieldsValue((0,J.Z)({},S(E,r),E))},{})},[(0,ae.P)(u),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,ie=$.position,me=$.creatorButtonText,he=$.newRecordType,Ee=$.parentKey,ge=$.style,De=(0,F.Z)($,q),ce=ie==="top",Q=(0,C.useMemo)(function(){return typeof b=="number"&&b<=(u==null?void 0:u.length)?!1:W!==!1&&(0,f.jsx)(Y,{record:(0,p.h)(fe,u==null?void 0:u.length,u)||{},position:ie,parentKey:(0,p.h)(Ee,u==null?void 0:u.length,u),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%"},ge),icon:(0,f.jsx)(j.Z,{})},De),{},{children:me||U.getMessage("editableTable.action.add","\u6DFB\u52A0\u4E00\u884C\u6570\u636E")}))})},[W,b,u==null?void 0:u.length]),Pe=(0,C.useMemo)(function(){return Q?ce?{components:{header:{wrapper:function(r){var o,l=r.className,d=r.children;return(0,f.jsxs)("thead",{className:l,children:[d,(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:(o=i.columns)===null||o===void 0?void 0:o.length,children:Q})]})]})}}}}:{tableViewRender:function(r,o){var l,d;return(0,f.jsxs)(f.Fragment,{children:[(l=(d=e.tableViewRender)===null||d===void 0?void 0:d.call(e,r,o))!==null&&l!==void 0?l:o,Q]})}}:{}},[ce,Q]),de=(0,t.Z)({},e.editable),Ce=(0,N.J)(function(E,r){var o,l,d;if((o=e.editable)===null||o===void 0||(l=o.onValuesChange)===null||l===void 0||l.call(o,E,r),(d=e.onValuesChange)===null||d===void 0||d.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||(I=e.editable)!==null&&I!==void 0&&I.onValuesChange||e.controlled&&e!==null&&e!==void 0&&e.onChange)&&(de.onValuesChange=Ce),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ee.Provider,{value:a,children:(0,f.jsx)(oe.Z,(0,t.Z)((0,t.Z)((0,t.Z)({search:!1,options:!1,pagination:!1,rowKey:m,revalidateOnFocus:!1},i),Pe),{},{tableLayout:"fixed",actionRef:a,onChange:x,editable:(0,t.Z)((0,t.Z)({},de),{},{formProps:(0,t.Z)({formRef:h},de.formProps)}),dataSource:u,onDataSourceChange:function(r){if(ve(r),e.name&&ie==="top"){var o,l=(0,B.Z)({},[e.name].flat(1).filter(Boolean),r);(o=h.current)===null||o===void 0||o.setFieldsValue(l)}}}))}),e.name?(0,f.jsx)(H.Z,{name:[e.name],children:function(r){var o,l;if(!D.current)return D.current=u,null;var d=(0,O.Z)(r,[e.name].flat(1)),v=d==null?void 0:d.find(function(P,T){var X;return!(0,z.A)(P,(X=D.current)===null||X===void 0?void 0:X[T])});return D.current=u,v&&(e==null||(o=e.editable)===null||o===void 0||(l=o.onValuesChange)===null||l===void 0||l.call(o,v,d)),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)(le,(0,t.Z)((0,t.Z)({},e),{},{editable:(0,t.Z)((0,t.Z)({},e.editable),{},{form:R})}))})):(0,f.jsx)(le,(0,t.Z)({},e))}G.RecordCreator=Y,V.Z=G},85968:function(_e,V,n){var J=n(23674),y=n(62086),F=function(A){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:A.children});var z=N.indexOf(A.action);return z>=0?(0,y.jsx)("span",{children:A.children}):(0,y.jsx)(y.Fragment,{})};V.Z=F},25299:function(_e,V,n){n.r(V);var J=n(57213),y=n.n(J),F=n(25359),M=n.n(F),A=n(49811),t=n.n(A),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.GoodsCategoryController,C=B.goodsCategoryItems,ae=B.goodsCategoryCreate,oe=B.goodsCategoryDelete,f=B.goodsCategoryUpdate;V.default=function(){var Z=(0,w.useRef)(),q={id:"",name:"",sort:100},ee=(0,w.useState)(q),Y=H()(ee,2),le=Y[0],G=Y[1],e=(0,w.useState)([]),R=H()(e,2),I=R[0],U=R[1],x=function(){var m=t()(M()().mark(function g(s){var c,_,i;return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,oe(s);case 2:c=a.sent,_=c.success,_&&(Z.current.clearSelected(),(i=Z.current)===null||i===void 0||i.reload());case 5:case"end":return a.stop()}},g)}));return function(s){return m.apply(this,arguments)}}(),b=function(){var m=t()(M()().mark(function g(s){var c,_,i;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,_=c.success,_&&(G(q),(i=Z.current)===null||i===void 0||i.reload());case 6:case"end":return a.stop()}},g)}));return function(s){return m.apply(this,arguments)}}(),L=function(){var m=t()(M()().mark(function g(s){var c,_,i;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,_=c.success,_&&((i=Z.current)===null||i===void 0||i.reload());case 5:case"end":return a.stop()}},g)}));return function(s){return m.apply(this,arguments)}}(),W=[{title:"\u5206\u7C7B\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(g,s,c,_){return[(0,O.jsx)(k.Z,{action:"admin/goods_category/update",children:(0,O.jsx)(p.ZP,{type:"link",onClick:function(){var D;G(s),_==null||(D=_.startEditable)===null||D===void 0||D.call(_,s.id)},children:"\u7F16\u8F91"},"editable")},"admin/goods_category/update"),(0,O.jsx)(k.Z,{action:"admin/goods_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/goods_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 g(s,c,_){var i,D,a;return M()().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.next=2,C(y()(y()({},s),{},{sorter:c,filter:_}));case 2:return i=K.sent,D=i.data,a=i.success,K.abrupt("return",{data:D||[],total:0,success:a});case 6:case"end":return K.stop()}},g)}));return function(g,s,c){return m.apply(this,arguments)}}(),recordCreatorProps:{position:"top",record:function(){return{id:0}}},editable:{type:"multiple",editableKeys:I,onSave:function(){var m=t()(M()().mark(function s(c,_,i){return M()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:c?L(_):b(_);case 1:case"end":return a.stop()}},s)}));function g(s,c,_){return m.apply(this,arguments)}return g}(),onChange:U},columns:W,pagination:!1})})})}}}]);
|