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__News__Edit__index.async.js

1 line
14 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([[28477],{52491:function(e,n,t){t.d(n,{Z:function(){return y}});var a=t(7557),s=t.n(a),i=t(41498),l=t.n(i),r=t(82242),o=t.n(r),u=t(79800),c=t.n(u),d=t(39647),p=t.n(d),h=t(59301),m=t(8591),f=t(54580),x=t(95237),g=t(91689),v=t(19248),j=t(940),b="tip___bHEXo",Z=t(37712),_=["ButtonText","ButtonOptions","uploadProps","showTip","showText","showListening","imgWidth"],y=function(e){var n,t,a,i=e.ButtonText,r=e.ButtonOptions,u=e.uploadProps,d=e.showTip,y=e.showText,w=e.showListening,C=e.imgWidth,k=p()(e,_),P=(0,h.useState)(null),I=c()(P,2),N=I[0],E=I[1],S=o()(o()({maxCount:1,accept:"image/*",withCredentials:!0,beforeUpload:function(e){if(!("image/jpeg"===e.type||"image/png"===e.type||"image/jpg"===e.type))return m.ZP.error("您上传的不是JPEG/PNG/JPG类型文件"),f.Z.LIST_IGNORE;var n=e.size/1024/1024;return 0==n?(m.ZP.error("".concat(e.name," 图片无法上传。").concat(0==n?"文件内容不能为空":"超过图片大小限制(2MB)")),f.Z.LIST_IGNORE):!(n>2)||(m.ZP.error("".concat(e.name," 图片无法上传。超过图片大小限制(2MB)")),f.Z.LIST_IGNORE)},onChange:function(e){var n;(["uploading","done","removed"].includes(e.file.status)&&E(e.file),"done"==e.file.status)&&(null==k||k.onChange(null===(n=e.file)||void 0===n||null===(n=n.response)||void 0===n?void 0:n.id))},action:"".concat(g.Z.API_SERVER,"/api/attachments.json")},u||{}),{},{onRemove:(t=l()(s()().mark((function e(n){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:F(),(null==u?void 0:u.onRemove)&&(null==u||u.onRemove(n));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}),F=function(){E(null),null==k||k.onChange()};return(0,h.useEffect)((function(){(null==k?void 0:k.value)&&E({response:{id:null==k?void 0:k.value}})}),[null==k?void 0:k.value]),(0,Z.jsx)("div",{id:(null==k?void 0:k.scrollId)||"",children:null!=N&&null!==(n=N.response)&&void 0!==n&&n.id?(0,Z.jsxs)(x.Z,{align:"middle",justify:"center",style:{position:"relative",width:C||400,backgroundColor:"#f4f3f4"},children:[(0,Z.jsx)("img",{src:g.Z.API_SERVER+"/api/attachments/"+(null==N||null===(a=N.response)||void 0===a?void 0:a.id),alt:"avatar",style:{width:"100%",height:C?"177px":"auto"}}),(0,Z.jsx)("div",{style:{position:"absolute",right:"-6px",top:"-6px",cursor:"pointer",width:16,height:16,borderRadius:"50%",backgroundColor:"#fff"},children:(0,Z.jsx)(v.Z,{onClick:l()(s()().mark((function e(){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:F();case 1:case"end":return e.stop()}}),e)}))),style:{fontSize:"16px",color:"red"}})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f.Z,o()(o()({},S),{},{children:(0,Z.jsx)(j.op,o()(o()({style:o()({borderRadius:"2px"},null==r?void 0:r.style)},r),{},{children:i}))})),d&&(0,Z.jsx)("span",{className:b,children:"建议上传尺寸为472*266的图片"}),y&&(0,Z.jsx)("span",{className:b,style:{width:"4rem"},children:"需上传尺寸为200*268的图片大小不超过2MB"}),w&&(0,Z.jsx)("span",{className:b,style:{width:"4rem"},children:"限制上传2MB内的图片建议上传尺寸为283*177的图片"})]})})}},20416:function(e,n,t){t.d(n,{Z:function(){return g}});var a=t(82242),s=t.n(a),i=t(7557),l=t.n(i),r=t(41498),o=t.n(r),u=t(79800),c=t.n(u),d=t(59301),p=t(84686),h=t(94171),m=t(49389),f=(t(20632),{editor_css:"editor_css___cm3Z8"}),x=t(37712),g=(0,m.connect)((function(e){return{user:e.user}}))((function(e){var n=e.defaultvalue,t=e.onChange,a=e.style,i=e.user,r=e.placeholder,u=2097152,m=(0,d.useRef)(null),g=(0,d.useState)(null),v=c()(g,2),j=v[0],b=v[1],Z=(0,d.useState)(""),_=c()(Z,2),y=_[0],w=_[1];(0,d.useEffect)((function(){w(n)}),[n]),(0,d.useEffect)((function(){t(y)}),[y]);var C={placeholder:r||"请输入内容...",MENU_CONF:{}};C.MENU_CONF.uploadImage={customUpload:function(e,n){return o()(l()().mark((function t(){var a,s;return l()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=new FormData).append("file",e),t.next=4,(0,h.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 o()(l()().mark((function t(){var a,s,r,o,c,d,p,f,x,g,v,j,b,Z;return l()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.size,s=Math.ceil(a/u),t.prev=2,t.next=5,(0,h.ZP)("/api/attachments/multipart_upload_start",{method:"POST",body:{fileName:e.name,chunkCount:s,user_id:null==i||null===(r=i.userInfo)||void 0===r?void 0:r.user_id}});case 5:if(0===(null==(c=t.sent)?void 0:c.status)){t.next=8;break}throw new Error;case 8:d=c.upload_id,m.current=new AbortController,p=[],0,f=l()().mark((function n(){var t,s,i,r;return l()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=x*u,s=Math.min(t+u,a),i=e.slice(t,s),(r=new FormData).append("chunk",i),r.append("fileName",e.name),r.append("chunkIndex",(x+1).toString()),r.append("uploadId",d),p.push((function(){return(0,h.ZP)("/api/attachments/multipart_upload",{method:"POST",body:r,signal:m.current.signal},!0).then((function(e){}))}));case 9:case"end":return n.stop()}}),n)})),x=0;case 14:if(!(x<s)){t.next=19;break}return t.delegateYield(f(),"t0",16);case 16:x++,t.next=14;break;case 19:g=0,v=4,console.log(p,"promises");case 22:if(!(g<p.length)){t.next=31;break}if(!((b=null===(j=p.slice(g,g+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,g+=v;case 29:t.next=22;break;case 31:return t.next=33,(0,h.ZP)("/api/attachments/multipart_upload_end",{method:"POST",body:{fileName:e.name,chunkCount:s,uploadId:d,user_id:null==i||null===(o=i.userInfo)||void 0===o?void 0:o.user_id}});case 33:Z=t.sent,n(null==Z?void 0:Z.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,x.jsx)(x.Fragment,{children:(0,x.jsxs)("div",{className:null==f?void 0:f.editor_css,style:{border:"1px solid #ccc",zIndex:100},children:[(0,x.jsx)(p.o,{editor:j,defaultConfig:{},mode:"default",style:{borderBottom:"1px solid #ccc"}}),(0,x.jsx)(p.M,{defaultConfig:C,value:y,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(/&nbsp;/gi,"").replace(/<[^<br/>]+>/g,"")))?w(e.getHtml()):w("")},mode:"default",style:s()({height:"500px",overflowY:"hidden"},a)})]})})}))},12588:function(e,n,t){t.r(n),t.d(n,{default:function(){return O}});var a=t(37205),s=t.n(a),i=t(7557),l=t.n(i),r=t(41498),o=t.n(r),u=t(82242),c=t.n(u),d=t(79800),p=t.n(d),h=t(59301),m=t(78241),f=t(8591),x=t(10249),g=t(95237),v=t(43604),j=t(5083),b=t(78673),Z=t(54580),_=t(3113),y=t(32050),w=t(49389),C="ContentWarp____NGO4",k="footst___JOtkR",P="tags___d8Fj9",I="hidden___Uq9ip",N=t(20416),E=(t(50946),t(94171)),S=t(91689),F=t(56656),R=t.n(F),T=t(940),L=t(52491),B=t(37712),O=(0,w.connect)((function(e){var n=e.homePage,t=e.loading,a=e.globalSetting,s=e.user;return{homePage:n,globalSetting:a,loading:t.models.homePage,user:s}}))((function(e){e.homePage,e.globalSetting,e.user,e.loading;var n=e.dispatch,t=(0,h.useState)(),a=p()(t,2),i=a[0],r=a[1],u=m.Z.useForm(),d=p()(u,1)[0],F=(0,h.useState)([]),O=p()(F,2),M=O[0],A=O[1],z=(0,h.useState)(!0),U=p()(z,2),G=U[0],V=U[1],q=(0,h.useState)(!0),H=p()(q,2),W=H[0],J=H[1],D=(0,h.useState)(c()({page:1,limit:10},(0,w.useParams)())),Y=p()(D,2),$=Y[0];Y[1];(0,h.useEffect)((function(){return n({type:"globalSetting/headerFooterToggle",payload:!1}),function(){n({type:"globalSetting/headerFooterToggle",payload:!0})}}),[]);function X(){return(X=o()(l()().mark((function e(){var n,t,a,s,i;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.ZP)("/api/news_events/".concat($.id,".json"),{method:"get"});case 2:0===(null==(n=e.sent)?void 0:n.status)&&(r(null==n?void 0:n.data),A(null==n||null===(t=n.data)||void 0===t?void 0:t.news_event_tags),V(!n.data.url.trim()),J(null==n||null===(a=n.data)||void 0===a?void 0:a.is_jump),d.setFieldsValue(c()(c()({},null==n?void 0:n.data),{},{publish_time:R()(null==n||null===(s=n.data)||void 0===s?void 0:s.publish_time),attachment_ids:null==n||null===(i=n.data)||void 0===i||null===(i=i.attachments)||void 0===i?void 0:i.map((function(e){return{uid:e.id,name:e.title,status:"down",response:{id:e.id}}}))})));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return(0,h.useEffect)((function(){!function(){X.apply(this,arguments)}()}),[]),(0,B.jsxs)("section",{style:{background:"#fff",paddingBottom:60},children:[(0,B.jsxs)("div",{style:{width:1200,margin:"0px auto"},children:[(0,B.jsxs)("div",{style:{paddingTop:40,display:"flex",alignItems:"center"},children:[(0,B.jsx)("div",{style:{background:"#666666",height:14,width:4,marginRight:8}}),(0,B.jsx)("span",{style:{color:"#232B40",fontWeight:500},children:"新闻动态"})]}),(0,B.jsx)("div",{className:C,children:(0,B.jsxs)(m.Z,{size:"large",colon:!1,form:d,onFinish:function(){var e=o()(l()().mark((function e(n){var t,a;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.ZP)("/api/news_events/".concat($.id,".json"),{method:"PUT",body:c()(c()({},n),{},{attachment_ids:null==n||null===(t=n.attachment_ids)||void 0===t?void 0:t.map((function(e){var n;return null==e||null===(n=e.response)||void 0===n?void 0:n.id})),news_event_tags:M,is_jump:W})});case 2:0===(null==(a=e.sent)?void 0:a.status)&&(f.ZP.info("保存成功"),history.back());case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),children:[(0,B.jsx)(m.Z.Item,{label:"标题",name:"title",labelCol:{span:2},rules:[{required:!0,message:"标题不能为空"}],children:(0,B.jsx)(x.Z,{maxLength:200,showCount:!0})}),(0,B.jsx)(m.Z.Item,{label:"标签",name:"tags",labelCol:{span:2},children:(0,B.jsx)(x.Z,{onPressEnter:function(e){5!==(null==M?void 0:M.length)?(M.push({id:null,name:e.target.value}),A(s()(M)),d.setFieldsValue({tags:""})):f.ZP.info("最多新增5个标签")},maxLength:10,addonAfter:"回车添加标签"})}),(0,B.jsxs)(g.Z,{children:[(0,B.jsx)(v.Z,{span:2}),null==M?void 0:M.map((function(e,n){return(0,B.jsxs)("div",{className:P,style:{position:"relative"},children:[(0,B.jsx)("span",{style:{display:"inline-flex",justifyContent:"center",padding:"0px 14px",background:"#F6F7F9",borderRadius:16,height:32,lineHeight:"32px",color:"#AC651A",marginRight:20,marginBottom:16},children:null==e?void 0:e.name}),(0,B.jsx)("span",{onClick:function(){M.splice(n,1),A(s()(M))},className:I,style:{position:"absolute",right:15,top:-5,width:14,height:14,background:"#E30000",color:"#FFFFFF",alignItems:"center",justifyContent:"center",borderRadius:"50%",fontSize:10,cursor:"pointer"},children:"x"})]})}))]}),(0,B.jsxs)(g.Z,{children:[(0,B.jsx)(v.Z,{span:12,children:(0,B.jsx)(m.Z.Item,{label:"来源",labelCol:{span:4},rules:[{required:!0,message:"来源不能为空"}],name:"publisher",children:(0,B.jsx)(x.Z,{maxLength:60,showCount:!0})})}),(0,B.jsx)(v.Z,{span:11,style:{marginLeft:46},children:(0,B.jsx)(m.Z.Item,{label:"发布时间",rules:[{required:!0,message:"发布时间不能为空"}],name:"publish_time",children:(0,B.jsx)(j.default,{style:{width:"100%"},showTime:!0})})})]}),(0,B.jsxs)(g.Z,{children:[(0,B.jsx)(v.Z,{span:12,children:(0,B.jsx)(m.Z.Item,{label:"编辑",labelCol:{span:4},name:"editor_name",children:(0,B.jsx)(x.Z,{maxLength:60,showCount:!0})})}),(0,B.jsx)(v.Z,{span:11,style:{marginLeft:46},children:(0,B.jsx)(m.Z.Item,{label:"审核",labelCol:{span:4},name:"reviewer_name",children:(0,B.jsx)(x.Z,{maxLength:60,showCount:!0})})})]}),(0,B.jsx)(m.Z.Item,{label:"链接",name:"url",labelCol:{span:2},children:(0,B.jsx)(x.Z,{onChange:function(e){e.target.value.trim()?V(!1):(J(!1),V(!0))}})}),(0,B.jsxs)("div",{style:{paddingLeft:"93px",marginBottom:20},children:[(0,B.jsx)(b.Z,{disabled:G,checked:W,onChange:function(e){return J(e)}}),(0,B.jsx)("span",{className:"ml10",style:{position:"relative",top:3},children:"进入新闻动态优先跳转链接"})]}),(0,B.jsx)(m.Z.Item,{label:"内容",name:"content",rules:[{required:!0,message:"请输入内容"}],labelCol:{span:2},children:(0,B.jsx)(N.Z,{defaultvalue:null==i?void 0:i.content})}),(0,B.jsx)(m.Z.Item,{label:"置顶",name:"is_top",valuePropName:"checked",labelCol:{span:2},children:(0,B.jsx)(b.Z,{})}),(0,B.jsxs)(g.Z,{wrap:!1,gutter:20,children:[(0,B.jsx)(v.Z,{flex:1,children:(0,B.jsx)(m.Z.Item,{name:"attachment_ids",label:(0,B.jsx)("div",{style:{textAlign:"right",width:82},children:"附件"}),valuePropName:"fileList",getValueFromEvent:function(e){return Array.isArray(e)?e:null==e?void 0:e.fileList},children:(0,B.jsx)(Z.Z,{onRemove:function(){var e=o()(l()().mark((function e(n){var t;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.ZP)("/api/attachments/".concat(null==n||null===(t=n.response)||void 0===t?void 0:t.id,".json"),{method:"delete"});case 2:e.sent;case 3:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),action:"".concat(S.Z.API_SERVER,"/api/attachments.json"),withCredentials:!0,listType:"picture",children:(0,B.jsx)(T.op,{style:{borderRadius:"2px"},icon:(0,B.jsx)(y.Z,{}),children:"上传文件"})})})}),(0,B.jsx)(v.Z,{flex:1,children:(0,B.jsx)(m.Z.Item,{name:"cover_id",label:"封面图",children:(0,B.jsx)(L.Z,{uploadProps:{accept:".jpg, .png",beforeUpload:function(e){return!(e.size/1024/1024>10)||(f.ZP.error("封面图仅支持上传文件大小10MB以下的文件。"),Z.Z.LIST_IGNORE)},data:{is_upload_cover:!0}},ButtonText:"上传图片",ButtonOptions:{icon:(0,B.jsx)(y.Z,{})}})})})]})]})})]}),(0,B.jsx)("div",{className:k,children:(0,B.jsxs)("div",{style:{width:1200,margin:"0px auto",display:"flex",alignItems:"center",justifyContent:"space-between",height:"100%"},children:[(0,B.jsx)(_.ZP,{onClick:function(){history.back()},size:"large",className:"canclebtn",children:"返回"}),(0,B.jsx)(_.ZP,{onClick:function(){d.submit()},style:{marginLeft:10},className:"confirmbtn",type:"primary",size:"large",children:"确认保存"})]})})]})}))}}]);