"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[284],{1816:function(t,e,a){a.r(e),a.d(e,{default:function(){return m}});var n=function(){var t=this,e=t._self._c;return e("Modal",{ref:"modal",attrs:{title:t.action.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("Отмена")]),e("button",{staticClass:"uk-margin-small-left uk-button uk-button-primary",attrs:{disabled:t.loading,type:"button"},domProps:{textContent:t._s(t.loading?"Выполняется...":"Выполнить")},on:{click:function(e){return e.preventDefault(),t.submitAction.apply(null,arguments)}}})])])},l=[],s=a(3216),i=a(2643),o=a(4041)["A"],r={name:"ModalAction",components:{Modal:()=>a.e(8362).then(a.bind(a,2215)),Loader:()=>a.e(8326).then(a.bind(a,1259)),ActionParamList:()=>a.e(492).then(a.bind(a,6897))},props:{documentIds:{type:Array,default:()=>[]},action:Object,params:Array,onBeforeAction:{type:Function,default:()=>null},cardId:{type:Number,default:()=>null}},data(){return{values:[],loading:!0,actionResult:!1}},computed:{resultParams(){let t=[];return this.values.forEach((e=>{if(!e.value)return;let a=null;a="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:a})})),t},resultGetParams(){return this.resultParams.reduce(((t,e)=>t+"&"+e.name+"="+encodeURIComponent(e.value)),"")}},async mounted(){this.loading=!1},methods:{closed(){this.actionResult?this.$emit("submit"):this.$emit("closed")},async submitAction(){this.loading=!0,this.onBeforeAction&&await this.onBeforeAction();let t=this.resultParams.map((t=>t.name+"|"+t.value)).join(";"),e=null;try{e=await s.vd.query("CRM_SET_DOCS_PARAM_ACTION4_CS",{DOCLIST:this.documentIds.join(","),BP_ACTION_ID:this.action.ID,PARAM_LIST:t,CARD_ID:this.cardId})}catch(a){e={ERRMESS:(0,i.CS)(a)}}if(this.loading=!1,this.actionResult=!0,e.not_nulls&&(e.NOT_NULLS=e.not_nulls),e.errmess&&(e.ERRMESS=e.errmess),e.ERRMESS){let t=e.ERRMESS.replace(/(?:\r\n|\r|\n)/g,"<br/>");o.alert(t)}if(e.NOT_NULLS){let t=null;try{t=JSON.parse(e.NOT_NULLS)}catch(a){console.error("NotNull parse",a,e.NOT_NULLS)}t&&this.$emit("mark-null-fields",t)}this.$refs.modal.close()}}},u=r,c=a(1656),d=(0,c.A)(u,n,l,!1,null,null,null),m=d.exports}}]);
//# sourceMappingURL=ModalAction.c50a00c1.js.map