| 1 |
- import{d as e,u as o,r as t,c as a,o as s,w as l,f as n,g as i,i as r,j as c,k as p,l as u,m as d,s as m,E as y,F as g,t as v,J as b,K as h,A as f,x as C,a3 as x,y as I,_ as O}from"./index-D4XVi_WI.js";import{_ as A}from"./cwg-combox.CjpXWcSP.js";import{_ as w,a as T}from"./uni-forms.eR0FAOXI.js";import{_ as S}from"./uni-loading.N1Pb5I2K.js";import{a as k}from"./user.Bbch2OWZ.js";import{i as E}from"./cwg-right-drawer.DZ1krOjc.js";const F=O(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:O}){const F=e,{Code:_,Host80:j}=x,{t:U,locale:M}=o(),G=t(null),N=t({customerId:""}),D=a(()=>"cn"!=M.value?["FX","ENERGY","CFD","INDEX","METAL"]:[U("vu.tradingCenter.item71"),U("vu.tradingCenter.item72"),U("vu.tradingCenter.item73"),U("vu.tradingCenter.item74"),U("vu.tradingCenter.item75")]),R=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 K=t([]),P=O,B=t(!1);s(()=>{}),l(()=>F.visible,async e=>{if(e){if(B.value=!0,F.isFormApplyIb&&await $(),F.detail.id){let e={customId:F.detail.id};N.value={customerId:F.detail.id},"vietnam"==F.paramsType&&(e={agentId:F.detail.id}),await X(e)}B.value=!1}});const L=e=>{const o=[];for(let t=0;t<=e;t++)o.push(t);return o},V=e=>e&&Array.isArray(e)?e.map(e=>({text:String(e),value:e})):[],X=async e=>{try{const o=await E.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};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)}),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)}),n.forexOptions=L(n.forex1),n.indexOptions=L(n.index1),n.metalOptions=L(n.metal1),n.energyOptions=L(n.energy1),n.energy2Options=L(n.energy2Max),e[t].push(n)}const n=Array.isArray(o.commissions)?o.commissions:[],i=Array.isArray(o.superCommissions)?o.superCommissions:[];if(i.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};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)}),i.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)}),s.forexOptions=L(s.forex1),s.indexOptions=L(s.index1),s.metalOptions=L(s.metal1),s.energyOptions=L(s.energy1),s.energy2Options=L(s.energy2Max),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(K.value=t)}K.value=[],f({title:o.msg||U("Ib.Custom.GetDataFailed"),icon:"none"})}catch(o){K.value=[],f({title:U("Ib.Custom.GetDataFailed"),icon:"none"})}},$=async()=>{try{let e=await E.customerSubsList({ibStatus:1});e.code==_.StatusOK?R.value=e.data.map(e=>({text:`${e.name||""}-${e.cId}`,value:e.id||"",cId:e.cId}))||[]:(f({title:e.msg,icon:"none"}),R.value=[])}catch(e){console.error("加载客户列表失败:",e),R.value=[]}},H=async e=>{e?(B.value=!0,await X({customId:e}),B.value=!1):K.value=[]},J=()=>{N.value={customerId:""},K.value=[],P("close")},W=async()=>{let e,o;if("vietnam"!==F.paramsType)if(F.isFormApplyIb){if(!N.value.customerId)return void f({title:U("placeholder.choose"),icon:"none"});const t=R.value.find(e=>e.value===N.value.customerId);if(!t)return void f({title:U("Ib.Custom.CustomerNotFound"),icon:"none"});e=t.value,o=t.cId}else{if(!F.detail.id)return void f({title:U("Ib.Custom.CustomerNotExist"),icon:"none"});const t=F.detail||{};e=t.id,o=t.cId}try{const t=(()=>{const e=[],o={};return K.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})})}),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"===F.paramsType&&(a={agentId:F.detail.id,points:t});const s="vietnam"===F.paramsType?await E.saveVietnamPoints(a):await E.agentApplyAddPoint(a);s.code==_.StatusOK?(f({title:s.msg||F.paramsType?U("Ib.Custom.SaveSuccess"):U("Ib.Custom.SubmitSuccess"),icon:"success"}),J(),P("confirm")):f({title:s.msg||F.paramsType?U("Ib.Custom.SaveFailed"):U("Ib.Custom.SubmitFailed"),icon:"none"})}catch(t){console.error("新增代理失败或保存越南分配数据失败:",t),f({title:F.paramsType?U("Ib.Custom.SaveFailed"):U("Ib.Custom.SubmitFailed"),icon:"none"})}};return(o,t)=>{const a=n(i("cwg-combox"),A),s=n(i("uni-forms-item"),w),l=n(i("uni-loading"),S),f=I,x=C,O=n(i("uni-forms"),T),E=n(i("cwg-popup"),k);return r(),c(E,{title:d(U)(e.title),visible:e.visible,onClose:J,onConfirm:W,width:"900px"},{default:p(()=>[u(x,{class:"dia-content"},{default:p(()=>[u(O,{ref_key:"formRef",ref:G,labelWidth:"200"},{default:p(()=>[e.isFormApplyIb?(r(),c(s,{key:0,label:d(U)("Ib.Custom.Manage3")+":",prop:"customerId"},{default:p(()=>[u(a,{value:N.value.customerId,"onUpdate:value":t[0]||(t[0]=e=>N.value.customerId=e),options:R.value,placeholder:d(U)("placeholder.choose"),onChange:H,style:{"max-width":"280px"}},null,8,["value","options","placeholder"])]),_:1},8,["label"])):m("",!0),B.value?(r(),c(l,{key:1})):(r(),y(b,{key:2},[N.value.customerId?(r(),c(x,{key:0,class:"commission-table-container"},{default:p(()=>[g("table",{class:"commission-table"},[g("thead",null,[g("tr",null,[g("th",{class:"status-col"},v(d(U)("Ib.Custom.Status")),1),g("th",{class:"group-col"}),g("th",{class:"type-col"}),(r(!0),y(b,null,h(D.value,(e,o)=>(r(),y("th",{class:"value-col",key:o},v(e),1))),128))])]),(r(!0),y(b,null,h(K.value,(e,o)=>(r(),y("tbody",{key:o},[(r(!0),y(b,null,h(e.items,(o,t)=>(r(),y("tr",{key:t},[0===t?(r(),y("td",{key:0,rowspan:e.items.length,class:"center-td"},[u(f,{checked:e.isOpen,onChange:o=>((e,o)=>{o.isOpen=e.detail.value})(o,e),color:"#2b5aed",style:{transform:"scale(0.7)"}},null,8,["checked","onChange"])],8,["rowspan"])):m("",!0),0===t?(r(),y("td",{key:1,rowspan:e.items.length,class:"center-td group-name-td"},v(e.accountGroup),9,["rowspan"])):m("",!0),g("td",{class:"center-td type-td"},v(o.type),1),g("td",{class:"value-col"},[u(a,{value:o.energy,"onUpdate:value":e=>o.energy=e,options:V(o.energyOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),g("td",{class:"value-col"},[u(a,{value:o.forex,"onUpdate:value":e=>o.forex=e,options:V(o.forexOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),g("td",{class:"value-col"},[u(a,{value:o.energy2,"onUpdate:value":e=>o.energy2=e,options:V(o.energy2Options),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),g("td",{class:"value-col"},[u(a,{value:o.index,"onUpdate:value":e=>o.index=e,options:V(o.indexOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])]),g("td",{class:"value-col"},[u(a,{value:o.metal,"onUpdate:value":e=>o.metal=e,options:V(o.metalOptions),placeholder:d(U)("placeholder.choose")},null,8,["value","onUpdate:value","options","placeholder"])])]))),128))]))),128))])]),_:1})):m("",!0)],64))]),_:1},512)]),_:1})]),_:1},8,["title","visible"])}}}),[["__scopeId","data-v-4fc3e99c"]]);export{F as A};
|