"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[5820],{3322:function(e,t,i){function l(e){if(!e)return e;var t,i=[Number,String,Boolean];if(i.forEach((function(i){e instanceof i&&(t=i(e))})),"undefined"==typeof t)if("[object Array]"===Object.prototype.toString.call(e))t=[],e.forEach((function(e,i,n){t[i]=l(e)}));else if("object"==typeof e)if(e.nodeType&&"function"==typeof e.cloneNode)t=e.cloneNode(!0);else if(e.prototype)t=e;else if(e instanceof Date)t=new Date(e);else for(var n in t={},e)t[n]=l(e[n]);else t=e;return t}i.d(t,{A:function(){return l}})},6852:function(e,t,i){i.r(t),i.d(t,{default:function(){return k}});var l=function(){var e=this,t=e._self._c;return e.loaded&&!e.inline?t(e.fieldComponent,{ref:"editor",tag:"component",attrs:{field:e.field,value:e.value},on:{close:function(t){return e.$emit("close")},change:e.change}}):e.loaded&&e.inline?t("inline-modal",{ref:"editor",attrs:{fieldComponent:e.fieldComponent,field:e.field,value:e.value},on:{close:function(t){return e.$emit("close")},change:e.change}}):e._e()},n=[],s=i(3216),o=function(){var e=this,t=e._self._c;return t("div",{attrs:{"uk-modal":""}},[t("div",{staticClass:"uk-modal-dialog uk-flex uk-flex-column"},[t("h4",{staticClass:"uk-modal-header uk-margin-remove"},[t("button",{staticClass:"uk-modal-close-default",attrs:{type:"button","uk-close":""}}),e._v(" "+e._s(e.field.DOCPROP_NAME)+" ")]),t("div",{staticClass:"uk-padding-small"},[t(e.fieldComponent,{ref:"editor",tag:"component",attrs:{field:e.field,value:e.value},on:{close:e.hide,change:e.change}})],1),t("div",{},[t("div",{staticClass:"uk-text-small uk-text-muted uk-margin-small-left"},[e._v(' "ESC" - отмена, "ENTER" - сохранить ')]),t("div",{staticClass:"uk-padding-small uk-text-center"},[e._m(0),t("button",{staticClass:"uk-button uk-button-primary uk-margin-small-left",on:{click:function(t){return e.$refs.editor.save()}}},[t("i",{staticClass:"uk-icon-floppy-o"}),e._v(" Применить ")])])])])])},a=[function(){var e=this,t=e._self._c;return t("button",{staticClass:"uk-modal-close uk-button"},[t("i",{staticClass:"uk-icon-close"}),e._v(" Отмена ")])}],u=i(2779),c={name:"InlineModal",components:{},props:{field:Object,fieldComponent:Function,value:{type:[String,Array],default:null}},data(){return{saving:!1,newValue:""}},mounted(){u.util.on(this.$el,"shown",(()=>{})),u.util.on(this.$el,"hidden",(()=>{this.saving?this.$emit("change",this.newValue):this.$emit("close")})),u.modal(this.$el).show()},methods:{change(e){this.saving=!0,this.newValue=e,u.modal(this.$el).hide()},hide(){u.modal(this.$el).hide()}}},d=c,r=i(1656),f=(0,r.A)(d,o,a,!1,null,null,null),h=f.exports,m=i(3322),p={name:"MassEditor",components:{InlineModal:h},props:{},data(){return{field:null,documentIds:null,loaded:!1,inline:!1,fieldComponent:null,value:null}},created(){this.fields=null},methods:{async open(e,t){this.fields||(this.fields=await i.e(6756).then(i.bind(i,6104)),this.fields=this.fields.default),e.DOCPROP_MULTI=e.DOCPROP_MULTI||e.MULTI;let l=this.fields.getDataType(e);console.log("!!!mass",e.DOCPROP_MULTI,l,e,this.field),this.field!==e&&(this.value="document"===l?[]:null),this.loaded=!1,await this.$nextTick(),this.field=e,this.documentIds=t;let n=this.fields.getComponent(this.field);if(console.log("component",n),!n.component)throw this.$emit("close"),"Тип данных не реализован";this.fieldComponent=n.component,this.inline=n.inline,this.loaded=!0},async change(e){try{this.$emit("block",!0),this.value=e.value;let t=[],i={};this.documentIds.forEach((l=>{let n=(0,m.A)(this.field);n.DOCUMENT_ID=l,n.DOCPROP_DESCR=n.PROP_SYS_NAME.substring(3),console.log("saveValue",n,e);let o=async()=>{try{let t=await this.fields.checkPermission(n);if(!t)return void(i[l]="readonly");await this.fields.saveValue(n,e.value,l),await s.FH.cards.transactionCommit(l),i[l]=null}catch(t){let e=t;"object"===typeof t&&(e=t.Message),i[l]=e}};t.push(o())})),await Promise.all(t),console.log("mass edit results",i),this.$emit("block",!1),this.$emit("change",i)}catch(t){throw this.$emit("block",!1),t}}}},v=p,g=(0,r.A)(v,l,n,!1,null,null,null),k=g.exports}}]);
//# sourceMappingURL=MassEditor.5d6ea3e4.js.map