NegativeWord.9cd246d5.js 4.7 KB

1
  1. import{u as R}from"./index.34b03be2.js";import{d as z,ay as O,B as V,Z as y,r as b,ai as _,o as H,c as q,U as l,O as c,a as n,u,D as I,S as w,T as F,aF as K,aG as M}from"./vue.adf17aba.js";import{c as X}from"./index.852227ba.js";import{E as C}from"./elementPlus.4833989a.js";import{_ as Z}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.72dc8373.js";const W=x=>(K("data-v-83c0bc34"),x=x(),M(),x),J={style:{width:"100%","margin-top":"20px"}},Q=W(()=>n("span",{style:{"font-size":"18px","font-weight":"700"}},"否定词",-1)),Y={style:{width:"100%",height:"520px",display:"flex",border:"1px solid #e5e7ec","border-radius":"6px"}},$={style:{width:"50%","border-right":"1px solid #e5e7ec"}},ee={style:{margin:"10px 0"}},te=W(()=>n("span",{style:{"margin-left":"25px",color:"#e47470"}},"*",-1)),oe=W(()=>n("span",{style:{color:"#666666","margin-right":"10px"}},"匹配类型: ",-1)),se={style:{display:"flex","flex-direction":"row-reverse","margin-top":"10px"}},ae={style:{width:"50%"}},le={class:"card-header"},ne={style:{"font-weight":"550","font-size":"15px",color:"#1f2128"}},ie={class:"card-body"},re={style:{display:"flex","justify-content":"space-around"}},de=z({__name:"NegativeWord",setup(x){const k=R(),{profile:S}=O(k),T=V("respCampaignId"),L=V("respAdGroupId");y([]);let N=b(!1),s=y([]),p=b(""),h=b(!0),v=b(!0),m=y([]),f=y([]);function A(){p.value.trim().split(/,|\n/).forEach(t=>{const a=t.trim();if(a){let g="词组: "+a,o="精确: "+a;h.value&&!s.some(r=>r.negativeWords===g)&&(s.push({negativeWords:g}),f.push(a)),v.value&&!s.some(r=>r.negativeWords===o)&&(s.push({negativeWords:o}),m.push(a))}else console.log("有空项目,未被添加到列表中")}),p.value="",console.log("🚀 ~ exactNegativeList-->>",m),console.log("🚀 ~ phraseNegativeList-->>",f)}function E(){s.length=0,m.length=0,f.length=0}function D(i){const e=s.findIndex(t=>t.negativeWords===i.row.negativeWords);if(e!==-1){const t=i.row.negativeWords.startsWith("词组: "),a=i.row.negativeWords.startsWith("精确: ");s.length?(s.splice(e,1),console.log(`已删除索引为 ${e} 的条目`)):console.log("无效的索引,无法删除条目");const g=i.row.negativeWords.substring(4).trim();if(t){const o=f.findIndex(r=>r===g);o!==-1&&f.splice(o,1)}else if(a){const o=m.findIndex(r=>r===g);o!==-1&&m.splice(o,1)}}else console.log("无效的索引,无法删除条目")}async function G(){N.value=!0,console.log("negativeList",s),U()}async function U(){const i={profile_id:S.value.profile_id,campaignId:T.value,adGroupId:L.value,state:"PAUSED",EkeywordList:m,PkeywordList:f},e=Object.fromEntries(Object.entries(i).filter(([t,a])=>a!=null));try{const t=await X(e);console.log("🚀 ~ createCampaigns ~ response-->>",t),t.data.negativeKeyworderror.length!==0?(C({message:"否定词创建成功",type:"success"}),E()):C.error("否定词创建失败!")}catch(t){console.error("请求失败:",t)}finally{N.value=!1}}function j(i){if(i.rowIndex===0)return{color:"#505968"}}return(i,e)=>{const t=_("el-divider"),a=_("el-checkbox"),g=_("el-input"),o=_("el-button"),r=_("el-table-column"),B=_("el-table"),P=_("el-card");return H(),q("div",J,[l(t,{"content-position":"left"},{default:c(()=>[Q]),_:1}),n("div",Y,[n("div",$,[n("div",ee,[te,oe,l(a,{modelValue:u(h),"onUpdate:modelValue":e[0]||(e[0]=d=>I(h)?h.value=d:h=d),label:"词组否定"},null,8,["modelValue"]),l(a,{modelValue:u(v),"onUpdate:modelValue":e[1]||(e[1]=d=>I(v)?v.value=d:v=d),label:"精确否定"},null,8,["modelValue"])]),l(g,{modelValue:u(p),"onUpdate:modelValue":e[2]||(e[2]=d=>I(p)?p.value=d:p=d),rows:17,type:"textarea",placeholder:"请输入关键词,多个关键词使用逗号或者换行符分隔。(最多添加1000个关键词)",maxlength:"11000",style:{padding:"0 20px"}},null,8,["modelValue"]),n("div",se,[l(o,{style:{"margin-right":"18px"},type:"primary",text:"",bg:"",disabled:!u(p),onClick:A},{default:c(()=>[w("添加")]),_:1},8,["disabled"])])]),n("div",ae,[l(P,{class:"box-card",shadow:"never",style:{border:"none"}},{header:c(()=>[n("div",le,[n("span",ne,"已添加: "+F(u(s).length),1),l(o,{class:"button",type:"danger",text:"",bg:"",onClick:E},{default:c(()=>[w("全部删除")]),_:1})])]),default:c(()=>[n("div",ie,[l(B,{data:u(s),style:{width:"100%",height:"370px","padding-bottom":"0"},"header-row-style":j},{default:c(()=>[l(r,{prop:"negativeWords",label:"否定词",width:"auto"}),l(r,{prop:"operate",label:"操作",width:"60",align:"right"},{default:c(d=>[l(o,{type:"primary",size:"small",onClick:ce=>D(d),text:""},{default:c(()=>[w("删除")]),_:2},1032,["onClick"])]),_:1})]),_:1},8,["data"])])]),_:1}),n("div",re,[l(o,{type:"primary",plain:"",onClick:G,disabled:!u(s).length},{default:c(()=>[w("保存")]),_:1},8,["disabled"])])])])])}}});const he=Z(de,[["__scopeId","data-v-83c0bc34"]]);export{he as default};