import{V as B,ab as I,a9 as N,a5 as L,r as U,av as q,I as A,aw as J,F as $}from"./index.17037962789732.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import"./index.170379627897315.js";import"./index.170379627897327.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import{P as E}from"./index.170379627897387.js";import"./Double.vue_vue_type_script_setup_true_name_DoubleParamsDropdown_lang.1703796278973.js";import{h as W}from"./index.1703796278973317.js";import{d as z,k as G,v as H,l as d,m as K,o as m,c as v,a as p,b as c,u as n,x as Q,F as X,h as Y,t as Z,A as R,B as M}from"./vue.1703796278973.js";const me=z({__name:"WriteProperty",props:{value:{type:Object,default:()=>{}},metadata:{type:Object,default:()=>({properties:[]})},builtInList:{type:Array,default:()=>[]}},emits:["update:value","change"],setup(b,{expose:O,emit:f}){const i=b,y=G(),t=H({properties:void 0,propertiesValue:void 0,source:"fixed"}),_=d(()=>i.metadata.properties.find(e=>e.id===t.properties)),k=d(()=>{var e,a;return[{label:"手动输入",component:(a=(e=_.value)==null?void 0:e.valueType)==null?void 0:a.type,key:"fixed"},{label:"内置参数",component:"tree",key:"upper"}]}),h=(e,a)=>{if(e&&a){const r=a.filter(o=>{if(o.children){const u=h(e,o.children);return o.children=u,!!u.length}else if(o.type===e)return!0;return!1});return W(r)}return a||[]},T=d(()=>{var a,r;return h((r=(a=_.value)==null?void 0:a.valueType)==null?void 0:r.type,B(i==null?void 0:i.builtInList))}),S=d(()=>{var r;const e=(r=_.value)==null?void 0:r.valueType,a=e==null?void 0:e.type;return a==="boolean"?[{label:e.trueText||!0,name:e.trueText||!0,value:e.trueValue||!0,id:String(e.trueValue||!0)},{label:e.falseText||!1,name:e.falseText||!1,value:e.falseValue||!1,id:String(e.falseValue||!1)}]:a==="enum"?e==null?void 0:e.elements.map(o=>({label:o.text,name:o.text,value:o.value,id:o.value})):[]}),C=()=>{t.propertiesValue=void 0,t.source="fixed",f("update:value",{[`${t.properties}`]:{value:t==null?void 0:t.propertiesValue,source:t==null?void 0:t.source}})},w=(e,a)=>{const r=I(e)&&e.metadata?[e.column]:[],o={[`${t.properties}`]:{value:t==null?void 0:t.propertiesValue,source:t==null?void 0:t.source}};f("update:value",o),f("change",a||e,r)};return K(()=>i.value,e=>{var a,r,o;if(e){const u=(a=Object.keys(e))==null?void 0:a[0];u&&(t.properties=u,t.propertiesValue=(r=e[u])==null?void 0:r.value,t.source=(o=e[u])==null?void 0:o.source)}},{deep:!0,immediate:!0}),O({onSave:()=>new Promise((e,a)=>{y.value.validate().then(()=>{e(!0)}).catch(r=>{a(r)})})}),(e,a)=>{const r=N,o=L,u=U,x=q,F=A,P=J,D=$;return m(),v(D,{layout:"vertical",ref_key:"propertyFormRef",ref:y,model:n(t)},{default:p(()=>[c(P,{gutter:24},{default:p(()=>[c(x,{span:12},{default:p(()=>[c(u,{name:"properties",label:"设置属性",rules:[{required:!0,message:"请选择设置属性"}]},{default:p(()=>[c(o,{showSearch:"",placeholder:"请选择属性",value:n(t).properties,"onUpdate:value":a[0]||(a[0]=l=>n(t).properties=l),onChange:C},{default:p(()=>{var l,g;return[(m(!0),Q(X,null,Y(((g=((l=b.metadata)==null?void 0:l.properties)||[])==null?void 0:g.filter(s=>{var V,j;return(j=(V=s==null?void 0:s.expands)==null?void 0:V.type)==null?void 0:j.includes("write")}))||[],s=>(m(),v(r,{value:s==null?void 0:s.id,key:s==null?void 0:s.id},{default:p(()=>[Z(R(s==null?void 0:s.name),1)]),_:2},1032,["value"]))),128))]}),_:1},8,["value"])]),_:1})]),_:1}),n(t).properties?(m(),v(x,{key:0,span:12},{default:p(()=>[c(u,{name:"propertiesValue",label:"属性值",rules:[{required:!0,message:"请选择"}]},{default:p(()=>[c(n(E),{options:n(S),tabsOptions:n(k),metricOptions:n(T),value:n(t).propertiesValue,"onUpdate:value":a[1]||(a[1]=l=>n(t).propertiesValue=l),source:n(t).source,"onUpdate:source":a[2]||(a[2]=l=>n(t).source=l),onSelect:w,valueName:"id"},{default:p(({label:l})=>[c(F,{readonly:"",value:l,placeholder:"请选择"},null,8,["value"])]),_:1},8,["options","tabsOptions","metricOptions","value","source"])]),_:1})]),_:1})):M("",!0)]),_:1})]),_:1},8,["model"])}}});export{me as _};
