"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[1236],{1068:function(t,n,e){e.r(n),e.d(n,{default:function(){return A}});var o=function(){var t=this,n=t._self._c;return t.openedAction?n("modal-action-params",{attrs:{documentIds:t.documentIds,action:t.openedAction,params:t.openedActionParams,isReport:!1,cardId:t.cardId,onBeforeAction:t.onBeforeAction},on:{closed:function(n){t.openedAction=null},submit:function(n){return t.$emit("reload")},"mark-nulls":function(n){return t.$emit("mark-null-fields",n)}}}):t._e()},i=[],r=e(3216),s=e(2643),a=e(2779),d=e(4041)["A"],l={name:"DocumentActionsModel",components:{ModalActionParams:()=>e.e(4726).then(e.bind(e,8150))},props:{documentIds:{type:Array,default:()=>[]},defaultActions:{type:Array,default:()=>[]},onBeforeAction:{type:Function,default:()=>null},cardId:{type:Number,default:()=>null}},data(){return{loaded:!1,running:!1,actions:[],openedAction:null,openedActionParams:null}},computed:{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.actions=this.defaultActions);this.loaded=!1;let t=await Promise.all([r.vd.select("CRM_GET_DOCS_BP_ACTIONS_CS",{ID_LIST:this.docIdsStr},1e3)]);this.actions=t[0],this.loaded=!0},async runAction(t){a.dropdown(this.$refs.dropdown).hide(!1),this.running=!0;let n=await r.vd.select("CRM_GET_ACTION_PARAMS_CS",{ACTION_ID:t.ID},1e3);n.length>0?(this.running=!1,this.openedAction=t,this.openedActionParams=n):await this.runActionsSimple(this.documentIds,t)},async runActionsSimple(t,n){this.running=!0;try{this.onBeforeAction&&await this.onBeforeAction();let o=null;try{o=await r.vd.query("CRM_SET_DOCS_PARAM_ACTION4_CS",{DOCLIST:t.join(","),BP_ACTION_ID:n.ID,PARAM_LIST:"",CARD_ID:this.cardId},1),o.not_nulls&&(o.NOT_NULLS=o.not_nulls),o.errmess&&(o.ERRMESS=o.errmess)}catch(e){o={ERRMESS:(0,s.CS)(e)}}if(o.NOT_NULLS){let t=null;try{t=JSON.parse(o.NOT_NULLS)}catch(e){console.error("NotNull parse",e,o.NOT_NULLS)}t&&this.$emit("mark-null-fields",t)}if(o.ERRMESS){let t=o.ERRMESS.replace(/(?:\r\n|\r|\n)/g,"<br/>");d.alert(t)}}finally{this.running=!1,this.$emit("reload")}}}},c=l,u=e(1656),h=(0,u.A)(c,o,i,!1,null,null,null),A=h.exports}}]);
//# sourceMappingURL=DocumentActionsModel.35f50e70.js.map