import{g as O,p as T,U as W,d as Z}from"./api.2785c8dc.js";import{g as q,p as J,E as d}from"./elementPlus.4833989a.js";/* empty css                   */import{d as Q,B as X,r as c,Z as Y,j as ee,ai as i,o as C,M as te,O as o,a as y,U as a,u as x,S as u,K as oe,am as ae,c as K,F as I,aF as ne,aG as le}from"./vue.adf17aba.js";import{_ as re}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.ad3efb29.js";import"./echarts.72dc8373.js";const ie=g=>(ne("data-v-2e588893"),g=g(),le(),g),se=ie(()=>y("div",{class:"my-4 mx-1.5",style:{"font-size":"18px","font-weight":"bold",color:"#464646"}},"谷歌关键词添加",-1)),de={class:"mx-2"},ce={class:"input-container"},ue={class:"button-group"},pe=Q({__name:"createKeyword",emits:["updateKeyword"],setup(g,{emit:F}){const $=F,_=X("refreshView"),p=c(""),w=c(!1),v=c(!1),k=c(!1),b=c([]),m=c(),n=Y({border:"inner",keepSource:!0,loading:!1,height:555,columnConfig:{resizable:!0},rowConfig:{isHover:!0,height:38},editConfig:{trigger:"manual",showIcon:!1,autoClear:!1},pagerConfig:{enabled:!0,total:20,currentPage:1,pageSize:20,pageSizes:[10,20,30]},columns:[{field:"keyword",title:"关键词",editRender:{name:"input"},slots:{edit:"keyword_edit"}},{field:"insert_time",title:"添加时间"},{title:"操作",width:120,slots:{default:"operate"},align:"center"}],data:[]}),B={pageChange({currentPage:e,pageSize:t}){n.pagerConfig&&(n.pagerConfig.currentPage=e,n.pagerConfig.pageSize=t),h()}},U=e=>{const t=m.value;return t?t.isEditByRow(e):!1};function R(e){v.value=!1,k.value=!0;const t=m.value;t&&(t.setEditRow(e),e.original_keyword=e.keyword)}function A({row:e}){k.value=!1,!v.value&&e.original_keyword!==e.keyword&&z(e)}async function h(){n.loading=!0;try{const e=await O({page:n.pagerConfig.currentPage,limit:n.pagerConfig.pageSize});n.data=e.data,b.value=e.data.map(t=>t.keyword),$("updateKeyword",b.value),n.pagerConfig.total=e.total,n.loading=!1}catch(e){console.log(e)}}async function P(){const e=p.value.trim();if(!e)return;const t=e.split(`
`).map(r=>r.trim()).filter(r=>r.length>0);try{w.value=!0,(await T({keyword:t.join(",")})).code===2e3&&(d.success("关键词添加成功"),p.value="",_&&_())}catch{d.error("添加关键词失败，请重试！")}finally{w.value=!1}}async function z(e){try{n.loading=!0,(await W({id:e.id,new_keyword:e.keyword})).code===2e3&&(await h(),d.success("关键词更新成功"))}catch{d.error("更新关键词失败，请重试！")}finally{n.loading=!1}}function j(e){v.value=!0;const t=m.value;t&&t.clearEdit().then(()=>{t.revertData(e)})}async function G(e){try{n.loading=!0,(await Z({keyword:e.keyword})).code===2e3&&(d.success("关键词删除成功"),_&&_())}catch{d.error("删除关键词失败，请重试！")}finally{n.loading=!1}}function L(){p.value=""}const M=()=>({fontSize:"13px",fontWeight:"500"}),N=()=>({fontSize:"13px",backgroundColor:"#f0f1f3",height:10});return ee(()=>{h()}),(e,t)=>{const r=i("el-input"),s=i("el-button"),E=i("el-popconfirm"),S=i("el-col"),D=i("vxe-grid"),V=i("el-card"),H=i("el-row");return C(),te(V,{class:"mx-2 my-5"},{default:o(()=>[se,y("div",de,[a(H,{gutter:20},{default:o(()=>[a(S,{span:8,class:"input-section"},{default:o(()=>[y("div",ce,[a(r,{modelValue:p.value,"onUpdate:modelValue":t[0]||(t[0]=l=>p.value=l),rows:26,class:"textarea",placeholder:"添加谷歌趋势关键词，一行一个关键词......（关键词添加上限200个）",type:"textarea"},null,8,["modelValue"]),y("div",ue,[a(E,{icon:e.InfoFilled,"icon-color":"#626AEF",title:"确认清空关键词？",width:"220",onConfirm:L},{reference:o(()=>[a(s,{icon:x(q),bg:"",size:"small",text:"",type:"danger"},{default:o(()=>[u("清空")]),_:1},8,["icon"])]),_:1},8,["icon"]),a(s,{icon:x(J),loading:w.value,bg:"",size:"small",text:"",type:"primary",onClick:P},{default:o(()=>[u("添加 ")]),_:1},8,["icon","loading"])])])]),_:1}),a(S,{span:16},{default:o(()=>[a(V,{"body-style":"padding: 0",shadow:"never"},{default:o(()=>[a(D,oe({ref_key:"xGrid",ref:m,"cell-style":M,"header-cell-style":N,"show-overflow":""},x(n),ae(B),{onEditClosed:A}),{operate:o(({row:l})=>[U(l)?(C(),K(I,{key:0},[a(s,{link:"",size:"small",onClick:f=>j(l)},{default:o(()=>[u("取消")]),_:2},1032,["onClick"]),a(s,{link:"",size:"small",type:"warning",onClick:f=>z(l)},{default:o(()=>[u("保存")]),_:2},1032,["onClick"])],64)):(C(),K(I,{key:1},[a(s,{link:"",size:"small",type:"primary",onClick:f=>R(l)},{default:o(()=>[u("编辑")]),_:2},1032,["onClick"]),a(E,{icon:e.InfoFilled,"icon-color":"#626AEF",title:"确认删除关键词？",width:"220",onConfirm:f=>G(l)},{reference:o(()=>[a(s,{disabled:k.value,link:"",size:"small",type:"danger"},{default:o(()=>[u("删除")]),_:1},8,["disabled"])]),_:2},1032,["icon","onConfirm"])],64))]),keyword_edit:o(({row:l})=>[a(r,{modelValue:l.keyword,"onUpdate:modelValue":f=>l.keyword=f},null,8,["modelValue","onUpdate:modelValue"])]),_:1},16)]),_:1})]),_:1})]),_:1})])]),_:1})}}});const ke=re(pe,[["__scopeId","data-v-2e588893"]]);export{ke as default};
