import{o as X,M as m,q as Y,a0 as Z,av as ee,aw as te,ax as se}from"./index.17037962789732.js";import"./index.1703796278973300.js";import"./index.170379627897315.js";import"./index.170379627897317.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.1703796278973303.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import"./index.1703796278973305.js";import"./index.1703796278973306.js";import{_ as ae}from"./index.vue_vue_type_script_setup_true_lang.17037962789733.js";import{_ as oe}from"./index.170379627897313.js";import"./index.170379627897319.js";import"./index.170379627897327.js";import"./index.170379627897336.js";import"./index.170379627897329.js";import"./index.170379627897330.js";import{_ as ie}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import{a as re}from"./comm.1703796278973.js";import{g as ne,q as ce,n as le,k as de,a as pe,B as ue,_ as me,C as _e,x as ye}from"./product.17037962789737.js";import{a as fe}from"./utils.1703796278973.js";import ve from"./index.1703796278973155.js";import{h as he}from"./system.1703796278973.js";import{u as ke}from"./useParams.1703796278973.js";import{a as xe}from"./setting.1703796278973.js";import{d as ge,k as d,v as we,p as Ce,r as f,o as v,c as I,a,b as o,u as _,t as A,z as p,A as h,y as be,j as Ie,x as P,F as q,h as Se,V as B,G as Te,H as Ne}from"./vue.1703796278973.js";import{_ as je}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./index.170379627897333.js";import"./index.170379627897335.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./permission.1703796278973.js";import"./moment.1703796278973.js";import"./consts.1703796278973.js";import"./index.170379627897337.js";import"./index.170379627897318.js";import"./index.1703796278973311.js";import"./default.1703796278973.js";import"./index.17037962789737.js";import"./index.170379627897326.js";import"./index.1703796278973154.js";import"./product.17037962789738.js";import"./encodeQuery.1703796278973.js";import"./index.170379627897334.js";import"./404.1703796278973.js";import"./regular.1703796278973.js";const D=k=>(Te("data-v-6be4e159"),k=k(),Ne(),k),Oe=["src"],Ae={style:{"font-weight":"600","font-size":"16px"}},Pe=D(()=>p("div",{class:"card-item-content-text"}," 设备类型 ",-1)),qe=D(()=>p("div",{class:"card-item-content-text"}," 接入方式 ",-1)),Be=ge({__name:"index",setup(k){const R=he(),x=d(0),g=d(""),S=d({}),F=[{title:"ID",dataIndex:"id",key:"id",scopedSlots:!0,width:200,ellipsis:!0},{title:"产品名称",dataIndex:"name",key:"name",width:220,ellipsis:!0},{title:"接入方式",dataIndex:"accessName",key:"accessName",width:220,ellipsis:!0},{title:"设备类型",dataIndex:"deviceType",key:"deviceType",scopedSlots:!0,ellipsis:!0,width:120},{title:"状态",dataIndex:"state",key:"state",scopedSlots:!0,ellipsis:!0,width:90},{title:"说明",dataIndex:"describe",key:"describe",ellipsis:!0},{title:"操作",key:"action",fixed:"right",width:200,scopedSlots:!0,ellipsis:!0}],J=d([]),$=d({}),T=(e,c)=>{if(!e)return[];const n=[{key:"view",text:"查看",tooltip:{title:"查看"},icon:"EyeOutlined",onClick:()=>{j(e.id)}},{key:"update",text:"编辑",tooltip:{title:"编辑"},icon:"EditOutlined",onClick:()=>{g.value="编辑",x.value=2,B(()=>{C.value.show(e)})}},{key:"export",text:"导出",tooltip:{title:"导出"},icon:"icon-xiazai",onClick:()=>{const i=X(e,["transportProtocol","protocolName","accessId","accessName","accessProvider","messageProtocol"]);fe(i,"产品")}},{key:"action",text:e.state!==0?"禁用":"启用",tooltip:{title:e.state!==0?"禁用":"启用"},icon:e.state!==0?"StopOutlined":"CheckCircleOutlined",popConfirm:{title:`确认${e.state!==0?"禁用":"启用"}?`,onConfirm:async()=>{var r;let i;e.state!==0?i=await ue(e.id):i=await me(e.id),i&&i.status===200?(m.success("操作成功!"),(r=y.value)==null||r.reload()):m.error("操作失败!")}}},{key:"delete",text:"删除",disabled:e.state!==0,tooltip:{title:e.state!==0?"已启用的产品不能删除":"删除"},popConfirm:{title:"确认删除?",onConfirm:async()=>{var r;(await _e(e.id)).status===200?(m.success("操作成功!"),(r=y.value)==null||r.reload()):m.error("操作失败!")}},icon:"DeleteOutlined"}];return c==="card"?n.filter(i=>i.key!=="view"):n},N=()=>{x.value=1,g.value="新增",B(()=>{C.value.show($.value)})},E=e=>{const c=new FileReader;return c.readAsText(e),c.onload=async n=>{var r,l;const i=(r=n.target)==null?void 0:r.result;if(console.log("text: ",i),!e.type.includes("json"))return m.error("请上传json格式文件"),!1;try{const u=JSON.parse(i||"{}");return u.state=0,Array.isArray(u)?(m.error("请上传json格式文件"),!1):(delete u.state,(await ye(u)).status===200&&(m.success("操作成功"),(l=y.value)==null||l.reload()),!0)}catch{}return!0},!1},j=e=>{R.jumpPage("device/Product/Detail",{id:e})},V=()=>{var e;(e=y.value)==null||e.reload()};d([]);const w=d([]),y=d({}),L=we({columns:[{title:"名称",dataIndex:"name",key:"name",search:{first:!0,type:"string"}},{title:"ID",dataIndex:"id",key:"id",search:{type:"string",defaultTermType:"eq"}},{title:"网关类型",key:"accessProvider",dataIndex:"accessProvider",search:{type:"select",options:()=>new Promise(e=>{ne().then(c=>{const n=c.result||[];e(xe(n))})})}},{title:"接入方式",key:"accessName",dataIndex:"accessName",search:{type:"select",options:async()=>new Promise(e=>{ce({paging:!1}).then(c=>{w.value=[],w.value=c.result.map(n=>({label:n.name,value:n.name})),e(w.value)})})}},{title:"设备类型",key:"deviceType",dataIndex:"deviceType",search:{type:"select",options:[{label:"直连设备",value:"device"},{label:"网关子设备",value:"childrenDevice"},{label:"网关设备",value:"gateway"}]}},{title:"状态",key:"state",dataIndex:"state",search:{type:"select",options:[{label:"正常",value:1},{label:"禁用",value:0}]}},{title:"说明",key:"describe",dataIndex:"describe",search:{type:"string"}},{title:"分类",key:"classified",dataIndex:"classifiedId",search:{type:"treeSelect",options:async()=>new Promise(e=>{le({paging:!1}).then(c=>{e(c.result)})})}},{title:"所属组织",key:"id$dim-assets",dataIndex:"id$dim-assets",search:{first:!0,type:"treeSelect",options:async()=>new Promise(e=>{de({paging:!1}).then(c=>{const n=i=>{const r=[];return i.forEach(l=>{l.children&&(l.children=n(l.children)),r.push({...l,value:JSON.stringify({assetType:"product",targets:[{type:"org",id:l.id}]})})}),r};e(n(c.result))})})}},{title:"操作",key:"action",fixed:"right",width:250,scopedSlots:!0}]}),C=d(),z=e=>{S.value=e},M=ke();return Ce(()=>{var e;(e=M.params)!=null&&e.value.save&&N()}),(e,c)=>{const n=f("pro-search"),i=f("AIcon"),r=ie,l=Y,u=Z,b=f("Ellipsis"),O=ee,U=te,G=oe,H=ae,K=se,Q=f("FullPage"),W=f("page-container");return v(),I(W,null,{default:a(()=>[o(n,{columns:_(L).columns,target:"product-manage",onSearch:z},null,8,["columns"]),o(Q,null,{default:a(()=>[o(K,{columns:F,request:_(pe),ref_key:"tableRef",ref:y,defaultParams:{sorts:[{name:"createTime",order:"desc"}]},params:_(S)},{headerTitle:a(()=>[o(u,null,{default:a(()=>[o(r,{type:"primary",onClick:N,hasPermission:"device/Product:add"},{icon:a(()=>[o(i,{type:"PlusOutlined"})]),default:a(()=>[A(" 新增 ")]),_:1}),o(l,{name:"file",accept:".json",showUploadList:!1,"before-upload":E},{default:a(()=>[o(r,{hasPermission:"device/Product:import"},{default:a(()=>[A("导入")]),_:1})]),_:1})]),_:1})]),deviceType:a(t=>[p("div",null,h(t.deviceType.text),1)]),card:a(t=>[o(G,be({value:t,actions:T(t,"card")},t,{active:_(J).includes(t.id),status:t.state,onClick:s=>j(t.id),statusText:t.state===1?"正常":"禁用",statusNames:{1:"processing",0:"error"}}),{img:a(()=>[Ie(e.$slots,"img",{},()=>[p("img",{src:t.photoUrl||_(re)("/device-product.png"),class:"productImg"},null,8,Oe)],!0)]),content:a(()=>[o(b,{style:{width:"calc(100% - 100px)","margin-bottom":"18px"}},{default:a(()=>[p("span",Ae,h(t.name),1)]),_:2},1024),o(U,null,{default:a(()=>[o(O,{span:12},{default:a(()=>{var s;return[Pe,p("div",null,h((s=t==null?void 0:t.deviceType)==null?void 0:s.text),1)]}),_:2},1024),o(O,{span:12},{default:a(()=>[qe,o(b,null,{default:a(()=>[p("div",null,h(t!=null&&t.accessName?t==null?void 0:t.accessName:"未接入"),1)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),actions:a(s=>[o(r,{disabled:s.disabled,popConfirm:s.popConfirm,tooltip:{...s.tooltip},onClick:s.onClick,hasPermission:s.key==="view"?!0:"device/Product:"+s.key},{default:a(()=>[s.key==="delete"?(v(),I(i,{key:0,type:"DeleteOutlined"})):(v(),P(q,{key:1},[o(i,{type:s.icon},null,8,["type"]),p("span",null,h(s==null?void 0:s.text),1)],64))]),_:2},1032,["disabled","popConfirm","tooltip","onClick","hasPermission"])]),_:2},1040,["value","actions","active","status","onClick","statusText"])]),state:a(t=>[o(H,{text:t.state===1?"正常":"禁用",status:t.state,statusNames:{1:"processing",0:"error"}},null,8,["text","status"])]),action:a(t=>[o(u,{size:16},{default:a(()=>[(v(!0),P(q,null,Se(T(t,"table"),s=>(v(),I(r,{key:s.key,disabled:s.disabled,popConfirm:s.popConfirm,hasPermission:s.key==="view"?!0:"device/Product:"+s.key,tooltip:{...s.tooltip},onClick:s.onClick,type:"link",style:{padding:"0px"},danger:s.key==="delete"},{icon:a(()=>[o(i,{type:s.icon},null,8,["type"])]),_:2},1032,["disabled","popConfirm","hasPermission","tooltip","onClick","danger"]))),128))]),_:2},1024)]),_:3},8,["request","params"])]),_:3}),o(ve,{ref_key:"saveRef",ref:C,isAdd:_(x),title:_(g),onSuccess:V},null,8,["isAdd","title"])]),_:3})}}});const Ft=je(Be,[["__scopeId","data-v-6be4e159"]]);export{Ft as default};