import{u as L,r as y,o as T,f as p,a as m,c as v,h as c,g as a,w as d,k as U,q as S,F as J,j as M,E as V,i as f,t as u,y as O,p as r,v as B,x as F}from"./index-ad591d72.js";import{s as R,a as j,c as q,b as z}from"./index-264c9d8d.js";import{_ as A}from"./_plugin-vue_export-helper-c27b6911.js";import"./request-2786ead7.js";import"./axios-4a70c6fc.js";const G=g=>(B("data-v-90f5b87e"),g=g(),F(),g),H={class:"container"},K={class:"left"},P={class:"topleft"},Q=["onClick"],W={key:0,class:"right"},X={class:"top"},Y={class:"icon",style:{"margin-right":"6px"},"aria-hidden":"true"},Z=G(()=>c("use",{"xlink:href":"#icon-baocun"},null,-1)),ee=[Z],te={class:"bottom"},se={class:"card shadow"},oe={class:"title"},le={__name:"contest",setup(g){const{locale:ae,t:l}=L(),i=y([]),t=y({Name:"",Code:"",Length:"",Start:"",Speed:""});T(()=>{h()});const h=o=>{R({Category:"Contest"}).then(e=>{console.log(e),!e.Err&&e.settings.length!=0?(i.value=e.settings.map(n=>({ID:n.ID,...JSON.parse(n.Value)})),console.log(i.value),b(o?i.value.find(n=>n.ID==o):i.value[0])):(i.value=[],t.value={})})},b=o=>{t.value=JSON.parse(JSON.stringify(o))},k=()=>{let o={Name:"Contest",Category:"Contest",Value:JSON.stringify({Name:"",Length:"",Start:"",Speed:"2:30",Code:i.value.length+1})};j(o).then(e=>{e.Err?V({message:e.Err,grouping:!0,type:"error"}):h(e.settings[0].ID)})},D=()=>{q({ID:t.value.ID}).then(o=>{h()})},N=()=>{let o=t.value.Code;return!!i.value.filter(n=>n.ID!=t.value.ID).map(n=>n.Code).includes(o)},E=()=>{if(N()){V.error({message:l("contests.idRepeat")});return}z({Category:"Contest",Value:JSON.stringify(t.value),ID:t.value.ID}).then(o=>{o.Err?V({message:o.Err,grouping:!0,type:"error"}):(console.log(o),h(t.value.ID))})};return(o,e)=>{const n=p("el-button"),$=p("el-input-number"),_=p("el-form-item"),C=p("el-input"),w=p("el-time-picker"),x=p("el-form");return m(),v("div",H,[c("div",K,[c("div",P,[a(n,{onClick:e[0]||(e[0]=s=>k())},{default:d(()=>[f(u(o.$t("contests.create")),1)]),_:1}),i.value.length>0?(m(),U(n,{key:0,onClick:e[1]||(e[1]=s=>D())},{default:d(()=>[f(u(o.$t("contests.del")),1)]),_:1})):S("",!0)]),(m(!0),v(J,null,M(i.value,s=>{var I;return m(),v("div",{class:O(["item",{active:((I=t.value)==null?void 0:I.ID)==s.ID}]),key:s.ID,onClick:ne=>b(s)},u(s.Code?`${s.Code}: ${s.Name}`:""),11,Q)}),128))]),i.value.length>0?(m(),v("div",W,[c("div",X,[a(n,{onClick:e[2]||(e[2]=s=>E())},{default:d(()=>[(m(),v("svg",Y,ee)),f(u(o.$t("participants.Edit")),1)]),_:1})]),c("div",te,[a(x,{model:t.value,"label-width":"100px"},{default:d(()=>[c("div",se,[c("div",oe,u(o.$t("contests.info")),1),a(_,{label:r(l)("contests.id")},{default:d(()=>[a($,{class:"input-code",style:{width:"100%"},controls:!1,modelValue:t.value.Code,"onUpdate:modelValue":e[3]||(e[3]=s=>t.value.Code=s),modelModifiers:{number:!0},placeholder:r(l)("contests.idTip")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),a(_,{label:r(l)("contests.name")},{default:d(()=>[a(C,{modelValue:t.value.Name,"onUpdate:modelValue":e[4]||(e[4]=s=>t.value.Name=s),placeholder:r(l)("contests.nameTip")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),a(_,{label:r(l)("contests.length")},{default:d(()=>[a(C,{modelValue:t.value.Length,"onUpdate:modelValue":e[5]||(e[5]=s=>t.value.Length=s),modelModifiers:{number:!0},placeholder:r(l)("contests.lengthTip")},{append:d(()=>[f(u(r(l)("contests.metre")),1)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),a(_,{label:r(l)("contests.start")},{default:d(()=>[a(w,{style:{width:"100%"},modelValue:t.value.Start,"onUpdate:modelValue":e[6]||(e[6]=s=>t.value.Start=s),placeholder:r(l)("contests.startTip")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),a(_,{label:r(l)("contests.speed")},{default:d(()=>[a(C,{modelValue:t.value.Speed,"onUpdate:modelValue":e[7]||(e[7]=s=>t.value.Speed=s),modelModifiers:{number:!0},placeholder:r(l)("contests.speedTip")},{append:d(()=>[f(u(r(l)("contests.speedUnit")),1)]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])])]),_:1},8,["model"])])])):S("",!0)])}}},pe=A(le,[["__scopeId","data-v-90f5b87e"]]);export{pe as default};
