import{o as e,h as t,w as s,i,X as l,A as n,j as a,t as o,W as r,N as c,k as h,F as d,l as u,z as m,y as p,bo as f,bp as $,a1 as g}from"./index-B3cqKsI_.js";/* empty css */import{_ as k}from"./_plugin-vue_export-helper.BCo6x5W8.js";const _={y:{text:"年",range:[null,null]},m:{text:"月",range:[1,12]},d:{text:"日",range:[1,31]},h:{text:"时",range:[0,23]},i:{text:"分",range:[0,59]},s:{text:"秒",range:[0,59]}};function y(e){const t=e.substring(0,e.lastIndexOf("-"));let s,i;const l=new Date;switch(t.length){case 0:s=l.getFullYear(),i=l.getMonth()+1;break;case 2:s=l.getFullYear(),i=parseInt(t);break;default:const[e,n]=t.split("-");s=parseInt(e),i=parseInt(n)}var n;return[31,(n=s,n%4==0&&n%100!=0||n%100==0&&n%400==0?29:28),31,30,31,30,31,31,30,31,30,31][i-1]}function x(e){if(!e)return null;const t=new Date,s=b(t.getFullYear()),i=b(t.getMonth()+1),l=b(t.getDate()),n=b(t.getHours()),a=b(t.getMinutes()),o=b(t.getSeconds());return{y:`${s}`,m:`${i}`,d:`${l}`,h:`${n}`,i:`${a}`,s:`${o}`,ym:`${s}-${i}`,md:`${i}-${l}`,hi:`${n}:${a}`,is:`${a}:${o}`,ymd:`${s}-${i}-${l}`,his:`${n}:${a}:${o}`,mdh:`${i}-${l} ${n}`,ymdh:`${s}-${i}-${l} ${n}`,mdhi:`${i}-${l} ${n}:${a}`,mdhis:`${i}-${l} ${n}:${i}:${o}`,yd:`${s}-${l}`,ymdhi:`${s}-${i}-${l} ${n}:${a}`,ymdhis:`${s}-${i}-${l} ${n}:${a}:${o}`}[e]}function b(e){return e>9?e+"":"0"+e}function C(e="uniForms"){let t=this.$parent,s=t.$options.name;for(;s!==e;){if(t=t.$parent,!t)return!1;s=t.$options.name}return t}const v=k({name:"XpPicker",data:()=>({isError:!1,pickerVisible:!1,cols:[],selected:[]}),props:{mode:{type:String,default:"ymd"},animation:{type:Boolean,default:!0},height:{type:[Number,String],default:35},actionPosition:{type:String,default:"bottom"},yearRange:{type:Array,default:()=>[2010,null]},value:String,modelValue:String,history:Boolean,placeholder:{type:String,default:"请选择"}},watch:{mode(){this.render()}},emits:["confirm","update:modelValue"],computed:{modeArr(){return this.mode.split("")},units(){const e=[];for(const t in this.template)-1!==this.mode.indexOf(t)&&e.push(this.template[t].text);return e},label(){const e=this.value||this.modelValue;return e||this.placeholder}},created(){this.bindForm(),this.isConfirm=!1,this.template={},this.render(),this.modelValue&&this.setSelected(this.modelValue)},methods:{bindForm(){this.form=C.call(this,"uniForms"),this.formItem=C.call(this,"uniFormsItem"),this.form&&this.formItem&&this.formItem.name&&(this.is_reset||(this.is_reset=!1,this.formItem.setValue(this.modelValue)),this.form.inputChildrens.push(this))},render(){try{this.template=function(e){const{mode:t,yearRange:s}=e;let i;i=e.modelValue;const[l,n]=s;let a={};for(const o of t)a[o]=_[o];if(-1!==t.indexOf("y")&&(a.y.range=[l||2016,n||(new Date).getFullYear()]),-1!==t.indexOf("d")){const e=y(i||x(t));a.d.range=[1,e]}return a}(this),this.initCols(),this.initSelected()}catch(e){this.isError=!0}},initCols(){for(const e of this.mode){const t=this.template[e].range;this.fillCol(e,...t)}},initSelected(){let e;e=this.modelValue,e||(e=x(this.mode)),e&&this.setSelected(e)},fillCol(e,t,s){const i=this.mode.indexOf(e);let l=[];for(let n=t;n<=s;n++)l.push(b(n));this.cols[i]=l},setSelected(e){const t=e.split(/-|:|\s/),s=this.cols;for(let i=0;i[i(v,{onClick:C.show,class:"xp-h-full"},{default:s((()=>[l(k.$slots,"default",{},(()=>[i(v,{class:n(["picker-label xp-h-full",{"is-placeholder":C.label===y.placeholder}])},{default:s((()=>[a(o(C.label),1)])),_:1},8,["class"])]),!0)])),_:3},8,["onClick"]),i(v,{class:"xp-picker",style:r({visibility:b.pickerVisible?"visible":"hidden"})},{default:s((()=>[i(v,{class:n(["xp-picker-mask",{"xp-picker-animation":y.animation}]),style:r({opacity:b.pickerVisible?.6:0}),onClick:C._cancel},null,8,["class","style","onClick"]),i(v,{class:n(["xp-picker-container",{"xp-picker-container--show":b.pickerVisible,"xp-picker-animation":y.animation}])},{default:s((()=>["top"===y.actionPosition?(e(),t(v,{key:0,class:"xp-picker-action"},{default:s((()=>[i(v,{class:"xp-picker-action--cancel",onClick:C._cancel},{default:s((()=>[a("取消")])),_:1},8,["onClick"]),i(v,{class:"xp-picker-action--confirm",onClick:C._confirm},{default:s((()=>[a("确定")])),_:1},8,["onClick"])])),_:1})):c("",!0),b.isError?(e(),t(v,{key:1,class:"xp-picker-error",style:r({height:y.height+"vh"})},{default:s((()=>[i(V,null,{default:s((()=>[a("(请检查你的配置 或 查看控制台错误信息)")])),_:1})])),_:1},8,["style"])):(e(),t(I,{key:2,style:r([{"margin-top":"40rpx"},{height:y.height+"vh"}]),"indicator-style":"height:50px;",value:b.selected,onChange:C._change},{default:s((()=>[(e(!0),h(d,null,u(C.modeArr,((i,l)=>(e(),t(S,{key:b.cols[l].length,class:"xp-picker-column"},{default:s((()=>[(e(!0),h(d,null,u(b.cols[l],((i,n)=>(e(),t(v,{class:"xp-picker-list-item",key:n},{default:s((()=>[a(o(i+C.units[l]),1)])),_:2},1024)))),128))])),_:2},1024)))),128))])),_:1},8,["style","value","onChange"])),"bottom"===y.actionPosition?(e(),t(v,{key:3,class:"xp-picker-btns"},{default:s((()=>[i(w,{class:"xp-button xp-button--cancel",onClick:C._cancel},{default:s((()=>[a("取消")])),_:1},8,["onClick"]),i(w,{class:"xp-button xp-button--confirm",onClick:C._confirm},{default:s((()=>[a("确定")])),_:1},8,["onClick"])])),_:1})):c("",!0)])),_:1},8,["class"])])),_:1},8,["style"])])),_:3})}],["__scopeId","data-v-2fabbcb7"]]);export{v as _};