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