|
- (self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[425],{33770:function(he,O,e){"use strict";e.r(O),e.d(O,{default:function(){return ae}});var me=e(57338),G=e(273),l=e(39428),h=e(3182),ve=e(57663),F=e(71577),pe=e(62350),U=e(24565),ye=e(34792),o=e(48086),T=e(2824),b=e(49101),y=e(67294),J=e(78009),K=e(85224),N=e(16894),z=e(12826),Ze=e(71194),H=e(50146),ge=e(9715),Z=e(55843),Ce=e(47673),w=e(4107),xe=e(43358),g=e(34041),t=e(85893),Q=function(s){var m=g.Z.Option,n=g.Z.OptGroup;return(0,t.jsx)(H.Z,{title:s.values.id?"\u7F16\u8F91":"\u65B0\u5EFA",width:640,visible:s.createModalVisible,bodyStyle:{padding:"32px 40px 48px"},footer:null,onCancel:function(){s.onCancel()},destroyOnClose:!0,maskClosable:!1,children:(0,t.jsxs)(Z.Z,{layout:"vertical",preserve:!1,initialValues:s.values,onFinish:s.onFinish,children:[(0,t.jsx)(Z.Z.Item,{name:"id",hidden:!0,children:(0,t.jsx)(w.Z,{})}),(0,t.jsx)(Z.Z.Item,{name:"name",label:"\u5546\u54C1\u5355\u4F4D\u540D\u79F0",rules:[{required:!0,max:64}],children:(0,t.jsx)(w.Z,{placeholder:"\u5546\u54C1\u5355\u4F4D\u540D\u79F0"})}),(0,t.jsx)(Z.Z.Item,{name:"status",label:"\u72B6\u6001",defaultValue:s.values.status,rules:[{required:!0,message:"\u8BF7\u9009\u62E9\u72B6\u6001"}],children:(0,t.jsx)(g.Z,{placeholder:"\u8BF7\u9009\u62E9\u72B6\u6001",children:(0,t.jsxs)(n,{children:[(0,t.jsx)(g.Z.Option,{value:"0",children:"\u6B63\u5E38"}),(0,t.jsx)(g.Z.Option,{value:"1",children:"\u505C\u7528"})]})})}),(0,t.jsxs)(Z.Z.Item,{children:[(0,t.jsx)(F.Z,{htmlType:"button",style:{float:"right",left:10},onClick:s.onCancel,children:"\u53D6\u6D88"}),(0,t.jsx)(F.Z,{type:"primary",htmlType:"submit",style:{float:"right"},children:"\u4FDD\u5B58"})]})]})})},X=Q,C=e(48971);function q(i){return R.apply(this,arguments)}function R(){return R=(0,h.Z)((0,l.Z)().mark(function i(s){return(0,l.Z)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",(0,C.WY)("/kitchen/api/goods-unit/type",{method:"Post",data:s}));case 1:case"end":return n.stop()}},i)})),R.apply(this,arguments)}function _(i){return E.apply(this,arguments)}function E(){return E=(0,h.Z)((0,l.Z)().mark(function i(s){return(0,l.Z)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",(0,C.WY)("/kitchen/api/goods-unit",{method:"POST",data:s}));case 1:case"end":return n.stop()}},i)})),E.apply(this,arguments)}function ee(i){return I.apply(this,arguments)}function I(){return I=(0,h.Z)((0,l.Z)().mark(function i(s){return(0,l.Z)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",(0,C.WY)("/kitchen/api/goods-unit",{method:"PUT",data:s}));case 1:case"end":return n.stop()}},i)})),I.apply(this,arguments)}function te(i){return $.apply(this,arguments)}function $(){return $=(0,h.Z)((0,l.Z)().mark(function i(s){return(0,l.Z)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return console.log(s),n.abrupt("return",(0,C.WY)("/kitchen/api/goods-unit",{method:"DELETE",data:s}));case 2:case"end":return n.stop()}},i)})),$.apply(this,arguments)}function ne(i){return B.apply(this,arguments)}function B(){return B=(0,h.Z)((0,l.Z)().mark(function i(s){return(0,l.Z)().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",(0,C.WY)("/kitchen/api/goods-unit/".concat(s),{method:"DELETE"}));case 1:case"end":return n.stop()}},i)})),B.apply(this,arguments)}var re=function(){var s=(0,y.useState)(!1),m=(0,T.Z)(s,2),n=m[0],x=m[1],ue=(0,y.useState)(!1),P=(0,T.Z)(ue,2),se=P[0],A=P[1],v=(0,y.useRef)(),le=(0,y.useState)(),W=(0,T.Z)(le,2),d=W[0],j=W[1],ie=(0,y.useState)([]),M=(0,T.Z)(ie,2),p=M[0],V=M[1];function oe(a){var r=o.default.loading("\u6B63\u5728\u6DFB\u52A0");try{return _(JSON.stringify(a)).then(function(u){u.succeeded?(v.current.reload(),o.default.success("\u6DFB\u52A0\u6210\u529F")):o.default.error(u.errors)}),r(),!0}catch(u){return o.default.error("\u6DFB\u52A0\u5931\u8D25\u8BF7\u91CD\u8BD5\uFF01"),!1}}function ce(a){try{return ee({id:a.id,name:a.name,status:a.status}).then(function(r){r.data?(o.default.success("\u4FEE\u6539\u6210\u529F"),v.current.reload()):o.default.error(r.errors)}),!0}catch(r){return o.default.error("\u4FEE\u6539\u5931\u8D25\u8BF7\u91CD\u8BD5\uFF01"),!1}}function de(){try{return te(p.map(function(a,r){return a.id})).then(function(a){a.data?o.default.success("\u5220\u9664\u6210\u529F"):o.default.error(a.errors)}),v.current.reload(),!0}catch(a){o.default.error("\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}function fe(a){try{return ne(a).then(function(r){r.data?(o.default.success("\u5220\u9664\u6210\u529F"),v.current.reload()):o.default.error(r.errors)}),!0}catch(r){o.default.error("\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}var Y=[{title:"\u4E3B\u952E",dataIndex:"id",tip:"\u89C4\u5219\u540D\u79F0\u662F\u552F\u4E00\u7684 key",hideInSearch:!0,hideInTable:!0,render:function(r,u){return(0,t.jsx)("a",{onClick:function(){j(u),A(!0)},children:r})}},{title:"\u540D\u79F0",dataIndex:"name",valueType:"textarea",ellipsis:!0},{title:"\u72B6\u6001",dataIndex:"status",hideInForm:!0,valueEnum:{0:{text:"\u6B63\u5E38",status:"Processing"},1:{text:"\u505C\u7528",status:"Success"}}},{title:"\u64CD\u4F5C",dataIndex:"option",valueType:"option",render:function(r,u){return[(0,t.jsx)("a",{onClick:function(){x(!0),j(u)},children:"\u66F4\u65B0"},"config"),(0,t.jsx)(U.Z,{type:"primary",title:"\u786E\u8BA4\u5220\u9664\u5417\uFF1F",okText:"\u662F",cancelText:"\u5426",onConfirm:function(){fe(u.id)},onCancel:function(){},children:(0,t.jsx)("a",{href:"#",children:"\u5220\u9664"})},"primary")]}}];return(0,t.jsxs)(J.ZP,{children:[(0,t.jsx)(N.ZP,{headerTitle:"\u5546\u54C1\u5355\u4F4D",actionRef:v,rowKey:"id",search:{labelWidth:120},columns:Y,toolBarRender:function(){return[(0,t.jsxs)(F.Z,{type:"primary",onClick:function(){x(!0),j({})},children:[(0,t.jsx)(b.Z,{})," \u65B0\u5EFA"]},"primary")]},request:function(){var a=(0,h.Z)((0,l.Z)().mark(function r(u){var c,D;return(0,l.Z)().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return c=[],D=0,S.next=4,q(u).then(function(L){c=L.data.data,c.forEach(function(k){k.status=k.status.toString()}),D=L.data.total});case 4:return S.abrupt("return",{data:c,success:!0,total:D});case 5:case"end":return S.stop()}},r)}));return function(r){return a.apply(this,arguments)}}(),rowSelection:{onChange:function(r,u){V(u)}}}),(p==null?void 0:p.length)>0&&(0,t.jsx)(K.Z,{extra:(0,t.jsxs)("div",{children:["\u5DF2\u9009\u62E9"," ",(0,t.jsx)("a",{style:{fontWeight:600},children:p.length})," ","\u9879 \xA0\xA0"]}),children:(0,t.jsx)(F.Z,{onClick:function(){var r,u;de(p),V([]),(r=v.current)===null||r===void 0||(u=r.reloadAndRest)===null||u===void 0||u.call(r)},type:"primary",children:"\u6279\u91CF\u5220\u9664"},"primary")}),(0,t.jsx)(X,{onFinish:function(){var a=(0,h.Z)((0,l.Z)().mark(function r(u){var c;return(0,l.Z)().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(c=!1,!u.id){f.next=7;break}return f.next=4,ce(u);case 4:c=f.sent,f.next=10;break;case 7:return f.next=9,oe(u);case 9:c=f.sent;case 10:c&&(x(!1),v.current&&v.current.reload());case 11:case"end":return f.stop()}},r)}));return function(r){return a.apply(this,arguments)}}(),onCancel:function(){j(void 0),x(!1)},createModalVisible:n,values:d||{}}),(0,t.jsx)(G.Z,{width:600,visible:se,onClose:function(){j(void 0),A(!1)},closable:!1,children:(d==null?void 0:d.name)&&(0,t.jsx)(z.ZP,{column:2,title:d==null?void 0:d.name,request:(0,h.Z)((0,l.Z)().mark(function a(){return(0,l.Z)().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",{data:d||{}});case 1:case"end":return u.stop()}},a)})),params:{id:d==null?void 0:d.name},columns:Y})})]})},ae=re}}]);
|