import{d as R,r as S,v as N,g as r,z as C,k as V,w as t,e as l,b as f,t as _,c as z,F as O,y as L,x as I,l as T,R as $,_ as j}from"./index-CUnFTKV2.js";const G={class:"miniprogram-header"},H={class:"miniprogram-title"},J=R({__name:"MiniprogramForm",props:{modelValue:{},index:{},canDelete:{type:Boolean},existingPrefixes:{},weixinMerchants:{}},emits:["update:modelValue","delete","change","defaultChange"],setup(g,{expose:A,emit:P}){const p=g,i=P,c=S(),a=N({get:()=>p.modelValue,set:v=>i("update:modelValue",v)}),U={name:[{required:!0,message:"请输入小程序名称",trigger:"blur"},{max:50,message:"小程序名称不能超过50个字符",trigger:"blur"}],appid:[{required:!0,message:"请输入AppId",trigger:"blur"},{max:50,message:"AppId不能超过50个字符",trigger:"blur"}],appsecret:[{required:!0,message:"请输入AppSecret",trigger:"blur"}],order_prefix:[{required:!0,message:"请输入订单前缀",trigger:"blur"},{validator:(v,e,n)=>{if(!e){n(new Error("请输入订单前缀"));return}if(e.length!==2){n(new Error("订单前缀必须为2位字符"));return}if(p.existingPrefixes.filter((h,d)=>d!==p.index).includes(e)){n(new Error("订单前缀已被其他小程序使用"));return}n()},trigger:"blur"}]},m=()=>{i("change")},k=()=>{a.value.is_default===1&&i("defaultChange",p.index),i("change")},B=()=>{i("delete",p.index)};return A({validate:async()=>{if(!c.value)return!1;try{return await c.value.validate(),!0}catch{return!1}}}),(v,e)=>{const n=r("el-tag"),b=r("el-icon"),h=r("el-button"),d=r("el-input"),s=r("el-form-item"),u=r("el-col"),x=r("el-row"),w=r("el-radio"),D=r("el-radio-group"),q=r("el-option"),E=r("el-select"),F=r("el-form"),M=r("el-card");return V(),C(M,{class:"miniprogram-card",shadow:"hover"},{header:t(()=>[f("div",G,[f("span",H,[l(n,{type:a.value.is_default===1?"success":"info",size:"small"},{default:t(()=>[_(I(a.value.is_default===1?"默认":"非默认"),1)]),_:1},8,["type"]),_(" "+I(a.value.name||"新小程序"),1)]),l(h,{type:"danger",link:"",disabled:!g.canDelete,onClick:B},{default:t(()=>[l(b,null,{default:t(()=>[l(T($))]),_:1}),e[6]||(e[6]=_("删除 ",-1))]),_:1},8,["disabled"])])]),default:t(()=>[l(F,{ref_key:"formRef",ref:c,model:a.value,rules:U,"label-width":"100px",class:"miniprogram-form"},{default:t(()=>[l(x,{gutter:20},{default:t(()=>[l(u,{span:12},{default:t(()=>[l(s,{label:"小程序名称",prop:"name"},{default:t(()=>[l(d,{modelValue:a.value.name,"onUpdate:modelValue":e[0]||(e[0]=o=>a.value.name=o),placeholder:"请输入小程序名称",maxlength:"50",onInput:m},null,8,["modelValue"])]),_:1})]),_:1}),l(u,{span:12},{default:t(()=>[l(s,{label:"AppId",prop:"appid"},{default:t(()=>[l(d,{modelValue:a.value.appid,"onUpdate:modelValue":e[1]||(e[1]=o=>a.value.appid=o),placeholder:"请输入小程序AppId",maxlength:"50",onInput:m},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),l(x,{gutter:20},{default:t(()=>[l(u,{span:12},{default:t(()=>[l(s,{label:"AppSecret",prop:"appsecret"},{default:t(()=>[l(d,{modelValue:a.value.appsecret,"onUpdate:modelValue":e[2]||(e[2]=o=>a.value.appsecret=o),type:"password",placeholder:"请输入小程序AppSecret","show-password":"",onInput:m},null,8,["modelValue"])]),_:1})]),_:1}),l(u,{span:12},{default:t(()=>[l(s,{label:"订单前缀",prop:"order_prefix"},{default:t(()=>[l(d,{modelValue:a.value.order_prefix,"onUpdate:modelValue":e[3]||(e[3]=o=>a.value.order_prefix=o),placeholder:"请输入2位订单前缀",maxlength:"2",onInput:m},null,8,["modelValue"]),e[7]||(e[7]=f("div",{class:"form-tip"},"必须为2位字符，用于区分不同小程序的订单",-1))]),_:1})]),_:1})]),_:1}),l(x,{gutter:20},{default:t(()=>[l(u,{span:12},{default:t(()=>[l(s,{label:"是否默认",prop:"is_default"},{default:t(()=>[l(D,{modelValue:a.value.is_default,"onUpdate:modelValue":e[4]||(e[4]=o=>a.value.is_default=o),onChange:k},{default:t(()=>[l(w,{value:1},{default:t(()=>[...e[8]||(e[8]=[_("是",-1)])]),_:1}),l(w,{value:0},{default:t(()=>[...e[9]||(e[9]=[_("否",-1)])]),_:1})]),_:1},8,["modelValue"]),e[10]||(e[10]=f("div",{class:"form-tip"},"默认小程序用于未匹配域名时的兜底",-1))]),_:1})]),_:1}),l(u,{span:12},{default:t(()=>[l(s,{label:"关联商户",prop:"merchants"},{default:t(()=>[l(E,{modelValue:a.value.merchants,"onUpdate:modelValue":e[5]||(e[5]=o=>a.value.merchants=o),multiple:"",placeholder:"请选择关联的微信支付商户",style:{width:"100%"},onChange:m},{default:t(()=>[(V(!0),z(O,null,L(g.weixinMerchants,(o,y)=>(V(),C(q,{key:y,label:o.name||`商户${y+1}`,value:o.mch_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),e[11]||(e[11]=f("div",{class:"form-tip"},"选择该小程序可使用的微信支付商户",-1))]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),_:1})}}}),X=j(J,[["__scopeId","data-v-b2192302"]]);export{X as default};
