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.
NewEduCoderBuild/p__Classrooms__Lists__Polls...

1 line
6.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[39695,28723],{87470:function(e,t,s){s.r(t),s.d(t,{default:function(){return F}});var n=s(7557),i=s.n(n),r=s(41498),a=s.n(r),l=s(37205),o=s.n(l),c=s(82242),d=s.n(c),u=s(79800),p=s.n(u),_=s(59301),x=s(64515),f=s(78241),m=s(8591),h=s(28103),b=s(66104),j=s(95237),v=s(43604),y=s(10249),g=s(3113),Z=s(14323),k={flex_box_center:"flex_box_center___awg_W",flex_space_between:"flex_space_between___vs3La",flex_box_vertical_center:"flex_box_vertical_center___I3QTf",flex_box_center_end:"flex_box_center_end___fRTLL",flex_box_column:"flex_box_column___Z539C",bg:"bg___Dw6dz",title:"title___Z4aJr",titleLeft:"titleLeft___hTg4o",titleRight:"titleRight___mYUY7"},q=s(30406),w=s(99645),I=s(32134),L=s(89763),N=s(95238),P=s(25186),C=s(37712),F=(0,x.connect)((function(e){var t=e.classroomList,s=e.loading,n=e.user;return{classroomList:t,globalSetting:e.globalSetting,user:n,loading:s.effects}}))((function(e){e.classroomList,e.globalSetting,e.loading;var t,s=e.user,n=e.dispatch,r=(0,x.useParams)();(0,_.useEffect)((function(){setTimeout((function(){document.body.scrollIntoView()}),300)}),[]);var l=s.userInfo,c=f.Z.useForm(),u=p()(c,1)[0],F=(0,_.useState)([]),S=p()(F,2),T=S[0],D=S[1],R=(0,_.useState)(-1),J=p()(R,2),K=J[0],V=J[1],A=(0,_.useRef)(),Y=function(e,t,s){switch(e){case"edit":-1===K||-1===t?(K=t,V(t)):m.ZP.error("不能同时编辑两题");break;case"add":if(-1!=K)return void m.ZP.error("不能同时编辑两题");delete t.id,T.splice(null==t?void 0:t.key,0,{insert_id:null==t?void 0:t.insert_id,question:d()({},t)}).slice(),D(o()(T)),V((null==t?void 0:t.key)+1);break;case"addContinue":D(o()(t));break;case"del":T.splice(t-1,1),D(o()(T)),V(-1);break;case"isadd":T[K-1]={question:t},s?(V(T.length+1),D([].concat(o()(T),[{question:{question_type:s}}]))):(D(o()(T)),V(-1))}},z=function(){var e=a()(i()().mark((function e(t){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===K){e.next=3;break}return m.ZP.error("不能同时编辑两题"),e.abrupt("return");case 3:V(T.length+1),D([].concat(o()(T),[{question:{question_type:t}}]));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(0,C.jsxs)("section",{className:"edu-container",children:[(0,C.jsxs)("section",{className:"animated fadeIn",children:[(0,C.jsx)("aside",{className:"mt10",children:l&&(0,C.jsxs)(b.Z,{separator:">",children:[(0,C.jsx)(b.Z.Item,{children:(0,C.jsx)(x.Link,{to:"".concat(l.first_category_url),children:null==l||null===(t=l.course)||void 0===t?void 0:t.course_name})}),(0,C.jsx)(b.Z.Item,{children:(0,C.jsx)(x.Link,{to:"/classrooms/".concat(r.coursesId,"/poll"),children:"问卷列表"})}),(0,C.jsx)(b.Z.Item,{children:"新建问卷"})]})}),(0,C.jsx)("aside",{className:[k.title,"mt20"].join(" "),children:(0,C.jsxs)(j.Z,{style:{width:"100%"},children:[(0,C.jsx)(v.Z,{flex:"1",children:(0,C.jsx)("strong",{className:"font20 ml5",children:"新建问卷"})}),(0,C.jsx)(v.Z,{children:(0,C.jsx)(x.Link,{className:"font16 c-light-black",to:"/classrooms/".concat(r.coursesId,"/poll"),children:"返回"})})]})})]}),(0,C.jsx)("section",{className:[k.bg,"pt30","pl30","pr30","pb30","mt20"].join(" "),children:(0,C.jsxs)(f.Z,{layout:"vertical",form:u,children:[(0,C.jsx)(f.Z.Item,{name:"polls_name",label:"问卷标题:",rules:[{required:!0,message:"请填写问卷标题"}],children:(0,C.jsx)(y.Z,{maxLength:60,placeholder:"问卷标题最大限制60个字符"})}),(0,C.jsx)(f.Z.Item,{label:"问卷须知:",name:"polls_description",children:(0,C.jsx)(w.Z,{watch:!0,placeholder:"请在此输入本次问卷答题的相关说明,最大限制5000字"})}),""!=T&&(0,C.jsx)("section",{className:[k.bg,"pt30","pl20","pr20","pb20","mt20"].join(" "),children:null==T?void 0:T.map((function(e,t){var s;return e.key=t+1,e.len=T.length,1===e.question.question_type?(0,C.jsxs)("aside",{children:[(0,C.jsx)(N.Z,{ref:A,editKey:K,polls_status:1,isadd:!0,callback:Y,editData:e}),(0,C.jsx)(h.Z,{})]},e.id):2===e.question.question_type?(0,C.jsxs)("aside",{children:[(0,C.jsx)(L.Z,{ref:A,editKey:K,polls_status:1,isadd:!0,callback:Y,editData:e}),(0,C.jsx)(h.Z,{})]},e.id):3===(null===(s=e.question)||void 0===s?void 0:s.question_type)?(0,C.jsxs)("aside",{children:[(0,C.jsx)(P.Z,{ref:A,editKey:K,polls_status:1,isadd:!0,callback:Y,editData:e}),(0,C.jsx)(h.Z,{})]},e.id):void 0}))}),(0,C.jsx)("section",{className:[k.bg,"pt30","pl30","pr30","pb30","mt20"].join(" "),children:[{name:"单选题",id:1},{name:"多选题",id:2},{name:"主观题",id:3}].map((function(e){return(0,C.jsxs)(g.ZP,{className:"mr20",type:"primary",onClick:function(){return z(e.id)},children:[(0,C.jsx)(I.Z,{className:"mr5"}),e.name]})}))}),(0,C.jsxs)(f.Z.Item,{className:"tr",children:[(0,C.jsx)(g.ZP,{type:"primary",onClick:a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:x.history.back();case 1:case"end":return e.stop()}}),e)}))),children:"取消"}),(0,C.jsx)(g.ZP,{type:"primary",style:{margin:"0px 20px"},onClick:a()(i()().mark((function e(){var t,s,n,a;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.validateFields();case 2:if((s=u.getFieldValue()).is_md=!0,!((null===(t=T.filter((function(e){return e.question.question_title})))||void 0===t?void 0:t.length)<=0)){e.next=7;break}return m.ZP.info("请至少添加一道试题"),e.abrupt("return");case 7:return e.next=9,(0,Z.rJ)(d()(d()(d()({},s),r),{},{poll_questions:T.map((function(e){return e.question}))}));case 9:0===(n=e.sent).status&&((0,q.L9)(["教学课堂","问卷","新建问卷"]),x.history.push("/classrooms/".concat(r.coursesId,"/poll/").concat(null===(a=n.data)||void 0===a?void 0:a.id,"/detail?tabs=2")));case 11:case"end":return e.stop()}}),e)}))),children:"保存"}),(0,C.jsx)(g.ZP,{type:"primary",onClick:a()(i()().mark((function e(){var t,s,a,l,o,c;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.validateFields();case 2:if((s=u.getFieldValue()).is_md=!0,!((null===(t=T.filter((function(e){return e.question.question_title})))||void 0===t?void 0:t.length)<=0)){e.next=7;break}return m.ZP.info("请至少添加一道试题"),e.abrupt("return");case 7:return e.next=9,(0,Z.rJ)(d()(d()(d()({},s),r),{},{poll_questions:T.map((function(e){return e.question}))}));case 9:0===(a=e.sent).status&&((0,q.L9)(["教学课堂","问卷","新建问卷"]),x.history.push("/classrooms/".concat(r.coursesId,"/poll/").concat(null===(l=a.data)||void 0===l?void 0:l.id,"/detail?tabs=2")),n({type:"polls/setActionTabs",payload:{key:"立即发布",selectArrs:[null===(o=a.data)||void 0===o?void 0:o.id],types:2,params:{categoryId:null===(c=a.data)||void 0===c?void 0:c.id}}}));case 11:case"end":return e.stop()}}),e)}))),children:"保存并发布"})]})]})})]})}))}}]);