CategorySearch.0b1d7021.js 6.8 KB

1
  1. import{f as fe,ak as ge,r as n,Q as I,d as _e,a7 as i,af as ve,h as c,i as f,H as N,M as a,G as s,j as r,L as P,J as G,K as p,u as T,F as M,$ as he,E as ye,ap as be,aq as Ce}from"./vue.9083513e.js";import{u as Ve,r as O}from"./index.136f97e1.js";import{e as we}from"./emitter.f2f0d2a8.js";import{a as xe}from"./elementPlus.97569cdd.js";import{_ as ke}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.594b4072.js";const v=h=>(be("data-v-4d738e3b"),h=h(),Ce(),h),Se={class:"custom-tree-node"},Re={style:{width:"75%"}},De={key:0,style:{color:"rgb(50, 108, 216)"}},Ie=["onClick"],Pe=["onClick"],Te={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)),Le=v(()=>r("span",{style:{"margin-right":"10px",color:"#616266","font-weight":"500"}},"价格范围",-1)),Ue=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"}},$e={key:0},je={class:"dialog-footer"},Ne=fe({__name:"CategorySearch",emits:["add-to-table","form-submitted","remove-from-table"],setup(h,{emit:q}){const A=Ve(),{profile:V}=ge(A),w=n(!1),g=n(!1),x=n(!1),k=n([]);let H=n([]);const J={children:"ch",label:"cna"},_=n(!1);let S=n(""),y=n(""),u=n([]),b=n(0),R=n("");const K=I({0:"0",1:"1",2:"2",3:"3",4:"4",5:"5"}),t=I({prices:{lowest:void 0,highest:void 0},starRating:[0,5],dialogselectValue:[],delivery:"all",isCount:!1}),F=n(),Q=I({prices:[{validator:z,trigger:"blur"}]});async function z(o,e){return e.highest!==""&&e.lowest!==""&&e.highest<=e.lowest?Promise.reject("最高价格必须大于最低价格"):Promise.resolve()}async function W(){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 X(o){const e=t.dialogOptions.find(d=>d.value===o);e?R.value=e.label:R.value=""}function L(){t.prices.lowest=void 0,t.prices.highest=void 0,t.starRating=[0,5],t.dialogselectValue=[],t.delivery="all",t.isCount=!1}function Y(){b.value++,L(),t.isCount=!1,u.value=[],g.value=!1}async function Z(o){try{const e=await O({url:"/api/ad_manage/products/count/",method:"POST",data:{profile_id:V.value.profile_id,category_id:y.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,Z(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:y.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,y.value=o.cid,le.value.push(o),_.value=!0,x.value=!0,te()}const U=q;function ae(o,e){H.value.some(d=>d.cid===e.cid),U("add-to-table",e)}async function se(){if(!await F.value.validate()){console.log("表单数据验证失败");return}const e={dialogTitle:S.value,cid:y.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};U("form-submitted",e),_.value=!1,L()}return _e(()=>{we.on("get-category-tree-data",()=>{k.value.length==0&&W()})}),(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"),$=ve("loading");return c(),f(M,null,[N((c(),f("div",null,[a(ne,{height:"525px"},{default:s(()=>[a(d,{data:k.value,props:J,"expand-on-click-node":!1},{default:s(({node:l,data:m})=>[r("span",Se,[r("span",Re,P(l.label),1),m.ta==!0?(c(),f("span",De,[r("a",{onClick:j=>oe(m)}," 细化 ",8,Ie),r("a",{style:{"margin-left":"8px"},onClick:j=>ae(l,m)}," 添加 ",8,Pe)])):G("",!0)])]),_:1},8,["data"])]),_:1})])),[[$,w.value]]),a(me,{modelValue:_.value,"onUpdate:modelValue":e[7]||(e[7]=l=>_.value=l),title:`细化分类: ${T(S)}`,onClose:Y,"destroy-on-close":""},{footer:s(()=>{var l,m;return[r("div",Ee,[N((c(),f("span",null,[p(" 定位到的商品数量: "),t.isCount==!0?(c(),f("span",$e,P((l=T(u)[0])==null?void 0:l.min)+" - "+P((m=T(u)[0])==null?void 0:m.max),1)):G("",!0)])),[[$,g.value]]),r("span",je,[a(E,{onClick:e[6]||(e[6]=j=>_.value=!1)},{default:s(()=>[p("取消")]),_:1}),a(E,{type:"primary",onClick:se},{default:s(()=>[p("确定")]),_:1})])])]}),default:s(()=>[r("div",Te,[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:Q,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:X,placeholder:"请选择",loading:x.value},{default:s(()=>[(c(!0),f(M,null,he(t.dialogOptions,l=>(c(),ye(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(()=>[Le,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(()=>[Ue,a(ue,{modelValue:t.starRating,"onUpdate:modelValue":e[4]||(e[4]=l=>t.starRating=l),range:"","show-stops":"",max:5,marks:K,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 Ke=ke(Ne,[["__scopeId","data-v-4d738e3b"]]);export{Ke as default};