import{M as h,a0 as D,av as M,aw as L,ax as G}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 H}from"./index.vue_vue_type_script_setup_true_lang.17037962789733.js";import{_ as K}from"./index.170379627897313.js";import"./index.170379627897319.js";import"./index.170379627897327.js";import"./index.170379627897336.js";import{_ as Q}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import{q as U,_ as W,s as X,a as Y,d as Z}from"./index.vue_vue_type_script_setup_true_lang.170379627897341.js";import{a as ee}from"./comm.1703796278973.js";import{S as te}from"./consts.1703796278973.js";import{u as oe}from"./useParams.1703796278973.js";import{d as se,k as b,p as ne,r as _,o as p,c as w,a as t,z as f,b as o,u as y,t as ae,y as ie,j as re,A as I,x as T,F as $,h as le,B as ce}from"./vue.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"./_plugin-vue_export-helper.1703796278973.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./permission.1703796278973.js";import"./index.170379627897337.js";import"./index.170379627897318.js";import"./system.1703796278973.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./404.1703796278973.js";const pe=["src"],ue={style:{"font-weight":"600","font-size":"16px"}},ot=se({__name:"index",setup(me){const B=b({});let k=b(!1);const g=b({});oe();const A={columns:[{title:"名称",dataIndex:"name",key:"name",search:{type:"string"}},{title:"状态",dataIndex:"state",key:"state",search:{type:"select",options:[{label:"正常",value:"started"},{label:"禁用",value:"disable"}]}},{title:"说明",key:"description",dataIndex:"description",search:{type:"string"}}]},N=[{title:"名称",dataIndex:"name",key:"name"},{title:"状态",dataIndex:"state",key:"state",scopedSlots:!0},{title:"说明",dataIndex:"description",key:"description"},{title:"操作",key:"action",fixed:"right",width:250,scopedSlots:!0}],S=b(),P=(e,O)=>{var r,c,u,m,C;if(!e)return[];const v=[{key:"update",text:"编辑",tooltip:{title:"编辑"},icon:"EditOutlined",onClick:()=>{S.value=e,k.value=!0}},{key:"view",text:"查看",tooltip:{title:"查看"},icon:"EyeOutlined",onClick:()=>{E(e)}},{key:"action",text:((r=e.state)==null?void 0:r.value)!=="disable"?"禁用":"启用",tooltip:{title:((c=e.state)==null?void 0:c.value)!=="disable"?"禁用":"启用"},icon:((u=e.state)==null?void 0:u.value)!=="disable"?"StopOutlined":"CheckCircleOutlined",popConfirm:{title:`确认${e.state!=="disable"?"禁用":"启用"}?`,onConfirm:async()=>{var l,x;let i;((l=e.state)==null?void 0:l.value)!=="started"?i=await X(e.id):i=await Y(e.id),i&&i.status===200?(h.success("操作成功!"),(x=g.value)==null||x.reload()):h.error("操作失败!")}}},{key:"delete",text:"删除",disabled:((m=e==null?void 0:e.state)==null?void 0:m.value)!=="disable",tooltip:{title:((C=e==null?void 0:e.state)==null?void 0:C.value)!=="disable"?"请先禁用再删除":"删除"},popConfirm:{title:"确认删除?",onConfirm:async()=>{var l;(await Z(e.id)).status===200?(h.success("操作成功!"),(l=g.value)==null||l.reload()):h.error("操作失败!")}},icon:"DeleteOutlined"}];return O==="card"?v.filter(i=>i.key!=="view"):v},R=()=>{S.value={name:"",description:""},k.value=!0},q=()=>{var e;(e=g.value)==null||e.reload()},J=e=>{B.value=e},E=e=>{window.open(`/${te.API_BASE}/rule-editor/index.html#flow/${e.id}`)},j=()=>{k.value=!1};return ne(()=>{var e;(e=history.state)!=null&&e.params&&R()}),(e,O)=>{const v=_("pro-search"),r=_("AIcon"),c=Q,u=D,m=_("Ellipsis"),C=M,i=L,l=K,x=H,F=G,V=_("FullPage"),z=_("page-container");return p(),w(z,null,{default:t(()=>[f("div",null,[o(v,{columns:A.columns,target:"device-instance",onSearch:J},null,8,["columns"]),o(V,null,{default:t(()=>[o(F,{columns:N,request:y(U),ref_key:"tableRef",ref:g,defaultParams:{sorts:[{name:"createTime",order:"desc"}]},params:y(B)},{headerTitle:t(()=>[o(u,null,{default:t(()=>[o(c,{type:"primary",onClick:R,hasPermission:"rule-engine/Instance:add"},{icon:t(()=>[o(r,{type:"PlusOutlined"})]),default:t(()=>[ae(" 新增 ")]),_:1})]),_:1})]),card:t(n=>{var s,d;return[o(l,ie({value:n,actions:P(n,"card")},n,{status:(s=n.state)==null?void 0:s.value,statusText:(d=n.state)==null?void 0:d.text,onClick:E,statusNames:{started:"processing",disable:"error"}}),{img:t(()=>[re(e.$slots,"img",{},()=>[f("img",{src:y(ee)("/scene/trigger-type/scene.png")},null,8,pe)])]),content:t(()=>[o(m,{style:{width:"calc(100% - 100px)","margin-bottom":"18px"}},{default:t(()=>[f("span",ue,I(n.name),1)]),_:2},1024),o(i,null,{default:t(()=>[o(C,{span:12},{default:t(()=>[o(m,null,{default:t(()=>[f("div",null,I(n.description),1)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),actions:t(a=>[o(c,{disabled:a.disabled,popConfirm:a.popConfirm,tooltip:{...a.tooltip},hasPermission:"rule-engine/Instance:"+a.key,onClick:a.onClick},{default:t(()=>[a.key==="delete"?(p(),w(r,{key:0,type:"DeleteOutlined"})):(p(),T($,{key:1},[o(r,{type:a.icon},null,8,["type"]),f("span",null,I(a==null?void 0:a.text),1)],64))]),_:2},1032,["disabled","popConfirm","tooltip","hasPermission","onClick"])]),_:2},1040,["value","actions","status","statusText"])]}),state:t(n=>{var s,d;return[o(x,{text:((s=n.state)==null?void 0:s.value)==="started"?"正常":"禁用",status:(d=n.state)==null?void 0:d.value,statusNames:{started:"processing",disable:"error"}},null,8,["text","status"])]}),action:t(n=>[o(u,{size:16},{default:t(()=>[(p(!0),T($,null,le(P(n,"table"),s=>(p(),w(c,{key:s.key,disabled:s.disabled,popConfirm:s.popConfirm,tooltip:{...s.tooltip},onClick:s.onClick,type:"link",style:{padding:"0px"},hasPermission:"rule-engine/Instance:"+s.key,danger:s.key==="delete"},{icon:t(()=>[o(r,{type:s.icon},null,8,["type"])]),_:2},1032,["disabled","popConfirm","tooltip","onClick","hasPermission","danger"]))),128))]),_:2},1024)]),_:3},8,["request","params"])]),_:3}),y(k)?(p(),w(W,{key:0,data:y(S),onSuccess:q,onCloseSave:j},null,8,["data"])):ce("",!0)])]),_:3})}}});export{ot as default};