1
0
Files
build.ems/build/usr/local/omc/htdocs/front/js/UploadMoreFile.B6BkvwOj.js
2024-10-25 14:59:47 +08:00

2 lines
7.0 KiB
JavaScript

import{g as P,_ as A,w as G,W as V,j as q,k as b,m as j,n as p,t as c,D as L,p as t,E as g,F as h,H as N,J as K,l as i,an as U,aU as X}from"./vendor/index.CRpmXtWV.js";import{d as Y,a7 as v,N as F,R as I}from"../index.D-NvtsOM.js";import{a as W}from"./neSoftware.CvdsdLsa.js";import{b as E}from"./file.BexoPAcX.js";const $=K("br",null,null,-1),Z=P({__name:"UploadMoreFile",props:{visible:{type:Boolean,default:!1},neType:{type:String}},emits:["ok","cancel","update:visible"],setup(B,{emit:O}){const{t:l}=Y(),_=O,w=B,T=v.concat(F);let o=A({visibleByMoreFile:!1,title:"软件包文件",from:[],confirmLoading:!1,uploadFiles:[],uploadFilesDep:[]});async function M(){if(o.confirmLoading)return;if(o.uploadFiles.length<1){i.message.warning({content:l("views.ne.neSoftware.uploadNotFile"),duration:3});return}const d=U(o.uploadFiles),e=U(o.from),n={};for(const a of d){if(a.status!=="done"||!a.path)continue;const s=e.find(m=>m.name===a.name);s&&F.includes(s.neType)&&(s.path=a.path),s&&v.includes(s.neType)&&(n[s.neType]=a.path)}const r=e.find(a=>a.neType==="IMS");if(r){const a=[];n.ADB&&a.push(n.ADB),n.KVDB&&a.push(n.KVDB),n.RTPROXY&&a.push(n.RTPROXY),n.MF&&a.push(n.MF),a.push(r.path),r.path=a.join(",")}const f=e.find(a=>a.neType==="UDM");if(f&&n.ADB?f.path=[n.ADB,f.path].join(","):f&&n.KVDB&&(f.path=[n.KVDB,f.path].join(",")),w.neType&&o.uploadFilesDep.length>0){const a=e.find(s=>s.neType===w.neType);if(a){const s=[];for(const m of o.uploadFilesDep)m.status==="done"&&m.path&&s.push(m.path);s.push(a.path),a.path=s.join(",")}}const u=[];o.confirmLoading=!0;for(const a of e.filter(s=>F.includes(s.neType)))try{const s=await W(a);s.code===I?u.push(a):i.message.error({content:`${a.neType} ${s.msg}`,duration:3})}catch(s){console.error(s)}_("ok",u),S()}function S(){o.visibleByMoreFile=!1,o.confirmLoading=!1,o.from=[],o.uploadFiles=[],o.uploadFilesDep=[],_("cancel"),_("update:visible",!1)}function x(d){if(o.confirmLoading)return!1;const e=d.name,n=e.substring(e.lastIndexOf("."));if(![".deb",".rpm"].includes(n))return i.message.error(l("views.configManage.softwareManage.onlyAble",{fileText:"(.deb、.rpm)"}),3),i.Upload.LIST_IGNORE;let r="";const f=e.indexOf("-");if(f!==-1&&(r=e.substring(0,f).toUpperCase()),!T.includes(r))return i.notification.warning({message:e,description:l("views.ne.neSoftware.fileCheckType")}),i.Upload.LIST_IGNORE;let u="";const a=e.match(/([0-9.]+[0-9x]+)/);if(a)u=a[0];else return i.notification.warning({message:e,description:l("views.ne.neSoftware.fileCheckVer")}),i.Upload.LIST_IGNORE;return w.neType&&w.neType!==r?(i.notification.warning({message:e,description:l("views.ne.neSoftware.fileTypeNotEq",{txt:w.neType})}),i.Upload.LIST_IGNORE):o.from.find(m=>m.neType===r)?(i.notification.warning({message:e,description:l("views.ne.neSoftware.fileTypeExists")}),i.Upload.LIST_IGNORE):(o.from.push({name:e,neType:r,version:u,path:"",description:""}),!0)}function R(d){const e=d.name;let n="";const r=e.indexOf("-");r!==-1&&(n=e.substring(0,r).toUpperCase());const f=o.from.findIndex(u=>u.neType===n);return o.from.splice(f,1),!0}function D(d){const e=o.uploadFiles.find(n=>n.uid===d.file.uid);e&&E(d.file,5,"software").then(n=>{n.code===I?(e.percent=100,e.status="done",e.path=n.data.fileName):i.message.error(n.msg,3)}).catch(n=>{e.percent=0,e.status="error",e.response=n.message}).finally(()=>{o.confirmLoading=!1})}function k(d){if(o.confirmLoading)return!1;const e=d.name,n=e.substring(e.lastIndexOf("."));if(![".deb",".rpm"].includes(n))return i.message.error(l("views.configManage.softwareManage.onlyAble",{fileText:"(.deb、.rpm)"}),3),i.Upload.LIST_IGNORE;if(o.uploadFilesDep.find(a=>a.name===e))return i.notification.warning({message:e,description:l("views.ne.neSoftware.fileNameExists")}),i.Upload.LIST_IGNORE;let f="";const u=e.indexOf("-");return u!==-1&&(f=e.substring(0,u).toUpperCase()),v.includes(f)?!0:(i.notification.warning({message:e,description:l("views.ne.neSoftware.fileCheckTypeDep")}),i.Upload.LIST_IGNORE)}function C(d){const e=o.uploadFilesDep.find(n=>n.uid===d.file.uid);e&&E(d.file,5,"software").then(n=>{n.code===I?(e.percent=100,e.status="done",e.path=n.data.fileName):i.message.error(n.msg,3)}).catch(n=>{e.percent=0,e.status="error",e.response=n.message}).finally(()=>{o.confirmLoading=!1})}return G(()=>w.visible,d=>{d&&(o.title=l("views.ne.neSoftware.uploadTitle"),o.visibleByMoreFile=!0)}),V(()=>{}),(d,e)=>{const n=i.Tag,r=i.FormItem,f=X,u=i.Button,a=i.Upload,s=i.Form,m=q("ProModal");return b(),j(m,{drag:!0,width:800,keyboard:!1,"mask-closable":!1,visible:t(o).visibleByMoreFile,title:t(o).title,"confirm-loading":t(o).confirmLoading,onOk:M,onCancel:S},{default:p(()=>[c(s,{name:"modalStateFrom",layout:"horizontal","wrapper-col":{span:18},"label-col":{span:6},labelWrap:!0},{default:p(()=>[w.neType?(b(),L(N,{key:0},[c(r,{label:t(l)("views.ne.common.neType"),name:"type"},{default:p(()=>[c(n,{color:"processing"},{default:p(()=>[g(h(w.neType),1)]),_:1})]),_:1},8,["label"]),c(r,{label:t(l)("views.ne.neSoftware.path"),help:t(l)("views.ne.neSoftware.uploadFileName"),required:!0,"validate-on-rule-change":!1,validateTrigger:[],name:"file"},{default:p(()=>[c(a,{name:"file","file-list":t(o).uploadFiles,"onUpdate:fileList":e[0]||(e[0]=y=>t(o).uploadFiles=y),accept:".rpm,.deb","list-type":"text","max-count":1,"show-upload-list":{showPreviewIcon:!1,showRemoveIcon:!1,showDownloadIcon:!1},"before-upload":x,"custom-request":D,disabled:t(o).confirmLoading},{default:p(()=>[c(u,{type:"primary"},{icon:p(()=>[c(f)]),default:p(()=>[g(" "+h(t(l)("views.ne.neSoftware.upload")),1)]),_:1})]),_:1},8,["file-list","disabled"])]),_:1},8,["label","help"]),c(r,{name:"dep",label:t(l)("views.ne.neSoftware.dependFile"),help:t(l)("views.ne.neSoftware.dependFileTip")},{default:p(()=>[c(a,{name:"file","file-list":t(o).uploadFilesDep,"onUpdate:fileList":e[1]||(e[1]=y=>t(o).uploadFilesDep=y),accept:".rpm,.deb","list-type":"text",multiple:!0,"max-count":5,"show-upload-list":{showPreviewIcon:!1,showRemoveIcon:!0,showDownloadIcon:!1},"before-upload":k,"custom-request":C,disabled:t(o).confirmLoading},{default:p(()=>[c(u,{type:"dashed"},{icon:p(()=>[c(f)]),default:p(()=>[g(" "+h(t(l)("views.ne.neSoftware.upload")),1)]),_:1})]),_:1},8,["file-list","disabled"])]),_:1},8,["label","help"])],64)):(b(),L(N,{key:1},[c(r,{label:t(l)("common.description")},{default:p(()=>[g(h(t(l)("views.ne.neSoftware.uploadBatchMax",{txt:t(T).length}))+" ",1),$,g(" "+h(t(l)("views.ne.neSoftware.uploadFileName")),1)]),_:1},8,["label"]),c(r,{label:t(l)("views.ne.neSoftware.path"),required:!0,"validate-on-rule-change":!1,validateTrigger:[],name:"file"},{default:p(()=>[c(a,{name:"file","file-list":t(o).uploadFiles,"onUpdate:fileList":e[2]||(e[2]=y=>t(o).uploadFiles=y),accept:".rpm,.deb","list-type":"text",multiple:!0,"max-count":t(T).length,"show-upload-list":{showPreviewIcon:!1,showRemoveIcon:!0,showDownloadIcon:!1},remove:R,"before-upload":x,"custom-request":D,disabled:t(o).confirmLoading},{default:p(()=>[c(u,{type:"primary"},{icon:p(()=>[c(f)]),default:p(()=>[g(" "+h(t(l)("views.ne.neSoftware.upload")),1)]),_:1})]),_:1},8,["file-list","max-count","disabled"])]),_:1},8,["label"])],64))]),_:1})]),_:1},8,["visible","title","confirm-loading"])}}});export{Z as default};