import{d as L,r as c,w as z,ai as i,o as x,c as O,U as l,u as a,O as s,a as n,S as d,P as S,V as k,M as P,R as $,aF as A,aG as J}from"./vue.adf17aba.js";import K from"./select-tmpl.1269a265.js";import{c as Q}from"./index.fdb4f26c.js";import{u as W}from"./common.89e0f16e.js";import X from"./freq-setting.ecd99b01.js";import Z from"./save-rule-dialog.e22020b1.js";import{E as T}from"./elementPlus.4833989a.js";import{_ as ee}from"./_plugin-vue_export-helper.c27b6911.js";import"./api.ecc2e6e0.js";import"./index.ad3efb29.js";import"./echarts.72dc8373.js";import"./api.39068aff.js";import"./index.ec96ead5.js";import"./enum.cd3ef671.js";const g=r=>(A("data-v-73ed07e1"),r=r(),J(),r),te={class:"mx-5"},ae=g(()=>n("div",{class:"asj-h2"},"开启/暂停广告活动",-1)),oe=g(()=>n("div",{class:"asj-h3"},[n("span",{class:"custom-title-icon"}),d(" 操作 ")],-1)),le={style:{display:"block",margin:"10px 0"}},se=g(()=>n("span",{style:{"font-size":"12px"}},"请至少选择一种操作",-1)),ie={class:"auto-page-foot"},ne=L({__name:"switch-campaign",props:{data:{},RuleStatusButton:{}},emits:["refresh","updateRuleStatusButton"],setup(r,{emit:V}){const C=r,m=V,p=c(),f=c(),{formData:e,submitFormData:R}=W(C);e.value.rule.action.state=[],e.value.rule.action.setTime="";const _=c(!1);c(!1);const B=[{label:"曝光量",value:"impressions"},{label:"点击量",value:"clicks"},{label:"转化率",value:"cr",suffix:"%"},{label:"单次点击费用",value:"cpc",prefix:"$"}],H=new Date;function M(o){return o<new Date().setHours(0,0,0,0)}const Y=()=>{const o=[];for(let t=0;t<24;t++)new Date().getHours()<=t||o.push(t);return o},F=()=>{const o=[];for(let t=0;t<60;t++)new Date().getMinutes()<=t||o.push(t);return o};function I(){e.value.rule.conditions.length===0&&f.value.addConditionGroup()}async function N(){const o=await f.value.validate();return console.log("=>(switch-campaign.vue:77) validList",o),!o.includes(!1)}async function w(){await R(),T.success("保存成功"),m("refresh")}function U(){m("refresh")}async function E(){const o=await N();p.value.validate(async t=>{const v=e.value.rule.action.state;if(!t||v.includes("paused")&&!o||e.value.rule.action.state.length===0)return;if(new Date(e.value.rule.action.setTime).setSeconds(0,0)<new Date().setSeconds(0,0)){T.error("保存失败，请重新选择时间");return}try{e.value.useTmpl?await w():_.value=!0}catch(h){console.error("提交失败:",h)}})}return z(()=>e.value,o=>{m("updateRuleStatusButton",o.RuleStatusButton)}),(o,t)=>{const v=i("el-divider"),b=i("el-checkbox"),h=i("el-date-picker"),y=i("el-form-item"),j=i("el-checkbox-group"),q=i("el-form"),G=i("el-card"),D=i("el-button");return x(),O("div",te,[ae,l(K,{data:a(e)},null,8,["data"]),l(G,{class:"mt-3"},{default:s(()=>[l(X,{disabled:a(e).useTmpl,rule:a(e).rule},null,8,["disabled","rule"]),l(v),l(q,{ref_key:"formRef",ref:p,disabled:a(e).useTmpl,model:a(e),"label-position":"top",style:{"margin-top":"20px"}},{default:s(()=>[oe,l(j,{modelValue:a(e).rule.action.state,"onUpdate:modelValue":t[1]||(t[1]=u=>a(e).rule.action.state=u),disabled:a(e).useTmpl},{default:s(()=>[n("div",null,[l(b,{label:"enabled"},{default:s(()=>[d("开始")]),_:1}),S(n("div",le,[l(y,{rules:[{required:a(e).rule.action.state.includes("enabled"),message:"必填项",trigger:"blur"}],prop:"rule.action.setTime"},{default:s(()=>[l(h,{modelValue:a(e).rule.action.setTime,"onUpdate:modelValue":t[0]||(t[0]=u=>a(e).rule.action.setTime=u),"default-time":a(H),"disabled-date":M,"disabled-hours":Y,"disabled-minutes":F,format:"YYYY-MM-DD HH:mm","time-format":"HH:mm",type:"datetime","value-format":"YYYY-MM-DD HH:mm"},null,8,["modelValue","default-time"])]),_:1},8,["rules"])],512),[[k,a(e).rule.action.state.includes("enabled")]])]),l(b,{label:"paused",onClick:I},{default:s(()=>[d("暂停")]),_:1})]),_:1},8,["modelValue","disabled"]),a(e).rule.action.state.length===0?(x(),P(y,{key:0,style:{color:"red"}},{default:s(()=>[se]),_:1})):$("",!0)]),_:1},8,["disabled","model"]),S(n("div",null,[l(Q,{ref_key:"condiBuilderRef",ref:f,"candidate-fields":B,data:a(e).rule.conditions,disabled:a(e).useTmpl},null,8,["data","disabled"])],512),[[k,a(e).rule.action.state.includes("paused")]])]),_:1}),l(Z,{modelValue:_.value,"onUpdate:modelValue":t[2]||(t[2]=u=>_.value=u),formData:a(e),formRef:p.value,onSubmit:w},null,8,["modelValue","formData","formRef"]),n("div",ie,[l(D,{style:{width:"200px"},onClick:U},{default:s(()=>[d("取消")]),_:1}),l(D,{style:{width:"200px"},type:"primary",onClick:E},{default:s(()=>[d("提交")]),_:1})])])}}});const De=ee(ne,[["__scopeId","data-v-73ed07e1"]]);export{De as default};
