applyIbDialog.nbXTT3ky.js 9.0 KB

1
  1. import{d as e,u as o,r as t,c as a,o as s,w as l,g as n,h as i,j as r,k as c,l as p,m as u,n as d,v as m,F as y,G as g,t as v,K as b,L as h,B as f,y as C,a4 as x,z as I,_ as O}from"./index-W42148QB.js";import{_ as A}from"./cwg-combox.2KAT0yqj.js";import{_ as w,a as T}from"./uni-forms.NzIjw_BH.js";import{_ as S}from"./uni-loading.B8skXSuN.js";import{a as k}from"./user.YHiBsroJ.js";import{i as F}from"./cwg-right-drawer.BYL-TXDg.js";const _=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 _=e,{Code:E,Host80:U}=x,{t:j,locale:G}=o(),M=t(null),N=t({customerId:""}),D=a((()=>"cn"!=G.value?["FX","ENERGY","CFD","INDEX","METAL"]:[j("vu.tradingCenter.item71"),j("vu.tradingCenter.item72"),j("vu.tradingCenter.item73"),j("vu.tradingCenter.item74"),j("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((()=>_.visible),(async e=>{if(e){if(B.value=!0,_.isFormApplyIb&&await $(),_.detail.id){let e={customId:_.detail.id};N.value={customerId:_.detail.id},"vietnam"==_.paramsType&&(e={agentId:_.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 F.getVietnamPoints(e);if(o.code==E.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||j("Ib.Custom.GetDataFailed"),icon:"none"})}catch(o){K.value=[],f({title:j("Ib.Custom.GetDataFailed"),icon:"none"})}},$=async()=>{try{let e=await F.customerSubsList({ibStatus:1});e.code==E.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=[]}},z=async e=>{e?(B.value=!0,await X({customId:e}),B.value=!1):K.value=[]},H=()=>{N.value={customerId:""},K.value=[],P("close")},W=async()=>{let e,o;if("vietnam"!==_.paramsType)if(_.isFormApplyIb){if(!N.value.customerId)return void f({title:j("placeholder.choose"),icon:"none"});const t=R.value.find((e=>e.value===N.value.customerId));if(!t)return void f({title:j("Ib.Custom.CustomerNotFound"),icon:"none"});e=t.value,o=t.cId}else{if(!_.detail.id)return void f({title:j("Ib.Custom.CustomerNotExist"),icon:"none"});const t=_.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"===_.paramsType&&(a={agentId:_.detail.id,points:t});const s="vietnam"===_.paramsType?await F.saveVietnamPoints(a):await F.agentApplyAddPoint(a);s.code==E.StatusOK?(f({title:s.msg||_.paramsType?j("Ib.Custom.SaveSuccess"):j("Ib.Custom.SubmitSuccess"),icon:"success"}),H(),P("confirm")):f({title:s.msg||_.paramsType?j("Ib.Custom.SaveFailed"):j("Ib.Custom.SubmitFailed"),icon:"none"})}catch(t){console.error("新增代理失败或保存越南分配数据失败:",t),f({title:_.paramsType?j("Ib.Custom.SaveFailed"):j("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),F=n(i("cwg-popup"),k);return r(),c(F,{title:d(j)(e.title),visible:e.visible,onClose:H,onConfirm:W,width:"900px"},{default:p((()=>[u(x,{class:"dia-content"},{default:p((()=>[u(O,{ref_key:"formRef",ref:M,labelWidth:"200"},{default:p((()=>[e.isFormApplyIb?(r(),c(s,{key:0,label:d(j)("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(j)("placeholder.choose"),onChange:z,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(j)("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(j)("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(j)("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(j)("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(j)("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(j)("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{_ as A};