2 lines
5.6 KiB
JavaScript
2 lines
5.6 KiB
JavaScript
import{g as A,cd as j,_ as C,l as o,w as G,W,j as z,k as J,m as H,n as d,t as i,p as a,E as v,F as b,a6 as L,I as K,an as Q,au as X,ce as Y,ay as Z,aU as ee}from"./vendor/index.CRpmXtWV.js";import{d as oe,R as u}from"../index.D-NvtsOM.js";import{c as ne,g as te,a as ae}from"./neLicense.DcFv0Yh8.js";import{a as le}from"./file.BexoPAcX.js";const me=A({__name:"EditModal",props:{visible:{type:Boolean,default:!1},editId:{type:String,default:""},neId:{type:String,default:""},neType:{type:String,default:""},reload:{type:Boolean,default:!1}},emits:["ok","cancel","update:visible"],setup(I,{emit:k}){const{copy:T}=j({legacy:!0}),{t}=oe(),_=k,r=I;let e=C({visibleByEdit:!1,title:"授权文件",from:{id:"",neType:"",neId:"",activationRequestCode:"",licensePath:"",remark:"",reload:!1},confirmLoading:!1,uploadFiles:[]});const f=o.Form.useForm(e.from,C({licensePath:[{required:!0,message:t("views.ne.neLicense.licensePathTip")}]}));function F(){e.confirmLoading||!e.from.id||f.validate().then(s=>{e.confirmLoading=!0;const l=o.message.loading(t("common.loading"),0),n=Q(e.from);ne(n).then(c=>{c.code===u?(o.message.success({content:t("common.operateOk"),duration:3}),_("ok",JSON.parse(JSON.stringify(n))),h()):o.message.error({content:`${c.msg}`,duration:3}),l(),e.confirmLoading=!1})}).catch(s=>{o.message.error(t("common.errorFields",{num:s.errorFields.length}),3)})}function h(){e.visibleByEdit=!1,e.confirmLoading=!1,f.resetFields(),e.uploadFiles=[],_("cancel"),_("update:visible",!1)}function O(s){if(e.confirmLoading)return!1;if(!s.name.endsWith(".ini")){const n=`${t("components.UploadModal.onlyAllow")} .ini`;return o.message.error(n,3),o.Upload.LIST_IGNORE}if(!(s.size/1024/1024<3)){const n=`${t("components.UploadModal.allowFilter")} 3MB`;return o.message.error(n,3),o.Upload.LIST_IGNORE}return!0}function B(s){const l=o.message.loading(t("common.loading"),0);e.confirmLoading=!0;let n=new FormData;n.append("file",s.file),n.append("subPath","license"),le(n).then(c=>{if(c.code===u){const p=e.uploadFiles[0];p.percent=100,p.status="done";const{fileName:g}=c.data;e.from.licensePath=g}else o.message.error(c.msg,3)}).finally(()=>{l(),e.confirmLoading=!1})}function R(){const s=e.from.activationRequestCode;s&&T(s).then(()=>{o.message.success(t("common.copyOk"),3)})}function S(){const{activationRequestCode:s,neType:l,neId:n}=e.from;s&&o.Modal.confirm({title:t("common.tipTitle"),content:t("views.ne.neLicense.downCodeTop"),onOk(){const c=new Blob([s],{type:"text/plain"});X(c,`${l}_${n}_code.txt`)}})}function x(s){const l=o.message.loading(t("common.loading"),0);te(s).then(n=>{n.code===u?(Object.assign(e.from,n.data),e.from.licensePath="",e.from.reload=r.reload,e.title=t("views.ne.neLicense.updateTtile"),e.visibleByEdit=!0):o.message.error(n.msg,3)}).finally(()=>{e.confirmLoading=!1,l()})}function U(s,l){const n=o.message.loading(t("common.loading"),0);ae(s,l).then(c=>{c.code===u?(Object.assign(e.from,c.data),e.from.licensePath="",e.from.reload=r.reload,e.title=t("views.ne.neLicense.updateTtile"),e.visibleByEdit=!0):o.message.error(c.msg,3)}).finally(()=>{e.confirmLoading=!1,n()})}return G(()=>r.visible,s=>{s&&(r.editId&&x(r.editId),r.neType&&r.neId&&U(r.neType,r.neId))}),W(()=>{}),(s,l)=>{const n=o.FormItem,c=o.Col,p=o.Row,g=o.Input,M=Y,y=o.Button,w=o.Tooltip,P=Z,E=o.InputGroup,N=ee,q=o.Upload,ie=o.Switch,D=o.Textarea,$=o.Form,V=z("ProModal");return J(),H(V,{drag:!0,width:800,destroyOnClose:!0,keyboard:!1,"mask-closable":!1,visible:a(e).visibleByEdit,title:a(e).title,"confirm-loading":a(e).confirmLoading,onOk:F,onCancel:h},{default:d(()=>[i($,{name:"modalStateFrom",layout:"horizontal","wrapper-col":{span:18},"label-col":{span:6},labelWrap:!0},{default:d(()=>[i(p,{gutter:16},{default:d(()=>[i(c,{lg:12,md:12,xs:24},{default:d(()=>[i(n,{"label-col":{span:12},label:a(t)("views.ne.common.neType"),name:"neType"},{default:d(()=>[v(b(a(e).from.neType),1)]),_:1},8,["label"])]),_:1}),i(c,{lg:12,md:12,xs:24},{default:d(()=>[i(n,{"label-col":{span:12},label:a(t)("views.ne.common.neId"),name:"neId"},{default:d(()=>[v(b(a(e).from.neId),1)]),_:1},8,["label"])]),_:1})]),_:1}),i(n,L({label:a(t)("views.ne.neLicense.activationRequestCode"),name:"activationRequestCode"},a(f).validateInfos.activationRequestCode),{default:d(()=>[i(E,{compact:""},{default:d(()=>[i(g,{value:a(e).from.activationRequestCode,"onUpdate:value":l[0]||(l[0]=m=>a(e).from.activationRequestCode=m),disabled:!0,style:{width:"calc(100% - 64px)"}},null,8,["value"]),i(w,{title:a(t)("common.copyText"),placement:"topRight"},{default:d(()=>[i(y,{type:"default",onClick:l[1]||(l[1]=m=>R())},{icon:d(()=>[i(M)]),_:1})]),_:1},8,["title"]),i(w,{title:a(t)("common.downloadText"),placement:"topRight"},{default:d(()=>[i(y,{type:"primary",onClick:l[2]||(l[2]=m=>S())},{icon:d(()=>[i(P)]),_:1})]),_:1},8,["title"])]),_:1})]),_:1},16,["label"]),i(n,L({label:a(t)("views.ne.neLicense.licensePath"),name:"file"},a(f).validateInfos.licensePath),{default:d(()=>[i(q,{name:"file","file-list":a(e).uploadFiles,"onUpdate:fileList":l[3]||(l[3]=m=>a(e).uploadFiles=m),accept:".ini","list-type":"text","max-count":1,"show-upload-list":{showPreviewIcon:!1,showRemoveIcon:!1,showDownloadIcon:!1},"before-upload":O,"custom-request":B,disabled:a(e).confirmLoading},{default:d(()=>[i(y,{type:"primary"},{icon:d(()=>[i(N)]),default:d(()=>[v(" "+b(a(t)("views.ne.neLicense.upload")),1)]),_:1})]),_:1},8,["file-list","disabled"])]),_:1},16,["label"]),K("",!0),i(n,{label:a(t)("common.remark"),name:"remark"},{default:d(()=>[i(D,{value:a(e).from.remark,"onUpdate:value":l[5]||(l[5]=m=>a(e).from.remark=m),maxlength:200,"show-count":!0,placeholder:a(t)("common.inputPlease")},null,8,["value","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1},8,["visible","title","confirm-loading"])}}});export{me as default};
|