"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[44216],{91936:function(e,n,s){s.r(n);var t=s(7557),r=s.n(t),a=s(41498),o=s.n(a),i=s(82242),l=s.n(i),c=s(79800),u=s.n(c),d=s(59301),h=s(49389),m=s(78241),p=s(66104),g=s(8591),x=s(10249),f=s(5112),v=s(57809),j=s(3113),_=s(7338),y=s(94171),k=s(59081),w=s(37712);n.default=(0,h.connect)((function(e){return{user:e.user}}))((function(e){var n,s,t=e.user,a=(0,d.useState)(l()(l()({},(0,h.useParams)()),{},{page:1,per_page:10,type:1,sort_by:"",course_group:(0,_.dE)()?[t.userInfo.course.course_group_id]:[]})),i=u()(a,2),c=i[0],Z=(i[1],(0,d.useState)([])),b=u()(Z,2),I=b[0],P=b[1],B=m.Z.useForm(),C=u()(B,1)[0],F=(0,d.useState)({}),V=u()(F,2),L=V[0],S=V[1];function q(){return(q=o()(r()().mark((function e(){var n,s,t;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,y.ZP)("/api/homework_commons/".concat(c.categoryId,"/get_hack_list.json"),{method:"get",params:l()(l()({},c),{},{type:1})});case 2:return s=e.sent,P(s),e.next=6,(0,y.ZP)("/api/hack_messages/".concat(c.answerid,".json"),{method:"get",params:l()(l()({},c),{},{type:1})});case 6:t=e.sent,C.setFieldsValue(l()(l()({},null==t?void 0:t.data),{},{message_type:(null==t||null===(n=t.data)||void 0===n?void 0:n.message_type)+""})),S(l()({},null==t?void 0:t.data));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return(0,d.useEffect)((function(){!function(){q.apply(this,arguments)}()}),[]),(0,w.jsxs)("div",{style:{width:1200,margin:"0px auto",marginBottom:"20px"},children:[(0,w.jsxs)(p.Z,{separator:">",style:{marginTop:20},children:[(0,w.jsx)(p.Z.Item,{children:(0,w.jsx)(h.Link,{to:"/classrooms/".concat(null==I?void 0:I.course_id,"/program_homework"),children:null==I?void 0:I.course_name})}),(0,w.jsx)(p.Z.Item,{children:(0,w.jsx)(h.Link,{to:"/classrooms/".concat(null==I?void 0:I.course_id,"/program_homework/").concat(null==I?void 0:I.homework_id,"/detail"),children:null==I?void 0:I.homework_name})}),(0,w.jsx)(p.Z.Item,{children:(0,w.jsx)(h.Link,{to:"/classrooms/".concat(null==I?void 0:I.course_id,"/program_homework/").concat(null==I?void 0:I.homework_id,"/answer"),children:"题解&问答"})}),(0,w.jsxs)(p.Z.Item,{children:["修改",(0,_.eB)()?"广播":"答疑"]})]}),(0,w.jsxs)("div",{style:{marginTop:10,padding:"20px",background:"#fff"},children:[(0,w.jsxs)("p",{style:{fontSize:18,fontWeight:400},children:["发布",(0,_.eB)()?"广播":"答疑"]}),(0,w.jsxs)(m.Z,{layout:"vertical",form:C,onValuesChange:function(){console.log("onchange: ",C.getFieldsValue()),S(l()({},C.getFieldsValue()))},onFinish:function(){var e=o()(r()().mark((function e(n){return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,y.ZP)("/api/hack_messages/".concat(c.answerid,".json"),{method:"PUT",body:l()(l()({},n),{},{message_type:(0,_.eB)()?parseInt(n.message_type):1})});case 2:0===e.sent.status&&(g.ZP.info("修改成功"),h.history.push("/classrooms/".concat(null==I?void 0:I.course_id,"/program_homework/").concat(null==I?void 0:I.homework_id,"/answer/").concat(c.answerid,"/detail")));case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),children:[(0,w.jsx)(m.Z.Item,{label:"标题",name:"name",rules:[{required:!0,message:"请输入标题"}],children:(0,w.jsx)(x.Z,{maxLength:30,suffix:"".concat((null===(n=L.name)||void 0===n?void 0:n.length)||0,"/30"),placeholder:"请输入名称"})}),(0,_.eB)()&&(0,w.jsx)(m.Z.Item,{label:"广播类型",name:"message_type",rules:[{required:!0,message:"请选择广播类型"}],children:(0,w.jsxs)(f.ZP.Group,{children:[(0,w.jsx)(f.ZP,{value:"2",children:"题解"}),(0,w.jsx)(f.ZP,{value:"3",children:"通知"})]})}),(0,w.jsx)(m.Z.Item,{label:"选择试题",name:"hack_id",children:(0,w.jsx)(v.default,{style:{width:400},children:null==I||null===(s=I.data)||void 0===s?void 0:s.map((function(e){return(0,w.jsx)(v.default.Option,{value:e.id,children:e.name})}))})}),(0,w.jsx)(m.Z.Item,{name:"content",label:"内容",rules:[{required:!0,message:"请输入内容"}],children:(0,w.jsx)(k.Z,{watch:!0,defaultValue:L.content})})]}),(0,w.jsxs)("div",{style:{width:"100%",textAlign:"end"},children:[(0,w.jsx)(j.ZP,{onClick:function(){h.history.back()},style:{marginRight:20,width:82,height:32},children:"取消"}),(0,w.jsx)(j.ZP,{onClick:function(){C.submit()},type:"primary",style:{width:82,height:32},children:"发布"})]})]})]})}))}}]);