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
7.2 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],{90340:function(e,t,n){n.r(t),n.d(t,{default:function(){return S}});var s=n(7557),i=n.n(s),o=n(41498),l=n.n(o),r=n(37205),a=n.n(r),c=n(82242),u=n.n(c),d=n(79800),f=n.n(d),_=n(59301),x=n(7880),p=n(78241),m=n(8591),h=n(28103),b=n(66104),v=n(95237),g=n(43604),j=n(98135),y=n(3113),k=n(27085),Z={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",footer:"footer___BXamP",footer_button:"footer_button___SgR41",button_style:"button_style___Dhnsl"},q=n(6457),w=n(11094),L=n(27020),N=n(19170),I=n(87298),P=n(37712),S=(0,x.connect)((function(e){var t=e.classroomList,n=e.loading,s=e.user;return{classroomList:t,globalSetting:e.globalSetting,user:s,loading:n.effects}}))((function(e){e.classroomList,e.globalSetting,e.loading;var t,n=e.user,s=e.dispatch,o=(0,x.useParams)();(0,_.useEffect)((function(){return setTimeout((function(){document.body.scrollIntoView()}),300),s({type:"globalSetting/footerToggle",payload:!1}),function(){s({type:"globalSetting/footerToggle",payload:!0})}}),[]);var r=n.userInfo,c=p.Z.useForm(),d=f()(c,1)[0],S=(0,_.useState)([]),C=f()(S,2),T=C[0],D=C[1],F=(0,_.useState)(-1),R=f()(F,2),J=R[0],K=R[1],V=(0,_.useRef)(),A=function(e,t,n){switch(e){case"edit":-1===J||-1===t?(J=t,K(t)):m.ZP.error("不能同时编辑两题");break;case"add":if(-1!=J)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:u()({},t)}).slice(),D(a()(T)),K((null==t?void 0:t.key)+1);break;case"addContinue":D(a()(t));break;case"del":T.splice(t-1,1),D(a()(T)),K(-1);break;case"isadd":T[J-1]={question:t},n?(K(T.length+1),D([].concat(a()(T),[{question:{question_type:n}}]))):(D(a()(T)),K(-1))}},Y=function(){var e=l()(i()().mark((function e(t){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===J){e.next=3;break}return m.ZP.error("不能同时编辑两题"),e.abrupt("return");case 3:K(T.length+1),D([].concat(a()(T),[{question:{question_type:t}}]));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return(0,P.jsxs)("div",{children:[(0,P.jsxs)("section",{className:"edu-container",children:[(0,P.jsxs)("section",{className:"animated fadeIn",children:[(0,P.jsx)("aside",{className:"mt10",children:r&&(0,P.jsxs)(b.Z,{separator:">",children:[(0,P.jsx)(b.Z.Item,{children:(0,P.jsx)(x.Link,{to:"".concat(r.first_category_url),children:null==r||null===(t=r.course)||void 0===t?void 0:t.course_name})}),(0,P.jsx)(b.Z.Item,{children:(0,P.jsx)(x.Link,{to:"/classrooms/".concat(o.coursesId,"/poll"),children:"问卷列表"})}),(0,P.jsx)(b.Z.Item,{children:"新建问卷"})]})}),(0,P.jsx)("aside",{className:[Z.title,"mt20"].join(" "),children:(0,P.jsxs)(v.Z,{style:{width:"100%"},children:[(0,P.jsx)(g.Z,{flex:"1",children:(0,P.jsx)("strong",{className:"font18 ml5",children:"新建问卷"})}),(0,P.jsx)(g.Z,{children:(0,P.jsx)(x.Link,{className:"font14 c-light-black",to:"/classrooms/".concat(o.coursesId,"/poll"),children:"返回"})})]})})]}),(0,P.jsx)("section",{className:[Z.bg,"pt30","pl30","pr30","pb30","mt10"].join(" "),children:(0,P.jsxs)(p.Z,{layout:"vertical",form:d,children:[(0,P.jsx)(p.Z.Item,{name:"polls_name",label:"问卷标题:",rules:[{required:!0,message:"请填写问卷标题"}],children:(0,P.jsx)(j.Z,{maxLength:60,placeholder:"问卷标题最大限制60个字符",style:{height:"40px"}})}),(0,P.jsx)(p.Z.Item,{label:"问卷须知:",name:"polls_description",children:(0,P.jsx)(w.Z,{watch:!0,height:200,placeholder:"请在此输入本次问卷答题的相关说明,最大限制5000字"})})]})}),""!=T&&(0,P.jsx)("section",{className:[Z.bg,"pt30","pl20","pr20","pb20","mt20"].join(" "),children:null==T?void 0:T.map((function(e,t){var n;return e.key=t+1,e.len=T.length,1===e.question.question_type?(0,P.jsxs)("aside",{children:[(0,P.jsx)(N.Z,{ref:V,editKey:J,polls_status:1,isadd:!0,callback:A,editData:e}),(0,P.jsx)(h.Z,{})]},e.id):2===e.question.question_type?(0,P.jsxs)("aside",{children:[(0,P.jsx)(L.Z,{ref:V,editKey:J,polls_status:1,isadd:!0,callback:A,editData:e}),(0,P.jsx)(h.Z,{})]},e.id):3===(null===(n=e.question)||void 0===n?void 0:n.question_type)?(0,P.jsxs)("aside",{children:[(0,P.jsx)(I.Z,{ref:V,editKey:J,polls_status:1,isadd:!0,callback:A,editData:e}),(0,P.jsx)(h.Z,{})]},e.id):void 0}))})]}),(0,P.jsx)("div",{className:Z.footer,children:(0,P.jsxs)("div",{className:Z.footer_button,children:[(0,P.jsx)("section",{className:Z.bg,style:{display:"flex"},children:[{name:"单选题",id:1},{name:"多选题",id:2},{name:"问答题",id:3}].map((function(e){return(0,P.jsxs)("div",{className:Z.button_style,onClick:function(){return Y(e.id)},children:[(0,P.jsx)("i",{className:"iconfont icon-tianjia4 mr5 font14"}),e.name]})}))}),(0,P.jsxs)(y.ZP,{type:"primary",style:{marginLeft:"auto",background:"#ffffff",color:"#343636",border:"1px #eeeeee solid"},onClick:l()(i()().mark((function e(){var t,n,s,l;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.validateFields();case 2:if((n=d.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,k.rJ)(u()(u()(u()({},n),o),{},{poll_questions:T.filter((function(e){var t;return null==e||null===(t=e.question)||void 0===t?void 0:t.question_title})).map((function(e){return e.question}))}));case 9:0===(s=e.sent).status&&((0,q.L9)(["教学课堂","问卷","新建问卷"]),x.history.push("/classrooms/".concat(o.coursesId,"/poll/").concat(null===(l=s.data)||void 0===l?void 0:l.id,"/detail?tabs=2")));case 11:case"end":return e.stop()}}),e)}))),children:[(0,P.jsx)("i",{className:"iconfont icon-baocun1 font14 mr5"}),"保存问卷"]}),(0,P.jsxs)(y.ZP,{type:"primary",style:{marginLeft:"20px"},onClick:l()(i()().mark((function e(){var t,n,l,r,a,c;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.validateFields();case 2:if((n=d.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,k.rJ)(u()(u()(u()({},n),o),{},{poll_questions:T.filter((function(e){var t;return null==e||null===(t=e.question)||void 0===t?void 0:t.question_title})).map((function(e){return e.question}))}));case 9:0===(l=e.sent).status&&((0,q.L9)(["教学课堂","问卷","新建问卷"]),x.history.push("/classrooms/".concat(o.coursesId,"/poll/").concat(null===(r=l.data)||void 0===r?void 0:r.id,"/detail?tabs=2")),s({type:"polls/setActionTabs",payload:{key:"立即发布",selectArrs:[null===(a=l.data)||void 0===a?void 0:a.id],types:2,params:{categoryId:null===(c=l.data)||void 0===c?void 0:c.id}}}));case 11:case"end":return e.stop()}}),e)}))),children:[(0,P.jsx)("i",{className:"iconfont icon-fasong font16 mr5"}),"发布问卷"]})]})})]})}))}}]);