You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
5.9 KiB
1 line
5.9 KiB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[74264],{19289:function(e,n,t){t.r(n),t.d(n,{default:function(){return D}});var s=t(7557),a=t.n(s),i=t(41498),r=t.n(i),l=t(82242),o=t.n(l),c=t(79800),d=t.n(c),u=t(39647),m=t.n(u),f=t(59301),h=t(49389),p=t(57809),v=t(78241),x=t(8591),j=t(66104),g=t(10249),_=t(3113),b=t(59081),w=t(90269),y=t(4440),N="bg___pOKLN",k="formWrap___D8WBe",I="fieldWrap___XNrtY",Z="mdWrap___gRykC",S="backgroundFa___jKoLp",C="button___f0Fqa",F=t(37712),L=["forumsDetail","globalSetting","loading","dispatch"],q=p.default.Option,D=(0,h.connect)((function(e){var n=e.forumsDetail,t=e.loading;return{forumsDetail:n,globalSetting:e.globalSetting,loading:t.models.forumsDetail}}))((function(e){e.forumsDetail,e.globalSetting,e.loading,e.dispatch,m()(e,L);var n,t,s,i=(0,h.useParams)(),l=v.Z.useForm(),c=d()(l,1)[0],u=(0,f.useState)({}),D=d()(u,2),P=D[0],V=D[1],z=(0,f.useState)(0),O=d()(z,2),W=O[0],R=O[1],T=(0,f.useState)(!1),E=d()(T,2),K=E[0],X=E[1],B=(0,f.useState)({}),M=d()(B,2),Y=M[0],A=M[1],G=(0,f.useState)(1),H=d()(G,2),J=H[0],Q=H[1];(0,f.useEffect)((function(){if(U(),i.memoId)X(!0),$();else{X(!1);var e={forum_id:5};V(o()({},e)),c.setFieldsValue(o()({},e))}}),[i.memoId]);var U=function(){var e=r()(a()().mark((function e(){var n;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,y.iI)({});case 2:n=e.sent,A(n||{});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$=function(){var e=r()(a()().mark((function e(){var n,t,s;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,y.qR)({id:i.memoId});case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0={};case 5:t=e.t0,s={subject:t.subject,content:t.content,attachments:(0,w.z)(t.attachments),forum_id:t.forum_id,memo_tags:null===(n=t.memo_tags)||void 0===n?void 0:n.map((function(e){return e.id}))},V(o()({},s)),c.setFieldsValue(o()({},s));case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=r()(a()().mark((function e(n){var t,s,r;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=o()(o()({id:K?i.memoId:null},P),{},{attachment_ids:null===(t=P.attachments)||void 0===t||null===(t=t.filter((function(e){var n;return null===(n=e.response)||void 0===n?void 0:n.id})))||void 0===t?void 0:t.map((function(e){var n;return null===(n=e.response)||void 0===n?void 0:n.id})),tags:P.memo_tags}),!K){e.next=7;break}return e.next=4,(0,y.b4)(s);case 4:e.t0=e.sent,e.next=10;break;case 7:return e.next=9,(0,y.dX)(s);case 9:e.t0=e.sent;case 10:r=e.t0,R(0),0===(null==r?void 0:r.status)&&(x.ZP.success(null==r?void 0:r.message),1===J?h.history.push("/forums/".concat(K?null==i?void 0:i.memoId:null==r?void 0:r.memo_id)):h.history.push("/forums/".concat(K?null==i?void 0:i.memoId:null==r?void 0:r.memo_id,"/edit")));case 13:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,F.jsxs)("section",{className:N,children:[(0,F.jsx)("section",{className:"animated fadeIn mb10",children:(0,F.jsx)("aside",{className:"mt10",children:(0,F.jsxs)(j.Z,{separator:"/",children:[(0,F.jsx)(j.Z.Item,{children:(0,F.jsx)(h.Link,{to:"/forums",children:"交流问答"})}),(0,F.jsx)(j.Z.Item,{children:"详情"})]})})}),(0,F.jsx)("aside",{className:"bg-white font16 pt20 pb20 pl20",children:K?"编辑话题":"发布话题"}),(0,F.jsxs)(v.Z,{form:c,className:k,scrollToFirstError:!0,layout:"vertical",onValuesChange:function(e,n){console.log(n,"values"),V(o()(o()({},P),e))},onFinish:ee,onFinishFailed:function(){R(0)},children:[(0,F.jsx)("div",{className:I,children:(0,F.jsx)(v.Z.Item,{name:"subject",label:(0,F.jsx)("span",{className:"font16",children:"话题名称: "}),rules:[{required:!0,message:"请先输入话题名称"}],children:(0,F.jsx)(g.Z,{maxLength:50,suffix:"".concat((null===(n=P.subject)||void 0===n?void 0:n.length)||0,"/50")})})}),(0,F.jsxs)("div",{className:Z,children:[(0,F.jsx)(v.Z.Item,{name:"content",label:(0,F.jsx)("span",{className:"font16",children:"内容: "}),rules:[{required:!0,message:"请先输入话题内容"}],children:(0,F.jsx)(b.Z,{height:600,id:"forums-new-content",watch:!0,defaultValue:P.content})}),(0,F.jsx)("div",{children:(0,F.jsx)(v.Z.Item,{name:"attachments",style:{width:350},children:(0,F.jsx)(w.Z,{showRemoveModal:!0})})})]}),(0,F.jsx)("div",{className:Z,children:(0,F.jsx)(v.Z.Item,{name:"forum_id",label:(0,F.jsx)("span",{className:"font16",children:"话题类型: "}),rules:[{required:!0,message:"请先选择话题类型"}],children:(0,F.jsx)(p.default,{style:{width:300},children:null==Y||null===(t=Y.forums)||void 0===t?void 0:t.map((function(e){return(0,F.jsx)(q,{value:e.id,children:e.name},e.id)}))})})}),5===P.forum_id&&(0,F.jsx)("div",{className:Z,children:(0,F.jsx)(v.Z.Item,{name:"memo_tags",label:(0,F.jsx)("span",{className:"font16",children:"技术标签: "}),rules:[{required:!0,message:"请先选择技术标签"}],children:(0,F.jsx)(p.default,{style:{width:300},placeholder:"请选择技术标签",mode:"multiple",tokenSeparators:[";"],filterOption:function(e,n){return-1!=n.props.children.toLocaleLowerCase().indexOf(e.toLocaleLowerCase())},children:null==Y||null===(s=Y.tag_list)||void 0===s?void 0:s.map((function(e){return(0,F.jsx)(q,{value:e.id,children:e.name},e.id)}))})})}),(0,F.jsx)("div",{className:S,children:(0,F.jsx)("div",{className:"pt40 mb30",children:(0,F.jsxs)(v.Z.Item,{children:[(0,F.jsx)(_.ZP,{size:"middle",type:"primary",className:"".concat(C," mr20"),htmlType:"submit",loading:1===W,onClick:function(){Q(1),R(1)},children:"提交"}),(0,F.jsx)(_.ZP,{size:"middle",type:"primary",className:"".concat(C," mr20"),htmlType:"submit",loading:2===W,onClick:function(){Q(2),R(2)},children:"保存"}),(0,F.jsx)(_.ZP,{size:"middle",type:"primary",ghost:!0,className:"".concat(C," mr20"),onClick:function(){document.body.scrollIntoView(),window.location.href.includes("new")?h.history.back():h.history.push("/forums/".concat(i.memoId))},children:"取消"})]})})})]})]})}))}}]); |