"use strict";(self.webpackChunkmodule_bz=self.webpackChunkmodule_bz||[]).push([[136,544],{3544:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var a,o,l,r,i=n(1504);class s extends i.Component{constructor(e){super(e),this.state={loading:!0,data:null,selected:null}}}a=s,l=void 0,(o="symbol"==typeof(r=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o="defaultProps"))?r:String(r))in a?Object.defineProperty(a,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):a[o]=l,s.defaultProps={isJustView:!1};var m=n(7888),c=n(9544),p=n(2400),u=n(3440),d=n(392),f=n(500),b=n(2168),h=n(408),g=n(760),E=n(2480),v=n(5496),_=n(6904);function y(e,t,n){return t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class C extends s{constructor(...e){var t;super(...e),t=this,y(this,"wrap",void 0),y(this,"drop",void 0),y(this,"table",void 0),y(this,"getDepartmentKey",(function(e){return"department"+e})),y(this,"isOpened",(function(e){return"1"==localStorage.getItem(t.getDepartmentKey(e))})),y(this,"openDepartment",(function(e){localStorage.setItem(t.getDepartmentKey(e),"1"),t.forceUpdate()})),y(this,"closeDepartment",(function(e){localStorage.removeItem(t.getDepartmentKey(e)),t.forceUpdate()})),y(this,"toggleDepartment",(function(e){t.isOpened(e)?t.closeDepartment(e):t.openDepartment(e)})),y(this,"getPostKey",(function(e){return"post"+e})),y(this,"isOpenedPost",(function(e){return"1"==localStorage.getItem(t.getPostKey(e))})),y(this,"openPost",(function(e){localStorage.setItem(t.getPostKey(e),"1"),t.forceUpdate()})),y(this,"closePost",(function(e){localStorage.removeItem(t.getPostKey(e)),t.forceUpdate()})),y(this,"togglePost",(function(e){t.isOpenedPost(e)?t.closePost(e):t.openPost(e)})),y(this,"setOpenedAll",(function(e){let n=Object.keys(t.state.data.base),a=[];for(let o of n)a=a.concat(t.state.data.base[o].directors.map((function(e){return e.id})),t.state.data.base[o].employees.map((function(e){return e.id}))),e?localStorage.setItem(t.getDepartmentKey(o),"1"):localStorage.removeItem(t.getDepartmentKey(o));for(let n of a)e?localStorage.setItem(t.getPostKey(n),"1"):localStorage.removeItem(t.getPostKey(n));t.drop.close(),t.forceUpdate()})),y(this,"openAll",(function(){t.setOpenedAll(!0)})),y(this,"closeAll",(function(){t.setOpenedAll(!1)})),y(this,"refresh",(function(){m.API.requestTheme(".dictionary.department/getStructure",{},(function(e,n){t.setState({data:e,loading:!1})}))})),y(this,"openForm",(function(e=0){let n=t;p.G.openForm("dictionary.department",{parent:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"openEditForm",(function(e){let n=t;p.G.openForm("dictionary.department",{id:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"remove",(function(e){p.G.showConfirm("Вы уверены, что хотите удалить отдел и должность и роли связанные с ним?",(function(){m.API.requestTheme(".dictionary.department/remove",{id:e},t.refresh.bind(t))}))})),y(this,"openAddPostForm",(function(e=0){let n=t;p.G.openForm("post",{department:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"openEditPostForm",(function(e){let n=t;p.G.openForm("post",{id:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"openAddRoleForm",(function(e=0){let n=t;p.G.openForm("emp.role",{post:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"removePost",(function(e){p.G.showConfirm("Вы уверены, что хотите удалить должность и роли связанные с ней?",(function(){m.API.requestTheme(".post/remove",{id:e},t.refresh.bind(t))}))})),y(this,"openEmp",(function(e=0){let n=t;p.G.openForm("emp",{id:e},{onSubmit(){p.G.closeTopModal(),n.refresh()},getCustomInput:p.G.app.props.getCustomInput,footerClassName:"dn"})})),y(this,"removeRole",(function(e){m.API.requestTheme(".emp.role/remove",{id:e},t.refresh.bind(t))})),y(this,"renderRole",(function(e){return i.createElement("div",{key:e.id,className:"department_role"},i.createElement("div",{className:"department_role_toggle",onClick:t.openEmp.bind(t,e.emp.id)},i.createElement("div",{className:"icon_wrap"},i.createElement("span",{className:"material-icons-outlined"},"person")),i.createElement("div",null,e.emp.name)),i.createElement(u.J,{mt:"mt0",mb:"mb0"},i.createElement("button",{onClick:t.removeRole.bind(t,e.id),className:"btn alt small only_icon mini_padding red "},i.createElement("span",{className:"material-icons-outlined"},"delete"))))})),y(this,"renderPost",(function(e){let{isJustView:n}=t.props,a=t.isOpenedPost(e.id),o=t.state.selected==e;return n&&e.emp&&e.emp.archive?null:i.createElement("div",{key:e.id,className:"department_post"+(a?" opened":"")+(o?" selected":"")},i.createElement("div",{className:"department_post_title"},i.createElement("div",{className:"department_post_title_toggle",onClick:function(){t.selectPost(e)}},i.createElement("div",{className:"icon_wrap"},e.is_director?i.createElement("span",{className:"material-icons-outlined"},"business_center"):i.createElement("span",{className:"material-icons-outlined"},"work_outline")),i.createElement("div",{className:"post_title"},i.createElement(_.C,{archive:e.emp.archive?1:0})," ",e.title," |",i.createElement("i",null,e.emp.staffing.join(", ")))),n?null:i.createElement(u.J,{mt:"mt0",mb:"mb0"},i.createElement("button",{onClick:t.openEditPostForm.bind(t,e.id),className:"btn alt small only_icon mini_padding blue "},i.createElement("span",{className:"material-icons-outlined"},"edit")),i.createElement("button",{onClick:t.removePost.bind(t,e.id),className:"btn alt small only_icon mini_padding red "},i.createElement("span",{className:"material-icons-outlined"},"delete")))))})),y(this,"sortEmp",(function(e,t){let n=e.emp?e.emp.name:"",a=t.emp?t.emp.name:"";return n==a?0:n>a?1:-1})),y(this,"renderDepartment",(function(e){let{data:n}=t.state,{isJustView:a}=t.props,o=n.base[e],l=t.isOpened(e);return i.createElement("div",{key:e,className:"department"+(l?" opened":"")},i.createElement("div",{className:"department_title"},i.createElement("div",{className:"department_title_toggle",onClick:t.toggleDepartment.bind(t,e)},i.createElement("span",{className:"material-icons-outlined"},l?"expand_less":"navigate_next"),i.createElement("span",null,i.createElement("b",null,o.title))),a?null:i.createElement(u.J,{mt:"mt0",mb:"mb0"},i.createElement(f.Tooltip,{content:i.createElement("div",{className:"tooltip_white"},"Добавить отдел")},i.createElement("button",{onClick:t.openForm.bind(t,e),className:"btn alt small only_icon mini_padding green "},i.createElement("span",{className:"material-icons-outlined"},"playlist_add"))),i.createElement(f.Tooltip,{content:i.createElement("div",{className:"tooltip_white"},"Добавить сотрудника")},i.createElement("button",{onClick:t.openAddPostForm.bind(t,e),className:"btn alt small only_icon mini_padding green "},i.createElement("span",{className:"material-icons-outlined"},"group_add"))),i.createElement("button",{onClick:t.openEditForm.bind(t,e),className:"btn alt small only_icon mini_padding blue "},i.createElement("span",{className:"material-icons-outlined"},"edit")),i.createElement("button",{onClick:t.remove.bind(t,e),className:"btn alt small only_icon mini_padding red "},i.createElement("span",{className:"material-icons-outlined"},"delete")))),l?i.createElement("div",{className:"posts"},o.directors?i.createElement(i.Fragment,null,o.directors.sort(t.sortEmp).map(t.renderPost.bind(t))):null,o.employees?i.createElement(i.Fragment,null,o.employees.sort(t.sortEmp).map(t.renderPost.bind(t))):null,n[e]?i.createElement(i.Fragment,null,n[e].map(t.renderDepartment.bind(t))):null):null)})),y(this,"onFormChange",(function(e,t,n,a){let o=e.inputs.children,l=e.inputs.has_children;o.setVisible(1==l.getValue())}))}componentDidMount(){this.refresh()}selectPost(e){this.props.isJustView&&this.setState({selected:e})}render(){var e=this;let{loading:t,data:n,selected:a}=this.state,{isJustView:o}=this.props,l=i.createElement(i.Fragment,null,i.createElement("div",{className:"f jc_sb mb_small"},i.createElement("div",{className:"merakomis_title mb0"},"Структура компании"),i.createElement(u.J,{mt:"mt0"},o?null:i.createElement("button",{onClick:this.openForm.bind(this,0),className:"btn green success"},"Добавить"),i.createElement(f.Drop,{ref:function(t){return e.drop=t},title:i.createElement("div",{className:"btn only_icon"},i.createElement("span",{className:"material-icons-outlined"},"more_vert")),horizontal:h.EHorizontalPosition.right,content:i.createElement("div",{className:"ava_drop_content"},i.createElement("div",{className:"li",onClick:this.openAll.bind(this)},"Развернуть все"),i.createElement("div",{className:"li",onClick:this.closeAll.bind(this)},"Свернуть все"))}))),i.createElement(E.c,{title:"structure_company_subtitle",text:"structure_company_text"}),t?i.createElement(c.c,null):i.createElement("div",null,n[0]?n[0].map(this.renderDepartment):null));return o?i.createElement("div",{id:"company_structure_modal"},i.createElement(d.Card,null,i.createElement(d.Row,null,i.createElement(d.Col,{all:"c-37",laptop:"c-100"},l),i.createElement(d.Col,{all:"c-63",laptop:"c-100"},null==a||null==a.emp?null:i.createElement(v.default,{key:a.emp.id.toString(),id:a.emp.id.toString()}))))):i.createElement(f.Scrollbar,{className:"form_content"},i.createElement("div",{ref:function(t){return e.wrap=t}},i.createElement(d.Card,null,i.createElement(d.Row,null,i.createElement(d.Col,{all:"c-37",laptop:"c-100"},i.createElement(d.Sheet,null,i.createElement(d.Body,null,i.createElement(d.Content,null,l)))),i.createElement(d.Col,{all:"c-63",laptop:"c-100"},i.createElement(b.c,{key:Date.now(),margin:!1,entity:"emp",onRef:function(t){e.table=t},checkable:!1,ajaxData:{mini:1},custom_filter_switcher:g.A.getCustomTableSwitcher(),renderTitle:g.A.renderTableTitle,search_placeholder:"Поиск по ФИО",customRowClick:function(e){},formOptions:{},onFormChange:this.onFormChange.bind(this),init_filter_values:p.G.app.state.options.company.emp.init_filter_values,renderTd:function(t,n,a,o){let l=n.column.split("_").pop();return["name"].indexOf(l)>=0&&(o=i.createElement(i.Fragment,null,i.createElement(_.C,{archive:t.archive}),i.createElement("span",{className:"link pointer",onClick:function(){p.G.openForm("emp",{id:t.id},{onSubmit:function(){e.table.reload()},getCustomInput:p.G.app.props.getCustomInput,onChange:e.onFormChange})}},t.name))),["phone","skype","email","login"].indexOf(l)>=0&&(o=g.A.makeCopyTD(o,t)),i.createElement(i.Fragment,null,o)}}))))))}}},5136:(e,t,n)=>{n.r(t),n.d(t,{default:()=>u});var a=n(1504),o=n(2168),l=n(760),r=n(500),i=n(9048),s=n(3544),m=n(2400),c=n(6904);function p(e,t,n){var a;return(t="symbol"==typeof(a=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,"string");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?a:String(a))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class u extends a.Component{constructor(...e){super(...e),p(this,"table",void 0),p(this,"openCompanyStructure",(function(){m.G.openStandardModal({header:"структура компании",footer:null,width:"100vw",content:a.createElement(s.default,{isJustView:!0}),className:"bg_white"})}))}render(){var e=this;return a.createElement(o.c,{key:Date.now(),entity:"emp",onRef:function(t){e.table=t},show_add_button:!1,show_download_button:!1,checkable:!1,ajaxData:{my_company:1},per_page:0,custom_filter_switcher:l.A.getCustomTableSwitcher(),renderTitle:l.A.renderTableTitle,search_placeholder:"Поиск по ФИО",customRowClick:function(e){},title_buttons:a.createElement("button",{className:"btn ",id:"btn_open_company",onClick:this.openCompanyStructure.bind(this)}),renderTd:function(e,t,n,o){let s=t.column.split("_").pop();return["absence"].indexOf(s)>=0&&(o=a.createElement(c.u,{name:e.name})),["image"].indexOf(s)>=0&&(o=(e=JSON.parse(e)).avatar?a.createElement(r.Tooltip,{position:i.EPosition.top,content:a.createElement("div",{className:"emp_avatar_tooltip"},a.createElement("img",{src:e.image}))},a.createElement("div",{className:"emp_avatar",style:{backgroundImage:"url("+e.avatar+")"}})):null),["name"].indexOf(s)>=0&&(o=a.createElement(a.Fragment,null,a.createElement(c.u,{name:e.absence}),a.createElement("span",{className:"link pointer",onClick:function(){l.A.openModalProfile(e.id)}},e.name))),["phone","skype","email","login"].indexOf(s)>=0&&(o=l.A.makeCopyTD(o,e)),a.createElement(a.Fragment,null,o)}})}}}}]);