import{h as i,q as E,c as u,a as t,b as c,w as _,F as k,i as b,r as p,o as s,B as F,k as N,e as V,n as U,t as w,E as C}from"./index-Dn6fDqC3.js";import{b as v}from"./index-D0SgC7D8.js";const Y={class:"content-card"},D={class:"card-title"},M={class:"filter-bar",style:{"margin-bottom":"0",display:"flex",gap:"8px"}},q={style:{display:"grid","grid-template-columns":"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px","margin-top":"8px"}},H={class:"label"},L={style:{display:"flex","align-items":"center",gap:"8px"}},T={style:{"margin-top":"6px","font-size":"12px",color:"var(--text-muted)"}},I={__name:"WorkdaySetting",setup($){const h=new Date().getFullYear(),B=Array.from({length:5},(a,e)=>h-2+e),n=i(h),m=i(!1),y=i(!1);async function W(){y.value=!0;try{const a=await v.syncWorkdays(n.value);C.success(a.message||"同步成功"),g()}catch{}finally{y.value=!1}}const f=i(Array.from({length:12},(a,e)=>({month:e+1,days:22})));async function g(){try{const a=await v.getWorkdays(n.value);a.data.length>0&&(f.value=Array.from({length:12},(e,o)=>{const r=a.data.find(d=>d.month===o+1);return{month:o+1,days:r?r.days:22}}))}catch{}}async function A(){m.value=!0;try{await v.setWorkdays({year:n.value,months:f.value.map(a=>({month:a.month,days:a.days}))}),C.success("保存成功")}finally{m.value=!1}}return E(g),(a,e)=>{const o=p("el-option"),r=p("el-select"),d=p("el-button"),S=p("el-input-number");return s(),u("div",null,[e[4]||(e[4]=t("div",{class:"page-header"},[t("h1",null,"工作日设置"),t("p",null,"按年份设定每月工作日天数，用于计算研发工时上限")],-1)),t("div",Y,[t("div",D,[t("div",M,[c(r,{modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=l=>n.value=l),onChange:g,style:{width:"120px"}},{default:_(()=>[(s(!0),u(k,null,b(F(B),l=>(s(),N(o,{key:l,label:`${l}年`,value:l},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),c(d,{type:"warning",loading:y.value,onClick:W},{default:_(()=>[...e[1]||(e[1]=[V("🔄 联网自动同步节假日",-1)])]),_:1},8,["loading"])]),c(d,{type:"primary",loading:m.value,onClick:A},{default:_(()=>[...e[2]||(e[2]=[V("保存设置",-1)])]),_:1},8,["loading"])]),t("div",q,[(s(!0),u(k,null,b(f.value,(l,x)=>(s(),u("div",{key:x,class:U(["stat-card",["purple","green","blue","orange"][x%4]])},[t("div",H,w(l.month)+"月",1),t("div",L,[c(S,{modelValue:l.days,"onUpdate:modelValue":z=>l.days=z,min:0,max:31,size:"default",style:{width:"120px"}},null,8,["modelValue","onUpdate:modelValue"]),e[3]||(e[3]=t("span",{class:"unit"},"天",-1))]),t("div",T," 工时上限: "+w(l.days*8)+" 小时 ",1)],2))),128))])])])}}};export{I as default};
