"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[7933],{3629:function(t,e,s){s.r(e),s.d(e,{default:function(){return p}});var o=function(){var t=this,e=t._self._c;return!t.loaded||t.reports.length>0?e("ButtonMenu",{attrs:{title:"Отчеты",dropdownTitle:"Выберите отчет",icon:'<img src="img/icons/icon__reports.svg" uk-svg width="16" height="16" style="margin-top: -3px">',showArrow:!0,buttonClasses:t.buttonClasses,showListIcons:!1,items:t.menuItems,disabled:!t.loaded},on:{select:function(e){return t.runReport(e.report)}}},[t.openedReport?e("modal-action-params",{attrs:{documentIds:t.documentIds,action:t.openedReport,params:t.openedReportParams,isReport:!0},on:{closed:function(e){t.openedReport=null}}}):t._e()],1):t._e()},r=[],n=s(3216),d=(s(5864),s(2779)),a={name:"DocumentReports",components:{ButtonMenu:()=>s.e(2466).then(s.bind(s,6433)),ModalActionParams:()=>s.e(4726).then(s.bind(s,8150))},props:{documentIds:{type:Array,default(){return[]}},successClass:{type:Boolean,default:!1},defaultReports:{type:Array,default(){return[]}}},data(){return{loaded:!1,reports:[],openedReport:null,openedReportParams:null}},computed:{buttonClasses(){let t=["uk-button","uk-button-small"];return this.successClass&&t.push("uk-button-success"),t},menuItems(){return this.reports.map((t=>({id:t.ID,title:t.NAME,descr:t.DESCR,report:t})))},docIdsStr(){return this.documentIds.join(",")}},watch:{documentIds(){this.load()}},created(){this.load()},methods:{async load(){if(0===this.documentIds.length)return this.loaded=!0,void(this.reports=this.defaultReports);this.loaded=!1;let t=await Promise.all([n.vd.select("CRM_GET_SINGLE_REPORTS_CS",{DOCS:this.docIdsStr},1e3)]);this.reports=t[0],this.loaded=!0},async runReport(t){if(d.dropdown(this.$refs.dropdown).hide(!1),"EXPORT"===t.REPORT_TYPE)return void this.$emit("export-table",t.ID);let e=await n.vd.select("CRM_GET_REPORT_PARAMS_CS",{REPORT_ID:t.ID},1e3);this.openedReport=t,this.openedReportParams=e}}},u=a,i=s(1656),l=(0,i.A)(u,o,r,!1,null,null,null),p=l.exports}}]);
//# sourceMappingURL=DocumentReports.e16bc7f1.js.map