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