"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[4637],{9030:function(t,e,r){r.r(e),r.d(e,{default:function(){return d}});var o=function(){var t=this,e=t._self._c;return e("Modal",{ref:"modal",attrs:{title:t.report.NAME,autoOpen:!0},on:{closed:t.closed}},[t.loading?e("div",{staticStyle:{position:"relative",height:"200px"}},[e("loader")],1):e("div",{staticClass:"uk-padding-small",staticStyle:{"flex-grow":"1","min-height":"1px",position:"relative"}},[e("ActionParamList",{attrs:{params:t.params},on:{init:function(e){t.values=e},change:function(e){t.values=e}}})],1),e("div",{staticClass:"uk-text-center uk-padding-small"},[e("button",{staticClass:"uk-button uk-modal-close",attrs:{type:"button"}},[t._v("Отмена")]),t.reportLinks?t._l(t.reportLinks,(function(r){return e("button",{key:r.format,staticClass:"uk-button uk-button-primary uk-margin-small-left",attrs:{disabled:t.loading,type:"button"},on:{click:function(e){return e.preventDefault(),t.openFastReport(r.format)}}},[t._v(t._s(r.name))])})):e("button",{staticClass:"uk-margin-small-left uk-button uk-button-primary",attrs:{disabled:t.loading,type:"button"},on:{click:function(e){return e.preventDefault(),t.submitReport.apply(null,arguments)}}},[t._v("Запустить")])],2)])},a=[],s=r(3216),n=(r(2643),r(9148)),l=r(4041)["A"],i={name:"ModalReportAppserv",components:{Modal:()=>r.e(8362).then(r.bind(r,2215)),Loader:()=>r.e(8326).then(r.bind(r,1259)),ActionParamList:()=>r.e(492).then(r.bind(r,6897))},props:{documentIds:{type:Array,default:()=>[]},report:Object,params:Array},data(){return{values:[],loading:!0,actionResult:!1}},computed:{reportLinks(){return this.report.IS_JOB||-1===this.report.RESULT_TYPE.indexOf("FASTREPORT")?null:[{name:"Просмотр",format:"html"},{name:"Word",format:"rtf"},{name:"Excel",format:"xls"},{name:"PDF",format:"pdf"}]},resultParams(){let t=[];return this.values.forEach((e=>{if(!e.value)return;let r=null;r="document"===e.dataType?e.value.map((t=>t.DOCUMENT_ID)).join(","):"multi"===e.dataType?e.value.join(","):e.value,t.push({name:e.param.PARAM_NAME,value:r})})),t},resultGetParams(){return this.resultParams.reduce(((t,e)=>t+"&"+e.name+"="+encodeURIComponent(e.value)),"")}},async mounted(){this.loading=!1},methods:{closed(){this.$emit("closed")},async submitReport(){this.report.IS_JOB?(this.loading=!0,await this.submitDelayedReport(),this.loading=!1):this.openNewReport()},openNewReport(){const t={TABLE:"rawxml",EXCEL:"rawxml",HTML:"html",ACCESS:"access"};if(!t[this.report.RESULT_TYPE])throw new Error("Неизвестный RESULT_TYPE отчета: "+this.report.RESULT_TYPE);let e=s.$W.reporter+"report/get?token="+s.FH.token+"&report="+this.report.ID+"&format="+t[this.report.RESULT_TYPE];this.documentIds.length>0&&(e+="&SN="+this.documentIds.join(",")),e+=this.resultGetParams,e+="&DAT="+n().format("DDMMYYYYHHmmss"),console.log("ReportUrl",e),window.open(e,"_blank").focus(),this.$refs.modal.close()},async submitDelayedReport(){if(!s.FH.appserver)throw new Error("Not implemented without appserv");await s.FH.appserver.serverHttp("report/runDelayed",{token:s.FH.token,report_id:this.report.ID,params:this.resultParams}),l.notify("Формирование отчета запущено","success"),this.$refs.modal.close()},openFastReport(t){let e=-1===this.report.RESULT_TYPE.indexOf("FASTREPORT2"),r=e?s.$W.oldReporter+"result":s.$W.reporter+"report/get";r+="?token="+s.FH.token+"&report="+this.report.ID+"&format="+t,this.documentIds.length>0&&(r+="&SN="+this.documentIds.join(",")),r+=this.resultGetParams,r+="&DAT="+n().format("DDMMYYYYHHmmss"),console.log("oldReportUrl",r),window.open(r,"_blank").focus(),this.$refs.modal.close()}}},u=i,p=r(1656),m=(0,p.A)(u,o,a,!1,null,null,null),d=m.exports}}]);
//# sourceMappingURL=ModalReportAppserv.0a34b64a.js.map