"use strict";(self["webpackChunkcarabi_x2"]=self["webpackChunkcarabi_x2"]||[]).push([[7737],{5227:function(e,t,s){s.r(t),s.d(t,{default:function(){return u}});var a=function(){var e=this,t=e._self._c;return t("Modal",{ref:"modal",attrs:{title:"Изменение доступа",autoOpen:!0,fullHeight:!0,large:!1},on:{closed:function(t){return e.$emit("closed")}}},[e.loaded?t("div",{staticClass:"flex-grow flex-column"},[t("ul",{staticClass:"uk-tab",staticStyle:{"margin-bottom":"0"}},[t("li",{class:{"uk-active":0===e.curTab}},[t("a",{attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.curTab=0}}},[e._v("Пользователи")])]),t("li",{class:{"uk-active":1===e.curTab}},[t("a",{attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.curTab=1}}},[e._v("Роли")])])]),t("PermissionsPanel",{directives:[{name:"show",rawName:"v-show",value:0===e.curTab,expression:"curTab === 0"}],attrs:{items:e.users,type:"users"}}),t("PermissionsPanel",{directives:[{name:"show",rawName:"v-show",value:1===e.curTab,expression:"curTab === 1"}],attrs:{items:e.roles,type:"roles"}}),t("div",{staticClass:"uk-modal-footer uk-text-center"},[t("button",{staticClass:"uk-button uk-modal-close uk-border-rounded",attrs:{type:"button"}},[e._v("Отмена")]),t("button",{staticClass:"js-save uk-button uk-button-primary uk-border-rounded",attrs:{disabled:e.saving,type:"button"},on:{click:e.save}},[e._v("Сохранить")])])],1):t("div",{staticClass:"flex-grow",staticStyle:{position:"relative"}},[t("loader")],1)])},i=[],r=s(3216),o={name:"Permissions",components:{Loader:()=>s.e(8326).then(s.bind(s,1259)),Modal:()=>s.e(8362).then(s.bind(s,2215)),PermissionsPanel:()=>Promise.all([s.e(3672),s.e(7105)]).then(s.bind(s,3106))},props:{ids:Array},data:()=>({loaded:!1,saving:!1,curTab:0,users:null,roles:null}),computed:{},async created(){let e=this.ids.join(","),t=await Promise.all([r.vd.select("CRM_GET_USER_ACCESS_LIST_CS",{doc_list:e},1e3),r.vd.select("CRM_GET_ROLE_ACCESS_LIST_CS",{doc_list:e},1e3)]);this.users=t[0].map((e=>({...e,ITEM_ID:e.CT_ITEM_ID,context:(e.FIO+" "+e.PODR_NAME).toLowerCase(),changed:!1}))),this.roles=t[1].map((e=>({...e,ITEM_ID:e.ROLE_ID,context:(e.ROLE_NAME+" "+e.ROLE_SYS_NAME).toLowerCase(),changed:!1}))),this.loaded=!0},methods:{async save(){if(!this.saving){this.saving=!0;try{let e=this.ids.join(","),t=this.users.filter((e=>e.changed)).map((e=>e.ITEM_ID+"|"+e.READ+"|"+e.EDIT+"|"+e.ACCESS)).join(","),s=this.roles.filter((e=>e.changed)).map((e=>e.ITEM_ID+"|"+e.READ+"|"+e.EDIT+"|"+e.ACCESS)).join(",");await r.vd.query("CRM_SET_DOC_ACCESS_2_CS",{doc_list:e,user_list:t,role_list:s})}catch(e){throw this.saving=!1,e}this.saving=!1,this.$emit("change"),this.$refs.modal.close()}}}},l=o,n=s(1656),c=(0,n.A)(l,a,i,!1,null,null,null),u=c.exports}}]);
//# sourceMappingURL=Permissions.539f1ef5.js.map