filesbox/web/dist/24189.baa62b5e.async.js
2024-07-26 14:10:54 +08:00

2 lines
14 KiB
JavaScript

(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[24189],{66615:function(k){k.exports={root:"root___ub1Qj",colorWeak:"colorWeak___3ghT2","ant-layout":"ant-layout___2ppjB",globalSpin:"globalSpin___U9pij","ant-table":"ant-table___1eKs1","ant-table-thead":"ant-table-thead___2wyQl","ant-table-tbody":"ant-table-tbody___1sYv6",formBox:"formBox___2a4mN",hrefModal:"hrefModal___3Jgpk",shop:"shop___1aagd",headBox:"headBox___8dqG4"}},24189:function(k,V,i){"use strict";i.r(V),i.d(V,{default:function(){return ya}});var Da=i(30887),R=i(28682),Ia=i(34669),ea=i(54458),xa=i(43185),ta=i(11324),Ca=i(57663),A=i(71577),La=i(14781),$=i(23492),Ma=i(13254),Z=i(14277),M=i(11849),Oa=i(34792),m=i(48086),Ba=i(32157),F=i(82363),Sa=i(71194),G=i(50146),Ta=i(63185),H=i(9676),ja=i(47673),W=i(4107),Ka=i(88983),ia=i(47933),Na=i(18106),la=i(95562),ra=i(67294),ca=i(28216),da=i(8212),J=i(73218),Q=i(1977),oa=i(84391),na=i(1085),ha=i.n(na),pa=i(66615),ua=i.n(pa),_a=i(56173),Y=i(30672),s=i(85893),X,w,Aa=la.Z.TabPane,Za=ia.ZP.Group,q=W.Z.Search,Ua=H.Z.Group,fa=G.Z.confirm,K=F.Z.TreeNode,aa=F.Z.DirectoryTree;function va(O,a){var t=O.size/1024/1024<2;return t||m.ZP.error("\u56FE\u7247\u6700\u5927\u4E0D\u8D85\u8FC72MB!"),t}function sa(O){for(var a=document.cookie,t=a.split("; "),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]==O)return n[1]}return""}var ya=(X=(0,ca.$j)(O=>{var a=O.commondesign,t=O.page;return{commondesign:a,page:t}}),X(w=class extends ra.PureComponent{constructor(){var a;super(...arguments);a=this,this.state={visible:!1,activeKey:"self",type:"false",value:"",upload:!0,breadData:[{name:"\u6211\u7684\u56FE\u7247",classifyId:""}],classifyList:[],picList:[],editid:"",editPicid:"",loading:!1,searchValue:"",paramBloo:{},classifyExpandedKeys:[],classifySelect:[],uploadTotal:0,openLrz:!1},this.show=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;a.paramBloo={},a.param={};var r=[{name:"\u6211\u7684\u56FE\u7247",classifyId:"",handle:()=>{a.setState({breadData:r,classifyList:a.classifyList,valueItem:""}),a.getClassifList(!0),a.getPicList(!0,0)}}];a.setState({breadData:r,paramBloo:{},searchValue:""})},this.getClassifId=t=>{var r=this;if(r.level=0,t){var n=[],h=_=>{_.map(p=>{p.classifyId==t?(r.level=p.level,n=Array.isArray(p.children)?p.children:[]):p.children&&h(p.children)})};return h(this.classifyList),n}else return this.classifyList},this.getClassifList=(t,r)=>{var n=this.props.dispatch;n({type:"page/getPicClassify",payload:{private:t,classifyType:2},callback:h=>{if(h.success){var _=Array.isArray(h.data)?h.data:[];this.setState({classifyList:_}),r&&r(_[0])}}})},this.current=1,this.pageSize=98,this.classify=0,this.picData={},this.getPicList=(t,r)=>{var n=this.state.searchValue,h=this.props.dispatch;this.classifyId=r;var _=this.picData[r];_&&_[this.current]&&!n?(this.total=_.total,this.setState({picList:_[this.current]})):h({type:"page/getClassifyPic",payload:{classifyId:r,sourceName:n,private:t,currentPage:this.current,pageSize:this.pageSize},callback:p=>{if(p.success){this.total=parseInt(p.data.total);var g=Array.isArray(p.data.list)?p.data.list:[];n||(this.picData[r]||(this.picData[r]={total:this.total}),this.picData[r].total=this.total,this.picData[r][this.current]=g),this.setState({picList:g})}}})}}componentDidMount(){var a=this.props,t=a.visible,r=a.callback,n=a.multiple,h=n===void 0?!1:n;this.setState({visible:t,callback:r,type:h}),this.show(h),this.getClassifList(!0),this.getPicList(!0,0)}getImageWidth(a,t){var r=new Image;r.src=a,r.complete?t(r.width,r.height,a):r.onload=function(){t(r.width,r.height,a)}}renderself(){var a=this,t=this.state,r=t.activeKey,n=t.type,h=t.value,_=t.searchValue,p=t.picList,g=t.classifyList,T=t.breadData,P=t.editid,x=t.editPicid,D=t.paramBloo,f=t.classifyExpandedKeys,v=t.classifySelect,B=this.props,y=B.dispatch,I=B.page,C=e=>{fa({title:"\u63D0\u793A",content:"\u5C06\u8981\u5220\u9664\u8BE5\u6587\u4EF6\u5939!",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",zIndex:2e3,onOk(){y({type:"page/deletePicClassify",payload:{classifyId:e.classifyId},callback:l=>{l.success?a.getClassifList(!0):m.ZP.error(l.message)}})},onCancel(){}})},j=e=>{this.setState({editid:e.classifyId})},S=(e,l)=>{this.setState({editid:""}),y({type:"page/editPicClassify",payload:{classifyId:l.classifyId,classifyName:e.target.value},callback:o=>{o.success&&a.getClassifList(!0)}})},L=e=>{parseInt(e.level)>2?m.ZP.warning("\u56FE\u7247\u5206\u7C7B\u5C42\u7EA7\u6700\u591A3\u7EA7"):(this.setState({classifyExpandedKeys:[...f,e.classifyId+""]}),y({type:"page/addPicClassify",payload:{classifyId:e.classifyId||0,classifyType:2,classifyName:"\u65B0\u5EFA\u6587\u4EF6\u5939"},callback:l=>{l.success&&this.getClassifList(!0)}}))},E=(e,l)=>{var o=l.node.props.item,ma=e;this.setState({classifySelect:ma}),this.classify=o.classifyId,this.current=1,this.getPicList(!0,o.classifyId)},d=(e,l)=>{var o=l.nativeEvent.target.className||"";(o=="openExpand"||o.indexOf("ant-tree-switcher")>-1)&&this.setState({classifyExpandedKeys:e})},c=e=>P==e.classifyId?(0,s.jsx)(W.Z,{onBlur:l=>S(l,e),onPressEnter:l=>S(l,e),defaultValue:e.classifyName,size:"small",style:{width:"70%"},maxLength:13}):(0,s.jsxs)("span",{className:"openExpand",title:e.classifyName,children:[e.classifyName,(0,s.jsx)(da.Z,{title:"\u7F16\u8F91",onClick:()=>j(e)}),(0,s.jsx)(J.Z,{title:"\u5220\u9664",onClick:()=>C(e)}),(0,s.jsx)(Q.Z,{title:"\u6DFB\u52A0",onClick:()=>L(e)})]}),u=e=>e.map(l=>l.children?(0,s.jsx)(K,{title:c(l),item:l,children:u(l.children)},l.classifyId+""):(0,s.jsx)(K,{title:c(l),item:l},l.classifyId+"")),N=(e,l)=>{e.stopPropagation(),y({type:"page/editCommonPicName",payload:{sourceId:l.sourceId},callback:o=>{o.success&&(a.picData={},a.getPicList(!0,a.classifyId))}})},b=(e,l)=>{e.stopPropagation(),this.setState({editPicid:l.sourceId})},U=(e,l)=>{this.setState({editPicid:""}),y({type:"page/editCommonPicName",payload:{sourceId:l.sourceId,sourceName:e.target.value},callback:o=>{o.success&&(a.picData={},a.getPicList(!0,a.classifyId))}})},z={style:{float:"right"},current:this.current?this.current:1,pageSize:this.pageSize,hideOnSinglePage:!0,total:this.total,onChange:(e,l)=>{this.current=e,this.getPicList(!0,this.classify)}},ga=(e,l)=>{var o={};o[l.sourceId]=!0,console.log("type",n),console.log("sourceId",l.sourceId),n?(D[l.sourceId]?(o[l.sourceId]=!1,this.param[l.sourceId]=!1):this.param[l.sourceId]=l,this.setState({paramBloo:(0,M.Z)((0,M.Z)({},D),o)})):(this.param=l,this.setState({paramBloo:o}))},Ea=e=>{this.setState({searchValue:e.target.value})},Pa=e=>{this.setState({searchValue:e}),this.current=1,this.getPicList(!0,this.classifyId)};return(0,s.jsx)("div",{className:"tabsContent",children:(0,s.jsx)("div",{className:"contentBox",id:"imglist",children:(0,s.jsxs)("div",{className:"pictureBox",children:[(0,s.jsxs)("div",{className:"leftTreeBox",children:[(0,s.jsx)(q,{onSearch:Pa,style:{width:180,marginLeft:10},value:_,onChange:Ea}),(0,s.jsxs)(aa,{expandedKeys:f,selectedKeys:v,onSelect:E,onExpand:d,children:[(0,s.jsx)(K,{title:"\u5176\u5B83",item:{classifyId:"0"}},"0"),u(g)]})]}),(0,s.jsxs)("div",{className:"rightPicBox",children:[p.map((e,l)=>(0,s.jsxs)("div",{className:"picLi",onClick:o=>ga(o,e),children:[(0,s.jsx)("div",{className:D[e.sourceId]?"picBox on":"picBox",style:{backgroundImage:"url(".concat((0,_a.Ho)(e.sourcePath,"false"),")")}}),(0,s.jsx)("div",{onClick:o=>b(o,e),children:x==e.sourceId?(0,s.jsx)(W.Z,{onBlur:o=>U(o,e),onPressEnter:o=>U(o,e),defaultValue:e.sourceName}):(0,s.jsx)("p",{title:e.sourceName,children:e.sourceName})}),(0,s.jsx)("div",{className:"close",onClick:o=>N(o,e),children:(0,s.jsx)(J.Z,{})})]},e.sourceId)),p.length<1?(0,s.jsx)(Z.Z,{image:Z.Z.PRESENTED_IMAGE_SIMPLE,style:{marginTop:180}}):""]}),(0,s.jsx)($.Z,(0,M.Z)({},z))]})})})}renderlibrary(){var a=this,t=this.state,r=t.value,n=t.type,h=t.picList,_=t.searchValue,p=t.classifyExpandedKeys,g=t.classifySelect,T=t.classifyList,P=t.breadData,x=t.paramBloo,D=this.props,f=D.dispatch,v=D.page,B=(d,c)=>{this.setState({breadData:bData,classifyList:c.children?c.children:[]}),this.getPicList(void 0,c.classifyId)},y=(d,c)=>{var u=c.node.props.item,N=d;this.setState({classifySelect:N}),this.classify=u.classifyId,this.current=1,this.getPicList(void 0,u.classifyId)},I=(d,c)=>{var u=c.nativeEvent.target.className||"";(u=="openExpand"||u.indexOf("ant-tree-switcher")>-1)&&this.setState({classifyExpandedKeys:d})},C=d=>d.map(c=>c.children?(0,s.jsx)(K,{title:c.classifyName,item:c,children:C(c.children)},c.classifyId+""):(0,s.jsx)(K,{title:c.classifyName,item:c},c.classifyId+"")),j=(d,c)=>{var u={};u[c.sourceId]=!0,n?(x[c.sourceId]?(u[c.sourceId]=!1,this.param[c.sourceId]=!1):this.param[c.sourceId]=c,this.setState({paramBloo:(0,M.Z)((0,M.Z)({},x),u)})):(this.param=c,this.setState({paramBloo:u}))},S=d=>{this.setState({searchValue:d.target.value})},L=d=>{this.setState({searchValue:d}),this.current=1,this.getPicList(void 0,this.classifyId)},E={style:{float:"right"},current:a.current?a.current:1,pageSize:a.pageSize,total:a.total,hideOnSinglePage:!0,onChange:(d,c)=>{a.current=d,a.getPicList(void 0,a.classify)}};return(0,s.jsx)("div",{className:"tabsContent",children:(0,s.jsx)("div",{className:"contentBox",id:"imglist",children:(0,s.jsxs)("div",{className:"pictureBox",children:[(0,s.jsxs)("div",{className:"leftTreeBox",children:[(0,s.jsx)(q,{onSearch:L,style:{width:180,marginLeft:10},value:_,onChange:S}),(0,s.jsx)(aa,{expandedKeys:p,selectedKeys:g,onSelect:y,onExpand:I,children:C(T)})]}),(0,s.jsxs)("div",{className:"rightPicBox",children:[h.map((d,c)=>(0,s.jsxs)("div",{className:"picLi",onClick:u=>j(u,d),children:[(0,s.jsx)("div",{className:x[d.sourceId]?"picBox on":"picBox",style:{backgroundImage:"url(".concat(""+d.sourcePath,")")}}),(0,s.jsx)("p",{title:d.sourceName,children:d.sourceName})]},d.sourceId)),h.length<1?(0,s.jsx)(Z.Z,{image:Z.Z.PRESENTED_IMAGE_SIMPLE,style:{marginTop:180}}):""]}),(0,s.jsx)($.Z,(0,M.Z)({},E))]})})})}renderUploadButton(){var a=this,t=this.props,r=t.dispatch,n=t.page,h=this.state,_=h.classifyList,p=h.uploadTotal,g=h.openLrz,T=()=>{r({type:"page/addPicClassify",payload:{classifyId:0,classifyType:2,classifyName:"\u65B0\u5EFA\u6587\u4EF6\u5939"},callback:f=>{f.success&&this.getClassifList(!0)}})},P=f=>{if(f.file.status==="uploading"){this.setState({loading:!0});return}if(f.file.status==="done"){var v=f.file.response;v.code=="200"?(m.ZP.success("\u4E0A\u4F20\u6210\u529F"),a.picData={},a.getPicList(!0,a.classifyId)):m.ZP.error("\u4E0A\u4F20\u5931\u8D25")}},x=g?{accept:"image/*",headers:{token:sa("token")},className:"avatar-uploader",showUploadList:!1,action:"/api/disk/upload?projectid=45",data:{busType:"common_pic",picClassifyId:a.classifyId||0},beforeUpload:(f,v)=>{a.uploadTotalNum=v.length,a.uploadTotal=v.length,a.setState({uploadTotal:a.uploadTotal})},multiple:!0,customRequest:f=>{ha()(f.file,{quality:.7}).then(v=>{var B=v.file.size/1024/1024<2;if(!B)return m.ZP.error("\u56FE\u7247\u6700\u5927\u4E0D\u8D85\u8FC72MB!"),B;var y=new FormData;y.append("file",v.file,v.origin.name),y.append("busType","common_pic"),y.append("picClassifyId",a.classifyId||0),fetch("/api/disk/upload?projectid=45",{method:"POST",body:y,headers:{credentials:"same-origin",token:f.headers.token}}).then(I=>I.text()).then(I=>{a.uploadTotal=a.uploadTotal-1;var C=JSON.parse(I);C.success?a.uploadTotal==0&&(m.ZP.success("\u4E0A\u4F20\u6210\u529F"),a.picData={},a.getPicList(!0,a.classifyId)):m.ZP.error(C.message||"\u4E0A\u4F20\u5931\u8D25"),a.setState({uploadTotal:a.uploadTotal})}).catch(I=>{m.ZP.error(I.message||"\u4E0A\u4F20\u5931\u8D25")})})}}:{accept:"image/*",headers:{token:sa("token")},className:"avatar-uploader",showUploadList:!1,action:"/api/disk/upload?projectid=45",data:{busType:"common_pic",picClassifyId:a.classifyId||0},beforeUpload:va,onChange:P,multiple:!0},D=f=>{this.setState({openLrz:f.target.checked})};return(0,s.jsxs)("div",{className:"btnBox",children:[(0,s.jsx)(A.Z,{icon:(0,s.jsx)(Q.Z,{}),style:{width:110},onClick:T,disabled:!!this.breadData,children:"\u65B0\u6587\u4EF6\u5939"}),(0,s.jsx)(ta.Z,(0,M.Z)((0,M.Z)({},x),{},{children:(0,s.jsx)(A.Z,{icon:(0,s.jsx)(oa.Z,{}),style:{width:110,marginBottom:5},disabled:!!(this.breadData||p>0),children:"\u4E0A\u4F20"})})),(0,s.jsx)(H.Z,{onChange:D,checked:g,style:{width:105,textAlign:"left",fontSize:12},children:"\u56FE\u7247\u4E0A\u4F20\u538B\u7F29"}),p&&a.uploadTotalNum>1?(0,s.jsx)(ea.Z,{percent:parseInt((1-p/a.uploadTotalNum)*100),size:"small"}):""]})}render(){var a=this,t=this.props,r=t.commondesign,n=t.dispatch,h=r.Picture,_=h.visible,p=h.callback,g=h.callClose,T=g===void 0?()=>{}:g,P=this.state,x=P.activeKey,D=P.type,f=P.value,v=P.upload,B=P.breadData,y=P.searchValue,I=(0,Y.lw)((0,Y.Kd)()),C=L=>{L.key=="self"?(this.getClassifList(!0,void 0,!0),this.classify=0,this.getPicList(!0,0),this.setState({classifySelect:[],activeKey:L.key,upload:!0,searchValue:""})):(this.getClassifList(void 0,E=>{this.classify=E.classifyId,this.getPicList(void 0,E.classifyId),this.setState({classifySelect:[E.classifyId+""]})}),this.setState({activeKey:L.key,upload:!1,searchValue:""}))},j=L=>{for(var E=this.refs.imgbox.querySelectorAll(".on"),d=0,c=E.length;d<c;d++)E[d].classList.remove("on");this.setState({value:""},()=>{n({type:"commondesign/setState",payload:{Picture:{visible:!1}}}),T()})},S=L=>{var E=this.refs.imgbox.querySelectorAll(".on");if(E.length>0){if(D){var d=[];for(var c in this.param){var u=this.param[c];u&&(u.src=""+u.sourcePath,d.push(u))}p(d),this.setState({paramBloo:{}},()=>{n({type:"commondesign/setState",payload:{Picture:{visible:!1}}})})}else{var N=(b,U,z)=>{a.param.width=b,a.param.height=U,a.param.src=z,p(a.param),this.setState({paramBloo:{}},()=>{n({type:"commondesign/setState",payload:{Picture:{visible:!1}}})})};a.param.src=""+a.param.sourcePath,this.getImageWidth(this.param.src,N)}this.paramBloo={},this.param={}}else m.ZP.info(I.formatMessage({id:"explorer.selectImage"}))};return(0,s.jsxs)(G.Z,{title:"\u56FE\u7247",visible:_,onOk:S,width:1200,onCancel:j,maskClosable:!1,className:ua().hrefModal,zIndex:1001,footer:null,children:[(0,s.jsxs)("div",{className:"left",children:[(0,s.jsxs)(R.Z,{onClick:C,style:{width:170},defaultSelectedKeys:["self"],mode:"inline",children:[(0,s.jsx)(R.Z.Item,{children:"\u6211\u7684\u56FE\u7247"},"self"),(0,s.jsx)(R.Z.Item,{children:"\u56FE\u7247\u5E93"},"library")]}),v?this.renderUploadButton():""]}),(0,s.jsx)("div",{className:"right",ref:"imgbox",style:{width:1005,paddingLeft:0},children:this["render"+x]()}),(0,s.jsxs)("div",{className:"footer",style:{width:1175},children:[(0,s.jsx)(A.Z,{onClick:S,type:"primary",children:"\u786E\u5B9A"}),(0,s.jsx)(A.Z,{onClick:j,children:"\u53D6\u6D88"})]})]})}})||w)}}]);