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