import{E as e,r as a,B as t,C as l,A as o,v as i,D as s,j as r,i as n,o as p,k as u,l as c}from"../element-plus/element-plus.DqqeXZzT.js";import{S as d}from"../_select/_select.DVQW4rAo.js";import{_ as v}from"../_popconfirm/_popconfirm.C2WlUwAw.js";import{p as m,T as f}from"../tableInfo/tableInfo.DCb2GEsc.js";import{I as y}from"../_input/_input.DPT4C86A.js";import{A as g}from"../api/api.BtQEnbVN.js";import{r as _,Y as h,d as j,E as x,w,L as b,o as k,c as I,a as M,T as R,u as C,S as z,Q as L,K as D,J as T,R as E,ba as V,b8 as N,U as S,a9 as U,M as A,ae as O,n as q,i as P,O as W,h as F}from"../@vue/@vue.lccsL1Mu.js";import{h as B,_ as $}from"../../assets/index-DYMYfyXS.js";import{t as J}from"../await-to-js/await-to-js.BuwTFY8y.js";import{t as H}from"../eventModel/eventModel.ekFf8kiN.js";import{_ as K}from"../lodash/lodash.S3QqMfIB.js";import{s as Q}from"../@element-plus/@element-plus.BWbqilIf.js";import{b as Y,u as G}from"../vue-router/vue-router.D86bYXwF.js";import"../lodash-es/lodash-es.LxYfApIs.js";import"../async-validator/async-validator.DSgsWN2H.js";import"../@vueuse/@vueuse.D2YafqsA.js";import"../dayjs/dayjs.D4rZQhfm.js";import"../axios/axios.CUN3se9v.js";import"../@ctrl/@ctrl.D2oWfImC.js";import"../@popperjs/@popperjs.D3lHDW-0.js";import"../escape-html/escape-html.J6B7JOz4.js";import"../normalize-wheel-es/normalize-wheel-es.Erkn7R64.js";import"../caret-top/caret-top.BxG-YGIs.js";import"../question-filled/question-filled.CpBGPdbF.js";import"../pinia/pinia.DodrAXQg.js";import"../vue-demi/vue-demi.Dq6ymT-8.js";import"../pinia-plugin-persist/pinia-plugin-persist.Cjrd7Wf_.js";import"../echarts/echarts.C_nC9ACL.js";import"../tslib/tslib.DduEQve-.js";import"../zrender/zrender.XYf_pgl8.js";const X=()=>{const a=_(),t=_(),l=h({list:[{id:"part",name:"部分导入"},{id:"all",name:"全部导入"}],type:"part"}),o=h({list:[{id:1,name:"手动输入"},{id:2,name:"手动选择"}],type:1}),i=h({list:[],active:""}),s=h({list:[],active:""});return{projectIdRef:t,ownerIdRef:a,importType:l,handType:o,userList:i,projectList:s,getProjectList:async()=>{const a=g.project_list,[t,l]=await J(B.get(a,{}));if(t||"0"!==l?.errNo)return e.error(t?.message||l?.errMsg||"操作失败");s.list=[...l?.rst]},getUserList:async()=>{const a=g.user_list,[t,l]=await J(B.get(a,{}));if(t||"0"!==l?.errNo)return e.error(t?.message||l?.errMsg||"操作失败");i.list=[...l?.rst]}}};const Z={class:"tMar15"},ee={class:"flex"},ae={key:0,class:"flex_1 flex"},te={class:"f12 c-555"},le={class:"flex_center tMar10 bMar10"},oe=j({__name:"childList",props:{agencyItem:{type:Object,default:()=>{}},importType:{type:String,default:""},handType:{type:Number,default:0}},emits:["total"],setup(s,{expose:r,emit:n}){const p=s,u=_(!1),c=_(""),d=_([]),v=_([]),m=_([]),f=_([]),y=_(!1),g=_(),j=_(0),V=h({page:1,pageSize:20,total:0}),N=(e,a)=>{f.value=e},S=()=>{f.value=[],g.value?.clearSelection()},U=()=>{let e=K.cloneDeep(d.value);isNaN(Number(c.value))?v.value=e.filter((e=>-1!=e.corporation_name?.indexOf(c.value))):v.value=e.filter((e=>-1!=e.account_id?.indexOf(c.value))),V.total=v.value.length,V.page=1,A()},A=()=>{const e=K.cloneDeep(v.value);m.value=e.slice((V.page-1)*V.pageSize,V.page*V.pageSize)},O=e=>{V.page=1,V.pageSize=e,A()},q=e=>{V.page=e,A()},P=()=>{var a;p.agencyItem?.agency_account_id&&(u.value=!0,(a={agency_account_id:p.agencyItem?.agency_account_id,keyword:c.value},new Promise((async(t,l)=>{const o=await B.get("/api/account/agentChildList",a);0==o.errNo?t(o.rst):(e.error(o.errMsg),l())}))).then((e=>{u.value=!1,d.value=e.list,v.value=K.cloneDeep(d.value),V.total=e.total,j.value=e.total,n("total",j.value),A()})).catch((()=>{u.value=!1})))};x((()=>{P()}));return r({getMultipleList:()=>new Promise(((e,a)=>{y.value?e(f.value):e(d.value)}))}),w([()=>p.importType,()=>p.handType],((e,a)=>{"part"==e[0]&&2==e[1]?(y.value=!0,f.value=[]):y.value=!1}),{immediate:!0}),(e,s)=>{const r=a,n=t,p=l,d=o,v=i;return b((k(),I("div",Z,[M("div",ee,[R(r,{modelValue:c.value,"onUpdate:modelValue":s[0]||(s[0]=e=>c.value=e),style:{width:"300px"},placeholder:"请输入搜索关键词","prefix-icon":C(Q),size:"default",clearable:"",onInput:s[1]||(s[1]=e=>U()),onClear:s[2]||(s[2]=e=>U())},null,8,["modelValue","prefix-icon"]),y.value?(k(),I("div",ae,[M("p",te,"(已选 "+z(f.value.length)+" 个媒体账户)",1),M("span",{class:"f13 pointer c-theme",onClick:S},"清空选择")])):L("",!0)]),R(p,{ref_key:"multipleTableRef",ref:g,data:m.value,style:{width:"100%"},"row-key":"account_id",class:"tMar15",height:"36vh","header-cell-style":C(H),onSelectionChange:N,border:""},{default:D((()=>[y.value?(k(),T(n,{key:0,"reserve-selection":"",type:"selection",width:"55",align:"center"})):(k(),T(n,{key:1,label:"序号",width:"80",align:"center"},{default:D((e=>[E(z(e.$index+1+(V.page-1)*V.pageSize),1)])),_:1})),R(n,{prop:"corporation_name",label:"账户名称"}),R(n,{prop:"account_id",label:"账户ID"})])),_:1},8,["data","header-cell-style"]),M("div",le,[R(d,{"current-page":V.page,"onUpdate:current-page":s[3]||(s[3]=e=>V.page=e),"page-size":V.pageSize,"onUpdate:page-size":s[4]||(s[4]=e=>V.pageSize=e),"page-sizes":[10,20,50,100],small:!0,layout:"total, sizes, prev, pager, next, jumper",total:V.total,onSizeChange:O,onCurrentChange:q},null,8,["current-page","page-size","total"])])])),[[v,u.value]])}}}),ie={class:"tMar20 textBox"},se={class:"flex_between titleBox"},re=(e=>(V("data-v-08106c32"),e=e(),N(),e))((()=>M("div",{class:"tips"},"请输入广告主账户ID,多账户请换行(即每个账户ID一行)",-1))),ne=$(j({__name:"manualInput",props:{maxRow:{type:Number,default:300}},emits:["mInput"],setup(e,{emit:t}){const l=e,o=_(""),i=()=>{let e=0;return o.value?.split("\n").forEach((a=>{""!==a&&e++})),e};return w((()=>o.value),((e,a)=>{i()>l.maxRow&&(o.value=a)}),{immediate:!0}),(l,s)=>{const r=a;return k(),I("div",ie,[M("div",se,[M("div",null,"请输入广告主账户ID("+z(i())+" / "+z(e.maxRow)+" )",1),M("div",{class:"c-theme pointer",onClick:s[0]||(s[0]=e=>o.value="")},"清空")]),re,R(r,{id:"emojiInput",modelValue:o.value,"onUpdate:modelValue":s[1]||(s[1]=e=>o.value=e),resize:"none",rows:12,type:"textarea",style:{width:"100%"},onInput:s[2]||(s[2]=e=>t("mInput",o.value))},null,8,["modelValue"])])}}}),[["__scopeId","data-v-08106c32"]]),pe={class:"container"},ue={class:"flex_start c-aaa line18 tMar10"},ce={key:0,class:"flex_1"},de={key:1,class:"flex_1"},ve={key:2,class:"flex_1"},me={class:"flex tMar15"},fe={class:"dialog-footer",style:{"text-align":"right",padding:"10px","padding-top":"0"}},ye=E(" 取 消 "),ge=E(" 确 认 "),_e=$(j({__name:"importDialog",emits:["close"],setup(a,{expose:t,emit:l}){const o=_(!1),v=_(""),m=_(""),f=_(!1),y=_(0),g=_(),{ownerIdRef:h,projectIdRef:j,importType:w,handType:V,userList:N,projectList:q,getUserList:P,getProjectList:W}=X();x((()=>{P(),W()}));const F=()=>{f.value=!1},$=e=>{y.value=e},J=e=>{m.value=e},H=async()=>{if(""==h.value?.value||!h.value?.value)return void e.warning("请选择所属人员");let a="";var t;("part"==w.type&&1==V.type?a=m.value:g.value&&await g.value.getMultipleList().then((e=>{a=JSON.stringify(e)})),""!=a)?(o.value=!0,(t={agency_account_id:v.value.agency_account_id,import_method:w.type,type:V.type,data_str:a,owner_id:h.value?.value,project_id:j.value?.value},new Promise((async(a,l)=>{const o=await B.post("/api/account/imAdd",t);0==o.errNo?a(o.rst):(e.error(o.errMsg),l())}))).then((a=>{o.value=!1,a&&(e.warning("导入成功"),f.value=!1,l("close"))})).catch((()=>{o.value=!1}))):e.warning("请输入账户ID或手动选择媒体账户!")};return t({initFun:async(e,a)=>{f.value=e,e&&(console.log(a),v.value=a)}}),(e,a)=>{const t=s,l=r,m=n,_=O("WarningFilled"),x=p,P=u,W=c,B=i;return k(),T(W,{class:"gdt-dialog","close-on-click-modal":!1,"destroy-on-close":!0,modelValue:f.value,"onUpdate:modelValue":a[2]||(a[2]=e=>f.value=e),title:"导入媒体账户",width:"800px",top:"40px","before-close":F},{footer:D((()=>[M("div",fe,[R(P,{size:"default",onClick:F},{default:D((()=>[ye])),_:1}),R(P,{size:"default",type:"primary",onClick:H},{default:D((()=>[ge])),_:1})])])),default:D((()=>[b((k(),I("div",pe,[R(l,{modelValue:C(w).type,"onUpdate:modelValue":a[0]||(a[0]=e=>C(w).type=e),size:"default",class:"block tMar20"},{default:D((()=>[(k(!0),I(S,null,U(C(w).list,(e=>(k(),T(t,{label:e.id},{default:D((()=>[E(z(e.name),1)])),_:2},1032,["label"])))),256))])),_:1},8,["modelValue"]),"part"==C(w).type?(k(),T(l,{key:0,modelValue:C(V).type,"onUpdate:modelValue":a[1]||(a[1]=e=>C(V).type=e),size:"default",class:"block tMar10"},{default:D((()=>[(k(!0),I(S,null,U(C(V).list,(e=>(k(),T(m,{label:e.id},{default:D((()=>[E(z(e.name),1)])),_:2},1032,["label"])))),256))])),_:1},8,["modelValue"])):L("",!0),M("div",ue,[R(x,{class:"rMar7 tMar2",color:"#ff9b48"},{default:D((()=>[R(_)])),_:1}),"part"==C(w).type&&1==C(V).type?(k(),I("span",ce,"请确保输入的广告主账户已属于对应的代理商,否则会导致失败;单次授权账户上限"+z(300)+"个,如账户数量较多,请分批次输入")):L("",!0),"part"==C(w).type&&2==C(V).type?(k(),I("span",de,"该代理商账户下共"+z(y.value)+"个媒体账户,请选择想要导入的账户名称",1)):L("",!0),"all"==C(w).type?(k(),I("span",ve,"该代理商账户下共"+z(y.value)+"个媒体账户",1)):L("",!0)]),M("div",me,[R(d,{ref_key:"ownerIdRef",ref:h,title:"所属人员",selectWidth:"160px",haveTag:!0,optObj:{k:"id",la:"username",val:"id"},options:C(N).list},null,8,["options"]),R(d,{ref_key:"projectIdRef",ref:j,title:"所属项目",selectWidth:"160px",optObj:{k:"id",la:"name",val:"id"},options:C(q).list},null,8,["options"])]),b(R(ne,{maxRow:300,onMInput:J},null,512),[[A,"part"==C(w).type&&1==C(V).type]]),b(R(oe,{ref_key:"ChildListRef",ref:g,agencyItem:v.value,importType:C(w).type,handType:C(V).type,onTotal:$},null,8,["agencyItem","importType","handType"]),[[A,"part"==C(w).type&&2==C(V).type||"all"==C(w).type]])])),[[B,o.value]])])),_:1},8,["modelValue"])}}}),[["__scopeId","data-v-84318d84"]]),he={class:"container"},je={class:"dialog-footer",style:{"text-align":"right",padding:"10px","padding-top":"0"}},xe=E(" 取 消 "),we=E(" 确 认 "),be=$(j({__name:"editDialog",emits:["close"],setup(a,{expose:t,emit:l}){const o=_(!1),s=_(!1),r=_(""),{ownerIdRef:n,projectIdRef:p,userList:v,projectList:m,getUserList:f,getProjectList:y}=X(),g=()=>{s.value=!1},h=()=>{var a;""!=r.value&&r.value?""!=n.value?.value&&n.value?.value?(o.value=!0,(a={account_id:r.value,owner_id:n.value?.value,project_id:p.value?.value},new Promise((async(t,l)=>{const o=await B.post("/api/account/setParam",a);0==o.errNo?t(o.rst):(e.error(o.errMsg),l())}))).then((a=>{o.value=!1,a&&(e.warning("编辑成功"),s.value=!1,l("close"))})).catch((()=>{o.value=!1}))):e.warning("请选择所属人员"):e.warning("获取账户ID失败")};x((()=>{f(),y()}));return t({initFun:async(e,a)=>{s.value=e,e&&(r.value=a.account_id,q((()=>{n.value&&a.owner_id&&(n.value.value=a.owner_id),p.value&&a.project_id&&(p.value.value=a.project_id)})))}}),(e,a)=>{const t=u,l=c,f=i;return k(),T(l,{class:"gdt-dialog","close-on-click-modal":!1,"destroy-on-close":!0,modelValue:s.value,"onUpdate:modelValue":a[0]||(a[0]=e=>s.value=e),title:`账户编辑(${r.value})`,width:"440px","before-close":g},{footer:D((()=>[M("div",je,[R(t,{size:"default",onClick:g},{default:D((()=>[xe])),_:1}),R(t,{size:"default",type:"primary",onClick:h},{default:D((()=>[we])),_:1})])])),default:D((()=>[b((k(),I("div",he,[R(d,{ref_key:"ownerIdRef",ref:n,title:"所属人员",class:"block tMar20",selectWidth:"260px",haveTag:!0,optObj:{k:"id",la:"username",val:"id"},options:C(v).list},null,8,["options"]),R(d,{ref_key:"projectIdRef",ref:p,class:"block tMar20",title:"所属项目",selectWidth:"260px",optObj:{k:"id",la:"name",val:"id"},options:C(m).list},null,8,["options"])])),[[f,o.value]])])),_:1},8,["modelValue","title"])}}}),[["__scopeId","data-v-c765d806"]]),ke={class:"typeBorlineBox flex_between"},Ie={class:"flex",style:{"margin-left":"15px"}},Me=["onClick"],Re=(e=>(V("data-v-3062648f"),e=e(),N(),e))((()=>M("div",{class:"borLine"},null,-1))),Ce=E("账号授权"),ze={class:"screenBox flex",style:{padding:"15px"}},Le={class:"text-center"},De=["onClick"],Te=$(j({__name:"index",setup(a){const t=Y(),l=G(),{proxy:o}=F(),s=h({list:[{id:"ADVERTISER",name:"广告账号"},{id:"CUSTOMER_ADMIN",name:"纵横组织"},{id:"UNCLAIMED",name:"待认领账号"}],typeAc:"CUSTOMER_ADMIN"}),{EditDialogRef:r,ImpoartDialogRef:n,agencyEvent:p,agencyEditEvent:c}=(()=>{const a=_(),t=_();return{EditDialogRef:a,ImpoartDialogRef:t,agencyEvent:a=>{a?.agency_account_id?t.value&&t.value.initFun(!0,a):e.error("代理商获取失败,无法导入账户!")},agencyEditEvent:t=>{t?.account_id?a.value&&a.value.initFun(!0,t):e.error("账户获取失败,无法进行编辑!")}}})(),j=h([{name:"账号名称",column:"advertiser_name",minWidth:"120px"},{name:"账号ID",column:"advertiser_id",cancleForMat:!0},{name:"投手",column:"promoter"},{name:"创建时间",column:"created_at",minWidth:"100px"}]),{tableInfo:x,tableListRef:w,total:L}=m(j),T=h({createrList:[]}),E=_(!1),V=_(),N=_(),A=async(a,t)=>{w.value.loading=!0;const l=h({type:s.typeAc,keyword:V.value.value,promoter_id:N.value.value,page:a||1,page_size:t||20});let i=await o.$http.get(g.oe_ad_account,l);w.value.loading=!1,i&&"0"==i.errNo?(x.tableList=i.rst.data,L.value=i.rst.pageInfo.total):e.error(i.errMsg)},O=()=>{t.query?.account_id&&l.replace("/adqManage"),A(1)};return P((async()=>{t.query?.account_id&&c({account_id:t.query?.account_id}),await A(),await(async()=>{let a=await o.$http.get(g.account_list);a&&"0"==a.errNo?T.createrList=a.rst:e.error(a.errMsg)})()})),(a,t)=>{const l=u,p=i;return k(),I(S,null,[M("div",ke,[M("div",Ie,[(k(!0),I(S,null,U(s.list,(e=>(k(),I("div",{class:W(["item",e.id==s.typeAc?"itemAc":""]),key:e.id,onClick:a=>{return t=e,s.typeAc=t.id,void A(1);var t}},[M("div",null,z(e.name),1),Re],10,Me)))),128))]),R(l,{type:"primary",size:"default",class:"rMar15",onClick:t[0]||(t[0]=a=>(async()=>{E.value=!0;let a=await o.$http.get(g.oe_account_auth);E.value=!1,a&&"0"==a.errNo?window.open(a.rst,"_blank"):e.error(a.errMsg)})())},{default:D((()=>[Ce])),_:1})]),b((k(),I("div",ze,[R(y,{ref_key:"InputRef_text",ref:V,title:"关键词",placeholderTxt:"关键词",onChangeEvent:t[1]||(t[1]=e=>A()),onClearEvent:t[2]||(t[2]=e=>A())},null,512),R(d,{ref_key:"ideaManRef",ref:N,clearFlag:!0,title:"所属人员",selectWidth:"160px",optObj:{k:"id",la:"username",val:"id"},onChangeEvent:t[3]||(t[3]=e=>A()),onClearEvent:t[4]||(t[4]=e=>A()),options:T.createrList},null,8,["options"])])),[[p,E.value]]),R(f,{ref_key:"tableListRef",ref:w,tableData:C(x).tableList,immobilizationHeight:"calc(100vh - 260px)",descol:C(x).descolList,total:C(L),onInit:A},{operate:D((a=>[M("div",Le,[M("span",{class:"c-theme pointer f13",onClick:e=>C(c)(a.row)},"编辑",8,De),R(v,{onConfirm:t=>(async a=>{w.value.loading=!0;const t=h({account_id:a.account_id});let l=await o.$http.post(g.adq_dele,t);w.value.loading=!1,e.info(l.errMsg),l&&"0"==l.errNo&&await A()})(a.row)},null,8,["onConfirm"])])])),_:1},8,["tableData","descol","total"]),R(_e,{ref_key:"ImpoartDialogRef",ref:n,onClose:t[5]||(t[5]=e=>A(1))},null,512),R(be,{ref_key:"EditDialogRef",ref:r,onClose:O},null,512)],64)}}}),[["__scopeId","data-v-3062648f"]]);export{Te as default};