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__MoopCases__FormPanel__in...

1 line
8.8 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([[76904],{48313:function(e,n,t){t.r(n),t.d(n,{default:function(){return P}});var r=t(7557),s=t.n(r),a=t(41498),i=t.n(a),c=t(79800),l=t.n(c),o=t(82242),u=t.n(o),d=t(59301),h=t(71418),p=(t(73327),t(49389)),m=t(39647),f=t.n(m),x=t(24905),j=t(54580),v=t(78241),_=t(8591),g=t(43418),y=t(10249),b=t(3113),Z=t(61481),E=t(91689),w=t(59081),T=t(37712),A=["cover_id","attachment_ids"],N=x.Z.Group,k=j.Z.Dragger;var I=function(e){var n=e.callback,t=e.tags,r=void 0===t?[]:t,s=e.initialValues,a=void 0===s?{}:s,i=e.removeAttachment,c=(0,d.useState)(""),o=l()(c,2),h=o[0],p=o[1],m=v.Z.useForm(),I=l()(m,1)[0];function G(e){return Array.isArray(e)?e:e&&e.fileList}var S={multiple:!0,beforeUpload:function(e){var n=e.size/1024/1024<100;if(!n)return _.ZP.error("该文件无法上传。超过文件大小限制(100MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传"),n},action:"".concat(E.Z.API_SERVER,"/api/attachments.json"),onRemove:function(e){g.Z.confirm({centered:!0,okText:"确定",cancelText:"取消",content:"是否确认删除?",onOk:function(){return i(e.response?e.response.id:e.uid)},onCancel:function(){return!1}})}};var L={showUploadList:!1,withCredentials:!0,action:"".concat(E.Z.API_SERVER,"/api/attachments.json"),onChange:function(e){"done"===e.file.status&&function(e,n){var t=new FileReader;t.addEventListener("load",(function(){return n(t.result)})),t.readAsDataURL(e)}(e.file.originFileObj,(function(e){return p(e)}))}};return(0,d.useEffect)((function(){a.title&&(I.setFieldsValue(a),a.cover_id.length>0&&p(E.Z.IMG_SERVER+a.cover_id[0].url))}),[a]),(0,T.jsxs)(v.Z,{form:I,initialValues:a,className:"moop-panel",onFinish:function(e){var t=e.cover_id,r=e.attachment_ids,s=f()(e,A);n(u()(u()({},s),{},{cover_id:null==t?void 0:t.map((function(e){return e.response?e.response.id:e.uid}))[(null==t?void 0:t.length)-1],attachment_ids:r?null==r?void 0:r.map((function(e){return e.response?e.response.id:e.uid})):[]}))},children:[(0,T.jsx)(v.Z.Item,{label:"标题",name:"title",extra:(0,T.jsx)("p",{className:"tip",children:"简明扼要介绍文档/视频所包含的主要的内容"}),rules:[{required:!0,message:"请输入标题"}],children:(0,T.jsx)(y.Z,{placeholder:"例如:软件工程教学案例"})}),(0,T.jsxs)("div",{className:"flex-container",children:[(0,T.jsx)(v.Z.Item,{label:"作者",name:"author_name",rules:[{required:!0,message:"请输入作者名称"}],children:(0,T.jsx)(y.Z,{placeholder:"请输入姓名",style:{marginRight:20,width:200}})}),(0,T.jsx)(v.Z.Item,{name:"author_school_name",rules:[{required:!0,message:"请输入作者单位名称"}],children:(0,T.jsx)(y.Z,{placeholder:"请输入作者单位名称",style:{width:200}})})]}),(0,T.jsx)(v.Z.Item,{name:"tag_ids",label:"标签",rules:[{required:!0,message:"请选择一个标签"}],children:(0,T.jsx)(N,{children:r.map((function(e){return(0,T.jsxs)(x.Z,{value:e.id,children:[" ",e.name," "]},e.id)}))})}),(0,T.jsx)(v.Z.Item,{name:"publish",valuePropName:"checked",children:(0,T.jsx)(x.Z,{children:"是否申请发布"})}),(0,T.jsx)(v.Z.Item,{name:"content",label:"描述",valuePropName:"defaultValue",rules:[{required:!0,message:"请输入描述内容"}],children:(0,T.jsx)(w.Z,{id:"moop_cases_content",height:400})}),(0,T.jsx)(v.Z.Item,{name:"attachment_ids",valuePropName:"fileList",getValueFromEvent:G,children:(0,T.jsxs)(k,u()(u()({},S),{},{children:[(0,T.jsx)("p",{className:"c-blue",style:{marginBottom:10,fontSize:18},children:"上传附件"}),(0,T.jsx)("p",{className:"c-grey-c",children:"从我的电脑选择要上传的文档按住CTRL可以上传多份文档。单个文件最大限制100MB"})]}))}),(0,T.jsx)(v.Z.Item,{name:"cover_id",label:"封面图",extra:"上传尺寸120*90 px",getValueFromEvent:G,valuePropName:"fileList",rules:[{required:!0,message:"请上传封面图"}],children:(0,T.jsx)(j.Z,u()(u()({},L),{},{children:h?(0,T.jsx)("img",{src:h,width:120}):(0,T.jsxs)("a",{title:"上传封面图",className:"upload-cover",children:[" ",(0,T.jsx)(Z.Z,{})," "]})}))}),(0,T.jsxs)("div",{className:"desc",children:[(0,T.jsx)("h3",{children:"审核说明"}),(0,T.jsx)("p",{children:" 平台管理员将对每天新上传的文档进行审核,审核通过的文档将公开显示,否则将私有化或移除 "})]}),(0,T.jsxs)("div",{className:"desc",children:[(0,T.jsx)("h3",{children:"温馨提示"}),(0,T.jsxs)("ul",{style:{padding:0},children:[(0,T.jsx)("li",{children:"1.请勿上传已设置加密口令的文档资源;"}),(0,T.jsxs)("li",{children:["2.可以上传符合教学案例标准的文档资料,如",(0,T.jsx)("a",{href:"https://www.educoder.net/courses/1309/boards/5909/messages/34799",target:"_blank",children:" 案例入库标准 "})," 、",(0,T.jsx)("a",{href:"https://www.educoder.net/courses/1309/boards/5909/messages/34798",target:"_blank",children:"案例使用说明书"}),"以及其他资料等上传支持的文件最大容量100MB"]}),(0,T.jsx)("li",{children:"3.请确保上传内容无侵权或违反国家关于互联网政策的不良行为;"}),(0,T.jsx)("li",{children:"4.请使用ChromeFirefoxSafariIE11及以上版本浏览器"})]})]}),(0,T.jsx)(v.Z.Item,{style:{marginTop:10},children:(0,T.jsx)(b.ZP,{type:"primary",htmlType:"submit",children:"提交"})})]})},G=t(59120),S={loading:!1,data:{},tags:[]},L=function(e){return e[e.GET_DATA=0]="GET_DATA",e[e.SET_LOADING=1]="SET_LOADING",e[e.GET_TAGS=2]="GET_TAGS",e}(L||{});function R(e,n){switch(n.type){case L.GET_DATA:return u()(u()({},e),n.payload);case L.GET_TAGS:return u()(u()({},e),{},{tags:n.payload});case L.SET_LOADING:return u()(u()({},e),{},{loading:n.payload});default:throw new Error}}var P=function(){var e=(0,p.useParams)().caseId,n=(0,d.useReducer)(R,S),t=l()(n,2),r=t[0],a=t[1],c=r.loading,o=r.tags,m=r.data;function f(){return(f=i()(s()().mark((function n(t){var r,a;return s()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e){n.next=6;break}return n.next=3,(0,G.bN)(e,t);case 3:p.history.push("/moop_cases/".concat(e,"/publish-success")),n.next=11;break;case 6:return n.next=8,(0,G.jP)(t);case 8:r=n.sent,(a=r.id)&&p.history.push("/moop_cases/".concat(a,"/publish-success"));case 11:case"end":return n.stop()}}),n)})))).apply(this,arguments)}(0,d.useEffect)((function(){function e(){return(e=i()(s()().mark((function e(){var n;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,G.rO)();case 2:n=e.sent,a({type:L.GET_TAGS,payload:n.library_tags});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]),(0,d.useEffect)((function(){var n=!1;function t(){return t=i()(s()().mark((function t(){var r,i,c,l,o,u,d,h,m;return s()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a({type:L.SET_LOADING,payload:!1}),t.next=3,(0,G.$J)(e);case 3:r=t.sent,i=r.author_name,c=r.author_school_name,l=r.content,o=r.cover,u=r.attachments,d=r.status,h=r.title,m=r.tags,n||(404===r.status?p.history.push("/moop_cases"):a({type:L.GET_DATA,payload:{data:{title:h,author_name:i,author_school_name:c,content:l,tag_ids:m.map((function(e){return e.id})),publish:"published"===d,attachment_ids:u.map((function(e){return{uid:e.id,id:e.id,name:e.title,url:e.url,filesize:e.filesize,status:"done"}})),cover_id:null!=o&&o.id?[{uid:null==o?void 0:o.id,id:null==o?void 0:o.id,name:null==o?void 0:o.title,url:null==o?void 0:o.url,filesize:null==o?void 0:o.filesize,status:"done"}]:[]},loading:!1}}));case 6:case"end":return t.stop()}}),t)}))),t.apply(this,arguments)}return!n&&e&&function(){t.apply(this,arguments)}(),function(){n=!0}}),[e]);var x={initialValues:m,tags:o,removeAttachment:G.JZ,callback:function(e){return f.apply(this,arguments)}};return(0,T.jsx)(h.Z,{spinning:c,delay:500,children:(0,T.jsxs)("div",{className:"moop-info",children:[(0,T.jsxs)("div",{className:"crumb",children:[(0,T.jsx)(p.Link,{to:"/moop_cases",children:"教学案例 > "}),(0,T.jsx)("span",{children:"新建"})]}),(0,T.jsxs)("div",{className:"title",children:[(0,T.jsx)("h2",{children:"上传教学案例"}),(0,T.jsx)(p.Link,{to:"/moop_cases",children:"返回"})]}),(0,T.jsx)(I,u()({},x))]})})}},59120:function(e,n,t){t.d(n,{$J:function(){return l},JZ:function(){return u},bN:function(){return p},jP:function(){return h},rO:function(){return o}});var r=t(7557),s=t.n(r),a=t(41498),i=t.n(a),c=t(94171);function l(e){return(0,c.U2)("libraries/".concat(e,".json"))}function o(){return(0,c.U2)("library_tags.json")}function u(e){return d.apply(this,arguments)}function d(){return(d=i()(s()().mark((function e(n){var t;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,c.IV)("attachments/".concat(n,".json"));case 2:return t=e.sent,e.abrupt("return",0===t.status);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return(0,c.v_)("libraries.json",e)}function p(e,n){return(0,c.gz)("libraries/".concat(e,".json"),n)}},73327:function(){}}]);