import{cx as F,cy as U,$ as A,K as L,W as $}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897335.js";import"./index.1703796278973316.js";import"./index.170379627897330.js";import M from"./Product.17037962789736.js";import{_ as W}from"./index.vue_vue_type_script_setup_true_name_Device_lang.17037962789732.js";import{_ as Y}from"./index.vue_vue_type_script_setup_true_lang.170379627897344.js";import{o as S}from"./comm.1703796278973.js";import{u as z}from"./scene.1703796278973.js";import{d as q,s as G,k as y,v as H,m as Q,o as c,c as l,a as s,z as K,u as a,t as d,b as N,M as X,B as Z}from"./vue.1703796278973.js";import{i as ee}from"./util.17037962789736.js";import{_ as te}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.1703796278973300.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"./index.170379627897313.js";import"./index.vue_vue_type_script_setup_true_lang.17037962789733.js";import"./index.170379627897333.js";import"./index.170379627897319.js";import"./index.170379627897327.js";import"./product.17037962789737.js";import"./system.1703796278973.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";import"./category.1703796278973.js";import"./department.1703796278973.js";import"./setting.1703796278973.js";import"./index.170379627897318.js";import"./index.170379627897326.js";import"./index.170379627897336.js";import"./TopCard.17037962789738.js";import"./index.170379627897320.js";import"./config.17037962789732.js";import"./Device.17037962789732.js";import"./instance.1703796278973.js";import"./Tag.17037962789733.js";import"./index.vue_vue_type_script_setup_true_name_ValueItem_lang.1703796278973.js";import"./index.170379627897338.js";import"./index.170379627897329.js";import"./index.170379627897325.js";import"./index.170379627897322.js";import"./index.170379627897323.js";import"./index.170379627897324.js";import"./style.1703796278973.js";import"./RelationSelect.vue_vue_type_script_setup_true_lang.17037962789732.js";import"./util.17037962789735.js";import"./EditTable.vue_vue_type_script_setup_true_lang.17037962789735.js";import"./FunctionItem.vue_vue_type_script_setup_true_lang.17037962789732.js";import"./index.1703796278973261.js";import"./DropdownButton.vue_vue_type_style_index_0_scoped_fa3712f8_lang.1703796278973.js";import"./Menus.17037962789732.js";import"./isUndefined.1703796278973.js";import"./Time.vue_vue_type_style_index_0_lang.17037962789732.js";import"./Double.vue_vue_type_script_setup_true_name_DoubleParamsDropdown_lang.17037962789732.js";import"./index.1703796278973325.js";import"./WriteProperty.vue_vue_type_script_setup_true_lang.17037962789732.js";import"./scene.17037962789732.js";import"./utils.1703796278973.js";import"./moment.1703796278973.js";const oe={class:"steps-content"},re={class:"steps-action"},ae=q({__name:"index",props:{value:{type:Object,default:()=>{}},name:{type:Number,default:0},thenName:{type:Number,default:0},branchesName:{type:Number,default:0},parallel:{type:Boolean},options:{type:Object,default:()=>({})}},emits:["cancel","save"],setup(n,{emit:b}){var x;const k=n,R=z(),{data:j}=G(R),i=y(0),_=y(),g=y(),f=y({}),t=H({productId:"",deviceId:"",selector:"fixed",selectorValues:[],upperKey:"",source:"fixed",message:{messageType:"INVOKE_FUNCTION"}}),v=y({}),O=y(((x=k.options)==null?void 0:x.otherColumn)||[]),I=()=>{b("cancel")},T=o=>{var u,m;const r={selector:t.selector,source:t.source,selectorValues:t.selectorValues,productId:t.productId,upperKey:t.upperKey,message:o.message};t.selector==="relation"&&(r.upperKey="scene.deviceId");const e={selector:t.selector,triggerName:((m=(u=j.value.options)==null?void 0:u.trigger)==null?void 0:m.name)||"触发设备",...v.value,otherColumns:[]},p=o.message.messageType;p==="INVOKE_FUNCTION"&&(e.type="执行"),p==="READ_PROPERTY"&&(e.type="读取"),p==="WRITE_PROPERTY"&&(e.type="设置",e.propertiesValue=typeof(e==null?void 0:e.propertiesValue)=="object"?JSON.stringify(e==null?void 0:e.propertiesValue):e==null?void 0:e.propertiesValue,e.otherColumns=O.value),b("save",r,JSON.parse(JSON.stringify(e)))},D=(o,r)=>{r||(t.selectorValues=void 0,t.deviceId="",t.selector="fixed",t.upperKey="",t.source="fixed",ee(JSON.parse(o.metadata||"{}"),t==null?void 0:t.message)||(t.message={messageType:"INVOKE_FUNCTION"})),f.value=o,v.value.productName=o==null?void 0:o.name},w=(o,r)=>{Object.assign(t,{...o}),v.value={...a(v),...r}},E=(o,r)=>{O.value=r;const e={...v.value,...o};v.value=e},h=async o=>{var e,p,u;let r=o!==void 0?o:i.value;if(r===0)t.productId?i.value=1:S("请选择产品","error");else if(r===1)_.value?(await((e=_.value)==null?void 0:e.onFormSave()),i.value=2):(p=t.selectorValues)!=null&&p.length?i.value=2:S("请选择设备","error");else if(g.value){const m=await((u=g.value)==null?void 0:u.onFormSave());T(m)}},J=o=>{o!==0?h(o-1):i.value=0},B=()=>{i.value-=1},V=()=>h();return Q(()=>k.value,o=>{Object.assign(t,o)},{immediate:!0}),(o,r)=>{const e=F,p=U,u=A,m=L,P=$;return c(),l(P,{title:"执行动作",visible:"",width:860,onCancel:I,onOk:h,maskClosable:!1},{footer:s(()=>[K("div",re,[a(i)===0?(c(),l(m,{key:0,onClick:I},{default:s(()=>[d("取消")]),_:1})):(c(),l(m,{key:1,onClick:B},{default:s(()=>[d("上一步")]),_:1})),a(i)<2?(c(),l(m,{key:2,type:"primary",onClick:V},{default:s(()=>[d("下一步")]),_:1})):(c(),l(m,{key:3,type:"primary",onClick:V},{default:s(()=>[d("确定")]),_:1}))])]),default:s(()=>[N(p,{current:a(i),onChange:J},{default:s(()=>[N(e,null,{title:s(()=>[d("选择产品")]),_:1}),N(e,null,{title:s(()=>[d("选择设备")]),_:1}),N(e,null,{title:s(()=>[d("执行动作")]),_:1})]),_:1},8,["current"]),N(u,{style:{"margin-bottom":"10px"}}),K("div",oe,[a(i)===0?(c(),l(M,{key:0,rowKey:a(t).productId,"onUpdate:rowKey":r[0]||(r[0]=C=>a(t).productId=C),detail:a(f),"onUpdate:detail":r[1]||(r[1]=C=>X(f)?f.value=C:null),onChange:D},null,8,["rowKey","detail"])):a(i)===1?(c(),l(W,{key:1,name:n.name,parallel:n.parallel,branchesName:n.branchesName,thenName:n.thenName,values:a(t),onSave:w,productDetail:a(f),ref_key:"deviceRef",ref:_},null,8,["name","parallel","branchesName","thenName","values","productDetail"])):a(i)===2?(c(),l(Y,{key:2,name:n.name,branchesName:n.branchesName,thenName:n.thenName,values:a(t),productDetail:a(f),ref_key:"actionRef",ref:g,onChange:E},null,8,["name","branchesName","thenName","values","productDetail"])):Z("",!0)])]),_:1})}}});const Rt=te(ae,[["__scopeId","data-v-6a35f267"]]);export{Rt as default};