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__Preface__New__index.asyn...

1 line
6.3 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([[25633],{38816:function(e,s,n){n.r(s),n.d(s,{default:function(){return Q}});var a=n(7557),l=n.n(a),t=n(41498),i=n.n(t),c=n(79800),o=n.n(c),r=n(39647),u=n.n(r),d=n(59301),p=n(58228),m=n(24650),h=n(78241),f=n(88522),g=n(53326),_=n(3113),x=n(98242),v="wrap___QJEfO",j="bg___YovF4",A="title_style___iKJsJ",y="line___CuDfk",N="text___wgTCa",b="fieldWrap___t32Tn",S="form_item_textarea___xeZJ0",w="textarea_suffix___xFmF9",Z="form_item___Qnp71",I="close_style___aXn53",C="xmfm___tSyD6",E="img_content___KFbBT",F="footer_style___Voi7E",P="backgroundFa___gy_Q2",U="form_item_item___cUboO",V=n(8591),k=n(43899),J=n(25600),R=n(93071),O=n(22102),q=n(28562),K=n(37712),T=["user","newCourse","globalSetting","loading","dispatch"],G=m.Z.TextArea,Q=(0,p.connect)((function(e){var s=e.user,n=e.newCourse,a=e.loading;return{user:s,newCourse:n,globalSetting:e.globalSetting,loading:a.effects}}))((function(e){e.user,e.newCourse,e.globalSetting,e.loading;var s,n,a=e.dispatch,t=(u()(e,T),h.Z.useForm()),c=o()(t,1)[0],r=(0,d.useState)({}),Q=o()(r,2),Y=Q[0],D=Q[1],L=(0,d.useState)(),H=o()(L,2),B=H[0],z=H[1],M=(0,p.useParams)(),W=(0,d.useState)([]),X=o()(W,2),$=X[0],ee=X[1];(0,d.useEffect)((function(){return se(),null!=M&&M.prefaceId&&(0,R.QJ)(null==M?void 0:M.prefaceId).then((function(e){0==(null==e?void 0:e.status)&&(c.setFieldsValue(e),D(e),z([{id:null==e?void 0:e.attachment_id,test:null==e?void 0:e.attachment_url}]))})),a({type:"globalSetting/footerToggle",payload:!1}),function(){a({type:"globalSetting/footerToggle",payload:!0})}}),[]);var se=function(){var e=i()(l()().mark((function e(){var s;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,q.H8)({is_ai:!1});case 2:0==(s=e.sent).status&&ee(null==s?void 0:s.preface_expansions_types);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,K.jsxs)("div",{className:v,children:[(0,K.jsx)("div",{className:j,children:(0,K.jsxs)(h.Z,{labelCol:{flex:"100px"},form:c,scrollToFirstError:!0,colon:!1,onValuesChange:function(){D(c.getFieldsValue())},children:[(0,K.jsxs)("div",{className:A,children:[(0,K.jsx)("div",{className:y}),(0,K.jsxs)("div",{className:N,children:[null!=M&&M.prefaceId?"编辑":"新建","前沿拓展"]})]}),(0,K.jsxs)("div",{className:b,children:[(0,K.jsx)(h.Z.Item,{className:Z,label:"标题",colon:!1,name:"title",rules:[{required:!0,message:"必填项:不能为空"},{whitespace:!0,message:"请勿输入空格"}],children:(0,K.jsx)(m.Z,{size:"large",className:U,placeholder:"请输入标题",maxLength:60,showCount:!0})}),(0,K.jsx)(h.Z.Item,{className:Z,label:"类型",colon:!1,name:"type_name",rules:[{required:!0,message:"必填项:不能为空"},{whitespace:!0,message:"请勿输入空格"}],children:(0,K.jsx)(f.Z,{size:"large",style:{width:"100%"},options:null==$?void 0:$.map((function(e){return{value:e,label:e}})),filterOption:function(e,s){var n;return-1!==(null==s||null===(n=s.label)||void 0===n||null===(n=n.toUpperCase())||void 0===n?void 0:n.indexOf(null==e?void 0:e.toUpperCase()))},onSearch:function(e){e.length>20&&c.setFieldValue("type_name",e.substring(0,20))}})}),(0,K.jsxs)("div",{className:S,children:[(0,K.jsx)(h.Z.Item,{className:Z,label:"简介",colon:!1,name:"description",rules:[{required:!0,message:"必填项:不能为空"},{whitespace:!0,message:"请勿输入空格"}],children:(0,K.jsx)(G,{placeholder:"请输入简介",maxLength:200,rows:7})}),(0,K.jsx)("div",{className:w,children:(0,K.jsxs)("span",{style:{fontSize:"14px"},children:[(null===(s=Y.description)||void 0===s?void 0:s.length)||0,(0,K.jsx)("span",{style:{color:"#c5c5c5"},children:"/200"})]})})]}),(0,K.jsx)(h.Z.Item,{className:Z,label:"链接",colon:!1,name:"url",rules:[{required:!0,message:"必填项:不能为空"},{whitespace:!0,message:"请勿输入空格"}],children:(0,K.jsx)(m.Z,{className:U,placeholder:"请输入链接",size:"large"})}),(0,K.jsxs)(h.Z.Item,{className:Z,label:"项目封面",colon:!1,name:"attachment_id",children:[(0,K.jsx)(g.Z,{action:"",accept:"image/*",withCredentials:!0,showUploadList:!1,beforeUpload:function(e){var s="image/jpeg"===e.type||"image/png"===e.type||"image/jpg"===e.type;return s||(V.ZP.error("您上传的不是JPEG/PNG/JPG类型文件"),Promise.reject())},customRequest:function(e){var s=new FormData;s.append("file",null==e?void 0:e.file),(0,J.ZP)("".concat(x.Z.API_SERVER,"/api/attachments.json"),{method:"post",body:s},!0).then((function(e){z([e]),c.setFieldsValue({attachment_id:e.id})}))},children:(0,K.jsxs)("div",{style:{height:"40px",display:"flex",alignItems:"center"},children:[(0,K.jsx)(O.op,{style:{borderRadius:"2px"},icon:(0,K.jsx)("i",{className:"iconfont icon-shangchuanfujian"}),children:"上传文件"}),(0,K.jsx)("span",{style:{color:"#999999",pointerEvents:"none",marginLeft:20},children:"封面图片尺寸为581*250px格式为png、jpeg、jpg大小不能超过100KB"})]})}),(null==B?void 0:B.length)>0&&(0,K.jsxs)("div",{className:C,children:[(0,K.jsx)("img",{src:x.Z.API_SERVER+(null===(n=B[0])||void 0===n?void 0:n.test),className:E}),(0,K.jsx)("img",{src:k,className:I,onClick:function(){z([]),c.setFieldsValue({attachment_id:""})}})]})]})]})]})}),(0,K.jsx)("div",{className:F,children:(0,K.jsxs)("div",{className:P,children:[(0,K.jsx)(_.ZP,{className:"canclebtn",onClick:function(){p.history.push("/preface")},children:"取消"}),(0,K.jsx)(_.ZP,{className:"confirmbtn",type:"primary",onClick:function(){(null==B?void 0:B.length)>0&&c.setFieldsValue({attachment_id:B[0].id}),c.validateFields().then((function(){null!=M&&M.prefaceId?(0,R.eb)({id:null==M?void 0:M.prefaceId,preface_expansion:c.getFieldsValue()}).then((function(e){0==(null==e?void 0:e.status)&&(V.ZP.success("编辑成功"),p.history.go(-1))})):(0,R.Ln)({preface_expansion:c.getFieldsValue(),is_ai:!1}).then((function(e){0==(null==e?void 0:e.status)&&(V.ZP.success("新增成功"),p.history.push("/preface"))}))}))},children:null!=M&&M.prefaceId?"保存编辑":"确认新建"})]})})]})}))},43899:function(e){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAOJJREFUOE+lkrEOAUEQhr+RULmLTqcQvRfxAKJX6o5GcISKTqkXD+BB6OUKNDpZV1Gs7MbKkZA4U83+M/8/f2ZHSEQExRy0NNQEyqakIRJYX2FehpNrF5fsoS6wAPJJsUQea2iWYGUwS3yQlu79gWgNaGgYshh7Wdh9mfSuE9+gIkcYa+i6qjcaoZUins0slA8CxPe59PtPAYGJHGADVB1qGgvTKSoMLeSHIed2+yn06NuaiUqDl/TjDwaWYMIIqOHwxa7AJT3xH6vfl9PpkPE8VK/3upzU35H6AP46OUf+5cjvSj1v2525UKMAAAAASUVORK5CYII="}}]);