1 |
- var w=(e,r,f)=>new Promise((T,h)=>{var v=n=>{try{c(f.next(n))}catch(i){h(i)}},g=n=>{try{c(f.throw(n))}catch(i){h(i)}},c=n=>n.done?T(n.value):Promise.resolve(n.value).then(v,g);c((f=f.apply(e,r)).next())});import{B as J,u as K}from"./useTable-B6PunZL5.js";import{T as Q,B as X,u as Y}from"./index-BIj58_Cj.js";import{ao as Z,v as x,ap as ee,_ as oe}from"./entry/index-DJx93RYF-1731481145019.js";import{u as ae}from"./index-CzIUqxsa.js";import{F as ne,c as le,s as te}from"./FileDrawer-CldYh8QW.js";import{g as ie,u as se,d as re,a as O}from"./file-UkiX_CBa.js";import{i as ce}from"./index-BQgPd3bX.js";import{a8 as de,M as S}from"./antd-CBeLo_oO.js";import{d as me,f as t,k as l,a9 as p,_ as V,$ as ue,a7 as a,a6 as E,G as k,a2 as y,a0 as M,a1 as j}from"./vue-B5pbXMv7.js";import"./useForm-pwHPrILC.js";import"./index-D_SNX-7K.js";import"./tree-BtJaOqz0.js";import"./copyTextToClipboard-Dngb1Nn3.js";import"./index-BDsRYE32.js";import"./index-wDJjh9Os.js";import"./index-BzfGKMh3.js";import"./index-DkGmfgEA.js";import"./index-Cuu0w1HY.js";import"./useWindowSizeFn-BxA6-zLj.js";import"./plugin-C2XGVjF6.js";import"./uuid-BUBnBT7J.js";import"./onMountedOrActivated-C3HH8-CK.js";import"./sortable.esm-BEDva30o.js";import"./useSortable-lvT7rWOs.js";import"./fileTag-8tH9yqzB.js";import"./ExclamationCircleOutlined-Ca0mYuiu.js";const pe=me({name:"FileManagement",components:{BasicTable:J,FileDrawer:ne,Button:Z,TableAction:Q,BasicUpload:X,Image:de,Modal:S},setup(){const{t:e}=x.useI18n(),{toClipboard:r}=Y(),{createErrorModal:f,createMessage:T}=ee(),h=t(!1),v=t(),[g,{openDrawer:c}]=ae(),[n,{reload:i}]=K({title:e("fms.file.fileList"),api:ie,columns:le,formConfig:{labelWidth:120,schemas:te},useSearchForm:!0,showTableSetting:!0,bordered:!1,clickToRowSelect:!1,showIndexColumn:!1,actionColumn:{width:50,title:e("common.action"),dataIndex:"action",fixed:void 0},rowKey:"id",rowSelection:{type:"checkbox",onChange:(o,u)=>{v.value=o,h.value=o.length>0}}}),D=t(!1),d=t(!1),b=t(!1),R=o=>{D.value=o},s=t(""),m=t(""),L=t(""),N=t(""),U=t("");function P(){c(!0,{isUpdate:!1})}function A(o){return w(this,null,function*(){let u=yield re(o.id,"none"),B=u.type.split("/")[0];if(U.value=o.name+"."+o.path.split(".")[1],B==="image")b.value=!0,s.value=URL.createObjectURL(u);else if(B==="video")d.value=!0,m.value=URL.createObjectURL(u),L.value=o.name;else{const C=document.createElement("a");C.href=URL.createObjectURL(u),C.download=U.value,C.click(),C.remove(),URL.revokeObjectURL(C.href)}})}function $(){const o=document.createElement("a");o.href=m.value,o.download=U.value,o.click(),o.remove(),URL.revokeObjectURL(o.href),F()}function _(){const o=document.createElement("a");o.href=s.value,o.download=U.value,o.click(),o.remove(),URL.revokeObjectURL(o.href),I()}function F(){d.value=!1}function I(){b.value=!1}function z(o){c(!0,{record:o,isUpdate:!0})}function G(o){return w(this,null,function*(){yield O({ids:[o.id]}),i()})}function W(){return w(this,null,function*(){S.confirm({title:e("common.deleteConfirm"),icon:l(ce.ExclamationCircleOutlined),onOk(){return w(this,null,function*(){const u=v.value;(yield O({ids:u})).code===0&&(yield i())})},onCancel(){}})})}function q(o){return w(this,null,function*(){try{yield r(o.publicPath),T.success(e("fms.file.copyURLSuccess"))}catch(u){f({title:e("fms.file.copyURLFailed"),content:o.publicPath})}})}function H(){i()}return{t:e,registerTable:n,registerDrawer:g,handleCreate:P,handleEdit:z,handleDelete:G,handleSuccess:H,handleDownload:A,handleChange:o=>{},uploadApi:se,visible:D,videoVisible:d,imageVisible:b,setVisible:R,imagePath:s,videoPath:m,videoTitle:L,imageTitle:N,handleDownloadVideo:$,handleDownloadImage:_,handleCloseVideo:F,handleCloseImage:I,handleCopyToClipboard:q,handleBatchDelete:W,showDeleteButton:h}}}),fe={width:"1280",height:"720",controls:""},he=["src"];function be(e,r,f,T,h,v){const g=p("Button"),c=p("BasicUpload"),n=p("TableAction"),i=p("BasicTable"),D=p("FileDrawer"),d=p("a-button"),b=p("Modal"),R=p("Image");return V(),ue("div",null,[l(i,{onRegister:e.registerTable},{tableTitle:a(()=>[e.showDeleteButton?(V(),E(g,{key:0,type:"primary",danger:"",preIcon:"ant-design:delete-outlined",onClick:e.handleBatchDelete},{default:a(()=>[k(y(e.t("common.delete")),1)]),_:1},8,["onClick"])):M("",!0)]),toolbar:a(()=>[l(c,{maxSize:1e3,maxNumber:10,onChange:e.handleChange,api:e.uploadApi,class:"my-5",accept:["image/*","video/*","audio/*"]},null,8,["onChange","api"])]),bodyCell:a(({column:s,record:m})=>[s.key==="action"?(V(),E(n,{key:0,actions:[{label:e.t("fms.file.download"),onClick:e.handleDownload.bind(null,m)},{label:e.t("fms.file.copyURL"),onClick:e.handleCopyToClipboard.bind(null,m)},{label:"编辑",onClick:e.handleEdit.bind(null,m)},{color:"error",label:"删除",popConfirm:{title:e.t("common.deleteConfirm"),placement:"left",confirm:e.handleDelete.bind(null,m)}}]},null,8,["actions"])):M("",!0)]),_:1},8,["onRegister"]),l(D,{onRegister:e.registerDrawer,onSuccess:e.handleSuccess},null,8,["onRegister","onSuccess"]),l(b,{open:e.videoVisible,"onUpdate:open":r[0]||(r[0]=s=>e.videoVisible=s),title:e.videoTitle,width:"80%","wrap-class-name":"full-modal",onOk:e.handleDownloadVideo},{footer:a(()=>[l(d,{key:"back",onClick:e.handleCloseVideo},{default:a(()=>[k(y(e.t("common.closeText")),1)]),_:1},8,["onClick"]),l(d,{key:"download",type:"primary",onClick:e.handleDownloadVideo},{default:a(()=>[k(y(e.t("fms.file.download")),1)]),_:1},8,["onClick"])]),default:a(()=>[j("video",fe,[j("source",{src:e.videoPath,type:"video/mp4"},null,8,he)])]),_:1},8,["open","title","onOk"]),l(b,{open:e.imageVisible,"onUpdate:open":r[1]||(r[1]=s=>e.imageVisible=s),title:e.imageTitle,width:"50%","wrap-class-name":"full-modal",onOk:e.handleDownloadImage},{footer:a(()=>[l(d,{key:"back",onClick:e.handleCloseImage},{default:a(()=>[k(y(e.t("common.closeText")),1)]),_:1},8,["onClick"]),l(d,{key:"download",type:"primary",onClick:e.handleDownloadImage},{default:a(()=>[k(y(e.t("fms.file.download")),1)]),_:1},8,["onClick"])]),default:a(()=>[l(R,{width:"100%",style:{},preview:{visible:e.visible,onVisibleChange:e.setVisible},src:e.imagePath},null,8,["preview","src"])]),_:1},8,["open","title","onOk"])])}const We=oe(pe,[["render",be]]);export{We as default};
|