import{d as fe,ay as ge,r as n,Z as P,j as _e,ai as i,aq as ve,o as c,c as f,P as $,U as a,O as s,a as r,T,R as G,S as p,u as I,F as M,a8 as ye,M as he,aF as be,aG as Ce}from"./vue.adf17aba.js";import{u as Ve,r as O}from"./index.34b03be2.js";import{e as we}from"./emitter.233282e9.js";import{E as xe}from"./elementPlus.4833989a.js";import{_ as ke}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.72dc8373.js";const v=y=>(be("data-v-4d738e3b"),y=y(),Ce(),y),Se={class:"custom-tree-node"},Re={style:{width:"75%"}},De={key:0,style:{color:"rgb(50, 108, 216)"}},Pe=["onClick"],Te=["onClick"],Ie={style:{display:"flex","justify-content":"space-between"}},Oe=v(()=>r("span",null,"根据特定品牌、价格范围、星级和Prime配送资格,细化分类",-1)),Fe=v(()=>r("span",{style:{"margin-right":"10px",color:"#616266","font-weight":"500"}},"品牌",-1)),Ue=v(()=>r("span",{style:{"margin-right":"10px",color:"#616266","font-weight":"500"}},"价格范围",-1)),Le=v(()=>r("span",{style:{"margin-right":"15px",color:"#616266","font-weight":"500"}},"查看星级评定",-1)),Be=v(()=>r("span",{style:{"margin-right":"10px",color:"#616266","font-weight":"500"}},"配送",-1)),Ee={style:{display:"flex","justify-content":"space-between"}},je={key:0},Ne={class:"dialog-footer"},$e=fe({__name:"CategorySearch",emits:["add-to-table","form-submitted","remove-from-table"],setup(y,{emit:q}){const A=Ve(),{profile:V}=ge(A),w=n(!1),g=n(!1),x=n(!1),k=n([]);let Z=n([]);const z={children:"ch",label:"cna"},_=n(!1);let S=n(""),h=n(""),u=n([]),b=n(0),R=n("");const H=P({0:"0",1:"1",2:"2",3:"3",4:"4",5:"5"}),t=P({prices:{lowest:void 0,highest:void 0},starRating:[0,5],dialogselectValue:[],delivery:"all",isCount:!1}),F=n(),J=P({prices:[{validator:K,trigger:"blur"}]});async function K(o,e){return e.highest!==""&&e.lowest!==""&&e.highest<=e.lowest?Promise.reject("最高价格必须大于最低价格"):Promise.resolve()}async function Q(){w.value=!0;try{const o=await O({url:"/api/ad_manage/targetable/categories/",method:"GET",params:{profile_id:V.value.profile_id}});k.value=o.data}catch(o){console.error("请求失败:",o),xe({message:o.message,type:"warning"})}finally{w.value=!1}}function W(o){const e=t.dialogOptions.find(d=>d.value===o);e?R.value=e.label:R.value=""}function U(){t.prices.lowest=void 0,t.prices.highest=void 0,t.starRating=[0,5],t.dialogselectValue=[],t.delivery="all",t.isCount=!1}function X(){b.value++,U(),t.isCount=!1,u.value=[],g.value=!1}async function Y(o){try{const e=await O({url:"/api/ad_manage/products/count/",method:"POST",data:{profile_id:V.value.profile_id,category_id:h.value}});o===b.value&&(u.value=e.data.AsinCounts)}catch(e){console.error("请求失败:",e)}finally{o===b.value&&(g.value=!1)}}function ee(){if(t.isCount){const o=b.value;g.value=!0,Y(o)}else g.value=!1,u.value=[]}async function te(){try{const e=(await O({url:"/api/ad_manage/categories/brands/",method:"GET",params:{profile_id:V.value.profile_id,category_id:h.value}})).data;t.dialogOptions=e.brands.map(d=>({label:d.name,value:d.id})),x.value=!1}catch(o){console.error("请求失败:",o)}}let le=n([]);function oe(o){u.value=[],S.value=o.cna,h.value=o.cid,le.value.push(o),_.value=!0,x.value=!0,te()}const L=q;function ae(o,e){Z.value.some(d=>d.cid===e.cid),L("add-to-table",e)}async function se(){if(!await F.value.validate()){console.log("表单数据验证失败");return}const e={dialogTitle:S.value,cid:h.value,prices:{lowest:t.prices.lowest,highest:t.prices.highest},starRating:t.starRating,selectedBrands:t.dialogselectValue,delivery:t.delivery,isCount:t.isCount,commodityCount:u.value,selectedLabels:R.value};L("form-submitted",e),_.value=!1,U()}return _e(()=>{we.on("get-category-tree-data",()=>{k.value.length==0&&Q()})}),(o,e)=>{const d=i("el-tree"),ne=i("el-scrollbar"),ie=i("el-checkbox"),re=i("el-option"),de=i("el-select"),C=i("el-form-item"),B=i("el-input-number"),ue=i("el-slider"),D=i("el-radio"),ce=i("el-radio-group"),pe=i("el-form"),E=i("el-button"),me=i("el-dialog"),j=ve("loading");return c(),f(M,null,[$((c(),f("div",null,[a(ne,{height:"525px"},{default:s(()=>[a(d,{data:k.value,props:z,"expand-on-click-node":!1},{default:s(({node:l,data:m})=>[r("span",Se,[r("span",Re,T(l.label),1),m.ta==!0?(c(),f("span",De,[r("a",{onClick:N=>oe(m)}," 细化 ",8,Pe),r("a",{style:{"margin-left":"8px"},onClick:N=>ae(l,m)}," 添加 ",8,Te)])):G("",!0)])]),_:1},8,["data"])]),_:1})])),[[j,w.value]]),a(me,{modelValue:_.value,"onUpdate:modelValue":e[7]||(e[7]=l=>_.value=l),title:`细化分类: ${I(S)}`,onClose:X,"destroy-on-close":""},{footer:s(()=>{var l,m;return[r("div",Ee,[$((c(),f("span",null,[p(" 定位到的商品数量: "),t.isCount==!0?(c(),f("span",je,T((l=I(u)[0])==null?void 0:l.min)+" - "+T((m=I(u)[0])==null?void 0:m.max),1)):G("",!0)])),[[j,g.value]]),r("span",Ne,[a(E,{onClick:e[6]||(e[6]=N=>_.value=!1)},{default:s(()=>[p("取消")]),_:1}),a(E,{type:"primary",onClick:se},{default:s(()=>[p("确定")]),_:1})])])]}),default:s(()=>[r("div",Ie,[Oe,r("span",null,[a(ie,{modelValue:t.isCount,"onUpdate:modelValue":e[0]||(e[0]=l=>t.isCount=l),label:"显示商品数量",onChange:ee},null,8,["modelValue"])])]),a(pe,{model:t,rules:J,ref_key:"dialogFormRef",ref:F,style:{"margin-top":"20px"}},{default:s(()=>[a(C,{style:{"padding-left":"140px"}},{default:s(()=>[Fe,a(de,{modelValue:t.dialogselectValue,"onUpdate:modelValue":e[1]||(e[1]=l=>t.dialogselectValue=l),onChange:W,placeholder:"请选择",loading:x.value},{default:s(()=>[(c(!0),f(M,null,ye(t.dialogOptions,l=>(c(),he(re,{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","loading"])]),_:1}),a(C,{prop:"prices",style:{"padding-left":"112px","margin-top":"10px"}},{default:s(()=>[Ue,a(B,{modelValue:t.prices.lowest,"onUpdate:modelValue":e[2]||(e[2]=l=>t.prices.lowest=l),min:1,controls:!1,placeholder:"无最低商品价格"},null,8,["modelValue"]),p(" -- "),a(B,{modelValue:t.prices.highest,"onUpdate:modelValue":e[3]||(e[3]=l=>t.prices.highest=l),min:1,controls:!1,placeholder:"无最高商品价格"},null,8,["modelValue"])]),_:1}),a(C,{prop:"starRating",style:{"padding-left":"85px","margin-top":"10px"}},{default:s(()=>[Le,a(ue,{modelValue:t.starRating,"onUpdate:modelValue":e[4]||(e[4]=l=>t.starRating=l),range:"","show-stops":"",max:5,marks:H,style:{width:"70%"}},null,8,["modelValue","marks"])]),_:1}),a(C,{prop:"delivery",style:{"padding-left":"140px","margin-top":"30px"}},{default:s(()=>[Be,a(ce,{modelValue:t.delivery,"onUpdate:modelValue":e[5]||(e[5]=l=>t.delivery=l)},{default:s(()=>[a(D,{label:"all",style:{"font-weight":"400"}},{default:s(()=>[p("所有")]),_:1}),a(D,{label:"eligible",style:{"font-weight":"400"}},{default:s(()=>[p("具备Prime资格")]),_:1}),a(D,{label:"diseligible",style:{"font-weight":"400"}},{default:s(()=>[p("不具备Prime资格")]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])],64)}}});const He=ke($e,[["__scopeId","data-v-4d738e3b"]]);export{He as default};