"use strict";(self.webpackChunkmodule_bz=self.webpackChunkmodule_bz||[]).push([[544],{3544:(e,t,n)=>{n.r(t),n.d(t,{default:()=>C});var o,l,a,r,i=n(1504);class s extends i.Component{constructor(e){super(e),this.state={loading:!0,data:null,selected:null}}}o=s,a=void 0,(l="symbol"==typeof(r=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,"string");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(l="defaultProps"))?r:String(r))in o?Object.defineProperty(o,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[l]=a,s.defaultProps={isJustView:!1};var m=n(7888),c=n(9544),p=n(2400),d=n(3440),u=n(392),f=n(500),h=n(2168),g=n(408),E=n(760),b=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 o=n.call(e,"string");if("object"!=typeof o)return o;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),o=[];for(let l of n)o=o.concat(t.state.data.base[l].directors.map((function(e){return e.id})),t.state.data.base[l].employees.map((function(e){return e.id}))),e?localStorage.setItem(t.getDepartmentKey(l),"1"):localStorage.removeItem(t.getDepartmentKey(l));for(let n of o)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(d.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,o=t.isOpenedPost(e.id),l=t.state.selected==e;return n&&e.emp&&e.emp.archive?null:i.createElement("div",{key:e.id,className:"department_post"+(o?" opened":"")+(l?" 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(d.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:"",o=t.emp?t.emp.name:"";return n==o?0:n>o?1:-1})),y(this,"renderDepartment",(function(e){let{data:n}=t.state,{isJustView:o}=t.props,l=n.base[e],a=t.isOpened(e);return i.createElement("div",{key:e,className:"department"+(a?" 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"},a?"expand_less":"navigate_next"),i.createElement("span",null,i.createElement("b",null,l.title))),o?null:i.createElement(d.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")))),a?i.createElement("div",{className:"posts"},l.directors?i.createElement(i.Fragment,null,l.directors.sort(t.sortEmp).map(t.renderPost.bind(t))):null,l.employees?i.createElement(i.Fragment,null,l.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,o){let l=e.inputs.children,a=e.inputs.has_children;l.setVisible(1==a.getValue())}))}componentDidMount(){this.refresh()}selectPost(e){this.props.isJustView&&this.setState({selected:e})}render(){var e=this;let{loading:t,data:n,selected:o}=this.state,{isJustView:l}=this.props,a=i.createElement(i.Fragment,null,i.createElement("div",{className:"f jc_sb mb_small"},i.createElement("div",{className:"merakomis_title mb0"},"Структура компании"),i.createElement(d.J,{mt:"mt0"},l?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:g.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(b.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 l?i.createElement("div",{id:"company_structure_modal"},i.createElement(u.Card,null,i.createElement(u.Row,null,i.createElement(u.Col,{all:"c-37",laptop:"c-100"},a),i.createElement(u.Col,{all:"c-63",laptop:"c-100"},null==o||null==o.emp?null:i.createElement(v.default,{key:o.emp.id.toString(),id:o.emp.id.toString()}))))):i.createElement(f.Scrollbar,{className:"form_content"},i.createElement("div",{ref:function(t){return e.wrap=t}},i.createElement(u.Card,null,i.createElement(u.Row,null,i.createElement(u.Col,{all:"c-37",laptop:"c-100"},i.createElement(u.Sheet,null,i.createElement(u.Body,null,i.createElement(u.Content,null,a)))),i.createElement(u.Col,{all:"c-63",laptop:"c-100"},i.createElement(h.c,{key:Date.now(),margin:!1,entity:"emp",onRef:function(t){e.table=t},checkable:!1,ajaxData:{mini:1},custom_filter_switcher:E.A.getCustomTableSwitcher(),renderTitle:E.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,o,l){let a=n.column.split("_").pop();return["name"].indexOf(a)>=0&&(l=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(a)>=0&&(l=E.A.makeCopyTD(l,t)),i.createElement(i.Fragment,null,l)}}))))))}}}}]);