import{u as e,a,r as t,b as r,cK as l,d,e as o,f as s,h as i,w as m,g as u,j as p,k as n,i as f,n as c,E as b,q as _}from"./index.286e9b79.js";import{v as g}from"./loading.c49775a6.js";import{E as j,a as v}from"./form.ad10dcd5.js";import{E as V,a as h}from"./tab-pane.1cc0f769.js";/* empty css                    *//* empty css              */import{E as x}from"./date-picker.78111f93.js";import{E as y}from"./input.31de1b37.js";import{E}from"./row.90d810f1.js";import{E as q}from"./col.5ff06cbd.js";import"./form-item.9355e6dc.js";import{_ as w}from"./page-header.29890ed0.js";import{g as Y,p as U}from"./http.f588794f.js";import{g as k}from"./days.686d9566.js";import{E as D,a as H}from"./index.569c0449.js";import"./_initCloneObject.fb8fbaea.js";import"./strings.8c60bfae.js";import"./event.776e7e11.js";import"./arrays.6dddb988.js";import"./index.e74be4b6.js";import"./debounce.caafe00b.js";import"./isEqual.57d72c4a.js";import"./index.ed3ed02e.js";import"./divider.948c4b18.js";const M={class:"card"},C={class:"editor-card"},F={class:"editor-card-box"},K=i("span",{style:{color:"#999"}},"元",-1),O=i("div",{class:"form-item-tips"},"订单金额满m元减n元（订单金额不包含运费）",-1),R={class:"tool"},z={class:"tool-box"},A={__name:"editor",setup(A){const B=e(),G=a().query.id;let I=t(!1),J=t(!1),L=t("0"),N=t(),P=r({data:{title:"",order_amount:"",price:"",start_time:"",end_time:"",status:1,id:0}});null!=G&&G>0&&(I.value=!0,Y("promotion.rebate/editor",{id:G}).then((e=>{I.value=!1,e.code&&!l(e.data)&&(P.data=e.data)})));const Q=(e,a,t)=>{/^[0-9]+.?[0-9]*/.test(a)?t():t(new Error("您填写的金额不合法"))},S=r({title:[{required:!0,message:"请输入活动名称",trigger:"blur"},{min:2,max:60,message:"活动名称长度请控制在2-60个字符内",trigger:"blur"}],order_amount:[{required:!0,message:"请输入金额",trigger:"blur"},{validator:Q,trigger:"blur"}],price:[{required:!0,message:"请输入金额",trigger:"blur"},{validator:Q,trigger:"blur"}],start_time:[{required:!0,message:"请选择开始时间",trigger:"blur"}],end_time:[{required:!0,message:"请选择结束时间",trigger:"blur"}],status:[{required:!0,message:"请选择状态",trigger:"change"}]}),T=async()=>{N.value&&await N.value.validate(((e,a)=>{if(J.value=!1,e){if(k(P.data.start_time)>k(P.data.end_time))return b.error("您选择的开始时间大于结束时间"),!1;J.value=!0,U("promotion.rebate/editor",P.data).then((e=>{J.value=!1,e.code?(N.value.resetFields(),B.replace("/marketing/rebate/index"),b.success("编辑成功")):b.error(e.msg)})).catch((e=>{b.error(e)}))}else b.error("请完善内容")}))},W=()=>{B.go(-1)};return(e,a)=>{const t=w,r=y,l=j,b=q,Y=E,U=x,k=D,A=H,B=V,G=h,Q=v,X=_,Z=g;return d(),o("div",M,[s(t,{title:"编辑活动"}),i("div",C,[m((d(),p(Q,{model:u(P).data,rules:u(S),ref_key:"ruleFormRef",ref:N},{default:n((()=>[i("div",F,[s(G,{modelValue:u(L),"onUpdate:modelValue":a[6]||(a[6]=e=>f(L)?L.value=e:L=e)},{default:n((()=>[s(B,{label:"基本信息",name:"0"},{default:n((()=>[s(l,{label:"活动名称",prop:"title","label-width":"100px"},{default:n((()=>[s(r,{modelValue:u(P).data.title,"onUpdate:modelValue":a[0]||(a[0]=e=>u(P).data.title=e)},null,8,["modelValue"])])),_:1}),s(l,{label:"订单金额",prop:"order_amount","label-width":"100px"},{default:n((()=>[s(Y,{gutter:24},{default:n((()=>[s(b,{span:11},{default:n((()=>[s(r,{modelValue:u(P).data.order_amount,"onUpdate:modelValue":a[1]||(a[1]=e=>u(P).data.order_amount=e),placeholder:"请输入订单金额"},{prepend:n((()=>[c("满")])),_:1},8,["modelValue"])])),_:1}),s(b,{span:2,class:"text-center",style:{paddign:"0 5px"}},{default:n((()=>[K])),_:1}),s(b,{span:11},{default:n((()=>[s(r,{modelValue:u(P).data.price,"onUpdate:modelValue":a[2]||(a[2]=e=>u(P).data.price=e),placeholder:"请输入金额"},{prepend:n((()=>[c("优惠")])),append:n((()=>[c("元")])),_:1},8,["modelValue"])])),_:1})])),_:1}),O])),_:1}),s(l,{label:"开始时间",prop:"start_time","label-width":"100px"},{default:n((()=>[s(U,{modelValue:u(P).data.start_time,"onUpdate:modelValue":a[3]||(a[3]=e=>u(P).data.start_time=e),type:"datetime",placeholder:"请选择开始时间",format:"YYYY-MM-DD HH:mm:ss"},null,8,["modelValue"])])),_:1}),s(l,{label:"结束时间",prop:"end_time","label-width":"100px"},{default:n((()=>[s(U,{modelValue:u(P).data.end_time,"onUpdate:modelValue":a[4]||(a[4]=e=>u(P).data.end_time=e),type:"datetime",placeholder:"请选择结束时间",format:"YYYY-MM-DD HH:mm:ss"},null,8,["modelValue"])])),_:1}),s(l,{label:"活动状态",prop:"status","label-width":"100px"},{default:n((()=>[s(A,{modelValue:u(P).data.status,"onUpdate:modelValue":a[5]||(a[5]=e=>u(P).data.status=e)},{default:n((()=>[s(k,{label:1},{default:n((()=>[c("开启")])),_:1}),s(k,{label:0},{default:n((()=>[c("关闭")])),_:1})])),_:1},8,["modelValue"])])),_:1})])),_:1})])),_:1},8,["modelValue"])])])),_:1},8,["model","rules"])),[[Z,u(I)]])]),i("div",R,[i("div",z,[s(X,{onClick:W},{default:n((()=>[c("取消")])),_:1}),s(X,{type:"primary",loading:u(J),onClick:T},{default:n((()=>[c("保存")])),_:1},8,["loading"])])])])}}};export{A as default};
