import{a5 as V,r as d,b as B,aH as M,n as l,o as f,c as v,p as _,q as m,v as p,P as x,x as i,s as P,t as $,l as S,bv as j,bH as q,D as H}from"./index.8d733f79.js";import{E as z}from"./el-progress.ee3fa77d.js";import{M as A,N as Q,O as G,P as J,Q as K}from"./deviceTree.170dfbd9.js";const W={"element-loading-background":"rgba(0,0,0,0.4)"},X={class:"importDialog"},Y={class:"tit"},Z={class:"desc"},ee={style:{position:"relative"}},te=["href","download"],oe={key:1},ae=["download"],le={key:3,style:{position:"absolute",left:"90px",top:"-5px",color:"#fff","font-size":"12px",width:"120px"}},se={class:"dialog-footer"},ie=V({name:"importModal"}),me=Object.assign(ie,{emits:["refresh"],setup(ne,{expose:T,emit:C}){const{proxy:I}=H(),h=d(!1),n=d(),u=d([]),r=d(!1),g=d(""),y=d(),a=d("");let k="",D="";const{t:s}=B(),L=(e,o,t)=>{r.value=!0,a.value=e,k=o,D=t,e==="org"?(g.value=s("importOrg"),y.value=s("importLimit200")):e==="device"?(g.value=s("importDevice"),y.value=s("importLimit100")):e==="deviceParams"&&(g.value=s("importDeviceParams"),y.value=s("importLimit200"))},E=e=>{var o,t;(o=n.value)==null||o.clearFiles(),(t=n.value)==null||t.handleStart(e[0])},F=()=>{var e;console.log("\u4E0A\u4F20\u7684\u6587\u4EF6",u.value),u.value.length||I.$modal.msgError(s("uploadFileP")),(e=n.value)==null||e.submit()},N=e=>{h.value=!0;let o="";a.value==="org"?o=G:a.value==="device"?o=J:a.value==="deviceParams"&&(o=K);const t=new FormData;t.append("file",e.file),o({factoryId:k},t).then(c=>{var b;I.$modal.msgSuccess(c.msg),C("refresh",a.value),(b=n.value)==null||b.clearFiles(),r.value=!1,h.value=!1}).catch(()=>{var c;(c=n.value)==null||c.clearFiles(),r.value=!1,h.value=!1})},O=()=>{var e;(e=n.value)==null||e.clearFiles()},R=()=>{a.value==="device"&&A({}).then(e=>{console.log("data----",e);const o=new Blob([e]),t=document.createElement("a");t.href=URL.createObjectURL(o),t.download=`${s("importDeviceT")}.xlsx`,t.style.display="none",document.body.appendChild(t),t.click(),t.remove()}),a.value==="deviceParams"&&Q({factoryId:k,factoryName:D}).then(e=>{console.log("data----",e);const o=new Blob([e]),t=document.createElement("a");t.href=URL.createObjectURL(o),t.download=D+`${s("importDeviceParamsT")}.xlsx`,t.style.display="none",document.body.appendChild(t),t.click(),t.remove()})};return T({showModal:L}),(e,o)=>{const t=S,c=z,b=j,U=q;return M((f(),v("div",W,[_(b,{title:l(g),modelValue:l(r),"onUpdate:modelValue":o[2]||(o[2]=w=>P(r)?r.value=w:null),width:"480px","align-center":!0,onClosed:O,"append-to-body":""},{footer:m(()=>[p("div",se,[_(t,{onClick:o[1]||(o[1]=w=>r.value=!1)},{default:m(()=>[x(i(e.$t("cancel")),1)]),_:1}),_(t,{type:"primary",onClick:F},{default:m(()=>[x(i(e.$t("confirm")),1)]),_:1})])]),default:m(()=>[p("div",X,[p("div",Y,[x(i(e.$t("uploadFile")),1),p("span",Z,i(l(y)),1)]),p("div",ee,[_(c,{ref_key:"uploadRef",ref:n,"file-list":l(u),"onUpdate:file-list":o[0]||(o[0]=w=>P(u)?u.value=w:null),accept:l(a)=="device"?".xlsx,.xls,.xlsm":".xlsx,.xls",action:"#","http-request":N,limit:1,"on-exceed":E,"auto-upload":!1},{default:m(()=>[_(t,{type:"primary"},{default:m(()=>[x(i(e.$t("selectImportFile")),1)]),_:1})]),_:1},8,["file-list","accept"]),p("div",{class:"download",onClick:R},[l(a)==="org"?(f(),v("a",{key:0,href:"/template/orgTemplate.xlsx",download:`${e.$t("importOrgT")}.xlsx`},i(e.$t("downImportTemplate")),9,te)):$("",!0),l(a)==="device"?(f(),v("a",oe,i(e.$t("downImportTemplate")),1)):$("",!0),l(a)==="deviceParams"?(f(),v("a",{key:2,download:`${e.$t("importDeviceParamsT")}.xlsx`},i(e.$t("downImportTemplate")),9,ae)):$("",!0),l(a)==="deviceParams"?(f(),v("div",le,"\u6A21\u677F\u5C06\u6839\u636E\u8BE5\u5DE5\u5382\u4E0B\u5177\u5907\u7684\u8BBE\u5907\u7C7B\u578B\u52A8\u6001\u751F\u6210")):$("",!0)])])])]),_:1},8,["title","modelValue"])])),[[U,l(h),void 0,{fullscreen:!0,lock:!0}]])}}});export{me as default};
