2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
import{g as E,_ as I,w as M,W as O,j as S,k as g,m as b,n as c,t as r,p as l,D as N,G as x,H as D,E as h,F as y,l as o,cf as _,aU as R}from"./vendor/index.CRpmXtWV.js";import{d as G,R as v}from"../index.D-NvtsOM.js";import{a as W}from"./file.BexoPAcX.js";import{c as j}from"./neLicense.DcFv0Yh8.js";const $=E({__name:"UploadLicenseFile",props:{visible:{type:Boolean,default:!1},licenseList:{type:Array,default:[]}},emits:["ok","cancel","update:visible"],setup(w,{emit:F}){const{t:a}=G(),p=F,d=w;let e=I({visibleByUploadFile:!1,licensePath:"",uploadFiles:[],title:"授权文件",confirmLoading:!1});async function U(){if(!e.licensePath){o.message.warning(a("views.ne.neLicense.licensePathTip"),3);return}if(e.confirmLoading)return;e.confirmLoading=!0;const i="NE_LICENSE_MORE";if(o.notification.info({key:i,message:e.title,description:a("common.loading"),duration:0}),d.licenseList.length===0){o.notification.close(i),e.confirmLoading=!1;return}const t=[];for(const n of d.licenseList)try{(await j({neType:n.neType,neId:n.neId,licensePath:e.licensePath,reload:!0})).code!==v&&t.push(n.neType)}catch(s){console.error(s)}t.length>0?o.notification.warning({message:e.title,description:_("div",{},[_("p",a("views.ne.neLicense.uploadChangeFail")),_("div",{style:{color:"#f5222d"}},t.join("、"))]),duration:4.5}):o.notification.success({message:e.title,description:a("views.ne.neLicense.uploadChangeOk"),duration:4.5}),p("ok",t),L(),o.notification.close(i),e.confirmLoading=!1}function L(){e.visibleByUploadFile=!1,e.confirmLoading=!1,e.licensePath="",e.uploadFiles=[],p("cancel"),p("update:visible",!1)}function T(i){if(e.confirmLoading)return!1;if(!i.name.endsWith(".ini")){const n=`${a("components.UploadModal.onlyAllow")} .ini`;return o.message.error(n,3),o.Upload.LIST_IGNORE}if(!(i.size/1024/1024<3)){const n=`${a("components.UploadModal.allowFilter")} 3MB`;return o.message.error(n,3),o.Upload.LIST_IGNORE}return!0}function k(i){const t=o.message.loading(a("common.loading"),0);e.confirmLoading=!0;let n=new FormData;n.append("file",i.file),n.append("subPath","license"),W(n).then(s=>{if(s.code===v){const f=e.uploadFiles[0];f.percent=100,f.status="done";const{fileName:m}=s.data;e.licensePath=m}else o.message.error(s.msg,3)}).finally(()=>{t(),e.confirmLoading=!1})}return M(()=>d.visible,i=>{i&&(e.title=a("views.ne.neLicense.updateTtile"),e.visibleByUploadFile=!0)}),O(()=>{}),(i,t)=>{const n=o.Tag,s=o.FormItem,f=R,m=o.Button,C=o.Upload,P=o.Form,B=S("ProModal");return g(),b(B,{drag:!0,destroyOnClose:!0,keyboard:!1,"mask-closable":!1,visible:l(e).visibleByUploadFile,title:l(e).title,"confirm-loading":l(e).confirmLoading,"cancel-button-props":{disabled:l(e).confirmLoading},closable:!1,onOk:U,onCancel:L},{default:c(()=>[r(P,{name:"modalStateFrom",layout:"horizontal","wrapper-col":{span:18},"label-col":{span:6},labelWrap:!0},{default:c(()=>[r(s,{label:l(a)("views.ne.common.neType")},{default:c(()=>[(g(!0),N(D,null,x(d.licenseList,u=>(g(),b(n,{color:"processing"},{default:c(()=>[h(y(u.neType),1)]),_:2},1024))),256))]),_:1},8,["label"]),r(s,{label:l(a)("views.ne.neLicense.licensePath"),name:"file",required:!0,"validate-on-rule-change":!1,validateTrigger:[]},{default:c(()=>[r(C,{name:"file","file-list":l(e).uploadFiles,"onUpdate:fileList":t[0]||(t[0]=u=>l(e).uploadFiles=u),accept:".ini","list-type":"text",multiple:!0,"max-count":1,"show-upload-list":{showPreviewIcon:!1,showRemoveIcon:!1,showDownloadIcon:!1},"before-upload":T,"custom-request":k,disabled:l(e).confirmLoading},{default:c(()=>[r(m,{type:"primary"},{icon:c(()=>[r(f)]),default:c(()=>[h(" "+y(l(a)("views.ne.neLicense.upload")),1)]),_:1})]),_:1},8,["file-list","disabled"])]),_:1},8,["label"])]),_:1})]),_:1},8,["visible","title","confirm-loading","cancel-button-props"])}}});export{$ as default};
|