import{c as R,r as S}from"./role-21d1ece6.js";import{p as T}from"./global-0d825ba6.js";import{u as x}from"./index-8db2df2c.js";import{h as E,d as K,M as f,A as P,j as C,f as k}from"./ui-ba7aaa7e.js";import{e as z,l as A,r as u,d as N,P as I,a3 as O,a4 as p,f as m,H as U}from"./vue-bf422dc1.js";const H=z({__name:"rate",setup(B,{expose:_}){const c=[{label:"角色费率",value:1},{label:"通道费率",value:0}],v=[{colKey:"id",title:"ID"},{colKey:"title",title:"通道名称"},{colKey:"show_name",title:"显示名称"},{colKey:"is_custom",title:"通道类型",cell:(e,{row:a})=>a.is_custom?"用户通道":"官方通道"},{colKey:"rate",title:"费率",edit:{component:E,props:{autofocus:!0,placeholder:"请输入费率",tips:"单位：千分率",suffix:"‰",theme:"normal",min:0},validateTrigger:"change",abortEditOnEvent:["onEnter"],onEdited:e=>{t.rate=e.newRowData.rate,t.channel_id=e.newRowData.id,t.status=e.newRowData.status,d()},rules:[{required:!0,message:"不能为空"}],defaultEditable:!1}},{colKey:"status",title:"模式",cell:(e,{row:a})=>{var s;return(s=c.find(r=>r.value===a.status))==null?void 0:s.label},edit:{component:K,props:{options:c},onEdited:e=>{t.rate=e.newRowData.rate,t.channel_id=e.newRowData.id,t.status=e.newRowData.status,d()}}}],t=A({channel_id:0,rate:0,status:0,role_id:0}),d=async()=>{const e=await R({...t});e.code===1?(f.success("操作成功"),n()):f.error(e.msg)},l=u(!1),h=e=>{t.role_id=e,n(),l.value=!0},o=u({defaultPageSize:20,total:0,defaultCurrent:1}),i=u([]),n=async()=>{const{data:e}=await S({id:t.role_id});i.value=e.list,o.value.total=e.total},g=e=>{o.value.defaultCurrent=e.current,o.value.defaultPageSize=e.pageSize,n()},w=x(),b=N(()=>({offsetTop:w.isUseTabsRouter?48:0,container:`.${T}-layout`}));return _({init:h}),(e,a)=>{const s=P,r=C,y=k;return I(),O(y,{visible:l.value,"onUpdate:visible":a[0]||(a[0]=D=>l.value=D),"close-on-overlay-click":!1,"destroy-on-close":!0,footer:!1,header:"角色费率设置",width:"900px"},{default:p(()=>[m(s,null,{default:p(()=>[U("优先级：用户费率》角色费率》通道费率。此处可将通道费率自定义提升到角色费率")]),_:1}),m(r,{ref:"tableRef","row-key":"id",data:i.value,columns:v,hover:i.value.length>0,"header-affixed-top":b.value,pagination:o.value,"lazy-load":"","table-layout":"auto","max-height":"100%",onPageChange:g},null,8,["data","hover","header-affixed-top","pagination"])]),_:1},8,["visible"])}}});export{H as _};
