import{I as T,r as $,F as A,a as O}from"./index.17037962789732.js";import"./index.170379627897317.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import"./index.170379627897315.js";import{_ as x}from"./BuildIn.vue_vue_type_script_setup_true_name_NotifyBuildIn_lang.1703796278973.js";import{_ as D}from"./Org.vue_vue_type_script_setup_true_lang.1703796278973.js";import{_ as F}from"./Tag.vue_vue_type_script_setup_true_lang.1703796278973.js";import{_ as z}from"./InputFile.vue_vue_type_script_setup_true_lang.1703796278973.js";import{_ as B}from"./User.vue_vue_type_script_setup_true_lang.1703796278973.js";import{d as R,k as C,v as Z,w as b,o as c,c as l,a as w,x as q,F as I,h as K,u as i}from"./vue.1703796278973.js";const ee=R({__name:"VariableDefinitions",props:{variableDefinitions:{type:Array,default:()=>[]},value:{type:Object,default:()=>({})},notify:{type:Object,default:()=>({})},template:{type:Object,default:()=>({})},options:{type:Object,default:()=>({})}},emits:["update:value","change"],setup(d,{expose:E,emit:y}){var k;const f=d,P=C(),t=Z({}),h=C(((k=f.options)==null?void 0:k.otherColumns)||[]);b(()=>{Object.assign(t,f==null?void 0:f.value)}),b(()=>{var s,e,n;y("change",{sendTo:(n=(e=(s=f==null?void 0:f.template)==null?void 0:s.template)==null?void 0:e.sendTo)==null?void 0:n.join(" ")})});const p=s=>{var e;return((e=s.expands)==null?void 0:e.businessType)||s.type},U=(s,e,n)=>{var u,_;if(!e)return Promise.resolve();const a=((u=n.expands)==null?void 0:u.businessType)||(n==null?void 0:n.type);if(a==="file")return Promise.resolve();if(a==="link")if(e){if(e.length>64)return Promise.reject(new Error("最多64个字符"))}else return Promise.reject(new Error("请输入"+n.name));else{if(a==="tag"&&!e)return Promise.reject(new Error("请选择"+n.name));if(["date","org"].includes(a))return e?(e==null?void 0:e.source)==="upper"?e!=null&&e.upperKey?Promise.resolve():Promise.reject(new Error("请选择"+n.name)):e!=null&&e.value?Promise.resolve():Promise.reject(new Error("请选择"+n.name)):Promise.reject(new Error("请选择"+n.name));if((e==null?void 0:e.source)==="fixed"&&!(e!=null&&e.value))return Promise.reject(new Error("请输入"+n.name));if((e==null?void 0:e.source)==="relation"&&!(e!=null&&e.value)&&!(e!=null&&e.relation))return Promise.reject(new Error("请选择"+n.name));if((e==null?void 0:e.source)==="upper"&&!e.upperKey)return Promise.reject(new Error("请选择"+n.name));if(a==="user"){if(f.notify.notifyType==="email"&&(e==null?void 0:e.source)!=="relation")if(Array.isArray(e==null?void 0:e.value)){if(!(e!=null&&e.value.length))return Promise.reject(new Error("请输入收件人"));const r=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;return(e==null?void 0:e.value.every(o=>r.test(o)))?Promise.resolve():Promise.reject(new Error("请输入正确的邮箱地址"))}else return Promise.resolve();if(f.notify.notifyType&&["sms","voice"].includes((_=f==null?void 0:f.notify)==null?void 0:_.notifyType)&&(e==null?void 0:e.source)!=="relation"&&(e!=null&&e.value))return/^[1][3-9]\d{9}$/.test(e==null?void 0:e.value)?Promise.resolve():Promise.reject(new Error("请输入正确的手机号码"))}}return Promise.resolve()},g=(s,e,n,a)=>{e==="build-in"?h.value[n]=a:h.value[n]=void 0,e==="org"?y("change",{orgName:s.join(","),otherColumns:[]}):e==="tag"?y("change",{tagName:s,otherColumns:[]}):e==="user"?y("change",{sendTo:s,otherColumns:[]}):y("change",{otherColumns:h.value})};return E({onSave:()=>new Promise((s,e)=>{var n;(n=P.value)==null||n.validate().then(a=>{s(a)}).catch(()=>{e(!1)})})}),(s,e)=>{const n=T,a=$,u=A,_=O;return d.variableDefinitions.length?(c(),l(u,{key:0,layout:"vertical",ref_key:"formRef",ref:P,model:i(t)},{default:w(()=>[(c(!0),q(I,null,K(d.variableDefinitions,(r,m)=>(c(),l(a,{name:`${r==null?void 0:r.id}`,label:r==null?void 0:r.name,key:r.id,required:p(r)!=="file",rules:[{validator:(o,j)=>U(o,j,r),trigger:["blur","change"]}]},{default:w(()=>[p(r)==="user"?(c(),l(B,{key:0,notify:d.notify,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o,onChange:o=>g(o,"user",m)},null,8,["notify","value","onUpdate:value","onChange"])):p(r)==="org"?(c(),l(D,{key:1,notify:d.notify,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o,onChange:o=>g(o,"org",m)},null,8,["notify","value","onUpdate:value","onChange"])):p(r)==="tag"?(c(),l(F,{key:2,notify:d.notify,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o,onChange:o=>g(o,"tag",m)},null,8,["notify","value","onUpdate:value","onChange"])):p(r)==="file"?(c(),l(z,{key:3,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o},null,8,["value","onUpdate:value"])):p(r)==="link"?(c(),l(n,{key:4,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o},null,8,["value","onUpdate:value"])):(c(),l(x,{key:5,item:r,value:i(t)[r.id],"onUpdate:value":o=>i(t)[r.id]=o,onChange:(o,j)=>g(o,"build-in",m,j)},null,8,["item","value","onUpdate:value","onChange"]))]),_:2},1032,["name","label","required","rules"]))),128))]),_:1},8,["model"])):(c(),l(_,{key:1,style:{margin:"20px 0"},description:"暂无模板变量"}))}}});export{ee as _};
