import{$ as e,H as t,L as n,P as r,V as i,Wt as a,_ as o,d as s,et as c,i as l,lt as u,p as d,st as f,u as p,v as m,z as h}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{l as g,s as _}from"./index-Mgun2LFs.js";import"./request-DG5cMCYw.js";import{a as v}from"./hr-efu8Toim.js";var y={class:`p-6 space-y-4`},b={class:`bg-white rounded-2xl border border-gray-100 shadow-sm p-4 flex items-center flex-wrap gap-3`},x={class:`bg-white rounded-2xl border border-gray-100 shadow-sm`},S={class:`flex items-center justify-between px-5 py-4 border-b border-gray-50`},C={class:`px-2`},w={class:`px-5 py-3 border-t border-gray-50`},T={__name:`index`,setup(T){let E=u([]),D=u(0),O=u(!1),k=u(!1),A=u(!1),j=f({user_id:``,start_date:``,end_date:``}),M=f({page:1,per_page:31}),N=f({user_id:``,schedule_date:``,shift_type:1,start_time:``,end_time:``}),P={1:`早班`,2:`中班`,3:`晚班`,4:`夜班`,5:`休息`},F={1:`success`,2:`primary`,3:`warning`,4:`danger`,5:`info`};async function I(){O.value=!0;try{let e=await v.getList({...j,...M});E.value=e.data?.list||e.data?.data||[],D.value=e.data?.total||0}finally{O.value=!1}}function L(){M.page=1,I()}function R(){Object.assign(j,{user_id:``,start_date:``,end_date:``}),L()}function z(){Object.assign(N,{user_id:``,schedule_date:``,shift_type:1,start_time:``,end_time:``}),k.value=!0}async function B(){if(!N.user_id||!N.schedule_date||!N.shift_type){_.warning(`请填写必要信息`);return}A.value=!0;try{await v.create(N),_.success(`排班成功`),k.value=!1,I()}finally{A.value=!1}}function V(e){M.page=e,I()}return r(()=>I()),(r,u)=>{let f=i(`el-input`),_=i(`el-date-picker`),v=i(`el-button`),T=i(`el-table-column`),I=i(`el-tag`),H=i(`el-table`),U=i(`el-pagination`),W=i(`el-form-item`),G=i(`el-option`),K=i(`el-select`),q=i(`el-time-picker`),J=i(`el-form`),Y=i(`el-dialog`),X=t(`loading`);return n(),d(`div`,y,[p(`div`,b,[m(f,{modelValue:j.user_id,"onUpdate:modelValue":u[0]||=e=>j.user_id=e,placeholder:`员工ID`,style:{width:`160px`},clearable:``,onKeydown:g(L,[`enter`])},null,8,[`modelValue`]),m(_,{modelValue:j.start_date,"onUpdate:modelValue":u[1]||=e=>j.start_date=e,type:`date`,"value-format":`YYYY-MM-DD`,placeholder:`开始日期`},null,8,[`modelValue`]),m(_,{modelValue:j.end_date,"onUpdate:modelValue":u[2]||=e=>j.end_date=e,type:`date`,"value-format":`YYYY-MM-DD`,placeholder:`结束日期`},null,8,[`modelValue`]),m(v,{type:`primary`,onClick:L},{default:e(()=>[...u[11]||=[o(`查询`,-1)]]),_:1}),m(v,{onClick:R},{default:e(()=>[...u[12]||=[o(`重置`,-1)]]),_:1})]),p(`div`,x,[p(`div`,S,[u[14]||=p(`div`,{class:`flex items-center gap-3`},[p(`span`,{class:`font-medium text-gray-700`},`排班列表`)],-1),m(v,{type:`primary`,onClick:z},{default:e(()=>[...u[13]||=[o(`新增排班`,-1)]]),_:1})]),p(`div`,C,[c((n(),s(H,{data:E.value,style:{width:`100%`}},{default:e(()=>[m(T,{label:`员工`,"min-width":`100`},{default:e(({row:e})=>[o(a(e.user?.name||`-`),1)]),_:1}),m(T,{prop:`schedule_date`,label:`排班日期`,width:`120`}),m(T,{label:`班次`,width:`90`,align:`center`},{default:e(({row:t})=>[m(I,{type:F[t.shift_type],size:`small`},{default:e(()=>[o(a(P[t.shift_type]),1)]),_:2},1032,[`type`])]),_:1}),m(T,{prop:`start_time`,label:`开始时间`,width:`100`}),m(T,{prop:`end_time`,label:`结束时间`,width:`100`})]),_:1},8,[`data`])),[[X,O.value]])]),p(`div`,w,[m(U,{"current-page":M.page,"onUpdate:currentPage":u[3]||=e=>M.page=e,total:D.value,layout:`total,prev,pager,next`,background:``,onCurrentChange:V},null,8,[`current-page`,`total`])])]),m(Y,{modelValue:k.value,"onUpdate:modelValue":u[10]||=e=>k.value=e,title:`新增排班`,width:`500px`,"destroy-on-close":``},{footer:e(()=>[m(v,{onClick:u[9]||=e=>k.value=!1},{default:e(()=>[...u[15]||=[o(`取消`,-1)]]),_:1}),m(v,{type:`primary`,loading:A.value,onClick:B},{default:e(()=>[...u[16]||=[o(`确定`,-1)]]),_:1},8,[`loading`])]),default:e(()=>[m(J,{"label-width":`80px`},{default:e(()=>[m(W,{label:`员工ID`},{default:e(()=>[m(f,{modelValue:N.user_id,"onUpdate:modelValue":u[4]||=e=>N.user_id=e},null,8,[`modelValue`])]),_:1}),m(W,{label:`排班日期`},{default:e(()=>[m(_,{modelValue:N.schedule_date,"onUpdate:modelValue":u[5]||=e=>N.schedule_date=e,type:`date`,"value-format":`YYYY-MM-DD`,style:{width:`100%`}},null,8,[`modelValue`])]),_:1}),m(W,{label:`班次`},{default:e(()=>[m(K,{modelValue:N.shift_type,"onUpdate:modelValue":u[6]||=e=>N.shift_type=e,style:{width:`100%`}},{default:e(()=>[(n(),d(l,null,h(P,(e,t)=>m(G,{key:t,label:e,value:Number(t)},null,8,[`label`,`value`])),64))]),_:1},8,[`modelValue`])]),_:1}),m(W,{label:`开始时间`},{default:e(()=>[m(q,{modelValue:N.start_time,"onUpdate:modelValue":u[7]||=e=>N.start_time=e,format:`HH:mm`,"value-format":`HH:mm`,style:{width:`100%`}},null,8,[`modelValue`])]),_:1}),m(W,{label:`结束时间`},{default:e(()=>[m(q,{modelValue:N.end_time,"onUpdate:modelValue":u[8]||=e=>N.end_time=e,format:`HH:mm`,"value-format":`HH:mm`,style:{width:`100%`}},null,8,[`modelValue`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])])}}};export{T as default};