import{_ as e}from"./index.D46A469w.js";import{F as t,ag as a,b6 as n,c as l,e as o,N as i,w as r,O as s,t as p,bS as c,g as u,ai as d,bN as h}from"./index.DMuoDWpw.js";import{E as g}from"./el-text.BNx45kFL.js";import"./el-col.COx331AE.js";const m={__name:"merchant-balance-details",props:{getTypeList:{type:Function,required:!0},getList:{type:Function,required:!0},getMerchantTypeList:{type:Function,required:!1},showMerchantFilter:{type:Boolean,required:!1,default:!0}},setup(m){const _=m,b=t(()=>{const e=[{label:"交易号",prop:"transaction_no",type:"input",value:""},{label:"类型",type:"select",prop:"type",value:"",options:y},{label:"收支",type:"select",prop:"in_out",value:"",options:F},{prop:"transaction_at",label:"交易时间",type:"date",dateType:"datetimerange",value:[]}];return _.showMerchantFilter&&e.unshift({label:"商户",prop:"merchant_id",type:"select",options:v,value:""}),e});let y=[],v=[];const F=[{label:"收",value:1},{label:"支",value:2}],f=a({columns:[{prop:"merchant_id",label:"商户编号",width:80,align:"center"},{prop:"merchant_name",label:"商户名称",align:"center"},{prop:"transaction_no",label:"交易号",align:"center"},{prop:"type_name",label:"类型",align:"center"},{prop:"in_out_name",label:"收/支",align:"center",slot:"in_out_slot"},{prop:"change_amount",label:"交易金额",align:"center",slot:"amount_slot"},{prop:"after_balance",label:"佣金余额",align:"center"},{prop:"transaction_time",label:"交易时间",align:"center"},{prop:"remark",label:"备注",align:"center"}],tableData:[],searchFields:b.value,total:0,page:1,limit:10,loading:!1}),w=()=>{f.searchFields.forEach(e=>{"datetimerange"==e.dateType?e.value=[]:e.value=""}),T()};const T=()=>{var e;f.loading=!0;let t={limit:f.limit,page:f.page},a=function(e){const t={};return e.forEach(e=>{e.prop&&void 0!==e.value&&(t[e.prop]=e.value)}),t}(f.searchFields);(null==(e=a.transaction_at)?void 0:e.length)>0&&(a.transaction_time_start=a.transaction_at[0]?h(a.transaction_at[0]):"",a.transaction_time_end=a.transaction_at[1]?h(a.transaction_at[1]):""),_.getList(Object.assign(t,a)).then(e=>{f.tableData=e.data,f.total=e.total,f.loading=!1}).catch(()=>{f.loading=!1})};return n(()=>{f.searchFields=b.value,_.getTypeList({}).then(e=>{y=[],Object.entries(e).forEach(([e,t])=>{y.push({label:t,value:e})}),d(()=>{f.searchFields.forEach(e=>{"type"==e.prop&&(e.options=y)})})}),_.getMerchantTypeList&&_.showMerchantFilter&&_.getMerchantTypeList({}).then(e=>{v=[],e.forEach(e=>{v.push({label:e.name,value:e.id})}),d(()=>{f.searchFields.forEach(e=>{"merchant_id"==e.prop&&(e.options=v)})})}),T()}),(t,a)=>{const n=c,d=g,h=e;return o(),l("div",null,[i(h,{type:"export",columns:u(f).columns,searchFields:u(f).searchFields,"onUpdate:searchFields":a[0]||(a[0]=e=>u(f).searchFields=e),data:u(f).tableData,limit:u(f).limit,"onUpdate:limit":a[1]||(a[1]=e=>u(f).limit=e),page:u(f).page,"onUpdate:page":a[2]||(a[2]=e=>u(f).page=e),total:u(f).total,onGetTableData:T,onResetForm:w,loading:u(f).loading,showSelection:!1,showRightRefreshSlot:!1},{in_out_slot:r(({row:e})=>[i(n,{type:1===e.in_out?"danger":"success"},{default:r(()=>[s(p(1===e.in_out?"收":"支"),1)]),_:2},1032,["type"])]),amount_slot:r(({row:e})=>[i(d,{type:1===e.in_out?"danger":"success"},{default:r(()=>[s(p(1===e.in_out?"+"+e.change_amount:"-"+e.change_amount),1)]),_:2},1032,["type"])]),_:1},8,["columns","searchFields","data","limit","page","total","loading"])])}}};export{m as default};