"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[6160],{2598:function(t,e,i){function r(t){let e=["Байт","KB","MB","GB","TB"];if(0==t)return"n/a";let i=parseInt(Math.floor(Math.log(t)/Math.log(1024)));return 0==i?t+" "+e[i]:(t/Math.pow(1024,i)).toFixed(1)+" "+e[i]}i.d(e,{A:function(){return r}})},7234:function(t,e,i){i.r(e),i.d(e,{default:function(){return p}});var r=function(){var t=this,e=t._self._c;return e("div",{ref:"grid",staticClass:"flex-grow flex-column"})},l=[],n=i(2158),s=i(2598),a=i(5517),o=i(1576),d=i.n(o),h=i(6587),c={name:"FilesGrid",components:{},props:{curFolder:Object,files:{type:Array,default:null},showPath:{type:Boolean,default:!1},order:{type:Object,default:null}},data:()=>({}),computed:{},watch:{files(){this.mainGrid&&(this.selectAll(!1),this.mainGrid.setData(this.files))},showPath(){this.mainGrid.setColumns(this.getStructure())}},mounted(){this.initGrid(),this.files&&this.mainGrid.setData(this.files)},methods:{initGrid(){this.mainGrid=new n.A(h(this.$refs.grid)),this.mainGrid.showSelector=!0,this.mainGrid.fixedCols=1,this.mainGrid.onCellEnter=t=>this.cellEnter(t),this.mainGrid.onColumnResize=(t,e)=>{},this.mainGrid.onSelect=t=>{if(!this.files)return[];this.$emit("select",this.files.filter(((e,i)=>-1!==t.indexOf(i))))},this.mainGrid.onColumnSort=(t,e)=>this.gridSort(t),this.mainGrid.setColumns(this.getStructure())},cellEnter(t){this.mainGrid.columns[t[0]];var e=this.mainGrid.data[t[1]];this.$emit("enter",e)},selectAll(t){this.mainGrid.selectAll(t)},getStructure(){console.log("curFolder",this.curFolder);let t=[];if(t.push({name:"BTN_DOWNLOAD",width:90,renderer:(t,e,i,r)=>{var l='<i class="uk-icon-download"></i> Скачать';"dir"===e.DOC_TYPE&&(l='<i class="uk-icon-folder-open-o"></i> Открыть'),i.html('<button type="button" class="uk-button uk-button-primary uk-width-1-1">'+l+"</button>"),i.find("button").on("click",(t=>{t.preventDefault(),this.$emit("enter",e)}))}}),t.push({title:"Имя файла",name:"DOC_NAME",width:200,resizable:!0,sortable:!0,renderer:(t,e,i,r)=>{let l='<i class="far fa-file-alt"></i>';"dir"===e.DOC_TYPE&&(l='<i class="far fa-folder"></i>'),i.html('<div class="cara-table-content-cell--title">'+l+" "+e.DOC_NAME+"</div>")}}),this.showPath&&t.push({title:"Путь к файлу",name:"DOC_PATH",width:150,resizable:!0,sortable:!0,renderer:(t,e,i,r)=>{i.html('<div class="cara-table-content-cell--title">'+(0,a.A)(e.DOC_PATH||"")+"</div>")}}),t.push({title:"Описание",name:"DOC_DESCR",width:200,resizable:!0}),t.push({name:"BTN_EDIT",width:40,renderer:(t,e,i,r)=>{e.EDIT&&(i.html('<button type="button" class="uk-button uk-button-primary uk-width-1-1"><i class="fas fa-pencil-alt"></i></button></div>'),i.find("button").on("click",(()=>{this.$emit("edit",e)})))}}),t.push({title:"Размер",name:"FILE_SIZE",width:100,sortable:!0,renderer:function(t,e,i,r){if("dir"!==e.DOC_TYPE){let t=isNaN(e.FILE_SIZE)?"—":(0,s.A)(e.FILE_SIZE);i.html('<div class="cara-table-content-cell--title">'+t+"</div>")}}}),t.push({title:"Дата изменения",name:"EVENT_DATE",width:130,sortable:!0,renderer:function(t,e,i,r){i.html('<div class="cara-table-content-cell--title">'+(e["EVENT_DATE"]?d()(e["EVENT_DATE"]).format("DD.MM.YYYY HH:mm"):"-")+"</div>")}}),t.push({title:"Запись",name:"EDIT",width:55,sortable:!0,renderer:u}),t.push({title:"Доступы",name:"ACCESS",width:55,sortable:!0,renderer:u}),this.order){let e=t.find((t=>t.name===this.order.name));e&&(e.order=this.order.desc?"down":"up")}return t},gridSort(t){console.log("gridSort",t.order),t.order?this.$emit("sort-change",{name:t.name,desc:"down"===t.order}):this.$emit("sort-change",null)}}};function u(t,e,i){var r="";e[t.name]&&(r='<div class="cara-table-content-cell--title" style="text-align:center"><i class="fas fa-check"></i></div>'),i.html(r)}var m=c,f=i(1656),b=(0,f.A)(m,r,l,!1,null,null,null),p=b.exports}}]);
//# sourceMappingURL=FilesGrid.2a9a4c2b.js.map