"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[3186],{6609:function(e,t,l){l.r(t),l.d(t,{default:function(){return c}});var a=function(){var e=this,t=e._self._c;return t("modal",{ref:"modal",attrs:{title:e.title,fullHeight:!0,large:!1,autoOpen:!0},on:{closed:function(t){return e.$emit("closed")}}},[t("div",{staticClass:"uk-flex uk-flex-column",staticStyle:{flex:"1","min-height":"1px"}},[e.treeData?t("LiquorTree",{ref:"tree",staticStyle:{height:"100%"},attrs:{data:e.treeData,options:e.treeOptions},on:{keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.save.apply(null,arguments)},"node:dblclick":e.save}}):e._e()],1),t("div",{staticClass:"uk-padding-small uk-text-center",staticStyle:{"border-top":"1px solid #d5e1e6"}},[t("button",{staticClass:"uk-modal-close uk-button"},[t("i",{staticClass:"uk-icon-close"}),e._v(" Отмена ")]),t("button",{staticClass:"uk-button uk-button-primary uk-margin-small-left",on:{click:e.save}},[t("i",{staticClass:"uk-icon-floppy-o"}),e._v(" Применить ")])])])},i=[],s=l(3216),n=l(3020),r={name:"ClassifSimpleModal",components:{Modal:()=>l.e(8362).then(l.bind(l,2215)),LiquorTree:n["default"]},props:{treeId:{type:String,default:null},title:String,multipile:Boolean,value:{type:[String,Array],default:null}},data(){return{changed:!1,rawData:[],treeData:null}},computed:{treeOptions(){return{checkbox:this.multipile,autoCheckChildren:!0,multiple:!1}}},async mounted(){if(await this.load(),await this.$nextTick(),!this.multipile&&this.value){let e=this.$refs.tree.findAll({data:{DESCR:this.value}});e.select(!0),console.log("activeElement",this.$refs.tree)}this.$refs.tree.$el.addEventListener("keydown",(e=>{"Enter"===e.key&&this.save()}),!0)},methods:{async load(){this.rawData=await s.vd.select("CARD_POPUP_RESTREE_CS",{RS_DESCR:this.treeId},1e4);let e=null;e=this.treeId?this.rawData.find((e=>e.DESCR===this.treeId)):this.rawData.find((e=>0===e.RS_PARENT)),console.log("rootRow",e),this.treeData=this.buildTree(e.RS_PARENT,1),console.log("treeData",this.treeData)},buildTree(e,t){let l=this.multipile?[]:null;this.value&&(l=this.value);let a=[];return this.rawData.filter((t=>t.RS_PARENT===e)).forEach((e=>{let i=this.buildTree(e.RS_ID,t+1),s=!1,n=!1;this.multipile?s=-1!==l.indexOf(e.DESCR):n=e.DESCR===l;let r=t<=1;i.forEach((e=>{(e.state.selected||e.state.checked||e.state.expanded)&&(r=!0)})),a.push({id:e.RS_ID,text:e.NAME,state:{expanded:r,checked:s,selected:n},data:{DESCR:e.DESCR},children:i})})),a},close(){this.$refs.modal.close()},save(){let e=null,t=null;this.multipile?(t=this.$refs.tree.checked(),e=t.map((e=>e.data.DESCR))):(t=this.$refs.tree.selected(),console.log("curNodes",t),t.length&&(e=t[0].data.DESCR));let l="";t.length>1?l="Выбрано: "+t.length:1===t.length&&(l=t[0].data.text),this.$emit("change",{value:e,display:l}),this.changed=!0,this.close()}}},o=r,u=l(1656),d=(0,u.A)(o,a,i,!1,null,null,null),c=d.exports}}]);
//# sourceMappingURL=SelectTreeModal.8b3c6793.js.map