"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[8237],{3077:function(t,e,s){s.r(e),s.d(e,{default:function(){return f}});var i=function(){var t=this,e=t._self._c;return e("div",{ref:"grid",staticStyle:{flex:"1","min-height":"1px",display:"flex"}})},r=[],a=s(3216),n=s(2158),o=s(6182),h=s(5512),l=s(6587),c={name:"ExportDataGrid",components:{},props:{xmlColumns:String,xmlFilter:String,fetchCount:{type:Number,default:50}},data(){return{columnsRaw:[],columns:[],sort:null,fetching:!1,curOffset:0}},watch:{async xmlColumns(){await this.reloadStruct(),await this.reload()},async xmlFilter(){await this.reload()}},created(){},async mounted(){this.grid=new n.A(l(this.$refs.grid)),this.grid.onCellEnter=(t,e,s)=>{h.A.openDocument(s.DOCUMENT_ID)},this.grid.onColumnSort=t=>{this.gridSort(t)},this.grid.onStartFetcher=()=>{this.fetch()},await this.reloadStruct(),await this.reload()},beforeDestroy(){this.grid.destroy()},methods:{async reloadStruct(){this.columnsRaw=await a.vd.select("CRM_GET_XML_DOCQUERY_FIELDS_CS",{XML:this.xmlColumns},1e3),this.columns=this.columnsRaw.map((t=>({name:t.NAME_FIELD,title:t.DESCR_FIELD,resizable:!0,sortable:!0,width:100}))),this.grid.setColumns(this.columns),this.sort=null},async reload(){console.log("reload"),this.curOffset=0,this.grid.showFetcher=!0,this.grid.setData([]),this.fetching=!1},async fetch(){if(this.fetching)return;this.fetching=!0;let t=await(0,o.A)(this.columnsRaw,this.xmlColumns,this.xmlFilter,this.sort,this.fetchCount,this.curOffset);this.curOffset+=this.fetchCount,console.log("fetch",t),this.grid.showFetcher=t.length>=this.fetchCount,this.grid.insertData(this.grid.data.length,t),this.fetching=!1},gridSort(t){console.log("gridSort",t.order),"up"===t.order?this.sort=t.name+" ASC":"down"===t.order?this.sort=t.name+" DESC":this.sort=null,this.reload()}},computed:{}},u=c,d=s(1656),m=(0,d.A)(u,i,r,!1,null,null,null),f=m.exports},6182:function(t,e,s){s.d(e,{A:function(){return o}});var i=s(9148),r=s.n(i),a=s(3216);function n(t,e){return r()(t,"DD.MM.YYYY HH:mm:ss").format(e)}async function o(t,e,s,i,r,o){let h=await a.vd.select("CRM_GET_VALUE_DATA_SEARCH_X_CS",{XML_FILTER:s,XML_VALUES:e,ORDER_BY:i},r,o);for(let a of h)for(let e of t){let t=a[e.NAME_FIELD];if(t){switch(e.TYPE_DESCR_FIELD){case"phone":t=t.split("^"),t="+"+t[0]+" ("+t[1]+") "+t[2];break;case"date":t=n(t,"DD.MM.YYYY");break;case"dateTime":t=n(t,"DD.MM.YYYY HH:mm");break;case"dateTimeSec":t=n(t,"DD.MM.YYYY HH:mm:ss");break;case"time":t=n(t,"HH:mm:ss");break;case"hourMinutes":t=n(t,"HH:mm");break;case"monthYear":t=n(t,"MM.YYYY");break}a[e.NAME_FIELD]=t}}return h}}}]);
//# sourceMappingURL=ExportDataGrid.17b8922a.js.map