applyIbDialog.CaBb4BYU.js 9.4 KB

1
  1. import{d as e,u as o,r as t,o as a,w as s,f as l,g as n,i as r,j as i,k as p,l as c,m as d,s as y,D as u,E as m,t as g,H as v,I as b,A as h,x as f,y as C,_ as x}from"./index-C9tefb_I.js";import{_ as I}from"./cwg-combox.Cz4GMd3X.js";import{_ as O,a as w}from"./uni-forms.PLvtWS4P.js";import{_ as A}from"./uni-loading.C4LzRuDn.js";import{c as T}from"./cwg-page-wrapper.DOjYNJIW.js";import{c as S}from"./index.DEN0qiOJ.js";import{i as k}from"./cwg-right-drawer.Dqta5KCZ.js";const E=x(e({__name:"applyIbDialog",props:{paramsType:{type:String,default:""},title:{type:String,default:"Ib.Report.Title5"},visible:{type:Boolean,default:!1},detail:{type:Object,default:()=>({})},isFormApplyIb:{type:Boolean,default:!1}},emits:["close","confirm"],setup(e,{emit:x}){const E=e,{Code:_,Host80:F}=S,{t:U}=o(),j=t(null),M=t({customerId:""}),D=t([]);t({ecn:{selectedIndex:null,selectedItem:null,loginType:"2"},standard:{selectedIndex:null,selectedItem:null,loginType:"7"},cent:{selectedIndex:null,selectedItem:null,loginType:"8"}}),t({ecn:[],standard:[],cent:[]});const G=t([]),N=x,R=t(!1);a((()=>{})),s((()=>E.visible),(async e=>{if(e){if(R.value=!0,E.isFormApplyIb&&await H(),E.detail.id){let e={customId:E.detail.id};M.value={customerId:E.detail.id},"vietnam"==E.paramsType&&(e={agentId:E.detail.id}),await B(e)}R.value=!1}}));const P=e=>{const o=[];for(let t=0;t<=e;t++)o.push(t);return o},K=e=>e&&Array.isArray(e)?e.map((e=>({text:String(e),value:e}))):[],B=async e=>{try{const o=await k.getVietnamPoints(e);if(o.code==_.StatusOK&&o.data&&Array.isArray(o.data)){const e={};o.data.forEach((o=>{const t=o.groupCategoryName||"--",a=void 0!==o.valid?o.valid:1;e[t]||(e[t]=[]);const s=Array.isArray(o.rebates)?o.rebates:[],l=Array.isArray(o.superRebates)?o.superRebates:[];if(l.length>0){const n={accountGroup:t,groupCategoryId:o.groupCategoryId,dataType:"rebates",type:o.rebateTypeName||"Point",isOpen:a,forex:0,index:0,metal:0,energy:0,energy2:0,energy2Max:0,forex1:0,index1:0,metal1:0,energy1:0,crypto:0,crypto1:0};s.forEach((e=>{1===e.symbolCategory?n.forex=e.point||0:2===e.symbolCategory?n.index=e.point||0:3===e.symbolCategory?n.metal=e.point||0:4===e.symbolCategory?n.energy=e.point||0:5===e.symbolCategory?n.energy2=e.point||0:6===e.symbolCategory&&(n.crypto=e.point||0)})),l.forEach((e=>{1===e.symbolCategory?n.forex1=e.point||0:2===e.symbolCategory?n.index1=e.point||0:3===e.symbolCategory?n.metal1=e.point||0:4===e.symbolCategory?n.energy1=e.point||0:5===e.symbolCategory?n.energy2Max=e.point||0:6===e.symbolCategory&&(n.crypto1=e.point||0)})),n.forexOptions=P(n.forex1),n.indexOptions=P(n.index1),n.metalOptions=P(n.metal1),n.energyOptions=P(n.energy1),n.energy2Options=P(n.energy2Max),n.cryptoOptions=P(n.crypto1),e[t].push(n)}const n=Array.isArray(o.commissions)?o.commissions:[],r=Array.isArray(o.superCommissions)?o.superCommissions:[];if(r.length>0){const s={accountGroup:t,groupCategoryId:o.groupCategoryId,dataType:"commissions",type:o.commissionTypeName||"Commission",isOpen:a,forex:0,index:0,metal:0,energy:0,energy2:0,energy2Max:0,forex1:0,index1:0,metal1:0,energy1:0,crypto:0,crypto1:0};n.forEach((e=>{1===e.symbolCategory?s.forex=e.point||0:2===e.symbolCategory?s.index=e.point||0:3===e.symbolCategory?s.metal=e.point||0:4===e.symbolCategory?s.energy=e.point||0:5===e.symbolCategory?s.energy2=e.point||0:6===e.symbolCategory&&(s.crypto=e.point||0)})),r.forEach((e=>{1===e.symbolCategory?s.forex1=e.point||0:2===e.symbolCategory?s.index1=e.point||0:3===e.symbolCategory?s.metal1=e.point||0:4===e.symbolCategory?s.energy1=e.point||0:5===e.symbolCategory?s.energy2Max=e.point||0:6===e.symbolCategory&&(s.crypto1=e.point||0)})),s.forexOptions=P(s.forex1),s.indexOptions=P(s.index1),s.metalOptions=P(s.metal1),s.energyOptions=P(s.energy1),s.energy2Options=P(s.energy2Max),s.cryptoOptions=P(s.crypto1),e[t].push(s)}}));const t=Object.keys(e).map((o=>({accountGroup:o,isOpen:e[o].some((e=>1==e.isOpen))||!1,items:e[o]}))).filter((e=>e.items.length>0));return console.log("tableData",t),void(G.value=t)}G.value=[],h({title:o.msg||U("Ib.Custom.GetDataFailed"),icon:"none"})}catch(o){G.value=[],h({title:U("Ib.Custom.GetDataFailed"),icon:"none"})}},H=async()=>{try{let e=await k.customerSubsList({ibStatus:1});e.code==_.StatusOK?D.value=e.data.map((e=>({text:`${e.name||""}-${e.cId}`,value:e.id||"",cId:e.cId})))||[]:(h({title:e.msg,icon:"none"}),D.value=[])}catch(e){console.error("加载客户列表失败:",e),D.value=[]}},L=async e=>{e?(R.value=!0,await B({customId:e}),R.value=!1):G.value=[]},V=()=>{M.value={customerId:""},G.value=[],N("close")},X=async()=>{let e,o;if("vietnam"!==E.paramsType)if(E.isFormApplyIb){if(!M.value.customerId)return void h({title:U("placeholder.choose"),icon:"none"});const t=D.value.find((e=>e.value===M.value.customerId));if(!t)return void h({title:U("Ib.Custom.CustomerNotFound"),icon:"none"});e=t.value,o=t.cId}else{if(!E.detail.id)return void h({title:U("Ib.Custom.CustomerNotExist"),icon:"none"});const t=E.detail||{};e=t.id,o=t.cId}try{const t=(()=>{const e=[],o={};return G.value.forEach((e=>{e.items.forEach((t=>{const a=t.groupCategoryId;o[a]||(o[a]={groupCategoryId:a,commissions:[],rebates:[],valid:e.isOpen?1:0});const s="commissions"===t.dataType?o[a].commissions:o[a].rebates;void 0!==t.forex&&null!==t.forex&&s.push({symbolCategory:1,point:t.forex}),void 0!==t.index&&null!==t.index&&s.push({symbolCategory:2,point:t.index}),void 0!==t.metal&&null!==t.metal&&s.push({symbolCategory:3,point:t.metal}),void 0!==t.energy&&null!==t.energy&&s.push({symbolCategory:4,point:t.energy}),void 0!==t.energy2&&null!==t.energy2&&s.push({symbolCategory:5,point:t.energy2}),void 0!==t.crypto&&null!==t.crypto&&s.push({symbolCategory:6,point:t.crypto})}))})),Object.keys(o).forEach((t=>{const a=o[t];(a.commissions.length>0||a.rebates.length>0)&&e.push({groupCategoryId:a.groupCategoryId,commissions:a.commissions.length>0?a.commissions:void 0,rebates:a.rebates.length>0?a.rebates:void 0,valid:a.valid})})),e})();let a={customId:e,cId:o,points:t};"vietnam"===E.paramsType&&(a={agentId:E.detail.id,points:t});const s="vietnam"===E.paramsType?await k.saveVietnamPoints(a):await k.agentApplyAddPoint(a);s.code==_.StatusOK?(h({title:s.msg||E.paramsType?U("Ib.Custom.SaveSuccess"):U("Ib.Custom.SubmitSuccess"),icon:"success"}),V(),N("confirm")):h({title:s.msg||E.paramsType?U("Ib.Custom.SaveFailed"):U("Ib.Custom.SubmitFailed"),icon:"none"})}catch(t){console.error("新增代理失败或保存越南分配数据失败:",t),h({title:E.paramsType?U("Ib.Custom.SaveFailed"):U("Ib.Custom.SubmitFailed"),icon:"none"})}};return(o,t)=>{const a=l(n("cwg-combox"),I),s=l(n("uni-forms-item"),O),h=l(n("uni-loading"),A),x=C,S=f,k=l(n("uni-forms"),w),E=l(n("cwg-popup"),T);return r(),i(E,{title:d(U)(e.title),visible:e.visible,onClose:V,onConfirm:X,width:"900px"},{default:p((()=>[c(S,{class:"dia-content"},{default:p((()=>[c(k,{ref_key:"formRef",ref:j,labelWidth:"200"},{default:p((()=>[e.isFormApplyIb?(r(),i(s,{key:0,label:d(U)("Ib.Custom.Manage3")+":",prop:"customerId"},{default:p((()=>[c(a,{value:M.value.customerId,"onUpdate:value":t[0]||(t[0]=e=>M.value.customerId=e),options:D.value,placeholder:d(U)("placeholder.choose"),filterable:"",onChange:L,style:{"max-width":"280px"}},null,8,["value","options","placeholder"])])),_:1},8,["label"])):y("",!0),R.value?(r(),i(h,{key:1})):(r(),u(v,{key:2},[M.value.customerId?(r(),i(S,{key:0,class:"commission-table-container"},{default:p((()=>[m("table",{class:"commission-table"},[m("thead",null,[m("tr",null,[m("th",{style:{width:"80px"}},g(d(U)("Ib.Custom.Status")),1),m("th",{style:{width:"100px"}}),m("th",{style:{width:"100px"}}),m("th",{style:{width:"80px"}},"METAL"),m("th",null,"FX"),m("th",null,"ENERGY"),m("th",null,"CFD"),m("th",null,"INDEX"),m("th",null,"CRYPTO")])]),(r(!0),u(v,null,b(G.value,((e,o)=>(r(),u("tbody",{key:o},[(r(!0),u(v,null,b(e.items,((o,t)=>(r(),u("tr",{key:t},[0===t?(r(),u("td",{key:0,rowspan:e.items.length,class:"center-td"},[c(x,{checked:e.isOpen,onChange:o=>((e,o)=>{o.isOpen=e.detail.value})(o,e),color:"#2b5aed",style:{transform:"scale(0.8)"}},null,8,["checked","onChange"])],8,["rowspan"])):y("",!0),0===t?(r(),u("td",{key:1,rowspan:e.items.length,class:"center-td group-name-td"},g(e.accountGroup),9,["rowspan"])):y("",!0),m("td",{class:"center-td type-td"},g(o.type),1),m("td",{style:{width:"80px"}},[c(a,{value:o.energy,"onUpdate:value":e=>o.energy=e,options:K(o.energyOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),m("td",null,[c(a,{value:o.forex,"onUpdate:value":e=>o.forex=e,options:K(o.forexOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),m("td",null,[c(a,{value:o.energy2,"onUpdate:value":e=>o.energy2=e,options:K(o.energy2Options),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),m("td",null,[c(a,{value:o.index,"onUpdate:value":e=>o.index=e,options:K(o.indexOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),m("td",null,[c(a,{value:o.metal,"onUpdate:value":e=>o.metal=e,options:K(o.metalOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),m("td",null,[c(a,{value:o.crypto,"onUpdate:value":e=>o.crypto=e,options:K(o.cryptoOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])])])))),128))])))),128))])])),_:1})):y("",!0)],64))])),_:1},512)])),_:1})])),_:1},8,["title","visible"])}}}),[["__scopeId","data-v-64c49801"]]);export{E as A};