import{d as e,e as t,c as a,a9 as s,dc as n,f as o,g as r,o as l,h as c,w as u,i,j as d,a as m,t as p,_ as f,x as _,ag as h,dd as x,ah as g,aF as v,z as I,a8 as y}from"./index-B3cqKsI_.js";import{_ as b}from"./uni-nav-bar.xE5Um1Eb.js";import{m as k}from"./index.CRonDE9r.js";import{_ as w}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./uni-icons.EqO7jntL.js";/* empty css                                                                  *//* empty css                                                                    */const j=w(e({__name:"scheduleAdd",setup(e){const w=new Date,j=w.getFullYear(),G=w.getMonth()+1,S=Array.from({length:10},((e,t)=>j+t)),C=Array.from({length:12},((e,t)=>t+1)),D=t({yearIndex:-1,monthIndex:-1,groupList:[],selectGroupIDs:[],selectGroupNames:[],multiplePickerShow:!1}),$=a((()=>[S,C])),L=a((()=>-1===D.yearIndex||-1===D.monthIndex?"请选择月份":`${S[D.yearIndex]}年${C[D.monthIndex]}月`)),N=a((()=>0===D.selectGroupNames.length?"请选择考勤组":D.selectGroupNames.join("/"))),P=()=>{D.multiplePickerShow=!0},A=()=>{D.multiplePickerShow=!1},F=e=>{D.selectGroupIDs=[...e.value],D.selectGroupNames=e.selected.map((e=>e.text)),A()},Y=()=>{f()},z=e=>{const[t,a]=e.detail.value;D.yearIndex=t,D.monthIndex=a},M=async()=>{if(-1===D.yearIndex||-1===D.monthIndex)return void _.error("请选择考勤时间!","none");const e=S[D.yearIndex],t=C[D.monthIndex];if(e===j&&t<G)return void _.error("不能选择历史月份!","none");if(0===D.selectGroupIDs.length)return void _.error("请选择考勤组!","none");h({mask:!0});const a={date:`${e}-${t.toString().padStart(2,"0")}`,groups:D.selectGroupIDs};try{await x(a),g(),_.success("新增排班成功!","none"),setTimeout((()=>{f()}),800);try{const e=v().at(-2);null==e||e.$vm.$.exposed.refreshList()}catch{}}catch(s){_.error("新增排班失败!","none"),g()}};return s((async()=>{const e=await n({page:1});D.groupList=e.data.list.map((e=>({...e,value:e.id})))})),(e,t)=>{const a=o(r("uni-nav-bar"),b),s=I,n=y;return l(),c(s,{class:"base-container"},{default:u((()=>[i(a,{"background-color":"transparent",border:!1,"status-bar":"",title:"新增排班","left-icon":"left",onClickLeft:Y,dark:"",class:"custom-nav-bar"}),i(s,{class:"form-wrapper"},{default:u((()=>[i(s,{class:"form-item"},{default:u((()=>[i(s,{class:"form-item-label"},{default:u((()=>[d(" 考勤时间 ")])),_:1}),i(s,{class:"form-item-content over-text"},{default:u((()=>[i(n,{mode:"multiSelector",range:m($),onChange:z,value:[0,G-1]},{default:u((()=>[i(s,{class:"picker-content"},{default:u((()=>[d(p(m(L))+" ",1),i(s,{class:"iconfont icon-jinru-copy"})])),_:1})])),_:1},8,["range","value"])])),_:1})])),_:1}),i(s,{class:"form-item"},{default:u((()=>[i(s,{class:"form-item-label"},{default:u((()=>[d(" 考勤组名称 ")])),_:1}),i(s,{class:"form-item-content over-text"},{default:u((()=>[i(s,{class:"picker-content",onClick:P},{default:u((()=>[d(p(m(N))+" ",1),i(s,{class:"iconfont icon-jinru-copy"})])),_:1}),i(k,{show:m(D).multiplePickerShow,columns:m(D).groupList,defaultIndex:m(D).selectGroupIDs,onChange:F,onCancel:A},null,8,["show","columns","defaultIndex"])])),_:1})])),_:1})])),_:1}),i(s,{class:"submit-btn-wrapper"},{default:u((()=>[i(s,{class:"submit-btn",onClick:M},{default:u((()=>[d(" 提交 ")])),_:1})])),_:1})])),_:1})}}}),[["__scopeId","data-v-7b1e5617"]]);export{j as default};
