import{aH as J,r as M,F as X,K as q,W as z}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.1703796278973311.js";import A from"./product.17037962789734.js";import{a as P,o as v}from"./comm.1703796278973.js";import H from"./file.17037962789732.js";import T from"./plugin.17037962789732.js";import{p as W}from"./instance.1703796278973.js";import{d as V,k as i,v as G,l as Q,r as R,o as n,x as f,b as r,a as l,u as t,c as u,t as p,B as y,z as I,A as Y,F as Z}from"./vue.1703796278973.js";const $={key:0},ee={key:1},te=["src"],oe={key:2},ae={style:{color:"#2F54EB"}},se=V({name:"DeviceImport"}),ge=V({...se,emits:["cancel","save"],setup(ne,{emit:g}){const o=i(0),a=G({productId:void 0,type:void 0}),c=i(),k=i([]),w=i(!0),C=i(!1),B=i(0),x=Q(()=>{var s;const e=[{value:"file",label:"文件导入",subLabel:"支持上传XLSX、CSV格式文件",iconUrl:P("/device/import1.png")}];return((s=c.value)==null?void 0:s.accessProvider)==="plugin_gateway"&&e.push({value:"plugin",label:"插件导入",subLabel:"读取插件中的设备信息同步至平台",iconUrl:P("/device/import2.png")}),e}),j=e=>{a.type=e[0]},D=e=>{c.value=e},K=()=>{var e,s;if(o.value===0){if(!a.productId)return v("请选择产品","error");if(((e=c.value)==null?void 0:e.accessProvider)!=="plugin_gateway"){a.type="file",a.productId=(s=c.value)==null?void 0:s.id,o.value=2;return}}if(o.value===1&&!a.type)return v("请选择导入方式","error");o.value+=1},N=()=>{var e;((e=c.value)==null?void 0:e.accessProvider)!=="plugin_gateway"?o.value=0:o.value-=1},h=()=>{g("cancel")},E=e=>{k.value=e},O=()=>{a.type==="file"?(h(),g("save")):k.value.length?W(a.productId,k.value).then(e=>{var s,d,_;e.success&&(v("操作成功"),w.value=!1,C.value=!0,B.value=(_=(d=(s=e.result)==null?void 0:s[0])==null?void 0:d.result)==null?void 0:_.updated)}):v("请选择设备","error")},F=()=>{C.value=!1,g("save")};return(e,s)=>{const d=J,_=M,S=X,m=q,L=z,U=R("a-icon");return n(),f(Z,null,[r(L,{maskClosable:!1,visible:t(w),width:"800px",title:"批量导入",onCancel:h},{footer:l(()=>[t(o)===0?(n(),u(m,{key:0,onClick:h},{default:l(()=>[p("取消")]),_:1})):y("",!0),t(o)!==0?(n(),u(m,{key:1,onClick:N},{default:l(()=>[p("上一步")]),_:1})):y("",!0),t(o)!==2?(n(),u(m,{key:2,onClick:K,type:"primary"},{default:l(()=>[p("下一步")]),_:1})):y("",!0),t(o)===2?(n(),u(m,{key:3,onClick:O,type:"primary"},{default:l(()=>[p("确认")]),_:1})):y("",!0)]),default:l(()=>[I("div",null,[t(o)===0?(n(),f("div",$,[r(A,{rowKey:t(a).productId,"onUpdate:rowKey":s[0]||(s[0]=b=>t(a).productId=b),onChange:D},null,8,["rowKey"])])):t(o)===1?(n(),f("div",ee,[r(S,{layout:"vertical"},{default:l(()=>[r(_,{required:"",label:"选择导入方式"},{default:l(()=>[r(d,{value:[t(a).type],column:t(x).length,options:t(x),onChange:j},{image:l(({image:b})=>[I("img",{src:b},null,8,te)]),_:1},8,["value","column","options"])]),_:1})]),_:1})])):(n(),f("div",oe,[t(a).type==="file"?(n(),u(H,{key:0,product:t(a).productId},null,8,["product"])):(n(),u(T,{key:1,accessId:t(c).accessId,onChange:E},null,8,["accessId"]))]))])]),_:1},8,["visible"]),r(L,{maskClosable:!1,visible:t(C),width:"400px",title:"导入完成",onCancel:F,onOk:F},{default:l(()=>[r(U,{type:"CheckOutlined",style:{color:"#2F54EB"}}),p(" 已完成 新增设备 "),I("span",ae,Y(t(B)),1)]),_:1},8,["visible"])],64)}}});export{ge as _};
