/* empty css             *//* empty css                   *//* empty css                     *//* empty css                  *//* empty css                 *//* empty css               *//* empty css                  *//* empty css                     *//* empty css                  */import{d as e,m as a,U as l,x as r,W as s,o as u,l as p,w as m,e as o,a as t,c as i,F as d,y as n,f as c,ao as v,ap as y,b as f,t as g,a4 as b,a2 as _,a3 as V,A as h,B as j,S as x,Y as w,$ as U}from"./index-2b50ecca.js";import{m as k}from"./index-3cdca181.js";import{o as q}from"./index-1eb7652b.js";/* empty css                 *//* empty css                   */const C={class:"flex flex-row justify-between"},$={class:"w-full"},F=o("div",{class:"flex items-center"},[o("span",{class:"mr-1 text-red-600"},"*"),f("公用支付参数 ")],-1),M={class:"flex justify-end"},T=e({__name:"create",props:{primary:null|Object},emits:["close"],setup(e,{emit:T}){const Y=e,A=a(),B=a({}),L=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),S=a([]),W=a([]),X=a([{params:"",value:""}]),Z=()=>{z()&&X.value.push({params:"",value:""})},z=()=>{for(const e of X.value){if(!e.params||!e.value)return b.warning("请输入完整公用支付参数的键值对"),!1;if(D(e))return b.warning(`键 ${e.params} 已存在，请输入一个唯一的键`),!1}return!0},D=e=>X.value.filter((a=>a.params===e.params)).length>1;return Y.primary,r((()=>{q().then((e=>{S.value=e.data.miniprogramType,W.value=e.data.payType}))})),(e,a)=>{const l=_,r=V,q=h,Y=j,D=x,E=w,G=U;return s((u(),p(E,{model:B.value,"label-width":"120px",ref_key:"ruleForm",ref:A,rules:c(L),class:"pr-4"},{default:m((()=>[o("div",C,[o("div",$,[t(r,{label:"支付名称",prop:"name"},{default:m((()=>[t(l,{modelValue:B.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>B.value.name=e),placeholder:"请输入支付名称"},null,8,["modelValue"])])),_:1}),t(r,{label:"收款主体",prop:"payee_name"},{default:m((()=>[t(l,{modelValue:B.value.payee_name,"onUpdate:modelValue":a[1]||(a[1]=e=>B.value.payee_name=e),placeholder:"请输入收款主体"},null,8,["modelValue"])])),_:1}),t(r,{label:"支付商户号",prop:"pay_appid"},{default:m((()=>[t(l,{modelValue:B.value.pay_appid,"onUpdate:modelValue":a[2]||(a[2]=e=>B.value.pay_appid=e),modelModifiers:{number:!0},clearable:"",placeholder:"请输入支付商户号"},null,8,["modelValue"])])),_:1}),t(r,{label:"支付方式",prop:"pay_type"},{default:m((()=>[t(Y,{class:"w-full",modelValue:B.value.pay_type,"onUpdate:modelValue":a[3]||(a[3]=e=>B.value.pay_type=e),clearable:"",filterable:"",placeholder:"请选择支付方式"},{default:m((()=>[(u(!0),i(d,null,n(W.value,((e,a)=>(u(),p(q,{key:a,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),t(r,{label:"小程序类型",prop:"miniprogram_type"},{default:m((()=>[t(Y,{class:"w-full",modelValue:B.value.miniprogram_type,"onUpdate:modelValue":a[4]||(a[4]=e=>B.value.miniprogram_type=e),clearable:"",filterable:"",placeholder:"请选择小程序类型"},{default:m((()=>[(u(!0),i(d,null,n(S.value,((e,a)=>(u(),p(q,{key:a,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),t(r,{label:"公用支付参数",prop:"pay_common_params"},{label:m((()=>[F])),default:m((()=>[(u(!0),i(d,null,n(X.value,((e,a)=>(u(),i("div",{class:"w-full mb-3",key:a},[t(l,{style:{width:"40%","margin-right":"6px"},modelValue:e.params,"onUpdate:modelValue":a=>e.params=a,clearable:"",placeholder:"请输入参数名称"},null,8,["modelValue","onUpdate:modelValue"]),t(l,{style:{width:"40%","margin-right":"6px"},modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,clearable:"",placeholder:"请输入参数值"},null,8,["modelValue","onUpdate:modelValue"]),t(D,{type:"primary",onClick:Z,icon:c(v),circle:""},null,8,["icon"]),t(D,{type:"primary",onClick:e=>{return l=a,void X.value.splice(l,1);var l},disabled:1==X.value.length,icon:c(y),circle:""},null,8,["onClick","disabled","icon"])])))),128))])),_:1})])]),o("div",M,[t(D,{type:"primary",onClick:a[5]||(a[5]=e=>(e=>{X.value;let a={};for(let l of X.value)a[l.params]=l.value;z()&&(B.value.pay_common_params=a,e&&e.validate((e=>{e?k(B.value).then((e=>{b.success(e.message),O.value=!1,T("close")})):O.value=!1})).then((()=>{})))})(A.value))},{default:m((()=>[f(g(e.$t("system.confirm")),1)])),_:1})])])),_:1},8,["model","rules"])),[[G,O.value]])}}});export{T as _};
