import{d as e,k as a,H as l,p as r,r as u,K as s,J as p,o as m,j as o,w as t,e as d,a as i,c as n,F as c,q as v,f as y,V as f,W as b,b as g,t as _,O as V}from"./index-018fb6dd.js";import{m as h}from"./index-1e83f7c7.js";import{o as w}from"./index-981be696.js";/* empty css             *//* empty css                   */const x={class:"flex flex-row justify-between"},k={class:"w-full"},j=d("div",{class:"flex items-center"},[d("span",{class:"mr-1 text-red-600"},"*"),g("公用支付参数 ")],-1),U={class:"flex justify-end"},q=e({__name:"create",props:{primary:null|Object},emits:["close"],setup(e,{emit:q}){const C=e,$=a(),F=a({}),J=l({pay_type:[{required:!0,message:"请选择支付方式"}],miniprogram_type:[{required:!0,message:"请选择小程序类型"}],pay_common_params:[{required:!1,message:"请输入公用支付参数",trigger:"blur"}],remark:[{required:!1,message:"请输入备注",trigger:"blur"}],name:[{required:!0,message:"请输入支付名称",trigger:"blur"}],payee_name:[{required:!0,message:"请输入收款主体",trigger:"blur"}],pay_appid:[{required:!0,message:"请输入支付商户号",trigger:"blur"},{pattern:/^[1-9]\d*$/,message:"只能输正整数",trigger:"blur"}]}),O=a(!1),T=a([]),H=a([]),I=a([{params:"",value:""}]),K=()=>{M()&&I.value.push({params:"",value:""})},M=()=>{for(const e of I.value){if(!e.params||!e.value)return V.warning("请输入完整公用支付参数的键值对"),!1;if(W(e))return V.warning(`键 ${e.params} 已存在，请输入一个唯一的键`),!1}return!0},W=e=>I.value.filter((a=>a.params===e.params)).length>1;return C.primary,r((()=>{w().then((e=>{T.value=e.data.miniprogramType,H.value=e.data.payType}))})),(e,a)=>{const l=u("el-input"),r=u("el-form-item"),w=u("el-option"),C=u("el-select"),W=u("el-button"),z=u("el-form"),A=s("loading");return p((m(),o(z,{model:F.value,"label-width":"120px",ref_key:"ruleForm",ref:$,rules:y(J),class:"pr-4"},{default:t((()=>[d("div",x,[d("div",k,[i(r,{label:"支付名称",prop:"name"},{default:t((()=>[i(l,{modelValue:F.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>F.value.name=e),placeholder:"请输入支付名称"},null,8,["modelValue"])])),_:1}),i(r,{label:"收款主体",prop:"payee_name"},{default:t((()=>[i(l,{modelValue:F.value.payee_name,"onUpdate:modelValue":a[1]||(a[1]=e=>F.value.payee_name=e),placeholder:"请输入收款主体"},null,8,["modelValue"])])),_:1}),i(r,{label:"支付商户号",prop:"pay_appid"},{default:t((()=>[i(l,{modelValue:F.value.pay_appid,"onUpdate:modelValue":a[2]||(a[2]=e=>F.value.pay_appid=e),modelModifiers:{number:!0},clearable:"",placeholder:"请输入支付商户号"},null,8,["modelValue"])])),_:1}),i(r,{label:"支付方式",prop:"pay_type"},{default:t((()=>[i(C,{class:"w-full",modelValue:F.value.pay_type,"onUpdate:modelValue":a[3]||(a[3]=e=>F.value.pay_type=e),clearable:"",filterable:"",placeholder:"请选择支付方式"},{default:t((()=>[(m(!0),n(c,null,v(H.value,((e,a)=>(m(),o(w,{key:a,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),i(r,{label:"小程序类型",prop:"miniprogram_type"},{default:t((()=>[i(C,{class:"w-full",modelValue:F.value.miniprogram_type,"onUpdate:modelValue":a[4]||(a[4]=e=>F.value.miniprogram_type=e),clearable:"",filterable:"",placeholder:"请选择小程序类型"},{default:t((()=>[(m(!0),n(c,null,v(T.value,((e,a)=>(m(),o(w,{key:a,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),i(r,{label:"公用支付参数",prop:"pay_common_params"},{label:t((()=>[j])),default:t((()=>[(m(!0),n(c,null,v(I.value,((e,a)=>(m(),n("div",{class:"w-full mb-3",key:a},[i(l,{style:{width:"40%","margin-right":"6px"},modelValue:e.params,"onUpdate:modelValue":a=>e.params=a,clearable:"",placeholder:"请输入参数名称"},null,8,["modelValue","onUpdate:modelValue"]),i(l,{style:{width:"40%","margin-right":"6px"},modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,clearable:"",placeholder:"请输入参数值"},null,8,["modelValue","onUpdate:modelValue"]),i(W,{type:"primary",onClick:K,icon:y(f),circle:""},null,8,["icon"]),i(W,{type:"primary",onClick:e=>{return l=a,void I.value.splice(l,1);var l},disabled:1==I.value.length,icon:y(b),circle:""},null,8,["onClick","disabled","icon"])])))),128))])),_:1})])]),d("div",U,[i(W,{type:"primary",onClick:a[5]||(a[5]=e=>(e=>{I.value;let a={};for(let l of I.value)a[l.params]=l.value;M()&&(F.value.pay_common_params=a,e&&e.validate((e=>{e?h(F.value).then((e=>{V.success(e.message),O.value=!1,q("close")})):O.value=!1})).then((()=>{})))})($.value))},{default:t((()=>[g(_(e.$t("system.confirm")),1)])),_:1})])])),_:1},8,["model","rules"])),[[A,O.value]])}}});export{q as _};
