index-d286d1b0.js 14 KB

1
  1. import{r as c,G as o,H as $e,I as ke,w as Ce,f as _,o as d,h as v,k as i,l as a,m as Te,u as k,J as ze,K as N,L as S,n as T,i as u,p as h,t as r,M as D,N as I,F as Ie,O as Q,P as L,Q as Ve,S as Fe,T as Ue,_ as Ne}from"./index-32c39055.js";import{g as Se,a as De,s as je,u as Ee,b as Be,c as Me,d as Ae,e as q,f as Oe}from"./case-de2e9213.js";import{s as Re}from"./file-serve-dfea9462.js";import"./scene-3c8ec63c.js";const Ke=""+new URL("obj-2f9b3629.jpg",import.meta.url).href,Ye=""+new URL("osgb-acb0e664.jpg",import.meta.url).href,qe=""+new URL("grouping-d68d1946.svg",import.meta.url).href;const xe={class:"mymediaLibrary"},Ge=["src"],He=["title","onClick"],Pe=["onClick"],We=["onClick"],Je={key:1},Qe={style:{"margin-bottom":"10px"}},Xe={style:{"margin-bottom":"10px"}},Ze=["src"],et={style:{"margin-bottom":"10px"}},tt=["src"],lt={class:"dialog-footer"},at={class:"itemTitle"},ot={class:"itemTitleList"},it={key:0,class:"itemTitle-list"},st={class:"name"},nt=["onClick"],rt={class:"dialog-footer"},dt={class:"showContent"},ut=["src"],pt=["src"],mt=["src"],ct={class:"dialog-footer"},yt=".jpg,.png,.jpeg,.mp4,.wav,.mp3,.shp,.zip",ft={__name:"TableComponent",props:{columns:{type:Array,default:()=>[]},searchColumns:{type:Array,default:()=>[]},getData:{type:Function,required:!0}},setup(M){const A=M,m=c({name:"",fileType:0,dictId:"0"}),w=c({fileType:"",dictId:"",name:""}),n=c({show:!1,url:"",type:"",data:{}}),s=c({show:!1,title:o.t("sys.upload"),data:{},fzshow:!1,fzName:"",fzList:[]}),F=c(null),x=c(null),j=c(null),O=c("0%"),X=()=>{console.log("handleClose",j.value),j.value&&j.value.pause()},Z=e=>{Q.confirm(o.t("mediaLibrary.tips.deltext"),o.t("sys.dialogTitle"),{confirmButtonText:o.t("sys.enter"),cancelButtonText:o.t("sys.cancel")}).then(async()=>{await Se(e),z.value=z.value.filter(t=>t.id!==e.id),m.value.dictId="0",$(),L({type:"success",message:o.t("mediaLibrary.tips.del")})}),console.log("upload",x)},{photography:ee,modeling:te}=$e(),le=e=>{console.log("previewFile",e)},ae=e=>{w.value.dictId=e.dictId,console.log("data",e,w.value),s.value={show:!0,title:o.t("mediaLibrary.setGrouping"),data:e}},oe=()=>(C.value=[],!0),ie=()=>{C.value=[],w.value.dictId="",s.value.title=o.t("sys.upload"),setTimeout(()=>{s.value.show=!0},100)},se=async()=>{var t;let e={dictName:(t=s.value.fzName)==null?void 0:t.trim()};if(!e.dictName)return L.error(o.t("mediaLibrary.tips.placeholderName"));await De(e),L({type:"success",message:o.t("mediaLibrary.tips.add")}),W(),s.value.fzName=""},ne=()=>{s.value.fzshow=!0},re=async()=>{var e;if(console.log("formData",s.value.title),s.value.title!=o.t("sys.upload")){if(!w.value.dictId)return L.error(o.t("mediaLibrary.tips.dictId"));await je({id:(e=s.value.data)==null?void 0:e.id,dictId:w.value.dictId}),$(),s.value.show=!1,s.value.title="",L({type:"success",message:o.t("mediaLibrary.tips.operate")})}else{const t=new FormData,p=C.value&&C.value[0];if(!p)return L.error(o.t("common.NoFilesSelected"));t.append("file",p),t.append("dictId",w.value.dictId),console.log(p,t,"formData");const g=Ve.service({lock:!0,text:O.value,background:"rgba(0, 0, 0, 0.7)"});D({type:"event",data:"menu-disabled"}),Ee({file:p,dictId:w.value.dictId},b=>{console.log("上传进度",b),O.value=b+"%",g.setText(o.t("mediaLibrary.tips.uplooad")+O.value)}).then(async b=>{var V,y;console.log("上传进度",b),((V=b.data)==null?void 0:V.status)!=-1?(g.close(),D({type:"event",data:"menu-enabled"}),$(),s.value.show=!1,L({type:"success",message:((y=b.data)==null?void 0:y.status)==0?o.t("record.backRun"):o.t("mediaLibrary.tips.uplooadSuccess")}),G(b.data.id)):L.error(o.t("mediaLibrary.tips.uplooadErr"))}).catch(b=>{g.close(),D({type:"event",data:"menu-enabled"})}),console.log(t)}},G=e=>{Be(e).then(t=>{t.percent==100?$():setTimeout(()=>{G(e)},1e3)})},de=e=>{console.log(x,"file"),Q.confirm(o.t("mediaLibrary.tips.deltext"),o.t("sys.dialogTitle"),{confirmButtonText:o.t("sys.enter"),cancelButtonText:o.t("sys.cancel")}).then(async()=>{await Me({id:e.id}),$(),L({type:"success",message:o.t("mediaLibrary.tips.del")})})},ue=c([{dictName:o.t("mediaLibrary.fileType.0"),id:"0"}]),z=c([]),H=c([]),C=c([]),U=c(1),R=c(10),P=c(0);ke(()=>{});const W=()=>{Ae({}).then(e=>{console.log("getByKeyList",e),z.value=e})};W();const E=()=>{console.log("submitClick",m.value),U.value=1,$()},pe=({row:e,rowIndex:t})=>t===1?"warning-row":t===3?"success-row":"",$=async()=>{const{list:e,totalCount:t}=await A.getData({...m.value,fileType:m.value.fileType==0?"":m.value.fileType-1,dictId:m.value.dictId==0?"":m.value.dictId,pageNum:U.value,pageSize:R.value});H.value=e.map(p=>({...p,statusStr:p.status==-1?o.t("mediaLibrary.tips.uplooadErr"):p.status==0?o.t("mediaLibrary.tips.uplooad"):o.t("mediaLibrary.tips.uplooadSuccess"),createTime:Fe(p.createTime).format("YYYY-MM-DD HH:mm:ss")})),P.value=t},me=e=>{if(n.value.type=e.fileType,n.value.data=e,e.fileType==3)n.value.url=q({...e,type:101}),n.value.show=!0;else if(e.fileType==2||e.fileType==1||e.fileType==0)n.value.url=q({type:102})+"/"+e.fileUrl,n.value.show=!0;else{n.value.url=e.fileUrl;var t=e.fileUrl&&e.fileUrl.match(/.[^.]+$/)[0]||".docx";console.log("downloadFile",e,n.value.url),ce(n.value.url,e.name+t)}};function ce(e,t){console.log("downloadFile",e,t+ye(e)),Re(q({type:102})+"/"+e,t)}function ye(e){try{return e.substring(e.lastIndexOf("."))}catch{return".docx"}}const fe=e=>{const t=e[0];if(!J(t))return!1;F.value&&F.value.clearFiles(),t.uid=Ue(),F.value&&F.value.handleStart(t)},J=e=>{console.log("beforeUpload",e);const t=e.name.substring(e.name.lastIndexOf(".")+1).toLowerCase();return["jpg","jpg","png","jpeg","mp4","wav","mp3","shp","zip"].includes(t)?e.size/1024/1024<2e3?(C.value=[e],!0):(C.value=[],L.error(o.t("mediaLibrary.tips.uplooadSize")),!1):(L.error(o.t("mediaLibrary.tips.uplooadfiletype")),C.value=[],!1)};Ce(m,()=>{U.value=1,$()});const ve=e=>{R.value=e,$()},ge=e=>{U.value=e,$()},be=e=>{e.filesUrl&&e.filesUrl.match(/.[^.]+$/)[0];const t=n.value.data,p=document.createElement("a");p.href=n.value.url,p.download=`${t.name}.${t.fileFormat}`,p.click(),p.remove()};return $(),(e,t)=>{const p=_("el-input"),g=_("el-form-item"),b=_("el-option"),V=_("el-select"),y=_("el-button"),K=_("el-form"),B=_("el-table-column"),he=_("el-table"),we=_("el-pagination"),_e=_("el-upload"),Y=_("el-dialog");return d(),v("div",xe,[i(K,{inline:!0,model:m.value},{default:a(()=>[i(g,{class:"formitem"},{default:a(()=>[i(p,{modelValue:m.value.name,"onUpdate:modelValue":t[0]||(t[0]=l=>m.value.name=l),onInput:E,onKeydown:Te(E,["enter"]),placeholder:e.$t("mediaLibrary.addFilePlace"),size:"default","prefix-icon":k(ze)},null,8,["modelValue","placeholder","prefix-icon"])]),_:1}),i(g,null,{default:a(()=>[i(V,{style:{width:"120px"},modelValue:m.value.fileType,"onUpdate:modelValue":t[1]||(t[1]=l=>m.value.fileType=l),onChange:E,placeholder:e.$t("mediaLibrary.fileType.0")},{default:a(()=>[(d(!0),v(N,null,S([e.$t("mediaLibrary.fileType.0"),e.$t("mediaLibrary.fileType.1"),e.$t("mediaLibrary.fileType.2"),e.$t("mediaLibrary.fileType.3"),e.$t("mediaLibrary.fileType.4"),e.$t("mediaLibrary.fileType.5")],(l,f)=>(d(),T(b,{key:f,label:l,value:f},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1}),i(g,{style:{"margin-right":"0px"}},{default:a(()=>[i(V,{class:"groupingSelcet",modelValue:m.value.dictId,"onUpdate:modelValue":t[2]||(t[2]=l=>m.value.dictId=l),style:{width:"120px"},onChange:E,placeholder:e.$t("mediaLibrary.fileType.0")},{default:a(()=>[(d(!0),v(N,null,S([...ue.value,...z.value],(l,f)=>(d(),T(b,{key:f,label:l.dictName,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"]),u("div",{class:"grouping",onClick:ne},[u("img",{src:k(qe),alt:""},null,8,Ge)])]),_:1}),i(g,{style:{float:"right","margin-right":"0"}},{default:a(()=>[k(ee)==1?(d(),T(y,{key:0,onClick:t[3]||(t[3]=l=>k(D)({type:"photography",library:!0}))},{default:a(()=>[h(r(e.$t("mediaLibrary.photography")),1)]),_:1})):I("",!0),k(te)==1?(d(),T(y,{key:1,onClick:t[4]||(t[4]=l=>k(D)({type:"modeling",library:!0}))},{default:a(()=>[h(r(e.$t("mediaLibrary.Modeling")),1)]),_:1})):I("",!0),i(y,{type:"primary",onClick:ie},{default:a(()=>[h(r(e.$t("mediaLibrary.upload")),1)]),_:1})]),_:1})]),_:1},8,["model"]),i(he,{"tooltip-effect":"dark",ref:"tableRef",size:"large",data:H.value,style:{width:"100%"},"row-class-name":pe},{default:a(()=>[i(B,{prop:"name",label:e.$t("program.case.title"),"min-width":"300px","show-overflow-tooltip":""},{default:a(l=>[l.row.fileUrl?(d(),v("a",{key:0,style:{color:"var(--primaryColor)",cursor:"pointer"},target:"_blank",title:l.row.name,onClick:f=>me(l.row)},r(l.row.name),9,He)):I("",!0)]),_:1},8,["label"]),i(B,{prop:"fileTypeStr",label:k(o).t("mediaLibrary.fileTypeStr"),"min-width":"100px","show-overflow-tooltip":""},{default:a(l=>[h(r(e.$t(`mediaLibrary.fileType.${l.row.fileType+1}`)),1)]),_:1},8,["label"]),(d(!0),v(N,null,S(M.columns,l=>(d(),T(B,{key:l.prop,prop:l.prop,"show-overflow-tooltip":"",align:"center","min-width":l.width,label:l.label},null,8,["prop","min-width","label"]))),128)),i(B,{align:"center",label:e.$t("mediaLibrary.operate"),width:"150"},{default:a(({row:l})=>[u("span",{class:"oper-span",style:{color:"var(--primaryColor)"},onClick:f=>ae(l)},r(e.$t("sys.edit")),9,Pe),u("span",{class:"oper-span",onClick:f=>de(l),style:{color:"var(--primaryColor)"}},r(e.$t("sys.delete")),9,We)]),_:1},8,["label"])]),_:1},8,["data"]),i(we,{class:"mt-3",background:"",onSizeChange:ve,onCurrentChange:ge,"current-page":U.value,"page-sizes":[10,20,30],"page-size":R.value,style:{"justify-content":"end"},layout:"prev, pager, next",total:P.value},null,8,["current-page","page-size","total"]),i(Y,{modelValue:s.value.show,"onUpdate:modelValue":t[7]||(t[7]=l=>s.value.show=l),title:s.value.title,width:"400"},{footer:a(()=>[u("div",lt,[i(y,{onClick:t[6]||(t[6]=l=>s.value.show=!1)},{default:a(()=>[h(r(e.$t("sys.cancel")),1)]),_:1}),i(y,{type:"primary",onClick:re},{default:a(()=>[h(r(e.$t("sys.enter")),1)]),_:1})])]),default:a(()=>[i(K,{"label-position":"top",model:e.form,"label-width":"110"},{default:a(()=>[s.value.title==e.$t("sys.upload")?(d(),T(g,{key:0,label:e.$t("mediaLibrary.file"),"label-width":e.formLabelWidth},{default:a(()=>[i(_e,{class:"upload-demo",style:{width:"100%"},ref_key:"upload",ref:F,multiple:!1,limit:1,"before-upload":J,"on-exceed":fe,"file-list":C.value,"http-request":()=>{},"on-preview":le,accept:yt,"before-remove":oe},{default:a(()=>[i(y,{type:"primary"},{default:a(()=>[h(r(e.$t("sys.upload")),1)]),_:1})]),_:1},8,["file-list"])]),_:1},8,["label","label-width"])):I("",!0),i(g,{label:s.value.title==e.$t("sys.upload")?e.$t("mediaLibrary.dictName"):e.$t("mediaLibrary.setGrouping"),"label-width":e.formLabelWidth},{default:a(()=>[i(V,{style:{width:"100%"},modelValue:w.value.dictId,"onUpdate:modelValue":t[5]||(t[5]=l=>w.value.dictId=l),placeholder:e.$t("mediaLibrary.tips.dictId")},{default:a(()=>[(d(!0),v(N,null,S(z.value,(l,f)=>(d(),T(b,{key:f,label:l.dictName,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label","label-width"]),s.value.title==e.$t("sys.upload")?(d(),v("div",Je,[u("div",Qe,r(e.$t("mediaLibrary.tips.uplooadfiletype"))+r(e.$t("mediaLibrary.tips.uplooadSize")),1),u("div",Xe,[u("div",null,r(e.$t("mediaLibrary.tips.objtips")),1),u("img",{style:{width:"150px"},src:k(Ke),alt:""},null,8,Ze)]),u("div",et,[u("div",null,r(e.$t("mediaLibrary.tips.osgbtips")),1),u("img",{style:{width:"150px"},src:k(Ye),alt:""},null,8,tt)])])):I("",!0)]),_:1},8,["model"])]),_:1},8,["modelValue","title"]),i(Y,{modelValue:s.value.fzshow,"onUpdate:modelValue":t[11]||(t[11]=l=>s.value.fzshow=l),title:e.$t("mediaLibrary.grouping"),width:"400"},{footer:a(()=>[u("div",rt,[i(y,{onClick:t[9]||(t[9]=l=>s.value.fzshow=!1)},{default:a(()=>[h(r(e.$t("sys.cancel")),1)]),_:1}),i(y,{type:"primary",onClick:t[10]||(t[10]=l=>s.value.fzshow=!1)},{default:a(()=>[h(r(e.$t("sys.enter")),1)]),_:1})])]),default:a(()=>[i(K,{"label-position":"top",model:e.form,"label-width":"50"},{default:a(()=>{var l;return[i(g,{label:e.$t("mediaLibrary.addgrouping"),"label-width":e.formLabelWidth},{default:a(()=>[i(p,{modelValue:s.value.fzName,"onUpdate:modelValue":t[8]||(t[8]=f=>s.value.fzName=f),maxlength:"50","show-word-limit":"",style:{width:"278px"}},null,8,["modelValue"]),i(y,{style:{"margin-left":"20px",width:"60px"},onClick:se},{default:a(()=>[h(r(e.$t("common.add")),1)]),_:1})]),_:1},8,["label","label-width"]),u("div",at,[u("p",null,r(e.$t("mediaLibrary.groupingList")),1),u("div",ot,[(l=z.value)!=null&&l.length?I("",!0):(d(),v("div",it,r(e.$t("program.undata")),1)),(d(!0),v(N,null,S(z.value,(f,Le)=>(d(),v("div",{class:"itemTitle-list",key:Le},[u("span",st,r(f.dictName),1),u("span",{class:"del",onClick:bt=>Z(f)},r(e.$t("sys.delete")),9,nt)]))),128))])])]}),_:1},8,["model"])]),_:1},8,["modelValue","title"]),i(Y,{modelValue:n.value.show,"onUpdate:modelValue":t[13]||(t[13]=l=>n.value.show=l),title:e.$t("sys.query"),width:n.value.type==4?800:600,onClose:X},{footer:a(()=>[u("div",ct,[i(y,{onClick:t[12]||(t[12]=l=>n.value.show=!1)},{default:a(()=>[h(r(e.$t("sys.cancel")),1)]),_:1}),n.value.type==0?(d(),T(y,{key:0,type:"primary",onClick:be},{default:a(()=>[h(r(e.$t("sys.download")),1)]),_:1})):I("",!0)])]),default:a(()=>[u("div",dt,[n.value.type==0?(d(),v("img",{key:0,style:{width:"100%","object-fit":"cover"},src:n.value.url,alt:""},null,8,ut)):n.value.type==1||n.value.type==2?(d(),v("video",{key:1,ref_key:"audio",ref:j,controls:"",style:Ie([{width:"100%","max-height":"300px"},{height:n.value.type==2?"50px":"auto"}]),src:n.value.url,alt:""},null,12,pt)):(d(),v("iframe",{key:2,style:{width:"100%",height:"400px"},src:n.value.url,frameborder:"0"},null,8,mt))])]),_:1},8,["modelValue","title","width"])])}}};const vt={id:"mediaLibraryApp"},gt={__name:"index",setup(M){const A=[{prop:"fileFormat",width:"100px",label:o.t("mediaLibrary.fileFormat")},{prop:"dictName",label:o.t("mediaLibrary.dictName")},{prop:"statusStr",label:o.t("mediaLibrary.statusStr")},{prop:"createTime",label:o.t("mediaLibrary.createTime"),width:200}],m=c([]),w=async n=>{const s=await Oe(n);return{list:s.list,totalCount:s.total}};return(n,s)=>(d(),v("div",vt,[i(ft,{columns:A,searchColumns:m.value,getData:w},null,8,["searchColumns"])]))}},$t=Ne(gt,[["__scopeId","data-v-c1b6a186"]]);export{$t as default};