2025-09-05 16:29:53 +08:00
|
|
|
|
import{ag as e,r as l,D as a,m as t,e as d,w as o,N as u,bp as r,g as n,al as s,bq as p,bZ as i,c,a7 as m,a8 as _,b_ as h,am as f,O as g,bR as y,d6 as b,l as v,an as V,aX as w,a_ as C,dB as k}from"./index.1757060910532DErf1CMz.js";import{g as A}from"./payee-suppiler.1757060910532DPkCYsdh.js";const U={class:"dialog-footer"},B={__name:"add-channel",props:{showAddChannel:{type:Boolean,default:!1},currentRow:{type:Object,default:{}}},emits:["update:showAddChannel","confirmAddChannel"],setup(B,{emit:q}){const x=B,R=e({shop_id:"",name:"",code:"",gateway:"",notify_url:"",notify_server:"",pr:"",bak_url:"",status:"",product_id:[],class_name:""}),T=e({shop_id:[{required:!0,message:"请选择供应商",trigger:"change"}],name:[{required:!0,message:"请输入中文名称",trigger:"blur"}],code:[{required:!0,message:"请输入支付渠道代码",trigger:"blur"}],pr:[{required:!0,message:"请输入费率",trigger:"blur"}],notify_url:[{required:!0,message:"请输入页面通知地址",trigger:"blur"}],status:[{required:!0,message:"请选择状态",trigger:"change"}],product_id:[{required:!0,message:"请选择支付通道",trigger:"change"}],gateway:[{required:!0,message:"请输入网关网站",trigger:"blur"}]}),j=l([]),F=l([]),O=l(!1);a(()=>x.showAddChannel,e=>{if(e&&(E(),P(),"{}"!=JSON.stringify(x.currentRow))){let e=x.currentRow;R.code=e.code,R.name=e.name,R.shop_id=e.shop_id,R.gateway=e.gateway,R.status=e.status,R.notify_url=e.notify_url,R.notify_server=e.notify_server,R.pr=e.pr,R.bak_url=e.bak_url,R.id=e.id,R.class_name=e.class_name,e.payProduct&&e.payProduct.map(e=>{R.product_id=e.id}),O.value=!0}});const E=()=>{A({saiType:"all"}).then(e=>{j.value=[],e.forEach(e=>{j.value.push({label:e.supplier_name,value:e.shop_id})})})},P=()=>{k({saiType:"all",status:"1"}).then(e=>{F.value=[],e.forEach(e=>{F.value.push({label:e.name,value:e.id})})})},N=()=>{for(let e in R)R[e]=""},S=q,D=()=>{H.value.resetFields(),S("update:showAddChannel",!1),N()},H=l(),J=()=>{O.value?L():H.value.validate(e=>{e&&(R.pay_info=[],R.product_id.length>0&&R.pay_info.push({id:R.product_id}),S("update:showAddChannel",!1),S("confirmAddChannel",R),H.value.resetFields(),N())})},L=()=>{H.value.validate(e=>{var l;if(e){R.pay_info=[],R.product_id.length>0&&R.pay_info.push({id:R.product_id});let e=[];x.currentRow&&Object.keys(x.currentRow).length>0&&(null==(l=null==x?void 0:x.currentRow)||l.payProduct.forEach(l=>{R.pr-l.pr>0&&e.push(l.name)})),e.length>0&&1==R.status?C({title:"提示",message:`<span style="color: red">通道[${e.join(",")}]费率小于渠道成本</span>`,confirmButtonText:"我已知晓",cancelButtonText:"取消",showCancelButton:!0,type:"warning",dangerouslyUseHTMLString:!0}).then(()=>{C.alert("确定修改渠道吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",showCancelButton:!0,type:"warning"}).then(()=>{S("update:showAddChannel",!1),S("confirmAddChannel",R),H.value.resetFields(),N()}).catch(()=>{})}).catch(()=>{}):C.alert("确定修改渠道吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",showCancelButton:!0,type:"warning"}).then(()=>{S("update:showAddChannel",!1),S("confirmAddChannel",R),H.value.resetFields(),N()}).catch(()=>{})}})};return(e,l)=>{const a=h,C=i,k=p,A=f,q=b,x=y,O=r,E=V,P=w;return d(),t(P,{"model-value":B.showAddChannel,title:"添加渠道配置",width:"600","before-close":D},{footer:o(()=>[v("div",U,[u(E,{type:"primary",onClick:J},{default:o(()=>l[14]||(l[14]=[g(" 提交保存 ")])),_:1,__:[14]})])]),default:o(()=>[u(O,{model:n(R),"label-width":"auto",ref_key:"channelRef",ref:H,rules:n(T)},{default:o(()=>[u(k,{label:"供应商",prop:"shop_id"},{default:o(()=>[u(C,{modelValue:n(R).shop_id,"onUpdate:modelValue":l[0]||(l[0]=e=>n(R).shop_id=e),placeholder:"选择供应商",filterable:"",clearable:""},{default:o(()=>[(d(!0),c(m,null,_(n(j),(e,l)=>(d(),t(a,{key:l,label:e.label,value:e.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),u(k,{label:"中文名称",prop:"name"},{default:o(()=>[u(A,{modelValue:n(R).name,"onUpdate:modelValue":l[1]||(l[1]=e=>n(R).name=e),placeholder:"<EFBFBD><EFBFBD>
|