import{b as E,r as v,ah as R,o as w,y as I,q as o,P as r,x as s,v as H,p as l,n as k,S as T,c5 as C,c0 as F,k as B,m as P,l as U,bv as q,D as N}from"./index.8d733f79.js";import{E as L}from"./el-date-picker-panel.089dbe6d.js";import{b as G}from"./deviceRunTime.517fd825.js";import"./panel-time-pick.b2dd8e75.js";import"./index.28f6da25.js";const j={class:"dialog-footer"},W={__name:"changeRunState",emits:["regetList"],setup(z,{expose:g,emit:D}){const{t:m}=E(),{proxy:c}=N(),d=v(!1),a=v({deviceCode:"",deviceId:"",endTime:"",factoryId:"",runState:"",startTime:""}),S=R({runState:[{required:!0,message:m("runStateP"),trigger:"change"}],startTime:[{required:!0,message:m("startTimeP"),trigger:"change"}]}),V=e=>e.getTime()<Date.now()-365*24*60*60*1e3,Y=e=>e.getTime()>Date.now();function b(e){a.value.startTime="",a.value.endTime="",a.value.runState=e.runState==="-"?"":e.runState,a.value.deviceId=e.deviceId,a.value.deviceCode=e.deviceCode,a.value.factoryId=e.factoryId,d.value=!0,setTimeout(()=>{c.$refs.runStatusFormRef.clearValidate()},0)}function h(){c.$refs.runStatusFormRef.validate(e=>{if(e){const t={...a.value};if(t.startTime=new Date(t.startTime).getTime(),t.endTime&&(t.endTime=new Date(t.endTime).getTime(),t.startTime>t.endTime)){T.error(m("timeRangeV"));return}G(t).then(u=>{T.success(u.msg),D("regetList"),f()}).catch(()=>{})}})}function f(){setTimeout(()=>{d.value=!1},0)}return g({showModal:b}),(e,t)=>{const u=C,y=F,i=B,p=L,M=P,_=U,$=q;return w(),I($,{modelValue:d.value,"onUpdate:modelValue":t[3]||(t[3]=n=>d.value=n),width:"480","align-center":""},{header:o(()=>[r(s(e.$t("changeRunState")),1)]),footer:o(()=>[H("span",j,[l(_,{onClick:f},{default:o(()=>[r(s(e.$t("cancel")),1)]),_:1}),l(_,{type:"primary",onClick:h},{default:o(()=>[r(s(e.$t("confirm")),1)]),_:1})])]),default:o(()=>[l(M,{model:a.value,rules:k(S),ref:"runStatusFormRef"},{default:o(()=>[l(i,{label:e.$t("runState"),prop:"runState"},{default:o(()=>[l(y,{modelValue:a.value.runState,"onUpdate:modelValue":t[0]||(t[0]=n=>a.value.runState=n)},{default:o(()=>[l(u,{value:"stop"},{default:o(()=>[r(s(e.$t("stop")),1)]),_:1}),l(u,{value:"run"},{default:o(()=>[r(s(e.$t("run")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),l(i,{label:e.$t("startTime"),prop:"startTime"},{default:o(()=>[l(p,{modelValue:a.value.startTime,"onUpdate:modelValue":t[1]||(t[1]=n=>a.value.startTime=n),type:"datetime",placeholder:e.$t("startTime"),format:"YYYY-MM-DD HH:mm","date-format":"YYYY-MM-DD","time-format":"HH:mm","disabled-date":V},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),l(i,{label:e.$t("endTime"),prop:"endTime"},{default:o(()=>[l(p,{modelValue:a.value.endTime,"onUpdate:modelValue":t[2]||(t[2]=n=>a.value.endTime=n),type:"datetime",placeholder:e.$t("endTime"),format:"YYYY-MM-DD HH:mm","date-format":"YYYY-MM-DD","time-format":"HH:mm","disabled-date":Y},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}};export{W as default};
