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__HttpStatus__HpcCourse.as...

2 lines
6.8 KiB

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[4496],{62288:function(ve,b,p){p.r(b),p.d(b,{default:function(){return ne}});var n=p(59301),V=p(90347),h=p(8591),z=p(92832),F=p(3113),C=p(7735),N=(e,a,t)=>new Promise((i,c)=>{var s=l=>{try{o(t.next(l))}catch(u){c(u)}},f=l=>{try{o(t.throw(l))}catch(u){c(u)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,f);o((t=t.apply(e,a)).next())});function T({setIscreate:e,init:a,UpdateItem:t}){const[i,c]=(0,n.useState)(""),[s,f]=(0,n.useState)("");(0,n.useEffect)(()=>{t&&(c(t&&t.name),f(t&&t.description))},[t]);function o(){return N(this,null,function*(){if(!i){h.ZP.info("\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A");return}if(!s){h.ZP.info("\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A");return}if(t){l();return}(yield(0,C.ZP)("/api/hpc_courses.json",{method:"post",body:{name:i,description:s,container_type:window.location.pathname.split("/")[1]}}))&&(h.ZP.info("\u521B\u5EFA\u6210\u529F"),e(!1),a("add"))})}function l(){return N(this,null,function*(){(yield(0,C.ZP)(`/api/hpc_courses/${t.id}.json`,{method:"put",body:{name:i,description:s,container_type:window.location.pathname.split("/")[1]}}))&&(h.ZP.info("\u7F16\u8F91\u6210\u529F"),e(!1),a(""))})}return n.createElement("div",null,n.createElement(z.default,{style:{marginBottom:"20px"},placeholder:"\u8BF7\u8F93\u5165\u6807\u9898",value:i,maxLength:60,addonAfter:String(i.length)+"/60",onChange:u=>c(u.target.value)}),n.createElement(V.Z,{id:"courseContentMD",defaultValue:s,onChange:u=>f(u)}),n.createElement("div",{className:"clearfix mt30 mb30"},n.createElement(F.ZP,{type:"primary",onClick:()=>o(),className:"defalutSubmitbtn fl mr20"},"\u63D0\u4EA4"),n.createElement("a",{className:"defalutCancelbtn fl",onClick:()=>e(!1)},"\u53D6\u6D88")))}var k=T,G=p(23600),J=(e,a,t)=>new Promise((i,c)=>{var s=l=>{try{o(t.next(l))}catch(u){c(u)}},f=l=>{try{o(t.throw(l))}catch(u){c(u)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,f);o((t=t.apply(e,a)).next())});function K({CourseItem:e,userId:a,init:t,ItemUpdate:i,setSee:c,UserInfo:s}){function f(){return J(this,null,function*(){(yield(0,C.ZP)(`/api/hpc_courses/${e.id}.json`,{method:"delete"}))&&(h.ZP.info("\u5220\u9664\u6210\u529F"),t("delete"),c(!1))})}function o(){i(e)}return n.createElement("div",null,a===299635||a===301458||s!=null&&s.admin||s!=null&&s.business?n.createElement("div",{style:{textAlign:"right"}},n.createElement(F.ZP,{onClick:()=>o()},"\u7F16\u8F91"),n.createElement(F.ZP,{onClick:()=>f(),style:{marginLeft:"30px"}},"\u5220\u9664")):null,n.createElement("h1",null,e==null?void 0:e.name),n.createElement(G.Z,{value:e==null?void 0:e.description}))}var Q=K,W=p(46651),D=p(53068),B=p(77530),X=Object.defineProperty,O=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,j=(e,a,t)=>a in e?X(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,q=(e,a)=>{for(var t in a||(a={}))Y.call(a,t)&&j(e,t,a[t]);if(O)for(var t of O(a))U.call(a,t)&&j(e,t,a[t]);return e},ee=(e,a,t)=>new Promise((i,c)=>{var s=l=>{try{o(t.next(l))}catch(u){c(u)}},f=l=>{try{o(t.throw(l))}catch(u){c(u)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,f);o((t=t.apply(e,a)).next())});function te({user:e,dispatch:a}){var t,i,c,s,f,o,l,u,M;const[L,he]=(0,n.useState)(1),[le,Ee]=(0,n.useState)(100),[$,ae]=(0,n.useState)([]),[ue,S]=(0,n.useState)(!1),[se,m]=(0,n.useState)(!1),[oe,E]=(0,n.useState)(""),[re,A]=(0,n.useState)(""),[H,ie]=(0,n.useState)("");let{itemname:P}=(0,B.useParams)();const[x,y]=(0,n.useState)("");(0,n.useEffect)(()=>{a({type:"globalSetting/headerToggle",payload:!1}),L&&Z("")},[L]);function Z(r){return ee(this,null,function*(){var v,I;const d=yield(0,C.ZP)("/api/hpc_courses.json",{method:"get",params:{page:L,per_page:le,container_type:window.location.pathname.split("/")[1]}});if(d){let w=d.data.hpc_courses.length;if(ae(d.data.hpc_courses),ie(d.data.file_url),A(""),!w)return;if(x)if(r==="delete"){if(w===0){m(!1);return}E(d.data.hpc_courses[0]),m(!0),y(d.data.hpc_courses[0].id)}else r==="add"?(E(d.data.hpc_courses[w-1]),m(!0),y(d.data.hpc_courses[w-1].id)):(E(d.data.hpc_courses.filter(g=>g.id===x)[0]),m(!0),y(x));else if(P){let g=0;(I=(v=d==null?void 0:d.data)==null?void 0:v.hpc_courses)==null||I.map((_,me)=>{var R;(P==null?void 0:P.toLocaleLowerCase())===((R=_==null?void 0:_.name)==null?void 0:R.toLocaleLowerCase())&&(g=me)}),E(d.data.hpc_courses[g]),m(!0),y(d.data.hpc_courses[g].id),(P==null?void 0:P.toLocaleLowerCase())==="resources"&&(E(d.data.hpc_courses.filter(_=>_.id===15)[0]),m(!0),y(15))}else E(d.data.hpc_courses[0]),m(!0),y(d.data.hpc_courses[0].id)}})}function ce(r){S(!1),m(!0),E(r),y(r.id)}function de(r){A(r),S(!0),m(!1)}function fe(){A(""),S(!0),m(!1)}const pe={name:"file",multiple:!0,action:"https://www.educoder.net/api/hpc_courses/upload_file.json",data:{container_type:window.location.pathname.split("/")[1]},onChange(r){const{status:v}=r.file;v==="done"?(h.ZP.success(`${r.file.name} \u6587\u4EF6\u4E0A\u4F20\u6210\u529F`),Z("")):v==="error"&&h.ZP.error(`${r.file.name} \u6587\u4EF6\u4E0A\u4F20\u5931\u8D25`)},beforeUpload:r=>{const v=r.size/1024/1024<150;return v||h.ZP.info("\u6587\u4EF6\u5927\u5C0F\u5FC5\u987B\u5C0F\u4E8E150MB"),v}};return n.createElement("div",{style:{marginBottom:"40px"}},n.createElement("div",{className:"bannterdiv",style:{background:`url(${D.Z.IMG_SERVER+`/${H}`})`}}),n.createElement("img",{style:{width:"100%"},src:D.Z.IMG_SERVER+`/${H}`}),n.createElement("div",{className:"edu-container minH500",style:{display:"flex",width:"1200px"}},n.createElement("div",{style:{flex:"1",marginTop:"17px"}},$&&$.map((r,v)=>n.createElement("p",{key:v,onClick:()=>ce(r),className:x===r.id?"menuitemselect":"menuitem task-hide"},r.name)),((t=e==null?void 0:e.userInfo)==null?void 0:t.user_id)===299635||((i=e==null?void 0:e.userInfo)==null?void 0:i.user_id)===301458||(c=e==null?void 0:e.userInfo)!=null&&c.admin||(s=e==null?void 0:e.userInfo)!=null&&s.business?n.createElement("p",{onClick:()=>fe(),className:"menuadd",style:{fontSize:"24px",paddingLeft:"10px"}},n.createElement("span",{style:{fontSize:"16px",marginLeft:"5px"}},"Last updated")):null),n.createElement("div",{className:"rightcount",style:{flex:"6",background:"#ffffff",padding:"20px",marginLeft:"30px",marginTop:"24px"}},ue?n.createElement(k,{UpdateItem:re,setIscreate:S,init:Z}):null,se?n.createElement(Q,{UserInfo:e==null?void 0:e.userInfo,setSee:m,userId:(f=e==null?void 0:e.userInfo)==null?void 0:f.user_id,ItemUpdate:de,CourseItem:oe,init:Z}):null)),((o=e==null?void 0:e.userInfo)==null?void 0:o.user_id)===299635||((l=e==null?void 0:e.userInfo)==null?void 0:l.user_id)===301458||(u=e==null?void 0:e.userInfo)!=null&&u.admin||(M=e==null?void 0:e.userInfo)!=null&&M.business?n.createElement(W.default,q({},pe),n.createElement(F.ZP,{className:"menuadd",style:{paddingLeft:"10px",marginLeft:"20px"}},"\u4E0A\u4F20\u9996\u9875\u56FE\u7247")):null)}var ne=(0,B.connect)(({user:e})=>({user:e}))(te)}}]);