"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[2952],{945:function(e,t,a){a.r(t),a.d(t,{default:function(){return v}});var i=function(){var e=this,t=e._self._c;return e.opened?t("div",{attrs:{"uk-modal":""}},[t("div",{staticClass:"uk-modal-dialog uk-flex uk-flex-column"},[t("h4",{staticClass:"uk-modal-header uk-margin-remove"},[t("button",{staticClass:"uk-modal-close-default",attrs:{type:"button","uk-close":""}}),e._v(" "+e._s(e.field.DOCPROP_NAME)+" ")]),t("div",{staticClass:"uk-flex uk-flex-column uk-padding-small",staticStyle:{"flex-grow":"1","min-height":"1px",overflow:"auto","padding-bottom":"0","align-items":"center"}},[t("div",{staticClass:"uk-flex uk-flex-row",staticStyle:{padding:"0 8px","margin-bottom":"8px"}},[t("div",{staticClass:"uk-text-right right uk-margin-small-right",staticStyle:{width:"250px","line-height":"40px"}},[e._v(" Год: ")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.valueYear,expression:"valueYear"}],ref:"inputYear",staticClass:"uk-input uk-text-center",attrs:{readonly:e.loading,type:"text"},domProps:{value:e.valueYear},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.saveYear.apply(null,arguments)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.hide.apply(null,arguments)}],input:function(t){t.target.composing||(e.valueYear=t.target.value)}}}),t("div",{staticClass:"uk-text-right right uk-margin-small-right",staticStyle:{width:"250px","line-height":"40px"}},[e._v(" Неделя: ")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.valueWeek,expression:"valueWeek"}],ref:"inputWeek",staticClass:"uk-input uk-text-center",attrs:{readonly:e.loading,type:"number"},domProps:{value:e.valueWeek},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.save.apply(null,arguments)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.hide.apply(null,arguments)}],input:function(t){t.target.composing||(e.valueWeek=t.target.value)}}})])]),e.dateFrom?t("div",{staticClass:"uk-text-center"},[e._v(" "+e._s(e.dateFrom)+" - "+e._s(e.dateTo)+" ")]):e._e(),t("div",{staticClass:"uk-padding-small"},[t("div",{staticClass:"uk-text-small uk-text-muted uk-float-left"},[e._v(' "ESC" - отмена, "ENTER" - сохранить и выйти" ')]),t("div",{staticClass:"uk-text-right"},[t("button",{staticClass:"uk-button",attrs:{type:"button"},on:{click:e.hide}},[e._v(" Отмена ")]),t("button",{staticClass:"uk-button uk-button-primary uk-border-rounded",attrs:{type:"button"},on:{click:e.save}},[e._v(" Сохранить ")])])])])]):e._e()},l=[],s=(a(3216),a(4355),a(588)),n=a.n(s),u=a(9148),r=a(2779),o=a(6587),d=a(4041)["A"],c={name:"weekModal",components:{},data(){return{opened:!1,loading:!0,valueYear:"",valueWeek:1,saving:!1}},props:{field:Object,value:{type:String,default:null}},computed:{dateFrom(){if(!this.valueYear||!this.valueWeek)return null;let e=this.valueYear;if(-1===e.search(/^[0-9]{4}$/))return null;let t=u(e,"YYYY");return t.week()>1&&t.add(7,"d"),console.log("week",t.week()),t=t.week(this.valueWeek).day(1),t.format("DD.MM.YYYY")},dateTo(){return this.dateFrom?u(this.dateFrom,"DD.MM.YYYY").add(6,"d").format("DD.MM.YYYY"):null}},watch:{},created(){},async mounted(){await this.open()},methods:{async open(){this.opened=!0,this.saving=!1,await this.$nextTick(),r.util.on(this.$el,"hide",(()=>{this.saving||this.$emit("close")})),r.util.on(this.$el,"hidden",(()=>{this.opened=!1})),r.util.on(this.$el,"shown",(()=>{this.$refs.inputYear.focus()})),r.modal(this.$el).show(),await this.load(),await this.$nextTick(),this.initDatepicker()},initDatepicker(){this.dateCleave=new(n())(this.$refs.inputYear,{date:!0,delimiter:".",datePattern:["Y"]});let e={timepicker:!1,autoClose:!0,toggleSelected:!1,dateFormat:"yyyy",todayButton:new Date,view:"years",minView:"years",keyboardNav:!1,onSelect:(e,t)=>{this.saveYear(e,t)}};o(this.$refs.inputYear).datepicker(e),console.log("init dp",this.$refs.inputYear),this.datePicker=o(this.$refs.inputYear).data("datepicker")},async load(){if(this.loading=!0,this.value){let e=u(this.value,"DD.MM.YYYY");if(e.isValid()){this.valueWeek=e.week();let t=e.year();console.log("load",e.week(),e.year(),e.month()),1===this.valueWeek&&11===e.month()&&t++,this.valueYear=t.toString(),console.log("load2",this.valueYear)}}this.loading=!1},async save(){try{this.saving=!0,this.loading=!0,this.$emit("change",{value:this.dateFrom,display:this.dateFrom}),r.modal(this.$el).hide()}catch(e){d.alert(e)}this.loading=!1},saveYear(){this.valueYear=o(this.$refs.inputYear).val(),this.$refs.inputWeek.focus()},hide(){r.modal(this.$el).hide()}}},h=c,k=a(1656),p=(0,k.A)(h,i,l,!1,null,null,null),v=p.exports}}]);
//# sourceMappingURL=FieldWeekModal.52fd0269.js.map