|
|
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[94715],{36586:function(e,n,t){t.d(n,{Z:function(){return x}});var a=t(82242),s=t.n(a),r=t(7557),i=t.n(r),c=t(41498),l=t.n(c),o=t(79800),u=t.n(o),d=t(59301),m=t(84686),p=t(51836),_=t(96707),f=(t(96080),{editor_css:"editor_css___cm3Z8"}),h=t(37712),x=(0,_.connect)((function(e){return{user:e.user}}))((function(e){var n=e.defaultvalue,t=e.onChange,a=e.style,r=e.user,c=e.placeholder,o=2097152,_=(0,d.useRef)(null),x=(0,d.useState)(null),v=u()(x,2),j=v[0],b=v[1],g=(0,d.useState)(""),w=u()(g,2),Z=w[0],N=w[1];(0,d.useEffect)((function(){N(n)}),[n]),(0,d.useEffect)((function(){t(Z)}),[Z]);var C={placeholder:c||"请输入内容...",MENU_CONF:{}};C.MENU_CONF.uploadImage={customUpload:function(e,n){return l()(i()().mark((function t(){var a,s;return i()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=new FormData).append("file",e),t.next=4,(0,p.ZP)("/api/attachments.json",{method:"post",body:a},!0);case 4:s=t.sent,n(null==s?void 0:s.url,"","");case 6:case"end":return t.stop()}}),t)})))()}},C.MENU_CONF.uploadVideo={customUpload:function(e,n){return l()(i()().mark((function t(){var a,s,c,l,u,d,m,f,h,x,v,j,b,g;return i()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.size,s=Math.ceil(a/o),t.prev=2,t.next=5,(0,p.ZP)("/api/attachments/multipart_upload_start",{method:"POST",body:{fileName:e.name,chunkCount:s,user_id:null==r||null===(c=r.userInfo)||void 0===c?void 0:c.user_id}});case 5:if(0===(null==(u=t.sent)?void 0:u.status)){t.next=8;break}throw new Error;case 8:d=u.upload_id,_.current=new AbortController,m=[],0,f=i()().mark((function n(){var t,s,r,c;return i()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=h*o,s=Math.min(t+o,a),r=e.slice(t,s),(c=new FormData).append("chunk",r),c.append("fileName",e.name),c.append("chunkIndex",(h+1).toString()),c.append("uploadId",d),m.push((function(){return(0,p.ZP)("/api/attachments/multipart_upload",{method:"POST",body:c,signal:_.current.signal},!0).then((function(e){}))}));case 9:case"end":return n.stop()}}),n)})),h=0;case 14:if(!(h<s)){t.next=19;break}return t.delegateYield(f(),"t0",16);case 16:h++,t.next=14;break;case 19:x=0,v=4,console.log(m,"promises");case 22:if(!(x<m.length)){t.next=31;break}if(!((b=null===(j=m.slice(x,x+v))||void 0===j?void 0:j.map((function(e){return e()}))).length>0)){t.next=29;break}return t.next=27,Promise.all(b);case 27:t.sent,x+=v;case 29:t.next=22;break;case 31:return t.next=33,(0,p.ZP)("/api/attachments/multipart_upload_end",{method:"POST",body:{fileName:e.name,chunkCount:s,uploadId:d,user_id:null==r||null===(l=r.userInfo)||void 0===l?void 0:l.user_id}});case 33:g=t.sent,n(null==g?void 0:g.object,""),t.next=39;break;case 37:t.prev=37,t.t1=t.catch(2);case 39:case"end":return t.stop()}}),t,null,[[2,37]])})))()}};return(0,d.useEffect)((function(){return function(){null!=j&&(j.destroy(),b(null))}}),[j]),(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)("div",{className:null==f?void 0:f.editor_css,style:{border:"1px solid #ccc",zIndex:100},children:[(0,h.jsx)(m.o,{editor:j,defaultConfig:{},mode:"default",style:{borderBottom:"1px solid #ccc"}}),(0,h.jsx)(m.M,{defaultConfig:C,value:Z,onCreated:b,onChange:function(e){var n;!function(e){return""==e||new RegExp("^[ ]+$").test(e)}((n=e.getHtml(),n.replace(/<[^<p>]+>/g,"").replace(/<[</p>$]+>/g,"").replace(/ /gi,"").replace(/<[^<br/>]+>/g,"")))?N(e.getHtml()):N("")},mode:"default",style:s()({height:"500px",overflowY:"hidden"},a)})]})})}))},52256:function(e,n,t){t.d(n,{Z:function(){return Z}});var a=t(7557),s=t.n(a),r=t(41498),i=t.n(r),c=t(82242),l=t.n(c),o=t(79800),u=t.n(o),d=t(59301),m=t(78241),p=t(8591),_=t(43418),f=t(98135),h=t(46651),x={flex_box_center:"flex_box_center___eFoM9",flex_space_between:"flex_space_between___Wg6Gr",flex_box_vertical_center:"flex_box_vertical_center___TqrrQ",flex_box_center_end:"flex_box_center_end___L9c4u",flex_box_column:"flex_box_column___SvH8v",form:"form___LQCl5",btn:"btn___l3d4K",img:"img___CeTIL"},v=t(42437),j=t(68339),b=t(97650),g=t(27030),w=t(37712),Z=function(e){var n,t=e.visible,a=e.onOk,r=e.onCancel,c=e.title,o=void 0===c?"":c,Z=m.Z.useForm(),N=u()(Z,1)[0],C=(0,d.useState)(!1),k=u()(C,2),S=k[0],y=k[1],I=(0,d.useState)([]),P=u()(I,2),E=P[0],F=P[1],L=(0,d.useState)(!1),T=u()(L,2),V=T[0],B=T[1];(0,d.useEffect)((function(){if(null!=t&&t.id){var e,n;N.setFieldsValue(l()(l()({},t),{},{attachment_id:null==t||null===(e=t.attachment)||void 0===e?void 0:e.id}));var a=[l()(l()({},null==t?void 0:t.attachment),{},{response:{id:null==t||null===(n=t.attachment)||void 0===n?void 0:n.id}})];F(a)}}),[t]);var M,R=function(){var e=i()(s()().mark((function e(n){var t,r;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:y(!0),r=l()(l()({},n),{},{attachment_id:(null==E||null===(t=E[0])||void 0===t||null===(t=t.response)||void 0===t?void 0:t.id)||""}),a(r);case 3:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,w.jsx)(_.Z,{title:"".concat(null!=t&&t.id?"编辑":"新建").concat(o),open:t,onOk:function(){N.submit()},centered:!0,onCancel:function(){r()},confirmLoading:S,okButtonProps:{disabled:V},width:686,afterClose:function(){y(!1),F([]),N.resetFields()},okText:"确认",cancelText:"取消",wrapClassName:v.Z.CustomCss,children:(0,w.jsxs)(m.Z,{form:N,colon:!1,labelCol:{span:4},wrapperCol:{span:18},onFinish:R,className:x.form,children:[(0,w.jsx)(m.Z.Item,{label:"".concat(o,"名称"),name:"name",rules:[{required:!0,message:"请输入".concat(o,"名称")},{whitespace:!0,message:"请输入".concat(o,"名称")},{max:100,message:"只能输入60个字符"}],children:(0,w.jsx)(f.Z,{maxLength:100,placeholder:"请输入".concat(o,"名称")})}),(0,w.jsx)(m.Z.Item,{label:"作者",name:"author",rules:[{required:!0,message:"请输入作者"},{whitespace:!0,message:"请输入作者"},{max:50,message:"只能输入50个字符"}],children:(0,w.jsx)(f.Z,{maxLength:50,placeholder:"请输入作者"})}),(0,w.jsx)(m.Z.Item,{label:"出版社",name:"publisher",rules:[{required:!0,message:"请输入出版社"},{whitespace:!0,message:"实践出版社"},{max:50,message:"只能输入50个字符"}],children:(0,w.jsx)(f.Z,{maxLength:50,placeholder:"请输入出版社"})}),(0,w.jsx)(m.Z.Item,{label:"出版时间",name:"publication_time",rules:[{required:!0,message:"请输入出版时间"},{whitespace:!0,message:"请输入出版时间"}],children:(0,w.jsx)(f.Z,{maxLength:60,placeholder:"请输入出版时间"})}),(0,w.jsx)(m.Z.Item,{label:"ISBN",name:"number",rules:[{required:!0,message:"请输入ISBN"},{whitespace:!0,message:"请输入ISBN"}],children:(0,w.jsx)(f.Z,{maxLength:60,placeholder:"请输入ISBN"})}),(0,w.jsx)(m.Z.Item,{name:"attachment_id",label:"封面图片",rules:[{required:!0,message:"请上传封面图片"}],children:(0,w.jsx)("div",{className:x.upload,children:null!=E&&null!==(n=E[0])&&void 0!==n&&null!==(n=n.response)&&void 0!==n&&n.id?(0,w.jsxs)("div",{className:x.img,children:[(0,w.jsx)("img",{src:j.Z.API_SERVER+"/api/attachments/"+(null==E||null===(M=E[0])||void 0===M||null===(M=M.response)||void 0===M?void 0:M.id),alt:"avatar",style:{width:"100%"}}),(0,w.jsx)("div",{children:(0,w.jsx)(b.Z,{onClick:function(){F([]),N.setFieldsValue({attachment_id:""})},style:{fontSize:"16px",color:"red"}})})]}):(0,w.jsx)(h.Z,{fileList:E,action:"".concat(j.Z.API_SERVER,"/api/attachments.json"),onChange:function(e){return n=e,N.setFieldsValue({attachment_id:""}),void(["uploading","done","removed"].includes(n.file.status)&&("uploading"===n.file.status&&B(!0),"done"===n.file.status&&B(!1),F(n.fileList),N.setFieldsValue({attachment_id:null===(t=n.fileList)||void 0===t||null===(t=t[0])||void 0===t||null===(t=t.response)||void 0===t?void 0:t.id})));var n,t},onRemove:function(e){F([])},beforeUpload:function(e){return"image/jpeg"===(n=e).type||"image/png"===n.type?n.size/1024/1024>2?(p.ZP.info("文件大小必须小于2MB"),Promise.reject()):(F([]),!0):(p.ZP.error("请上传jpg或png的图片!"),Promise.reject());var n},withCredentials:!0,accept:"image/*",children:(0,w.jsxs)(g.op,{style:{borderRadius:"2px",marginLeft:4,marginTop:3},children:[(0,w.jsx)("i",{className:"iconfont icon-shangchuantupian2 mr5"}),"上传图片"]})})})})]})})}},72034:function(e,n,t){t.r(n),t.d(n,{default:function(){return F}});var a=t(7557),s=t.n(a),r=t(82242),i=t.n(r),c=t(41498),l=t.n(c),o=t(79800),u=t.n(o),d=t(59301),m=t(43418),p=t(8591),_=t(51836),f="wrap___cwBRd",h="editor___arbaB",x="btns___HTQm5",v="list___tBaoe",j="left___GF5gU",b="right___MFAP_",g="title___piSmp",w=t(44132),Z=t(52256),N=t(68339),C=t(27030),k=t(42437),S=t(96707),y=t(22961),I=t(76279),P=t(36586),E=t(37712),F=(0,S.connect)((function(e){var n=e.virtualSpaces;return{globalSetting:e.globalSetting,virtualSpaces:n}}))((function(e){e.globalSetting,e.dispatch;var n=e.virtualSpaces,t=(0,S.useParams)(),a=t.id,r=t.virtual_spacesId,c=(0,d.useState)("description"),o=u()(c,2),F=o[0],L=o[1],T=(0,d.useState)({}),V=u()(T,2),B=V[0],M=V[1],R=(0,d.useState)(!0),O=u()(R,2),q=(O[0],O[1]),A=(0,d.useState)(!1),U=u()(A,2),z=U[0],H=U[1],D=(0,d.useState)(""),G=u()(D,2),Q=G[0],Y=G[1],$=(0,d.useState)(""),K=u()($,2),W=K[0],J=K[1],X=(0,d.useRef)(""),ee=(0,d.useState)(!1),ne=u()(ee,2),te=ne[0],ae=ne[1],se=(0,d.useState)(!1),re=u()(se,2),ie=re[0],ce=re[1],le=n.virtualSpacesDetails,oe=B.name,ue=B.attachment,de=B.author,me=B.publisher,pe=B.number,_e=B.publication_time,fe=B.material_type;(0,d.useEffect)((function(){xe()}),[a]),(0,d.useEffect)((function(){ve()}),[F]);var he=function(e){return(0,y.Ny)()||(null==le?void 0:le.is_creator)||(null==le?void 0:le.is_member)&&(null==le?void 0:le.user_id)===e},xe=function(){var e=l()(s()().mark((function e(){var n;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q(!0),e.next=3,(0,_.ZP)("/api/virtual_classrooms/".concat(t.virtual_spacesId,"/subject_materials/").concat(a,".json"),{method:"get"});case 3:-1!==(null==(n=e.sent)?void 0:n.status)&&M(i()({},n)),q(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ve=function(){var e=l()(s()().mark((function e(){var n;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q(!0),e.next=3,(0,_.ZP)("/api/virtual_classrooms/".concat(t.virtual_spacesId,"/subject_materials/").concat(a,"/show_desc.json"),{method:"get",params:{column:F}});case 3:-1!==(null==(n=e.sent)?void 0:n.status)&&(Y((null==n?void 0:n[F])||""),J((null==n?void 0:n[F])||""),X.current=(null==n?void 0:n[F])||""),q(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),je=function(){var e=l()(s()().mark((function e(n){var r;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_.ZP)("/api/virtual_classrooms/".concat(t.virtual_spacesId,"/subject_materials/").concat(a,".json"),{method:"put",body:i()({material_type:String(fe)},n)});case 2:-1!==(null==(r=e.sent)?void 0:r.status)&&(xe(),H(!1));case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),be=function(){var e=l()(s()().mark((function e(){var n,r;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ce(!0),(n={})[F]=Q,e.next=5,(0,_.ZP)("/api/virtual_classrooms/".concat(t.virtual_spacesId,"/subject_materials/").concat(a,"/update_desc.json"),{method:"put",body:n});case 5:-1!==(null==(r=e.sent)?void 0:r.status)&&(ve(),ae(!1)),ce(!1);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,E.jsxs)("div",{className:f,children:[(0,E.jsx)(C.qE,{title:"教材详情",onClick:function(){return S.history.push("/".concat(I.AS,"/").concat(r,"/material"))},children:he(B.user_id)&&(0,E.jsxs)("div",{className:x,children:[(0,E.jsx)("div",{onClick:function(){H(i()({},B))},children:(0,E.jsxs)("span",{className:"primary-hover",children:[(0,E.jsx)("i",{className:"iconfont icon-bianji7 font14 mr5"}),"编辑"]})}),(0,E.jsx)("div",{onClick:function(){var e;m.Z.confirm({title:"提示",okText:"确定删除",okButtonProps:{danger:!0},icon:!1,className:k.Z.CustomTipsModalCss,cancelText:"取消",content:(0,E.jsxs)("div",{children:[(0,E.jsxs)("div",{children:["确认删除《",oe,"》吗?"]}),(0,E.jsx)("div",{className:"mt10",children:"删除后,将无法恢复,请谨慎操作"})]}),onOk:(e=l()(s()().mark((function e(){var n;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_.ZP)("/api/virtual_classrooms/".concat(t.virtual_spacesId,"/subject_materials/").concat(a,".json"),{method:"delete"});case 2:-1!==(null==(n=e.sent)?void 0:n.status)&&(p.ZP.success("操作成功"),S.history.push("/".concat(I.AS,"/").concat(r,"/material")));case 4:case"end":return e.stop()}}),e)}))),function(){return e.apply(this,arguments)})})},children:(0,E.jsxs)("span",{className:"delete-hover",children:[" ",(0,E.jsx)("i",{className:"iconfont icon-piliangshanchubeifen font14 mr5"}),"删除"]})})]})}),(0,E.jsxs)("div",{className:v,children:[(0,E.jsx)("div",{className:j,children:(0,E.jsx)("img",{src:N.Z.API_SERVER+(null==ue?void 0:ue.url)})}),(0,E.jsxs)("div",{className:b,children:[(0,E.jsx)("div",{className:g,children:oe}),(0,E.jsxs)("aside",{children:[(0,E.jsxs)("span",{children:["作者:",de]}),(0,E.jsxs)("span",{children:["出版社:",me]})]}),(0,E.jsxs)("aside",{children:[(0,E.jsxs)("span",{children:["ISBN:",pe]}),(0,E.jsxs)("span",{children:["出版时间:",_e]})]})]})]}),(0,E.jsx)(C.YG,{value:F,onChange:function(e){L(e)},tabBarExtraContent:he(B.user_id)&&(0,E.jsx)("div",{className:x,children:(0,E.jsx)("div",{onClick:function(){ae(!0)},children:(0,E.jsxs)("span",{className:"primary-hover",children:[(0,E.jsx)("i",{className:"iconfont icon-bianji7 font14 mr5"}),"编辑"]})})}),dataSource:[{id:"description",name:"简介"},{id:"directory",name:"目录"},{id:"foreword",name:"前言"}]}),(0,E.jsx)("div",{className:"mt20",children:te?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(P.Z,{defaultvalue:W,onChange:function(e){Y(e)}}),(0,E.jsx)(C.QD,{confirmTitle:"保存",confirmLoading:ie,confirmClick:be,cancelClick:function(){ae(!1),Y(X.current)},cancelTitle:"取消",className:"mb25 mt20"})]}):(0,E.jsx)(w.Z,{className:h,value:Q})}),(0,E.jsx)(Z.Z,{visible:z,title:1===fe?"主教材":"实践教材",onCancel:function(){return H(!1)},onOk:je})]})}))},42437:function(e,n){n.Z={flex_box_center:"flex_box_center___vG4eV",flex_space_between:"flex_space_between___qVVxe",flex_box_vertical_center:"flex_box_vertical_center___P8Z8s",flex_box_center_end:"flex_box_center_end___VMme3",flex_box_column:"flex_box_column___VMHwm",dropdownmenus:"dropdownmenus___oVzoj",popupClassNames:"popupClassNames___OcZq7",selectdown:"selectdown___mmcA8"}}}]); |