|
|
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[86820],{56279:function(e,n,t){t.r(n),t.d(n,{default:function(){return V}});var s=t(82242),a=t.n(s),i=t(7557),r=t.n(i),c=t(37205),o=t.n(c),l=t(41498),d=t.n(l),u=t(79800),m=t.n(u),p=t(59301),h=t(49389),f=t(78241),x=t(8591),_=t(66104),j=t(10249),v=t(54580),Z=t(3113),g=t(59081),w=t(76794),y=t(91689),b="bg___VqFqM",k="formWrap___iwUem",I="fieldWrap___tSPUZ",N="mdWrap___C7Agk",F="backgroundFa___FaNz_",C="button___fqiOn",S=t(37712),V=(0,h.connect)((function(e){var n=e.shixunHomeworks,t=e.newCourse,s=e.loading;return{shixunHomeworks:n,newCourse:t,globalSetting:e.globalSetting,loading:s.effects}}))((function(e){var n,t=e.shixunHomeworks,s=(e.newCourse,e.globalSetting,e.loading,e.dispatch),i=(e.match,(0,h.useParams)()),c=f.Z.useForm(),l=m()(c,1)[0],u=(0,p.useState)({}),V=m()(u,2),L=V[0],P=V[1],H=(0,p.useState)(!1),q=m()(H,2),E=q[0],W=q[1],D=(0,p.useState)([]),z=m()(D,2),B=z[0],M=z[1],T=(0,p.useState)([]),A=m()(T,2),R=A[0],U=A[1],O=t.commonHomeWorkEditDefaultData,G={name:"file",multiple:!0,action:y.Z.API_SERVER+"/api/attachments.json",defaultFileList:B,onChange:function(e){var n=e.file.status;"done"===n?x.ZP.success("".concat(e.file.name," 文件上传成功")):"error"===n&&x.ZP.error("".concat(e.file.name," 文件上传失败"))}};(0,p.useEffect)((function(){K()}),[i.topicId]);var J=function(e){return null==e?void 0:e.map((function(e){return{uid:e.id,response:{id:e.id},name:e.title,status:"done",url:e.url}}))},K=function(){var e=d()(r()().mark((function e(){var n;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s({type:"shixunHomeworks/editCommonHomeWorkDefaultBankData",payload:{id:i.topicId}});case 2:(n=e.sent)&&(l.setFieldsValue({name:n.name}),l.setFieldsValue({description:n.description}),l.setFieldsValue({reference_answer:n.reference_answer}),M(o()(J(n.attachments))),U(o()(J(n.reference_attachments))),W(!0));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=d()(r()().mark((function e(n){var t,s,c;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=a()({},L)).attachment_ids&&(t.attachment_ids=null==t||null===(s=t.attachment_ids.fileList)||void 0===s?void 0:s.map((function(e){var n;return null===(n=e.response)||void 0===n?void 0:n.id}))),t.reference_attachment_ids&&(t.reference_attachment_ids=null==t||null===(c=t.reference_attachment_ids.fileList)||void 0===c?void 0:c.map((function(e){var n;return null===(n=e.response)||void 0===n?void 0:n.id}))),e.next=5,(0,w.yT)(a()(a()({id:i.topicId},t),{},{base_on_project:null,type:1}));case 5:e.sent&&h.history.push("/users/".concat(i.username,"/topics/").concat(i.topicId,"/").concat(i.topictype,"/normal/detail"));case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,S.jsxs)("section",{className:b,children:[(0,S.jsx)("section",{className:"animated fadeIn",children:(0,S.jsx)("aside",{className:"mt10",children:(0,S.jsxs)(_.Z,{separator:">",children:[(0,S.jsx)(_.Z.Item,{children:(0,S.jsx)(h.Link,{to:"/users/".concat(i.username,"/").concat("personal"===i.topictype?"topics":"topicbank","/").concat(i.topictype),children:"personal"===i.topictype?"我的课堂资源":"公共题库"})}),(0,S.jsx)(_.Z.Item,{children:(0,S.jsx)(h.Link,{to:"/users/".concat(i.username,"/topics/").concat(i.topicId,"/").concat(i.topictype,"/normal/detail"),children:"详情"})}),(0,S.jsx)(_.Z.Item,{children:"编辑"})]})})}),(0,S.jsx)("aside",{className:"font24 bold mt20 mb20",children:"编辑"}),(0,S.jsxs)(f.Z,{form:l,className:k,scrollToFirstError:!0,layout:"vertical",onValuesChange:function(){P(a()({},l.getFieldsValue()))},onFinish:Q,children:[(0,S.jsx)("div",{className:I,children:(0,S.jsx)(f.Z.Item,{name:"name",label:"标题:",rules:[{required:!0,message:"请输入标题"}],children:(0,S.jsx)(j.Z,{maxLength:60,suffix:"".concat((null===(n=L.name)||void 0===n?void 0:n.length)||0,"/60"),placeholder:"例如:从Python程序设计-入门精通"})})}),(0,S.jsxs)("div",{className:N,children:[(0,S.jsx)(f.Z.Item,{name:"description",label:"简介:",rules:[{required:!0,message:"请输入作业的简介"},{max:5e3,message:"作业简介最大限制5000个字符"}],children:(0,S.jsx)(g.Z,{id:"topic-normal-description",watch:!0,defaultValue:O.description})}),(0,S.jsx)("div",{children:(0,S.jsx)(f.Z.Item,{name:"attachment_ids",children:E&&(0,S.jsxs)(v.Z,a()(a()({defaultFileList:B},G),{},{children:[(0,S.jsx)("span",{className:"c-blue",children:"上传附件"})," (单个文件150MB以内)"]}))})})]}),(0,S.jsxs)("div",{className:N,children:[(0,S.jsx)(f.Z.Item,{name:"reference_answer",label:"参考答案:",children:(0,S.jsx)(g.Z,{id:"topic-normal-reference_answer",defaultValue:O.reference_answer,watch:!0})}),(0,S.jsx)("div",{children:(0,S.jsx)(f.Z.Item,{name:"reference_attachment_ids",children:E&&(0,S.jsxs)(v.Z,a()(a()({},G),{},{defaultFileList:R,children:[(0,S.jsx)("span",{className:"c-blue",children:"上传附件"})," (单个文件150MB以内)"]}))})})]}),(0,S.jsx)("div",{className:F,children:(0,S.jsx)("div",{className:"pt40 mb30",children:(0,S.jsxs)(f.Z.Item,{children:[(0,S.jsx)(Z.ZP,{size:"middle",type:"primary",className:"".concat(C," mr20"),htmlType:"submit",children:"提交"}),(0,S.jsx)(Z.ZP,{size:"middle",type:"primary",ghost:!0,className:C,onClick:function(){return h.history.push("/users/".concat(i.username,"/topics/").concat(i.topicId,"/").concat(i.topictype,"/normal/detail"))},children:"取消"})]})})})]})]})}))}}]); |