diff --git a/pc4mobx/organization/components/fieldDefinedSet/AdvanceSearchFormInfo.js b/pc4mobx/organization/components/fieldDefinedSet/AdvanceSearchFormInfo.js new file mode 100644 index 0000000..8af9ca3 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/AdvanceSearchFormInfo.js @@ -0,0 +1,143 @@ +import React, { + Component +} from 'react'; +import { + Button, + Form, + Row, + Col +} from 'antd'; +import { + WeaFormItem, + WeaNewScroll, + WeaSearchGroup, +} from 'ecCom'; +import { + WeaSwitch +} from 'comsMobx'; +import _ from 'lodash'; + +export default class AdvanceSearchFormInfo extends Component { + renderForm = () => { + const { + form, + formFields, + itemRender + } = this.props; + let arr = []; + let formParams = form.getFormParams(); + formFields.map(c => { + let _arr = []; + c.items.map((field, index) => { + const customerRender = itemRender != null ? itemRender[field.domkey[0]] : null; + const itemProps = { + ratio1to2: true, + label: field.label, + labelCol: { + span: `${window.HrmEngineLabelCol}` + }, + error: form.getError(field), + tipPosition: 'bottom', + wrapperCol: { + span: `${window.HrmEngineWrapperCol}` + } + } + let coms; + if (customerRender == null) { + coms = ; + } else { + coms = customerRender(field, form, formParams); + } + coms != null && _arr.push( + ( + + + {coms} + + + ) + ) + if (_arr.length === 2 || index === c.items.length - 1) { + const clone = [..._arr]; + _arr.length = 0; + arr.push({clone}); + } + }) + }) + return
{arr}
; + } + + renderGroupForm = () => { + const { + form, + formFields, + itemRender + } = this.props; + let formParams = form.getFormParams(); + let arr = []; + formFields.map((c, i) => { + let _arr = []; + c.items.map((field, index) => { + const customerRender = itemRender != null ? itemRender[field.domkey[0]] : null; + const itemProps = { + ratio1to2: true, + label: field.label, + labelCol: { + span: `${window.HrmEngineLabelCol}` + }, + error: form.getError(field), + tipPosition: 'bottom', + wrapperCol: { + span: `${window.HrmEngineWrapperCol}` + } + } + let coms; + if (customerRender == null) { + coms = ; + } else { + coms = customerRender(field, form, formParams); + } + coms != null && _arr.push({ + com: ( + + {coms} + + ), + col: field.colSpan || 2 + }) + }) + arr.push(); + }) + return arr; + } + + renderFormComponent = () => { + const { + formFields + } = this.props; + + const com = formFields.length > 1 ? this.renderGroupForm() : this.renderForm(); + return com; + } + + render() { + return ( + + {this.renderGroupForm()} + + ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/EncryptSetting.js b/pc4mobx/organization/components/fieldDefinedSet/EncryptSetting.js new file mode 100644 index 0000000..57c0063 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/EncryptSetting.js @@ -0,0 +1,26 @@ +import React, {Component} from 'react'; +import {observer} from 'mobx-react'; +import { WeaDialog } from "ecCom"; +import Tip from './Tip'; +import FormInfo from './FormInfo'; + +@observer +export default class EncryptSetting extends Component{ + render(){ + const {store} = this.props; + const {encryptDialogProps, formTarget, encryptFormItemRender} = store; + const { + encryptForm, + encryptFormFields, + } = formTarget; + + return ( + + +
+ +
+
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js new file mode 100644 index 0000000..b5f613f --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js @@ -0,0 +1,178 @@ +import React, { + Component +} from 'react'; +import { + observer +} from 'mobx-react'; +import { + WeaRightMenu, + WeaTableEdit, + WeaDialog +} from 'ecCom'; +import classnames from 'classnames'; +import EncryptSetting from './EncryptSetting'; +import ViewRangeForm from './ViewRangeForm'; +import ViewRangeSetting from './ViewRangeSetting'; +import FormInfo from './FormInfo'; + +@observer +export default class FieldDef extends Component { + constructor(props) { + super(props); + this.state = { + resize: new Date().getTime() + } + } + + componentDidMount() { + window.addEventListener('resize', this.resizeHandle); + } + + componentWillUnmount() { + window.removeEventListener('resize', this.resizeHandle); + } + + resizeHandle = (e) => { + this.setState({ + resize: new Date().getTime() + }) + } + + render() { + const { + resize + } = this.state; + const { + rightMenu, + store, + resetClass + } = this.props; + const { + setEditTable, + tableEditConfig, + formTarget, + dialogParams, + setDialogVisible, + getDialogOpButtons, + showError, + editorDialogRightMenu, + refreshFeildDef, + refreshForm, + dropdownSelectedKey, + + moduleName, + isJobTreeNode + } = store; + const classes = classnames({ + ['tabPane']: true, + ['tabPane-include']: resetClass + }) + const { + groupInfoFrom, + groupInfoFromFields, + childInfoForm, + childInfoFormFields + } = formTarget; + const { + editGroupInfo, + groupInfoSetting, + createChildInfo, + childInfoSetting + } = dialogParams; + + let tableProps = {}; + if (this.tabDom) { + tableProps = { + scroll: { + y: this.tabDom.offsetHeight - 80, + } + } + //人员卡片字段定义页面 + if (moduleName === 'resourcefielddefined') { + if ((window.e9_locale.userLanguage == 7)) { //系统语言为中文 + Object.assign(tableProps.scroll, { + x: 1200 + }); + } else { + Object.assign(tableProps.scroll, { + x: isJobTreeNode ? 1400 : 1900 + }); + } + } + } + + const rMenu = [...rightMenu, ...store.getBasicMenus(this.props.logSmallType, this.props.targetId)] + + return ( +
{this.tabDom = dom}}> + + setEditTable(editTable, 'fieldDef')} + {...tableEditConfig['fieldDef']} + /> + + + + + setDialogVisible('editGroupInfo', false)} + buttons={getDialogOpButtons()} + moreBtn={{datas:editorDialogRightMenu}} + > + + + setDialogVisible('groupInfoSetting', false, '')} + buttons={getDialogOpButtons()} + moreBtn={{datas:editorDialogRightMenu}} + > + + setEditTable(editTable, 'groupSetting')} + tableProps={{scroll: {y: 360}}} + {...tableEditConfig['groupSetting']}/> + + + setDialogVisible('createChildInfo', false)} + buttons={getDialogOpButtons()} + moreBtn={{datas:editorDialogRightMenu}} + > + + + setDialogVisible('childInfoSetting', false, '')} + buttons={getDialogOpButtons()} + moreBtn={{datas:editorDialogRightMenu}} + > + + setEditTable(editTable, 'childInfoSetting')} + tableProps={{scroll: {y: 360}}} + {...tableEditConfig['childInfoSetting']}/> + + +
+ ) + }; +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js index 8300743..7b71756 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js @@ -1,272 +1,210 @@ import '../../style/index.less'; import React, { - Component + Component } from 'react'; -import * as mobx from 'mobx' import { - inject, - observer + inject, + observer } from 'mobx-react'; import { - WeaTop, - WeaTab, - WeaAlertPage, - WeaLeftTree, - WeaLeftRightLayout, - WeaDropdown, - WeaRightMenu, - WeaTableEdit, - WeaDialog - + WeaTop, + WeaAlertPage, + WeaLeftTree, + WeaLeftRightLayout, + WeaDropdown } from 'ecCom'; -import { Spin, Button } from 'antd'; - +import {Spin} from 'antd'; +import Tabs from './Tabs'; +import FieldDef from './FieldDef'; import { - i18n + i18n } from '../../public/i18n'; -import FormInfo from './FormInfo'; const { ButtonSelect } = WeaDropdown; -const toJS = mobx.toJS; @inject('fieldDefined') @observer export default class FieldDefined extends Component { constructor(props) { - super(props); - this.setState = { + super(props); + this.state = { + logSmallType: '' + } + } - } - } + componentDidMount() { + this.init(this.props); + } - componentDidMount() { - this.init(this.props); - } + componentWillReceiveProps(nextProps) { + if (this.props.location.key !== nextProps.location.key) { + this.init(nextProps); + } + } - componentWillReceiveProps(nextProps) { - if (this.props.location.key !== nextProps.location.key) { - this.init(nextProps); - } - } + init = (props) => { + const { + fieldDefined: store, + params + } = props, { + checkAuthorized, + initData, + initResourceData + } = store, { + type: moduleType + } = params + let moduleName, logSmallType; + if(moduleType === 'subCompany'){ + moduleName = 'subcompanyfielddefined'; + logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED'; + }else if(moduleType === 'department'){ + moduleName = 'departmentfielddefined'; + logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED'; + }else{ + moduleName = 'resourcefielddefined'; + logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; + } + let callbackFunc = () => initData(false, true, moduleName); + if (moduleType === 'resource') + callbackFunc = () => initResourceData(moduleName); + checkAuthorized(moduleName, null, callbackFunc); + this.setState({logSmallType}) + } - init = (props) => { - const { - fieldDefined: store, - params - } = props, { - // checkAuthorized, - //initData, - initResourceData - } = store, { - type: moduleType - } = params - let moduleName, logSmallType; - if (moduleType === 'subCompany') { - moduleName = 'subcompanyfielddefined'; - } else if (moduleType === 'department') { - moduleName = 'departmentfielddefined'; - } else if (moduleType === 'job') { - moduleName = 'jobfielddefined'; - } else { - moduleName = 'resourcefielddefined'; - } - initResourceData(moduleName); - //checkAuthorized(moduleName, null, callbackFunc); - } + tabChangeHandle = (key) => { + const { + fieldDefined: store + } = this.props, { + tabConfig + } = store; + store.setActiveTab(tabConfig, key); + } - getDropMenuDatas() { - const { - fieldDefined - } = this.props; - const { - rightMenu - } = fieldDefined; + render() { + const { + fieldDefined: store, + params + } = this.props, { + containerInitFinished, + refreshMainTabComponent, + spinning + } = store, { + type: moduleType + } = params, { + tabConfig, + btnsAndMenus, + formTarget, + activeTabInfo, + treeConfig, + refreshTree, + selectedTreeNodeInfo, + dropdownProps, + feildDefRemoveable + } = store, { + btns, + menus, + tabBtnDef + } = btnsAndMenus(tabConfig), { + conditionForm: form, + conditionFormFields: fields, + } = formTarget, tabProps = { + tabConfig: tabConfig, + tabChangeHandle: this.tabChangeHandle, + activeTabInfo, + rightMenu: menus, + store: store, + conditionForm: form, + conditionFormFields: fields, + tabBtnDef: [ + ...tabBtnDef, + + ] + }, title = moduleType === 'subCompany' ? i18n.module.subCompanyFieldDef() : moduleType === 'department' ? i18n.module.departmentFieldDef() : i18n.module.resourceFieldDef(), + topProps = { + title, + icon: , + iconBgcolor: '#217346', + showDropIcon: true, + buttons: btns, + dropMenuDatas: menus + }; + let logType; + if(selectedTreeNodeInfo){ + if(selectedTreeNodeInfo.viewAttr == 1){ + logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; + }else{ + logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED_DETAIL'; + } + } + let children = []; + if (containerInitFinished.init && containerInitFinished.authorized) { + switch (moduleType) { + case 'resource': + const { + data, + onSelectedTreeNode, + selectedKeys, + onExpand, + treeExpandKeys + } = store.toJS(treeConfig); + const treeCom = ( + + ) + children = [ + ( + + + + { + + + + } + + + + ) + ] + break; + default: + children = [ + ( + + + + + + + + ) + ] + break; + } + } else if (containerInitFinished.init && !containerInitFinished.authorized) { + children = [ + ( + +
{i18n.message.authFailed()}
+
+ ) + ]; + } - let menus = []; - toJS(rightMenu).map((item, index) => { - let obj = { - key: item.menuFun, - icon: , - content: item.menuName, - } - if (item.menuFun == 'collection' || item.menuFun == 'help' || item.menuFun == 'pageAddress') { - obj.disabled = true; - } - menus.push(obj); - }) - return menus; - } - - getTopMenuBtns() { - const { - fieldDefined - } = this.props; - const { - topMenu, - } = fieldDefined; - - let btns = []; - topMenu.map((item, i) => { - btns.push(); - }); - - return btns; - } - - handleClick(item) { - const { - fieldDefined - } = this.props; - this[item.menuFun] && this[item.menuFun](); - } - - new() { - const { - fieldDefined - } = this.props; - fieldDefined.editGroup(); - } - - onTabChange = tabKey => { - const { - fieldDefined - } = this.props; - fieldDefined.onTabChange(tabKey); - } - - onTabEdit = (tabKey, type) => { - debugger - console.log('onTabEdit: ', tabKey, type); - } - - render() { - - - const { - fieldDefined: store, - params - } = this.props, { - spinning, - refreshMainTabComponent, - treeConfig, - formTarget, - tabInfo, - tabKey, - setEditTable, - tableEditConfig, - dialogParams, - setDialogVisible, - getDialogOpButtons, - editorDialogRightMenu, - - } = store, { - type: moduleType - } = params, - title = moduleType === 'subCompany' ? i18n.module.subCompanyFieldDef() : moduleType === 'department' ? i18n.module.departmentFieldDef() : i18n.module.resourceFieldDef(), - topProps = { - title, - icon: , - iconBgcolor: '#217346', - showDropIcon: true, - buttons: this.getTopMenuBtns(), - dropMenuDatas: this.getDropMenuDatas(), - - }; - let children = []; - - //tabprops - let tabsData = cloneDeep(tabConfig.tabs) || []; - let tabProps = { - type: 'editable-inline', - datas: tabsData, - keyParam: tabConfig.keyParam, - selectedKey: tabConfig.activeTabKey, - onChange: tabChangeHandle, - leftStyle - } - - //end - - const { - groupInfoFrom, - groupInfoFromFields, - childInfoForm, - childInfoFormFields - } = formTarget; - - const { - editGroupInfo, - groupInfoSetting, - createChildInfo, - childInfoSetting - } = dialogParams; - - - const { - data, - onSelectedTreeNode, - selectedKeys, - onExpand, - treeExpandKeys - } = store.toJS(treeConfig); - const treeCom = ( - - ) - children = [ - ( - - - - - - { - - setEditTable(editTable, 'fieldDef')} - {...tableEditConfig['fieldDef']} - /> - - } - setDialogVisible('editGroupInfo', false)} - buttons={getDialogOpButtons()} - moreBtn={{ datas: editorDialogRightMenu }} - > - - - - - - ) - ] - - - return ( -
- {children} -
- ) - } + return ( +
+ {children} +
+ ) + } } \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/Tabs.js b/pc4mobx/organization/components/fieldDefinedSet/Tabs.js new file mode 100644 index 0000000..d9ef164 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/Tabs.js @@ -0,0 +1,220 @@ +import React, { + Component +} from 'react'; +import { + WeaTab +} from 'ecCom'; +import { + observer +} from 'mobx-react'; +import { + Button +} from 'antd'; +import AdvanceSearchFormInfo from './AdvanceSearchFormInfo'; +import { + cloneDeep +} from 'lodash'; +import { + calFormHeight +} from '../../util/index'; +import { + i18n +} from '../../public/i18n'; + +@observer +export default class Tabs extends Component { + constructor(props) { + super(props); + this.state = { + showSearchAd: false, + }; + } + + componentWillReceiveProps(nextProps) { + this.setState({ + showSearchAd: false, + }) + } + + doSearch = () => { + const { + conditionForm, + tabConfig, + activeTabInfo, + } = this.props; + + let tabInfo = tabConfig.tabs[activeTabInfo.activeTabIndex]; + tabInfo.doSearch(conditionForm.getFormParams()); + this.setState({ + showSearchAd: false + }); + } + + doReset = () => { + const { + conditionForm + } = this.props; + conditionForm.resetConditionValue(); + } + + doCancel = () => { + const { + conditionForm + } = this.props; + this.setState({ + showSearchAd: false, + }); + } + + getTabButtonsAd() { + return [ + (), + (), + () + ] + } + + renderForm = () => { + const { + conditionForm, + conditionFormFields, + itemRender + } = this.props; + const { + isFormInit + } = conditionForm; + if (isFormInit) + return + else + return ''; + } + + initTab = (props) => { + return React.cloneElement(, { + ...props + }); + } + + renderTabNav = () => { + //data + const { + activeTabInfo, + tabConfig, + tabChangeHandle, + tabBtnDef, + conditionForm, + conditionFormFields, + advanceHeight, + store, + leftStyle, + } = this.props; + + let tabInfo = tabConfig.tabs[activeTabInfo.activeTabIndex]; + let tabsData = cloneDeep(tabConfig.tabs) || []; + tabsData != null && tabsData.map(tab => { + if (typeof(tab.title) == 'function'){ + tab.title = tab.title(); + } + delete tab.topButtonDef; + delete tab.tabButtonDef; + }); + let tabProps = { + type: 'editable-inline', + datas: tabsData, + keyParam: tabConfig.keyParam, + selectedKey: tabConfig.activeTabKey, + onChange: tabChangeHandle, + leftStyle + } + tabBtnDef && Object.assign(tabProps, { + buttons: tabBtnDef + }); + const searchType = tabInfo.searchType || []; + if (searchType.length > 0) { + Object.assign(tabProps, { + searchType: searchType, + onSearch: (value) => { + if (searchType.indexOf('advanced') >= 0) { + tabInfo.doSearch(conditionForm.getFormParams()); + } else { + tabInfo.doSearch({ + [tabInfo.searchKey]: value + }); + } + } + }); + if (searchType.indexOf('advanced') >= 0 && conditionForm != null && conditionForm.isFormInit) { + const formParams = conditionForm.getFormParams(); + Object.assign(tabProps, { + searchsBaseValue: formParams[tabInfo.searchKey] || '', + showSearchAd: this.state.showSearchAd, + setShowSearchAd: (bool) => { + this.setState({ + showSearchAd: bool + }) + }, + onSearchChange: (value) => conditionForm.updateFields({ + [tabInfo.searchKey]: { + value + } + }, false), + buttonsAd: this.getTabButtonsAd(), + searchsAd:
{ + if (e.keyCode == 13 && e.target.tagName === "INPUT") { + tabInfo.doSearch(conditionForm.getFormParams()); + this.setState({ + showSearchAd: false + }) + } + } } + >{this.renderForm()}
+ }); + + Object.assign(tabProps, { + //advanceHeight: calFormHeight(conditionFormFields.length, _.keys(formParams).length) + advanceHeight: advanceHeight ? advanceHeight : calFormHeight(conditionFormFields.length, conditionForm.fieldArr) + }); + } + } + tabConfig.onTabEdit && Object.assign(tabProps, { + onEdit: tabConfig.onTabEdit + }); + + return this.initTab(tabProps); + } + + renderTabContent = () => { + const { + children, + activeTabInfo, + rightMenu, + store + } = this.props; + if (Array.isArray(children)) { + return React.cloneElement(children[activeTabInfo.activeTabIndex], { + rightMenu, + activeTabIndex: activeTabInfo.activeTabIndex, + store + }); + } else { + return React.cloneElement(children, { + rightMenu, + activeTabIndex: activeTabInfo.activeTabIndex, + store + }); + } + } + + render() { + const { + tabConfig + } = this.props; + return ( +
+ {tabConfig.tabs.length > 0 && this.renderTabNav()} + {tabConfig.tabs.length > 0 && this.renderTabContent()} +
+ ); + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/Tip.js b/pc4mobx/organization/components/fieldDefinedSet/Tip.js new file mode 100644 index 0000000..22986ff --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/Tip.js @@ -0,0 +1,13 @@ +import React, {Component} from 'react'; +import {WeaLocaleProvider} from 'ecCom'; + +const {getLabel} = WeaLocaleProvider; + +export default class Tip extends Component{ + render(){ + const label = this.props.label || getLabel('524355','提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!'); + return ( +
{label}
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/ViewRangeForm.js b/pc4mobx/organization/components/fieldDefinedSet/ViewRangeForm.js new file mode 100644 index 0000000..c4d94be --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/ViewRangeForm.js @@ -0,0 +1,16 @@ +import React, {Component} from 'react'; +import {observer} from 'mobx-react'; +import { WeaAuth } from "ecCom"; + +@observer +export default class ViewRangeForm extends Component{ + render(){ + const {store} = this.props; + const {viewRangeAuthProps} = store; + + return ( + + + ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/ViewRangeSetting.js b/pc4mobx/organization/components/fieldDefinedSet/ViewRangeSetting.js new file mode 100644 index 0000000..5af2c8a --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/ViewRangeSetting.js @@ -0,0 +1,21 @@ +import React, {Component} from 'react'; +import {observer} from 'mobx-react'; +import { WeaDialog, WeaTab } from "ecCom"; +import {WeaTableNew} from "comsMobx"; + +const {WeaTable} = WeaTableNew; + +@observer +export default class ViewRangeSetting extends Component{ + render(){ + const {store} = this.props; + const {dialogProps, rangeViewTabProps, rangeViewTableProps} = store; + + return ( + + + + + ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index c576ff0..713d838 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -43,28 +43,31 @@ const {TableStore} = WeaTableNew; export class FieldDefinedStore extends HrmBaseStore { - tabDef = { + /********************* unobservable list *********************/ + //override baseStore.tabConfig + tabDef = { + color: '#000000', + groupId: '', + viewCondition: '1', topButtonDef: [{ - isBatch: 0, - isTop:1, - menuFun: "save", - menuIcon: "icon-coms-Preservation", - menuName: "保存", - type: "BTN_Save" + comType: 'button', + type: 'primary', + onClickHandle: this.saveFieldDefine, + label: i18n.button.save, + icon: this.menuIconCollection.save }, { - isBatch: 0, - isTop:1, - menuFun: "new", - menuIcon: "icon-coms-New-Flow", - menuName: "新建分组", - type: "BTN_Addnew" + comType: 'button', + type: 'primary', + onClickHandle: () => this.editGroup(), + label: i18n.button.createGroup, + icon: this.menuIconCollection.create }, { - isBatch: 0, - isTop:1, - menuFun: "set", - menuIcon: "icon-coms-Flow-setting", - menuName: "分组维护", - type: "BTN_GroupSet" + comType: 'button', + type: 'primary', + onClickHandle: this.doGroupSetting, + label: i18n.button.groupMaintain, + icon: this.menuIconCollection.setting, + checkAction: 'groupInfoOperability' }], tabButtonDef: [{ comType: 'button', @@ -74,18 +77,93 @@ export class FieldDefinedStore extends HrmBaseStore { onClickHandle: () => this.recordOP(this.editTable['fieldDef'], 'add') }] } - - /********************* tabProps *********************/ - tabConfig = { + tabConfig = { tabs: [], keyParam: 'viewCondition', activeTabKey: '1', onTabEdit: this.onTabEdit }; - activeTabInfo = {} - tabRecord = []; + moveToGroup = false; + moveDropDown = () => ( + + { + filter(this.tabConfig.tabs, (d) => { + try{ + return d.groupid != this.activeTabInfo.tabInfo.groupid + }catch(e){ + return true; + } + }).map((tab, index) => ( + +
{tab.title}
+
+ )) + } + + +
{i18n.label.createAndMoveGroup()}
+
+
+ ) + getDropdownDatas = () => { + let datas = [ + { + key: '1', + text: i18n.button.delete(), + show: , + selected: this.dropdownSelectedKey === '1' + }, + { + key: '2', + text: i18n.button.copy(), + show: , + selected: this.dropdownSelectedKey === '2' + }, + { + key: '3', + text: i18n.button.moveToGroup(), + show: , + selected: this.dropdownSelectedKey === '3', + isDropBtn: true + } + ] + if(this.selectedTreeNodeInfo != null && this.selectedTreeNodeInfo.viewAttr != 1){ + datas.splice(2, 1); + } + return datas; + } + dropdownProps = () => ({ + type: 'small', + datas: this.getDropdownDatas(), + dropBtnProps: { + style: { padding: '10px 4px' } + }, + btnDropPropsDatas: { + '3': { + overlay: this.moveDropDown() + } + }, + btnOnClick: key => { + switch(key){ + case '1': + this.recordOP(this.editTable['fieldDef'], 'remove') + break; + case '2': + this.recordOP(this.editTable['fieldDef'], 'copy') + break; + case '3': + break; + } + }, + menuOnClick: (key, e) => { + this.tableEditConfig.fieldDef.selectedRowKeys = []; + this.feildDefTableSelectedRows.length = 0; + this.refreshMainTabComponent = new Date().getTime(); + this.dropdownSelectedKey = key; + } + }) - fieldDefColumns = () => { + fieldDefColumns = () => { const columns = [{ title: i18n.label.fieldLabel(), //列名 dataIndex: 'fieldlabel', //列的id 对应数据 @@ -295,12 +373,19 @@ export class FieldDefinedStore extends HrmBaseStore { width: '30%' }]; - getColumns = () => { + getColumns = () => { let columns = cloneDeep(this.fieldDefColumns()) + if (this.moduleName.indexOf('resource') >= 0) { + columns[1].com = [{ + label: '', + type: 'TEXT', + key: 'fieldname', + }] + } return columns; } - - tableEditConfig = { + + tableEditConfig = { fieldDef: { ...this.editTableConfig, showAdd: false, @@ -349,10 +434,13 @@ export class FieldDefinedStore extends HrmBaseStore { } } - + activeTabInfo = {} + tabRecord = []; + isDBKeyValid = true; + /********************* unobservable list *********************/ - /********************* dialog info setting *********************/ - editorDialogRightMenu = []; + /********************* dialog info setting *********************/ + editorDialogRightMenu = []; getDialogOpButtons = () => { //获取权限组编辑对话框按钮列表 this.editorDialogRightMenu.length = 0; let buttons = []; @@ -365,23 +453,24 @@ export class FieldDefinedStore extends HrmBaseStore { if(this.dialogParams.groupInfoSetting.visible){ let logType = ''; - // switch(this.moduleName){ - // case 'subcompanyfielddefined': - // logType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED_GROUP'; - // break; - // case 'departmentfielddefined': - // logType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED_GROUP'; - // break; - // case 'resourcefielddefined': - // logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED_GROUP'; - // break; - // } + switch(this.moduleName){ + case 'subcompanyfielddefined': + logType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED_GROUP'; + break; + case 'departmentfielddefined': + logType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED_GROUP'; + break; + case 'resourcefielddefined': + logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED_GROUP'; + break; + } this.editorDialogRightMenu.push(...this.getBasicMenus(logType)); } return buttons; } - + /********************* dialog info setting *********************/ + /***** form ****/ editGroupInfoFormFields = [{ "title": i18n.label.basicSetting(), @@ -430,7 +519,7 @@ export class FieldDefinedStore extends HrmBaseStore { "defaultshow": true }] - /********************* observable list *********************/ + /********************* observable list *********************/ dialogParams = { //override baseStore.dialogParams editGroupInfo: { visible: false, @@ -462,81 +551,147 @@ export class FieldDefinedStore extends HrmBaseStore { } } - @observable spinning = false; - @observable moduleName = ''; //模块名称 - @observable topMenu = []; - @observable rightMenu = []; + @observable dropdownSelectedKey = '1'; + @observable _groupInfoOperability = true; + @observable feildDefTableSelectedRows = []; + @observable groupSettingTableSelectedRows = []; + @observable _feildDefSaveable = true; - @observable tabKey = '1' - @observable tabInfo = [] //需要自定义返回 - - //选中树节点信息 - @observable selectedTreeNodeInfo; - @observable treeConfig = { - data: [], - selectedKeys: [], - treeExpandKeys: [], - onExpand: (keys) => { - this.treeConfig.treeExpandKeys = keys; - }, - onSelectedTreeNode: (key, count, countType) => { - this.treeConfig.selectedKeys = [key]; - this.selectedTreeNodeInfo = countType.node.props.data; - this.getTabInfoByTreeNode(null, true); - } + @observable refreshMainTabComponent = new Date().getTime(); + @observable refreshFeildDef = new Date().getTime(); //当需要刷新主页面tab时,变更此值 + @observable refreshForm = new Date().getTime(); + @observable refreshEditGroupTabComponent = new Date().getTime(); //当需要刷新权限组编辑tab时,变更此值 + @observable spinning = false; + @observable moduleName = ''; + /********************* observable list *********************/ + + /********************* computed list *********************/ + @computed get feildDefRemoveable() { //字段定义表是否有选中行 + return this.feildDefTableSelectedRows.length === 0; } - @observable refreshMainTabComponent = new Date().getTime(); + @computed get groupInfoRemoveable() { //字段定义表是否有选中行 + return this.groupSettingTableSelectedRows.length === 0; + } + @computed get feildDefSaveable() { //字段定义表是否有记录 + return this._feildDefSaveable; + } - @observable moveToGroup = false; //移动到组 - /** - * 初始化模块数据 - */ - @action initResourceData = (module) => { - this.selectedTreeNodeInfo = null; - this.treeConfig.treeExpandKeys.length = 0; - this.moduleName = module; - api.getTree().then(data => { + @computed get groupInfoOperability() { //是否有组信息 + return this._groupInfoOperability; + } + /********************* computed list *********************/ + + /********************* action list *********************/ + /** + * 初始化模块数据 + * @return {null} + */ + @action initData = (create = false, init = false, module) => { + this.dropdownSelectedKey = '1'; + if (module != null) { + this.moduleName = module; + } + this.selectedTreeNodeInfo = null; + // this.tableEditConfig.fieldDef.columns = cloneDeep(this.fieldDefColumns()); + api.getTabInfo(this.moduleName).then(data => { + this._groupInfoOperability = data.tabs.length === 0; if (data.status === '1') { - // this.setTableEditColTitle(); - if (data.treejson.length > 0) { - this.treeConfig.data = data.treejson; - this.treeConfig.selectedKeys = [data.treejson[0].key]; - this.selectedTreeNodeInfo = data.treejson[0]; - this.getTabInfoByTreeNode(null, true); - + let tabArr = []; + this.tabRecord = data.tabs; + data.tabs && data.tabs.map((tabInfo, index) => { + let t = cloneDeep(this.tabDef); + tabArr.push({ + ...t, + ...tabInfo, + viewCondition: `${tabArr.length + 1}` + }); + }); + if (tabArr.length > 0) { + this.tabConfig.tabs = [...tabArr]; + // this.setTableEditColTitle(); + this.setActiveTab(this.tabConfig, init ? '1' : !create ? this.tabConfig.activeTabKey : `${tabArr.length}`); + this.containerInitFinished = { + ...this.containerInitFinished, + init: true + } } } else { message.error(data.message); } - }, error => {}) - } + }, error => { - @action getTabInfoByTreeNode = (create = false, init = false, isLeaf) => { - api.getTabInfo(this.moduleName, { - groupType: this.treeConfig.selectedKeys[0] - }).then(data => { - if (data.status === '1') { - let t = cloneDeep(this.tabDef); - this.setTopMenu(t.topButtonDef); - this.setRightMenu(t.topButtonDef); - data.tabs && this.setTabInfo(data.tabs); - this.getFieldDefinedInfo(this.tabKey); - } else { - message.error(data.message); - } }) - } + } - - - @action("tab切换") onTabChange(tabKey) { - this.setTabKey(tabKey); - this.getFieldDefinedInfo(tabKey); - } + setTableEditColTitle = () => { + [...Object.keys(this.tableEditConfig)].map(k => { + this.tableEditConfig[k].columns.map(c => { + if (typeof(c.title) == 'function') + c.title = c.title(); + else + c.title = c.title; + }) + }) + } - @action onTabEdit = (targetKey, action) => { + /** + * tab change事件(通过变更refreshMainTabComponent使index重新render) + * @param {Object} tabConfig [tabConfig] + * @param {String} key [tabKey] + * @return {null} + */ + @action setActiveTab = (tabConfig, key) => { + tabConfig.activeTabKey = key || tabConfig.tabs[0].viewCondition; + const tabIndex = this.getTabIndex(this.tabConfig.tabs, key); + if (tabIndex < 0) return; + this.dropdownSelectedKey = '1'; + this.feildDefTableSelectedRows.length = 0; + this.tableEditConfig.fieldDef.selectedRowKeys = []; + this.activeTabInfo = { + activeTabKey: this.tabConfig.activeTabKey, + activeTabIndex: this.getTabIndex(this.tabConfig.tabs, this.tabConfig.activeTabKey), + tabInfo: this.tabConfig.tabs[tabIndex] + } + let params = { + groupId: this.activeTabInfo.tabInfo.groupid, + } + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key + this.spinning = true; + api.getFieldDefinedInfo(this.moduleName, params).then(data => { + if (data.status === '1') { + const { + datas, + selectedData + } = this.convertData(data.data, 'fieldDef'); + this.encryptEnable = data.encryptEnable; + this.tableEditConfig.fieldDef.datas = datas; + this.tableEditConfig.fieldDef.columns = this.getColumns(); + + //人员卡片字段定义columns是动态的,因此需要重新计算得出selectedData + if (this.moduleName === 'resourcefielddefined') { + const { + selectedData + } = this.convertData(data.data, 'fieldDef'); + this.tableEditConfig.fieldDef.selectedData = selectedData; + } else { + this.tableEditConfig.fieldDef.selectedData = selectedData; + } + + if (this.tabRecord.length > 0) { + this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (data.data.length === 0); + this.activeTabInfo.tabInfo.editable = (data.data.length === 0); + } + } else + message.error(data.message); + this.spinning = false; + this.refreshMainTabComponent = new Date().getTime(); + }, error => {this.spinning = false;}) + } + + @action onTabEdit = (targetKey, action) => { const tabIndex = this.getTabIndex(this.tabConfig.tabs, targetKey); if (tabIndex < 0) return; const tabInfo = this.tabConfig.tabs[tabIndex]; @@ -570,44 +725,14 @@ export class FieldDefinedStore extends HrmBaseStore { } } - @action getFieldDefinedInfo(tabKey) { - let params = { - groupId:tabKey, - groupType: -1 - } - api.getFieldDefinedInfo(this.moduleName, params).then(data => { - if (data.status === '1') { - const { - datas, - selectedData - } = this.convertData(data.data, 'fieldDef'); - this.encryptEnable = data.encryptEnable; - this.tableEditConfig.fieldDef.datas = datas; - this.tableEditConfig.fieldDef.columns = this.getColumns(); + @action dialogSaveOp = () => { + this.dialogParams.editGroupInfo.visible && this.doSaveGroupInfo(); + this.dialogParams.groupInfoSetting.visible && this.doSaveGroupSetting(); + this.dialogParams.createChildInfo.visible && this.doSaveChildInfo(); + this.dialogParams.childInfoSetting.visible && this.doSaveChildInfoSetting(); + } - //人员卡片字段定义columns是动态的,因此需要重新计算得出selectedData - if (this.moduleName === 'resourcefielddefined') { - const { - selectedData - } = this.convertData(data.data, 'fieldDef'); - this.tableEditConfig.fieldDef.selectedData = selectedData; - } else { - this.tableEditConfig.fieldDef.selectedData = selectedData; - } - - // if (this.tabRecord.length > 0) { - // this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (data.data.length === 0); - // this.activeTabInfo.tabInfo.editable = (data.data.length === 0); - // } - } else - message.error(data.message); - this.spinning = false; - this.refreshMainTabComponent = new Date().getTime(); - }, error => {this.spinning = false;}) - } - - - @action editGroup = (group, moveToGroup = false) => { + @action editGroup = (group, moveToGroup = false) => { this.moveToGroup = moveToGroup; this.editGroupInfoFormFields.map(f => { if (typeof(f.title) == 'function') @@ -637,22 +762,60 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('editGroupInfo', true, dialogTitle); } - @action dialogSaveOp = () => { - this.dialogParams.editGroupInfo.visible && this.doSaveGroupInfo(); - // this.dialogParams.groupInfoSetting.visible && this.doSaveGroupSetting(); - // this.dialogParams.createChildInfo.visible && this.doSaveChildInfo(); - // this.dialogParams.childInfoSetting.visible && this.doSaveChildInfoSetting(); + @action doGroupSetting = () => { + this.tableEditConfig.groupSetting.datas.length = 0; + let arr = []; + this.tabRecord.map(tabInfo => { + let viewAttr = tabInfo.viewAttr; + // if (viewAttr != 1 && has(tabInfo, 'editable')) { + // viewAttr = !tabInfo.editable ? 1 : 2; + // } + arr.push({ + "record": { + "id": tabInfo.groupid, + "viewAttr": tabInfo.viewAttr, + "isShow": tabInfo.isShow, + "groupName": tabInfo.multiTitle || tabInfo.title || '', + "editable": tabInfo.editable + }, + "props": { + "checkProps": { + "isShow": { + viewAttr + } + } + } + }) + }) + Object.assign(this.tableEditConfig.groupSetting, { ...this.convertData(arr, 'groupSetting') + }); + this.tableEditConfig.groupSetting.columns = this.groupDefColumns(); + this.tableEditConfig.groupSetting.datas.map(d => { + Object.assign(d, { + com: { + groupName: [{ + label: '', + type: 'INPUT', + key: 'groupName', + viewAttr: d.viewAttr, + otherParams: { + ...window.inputType + } + }] + } + }) + }) + this.setDialogVisible('groupInfoSetting', true, i18n.button.groupMaintain()); } - - doSaveGroupInfo = () => { + doSaveGroupInfo = () => { this.formTarget.groupInfoFrom.validateForm().then(f => { if (f.isValid) { let record = { ...this.formTarget.groupInfoFrom.getFormParams(), isShow: 1 } - const recordIndex = findIndex(this.tabInfo.tabs, { + const recordIndex = findIndex(this.tabConfig.tabs, { title: getCurrentLabel(record.groupName) }); if (recordIndex >= 0) { @@ -664,9 +827,9 @@ export class FieldDefinedStore extends HrmBaseStore { records = []; this.opId != null && Object.assign(record, { id: this.opId, - isShow: this.tabInfo.isShow + isShow: this.activeTabInfo.tabInfo.isShow }); - this.tabInfo.map(tabInfo => { + this.tabConfig.tabs.map(tabInfo => { if (tabInfo.groupid === this.opId) { found = true; records.push(record) @@ -692,9 +855,12 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('editGroupInfo', false, ''); if(this.moveToGroup){ const ids = data.groupid.split(','); - //this.changeGroup(null, ids[ids.length - 1]); 移动到组 + this.changeGroup(null, ids[ids.length - 1]); }else{ - this.getTabInfoByTreeNode(); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(this.opId == null); message.success(i18n.message.saveSuccess()); } } else @@ -709,22 +875,1354 @@ export class FieldDefinedStore extends HrmBaseStore { }); } - setTabInfo(tabInfo) { - this.tabInfo = tabInfo; + @action saveFieldDefine = () => { + if(this.spinning) + return; + this.spinning = true; + this.recordOP(this.editTable['fieldDef'], 'valid'); + let data = cloneDeep(this.tableEditConfig.fieldDef.datas), + labelArr = [], + nameArr = []; + if (!this.isDBKeyValid) { + this.spinning = false; + return; + } + + const invalidEmpty = data.some((d, index) => { + d.key = index; + delete d.com; + delete d.checkProps; + delete d.viewAttr; + if (has(d, 'fieldTypeObj')) { + if (Array.isArray(d.fieldTypeObj) && d.fieldTypeObj.length > 0 && d.fieldTypeObj[0] != 'select') + d.fieldType = d.fieldTypeObj; + delete d.fieldTypeObj; + } + if (!Array.isArray(d.fieldType)) + delete d.fieldType; + + if (!has(d, 'enable')) + d.enable = '0'; + if (!has(d, 'required')) + d.required = '0'; + + let fieldlabel = d.fieldlabel || '', + fieldname = d.fieldname || ''; + if (fieldlabel === '' || (this.moduleName != 'resourcefielddefined' && fieldname === '')) { + return true; + } + labelArr.push(getCurrentLabel(d.fieldlabel)); + nameArr.push(d.fieldname); + return false; + }) + let checkSame = false; + if (this.moduleName.indexOf('resource') >= 0) + checkSame = uniq(labelArr).length === data.length; + else + checkSame = uniq(labelArr).length === data.length && uniq(nameArr).length === data.length; + if (invalidEmpty) { + this.spinning = false; + return; + } else if (checkSame) { + this.spinning = true; + let dataObj = { + groupId: this.activeTabInfo.tabInfo.groupid, + records: data + } + if (this.selectedTreeNodeInfo != null) + dataObj.groupType = this.selectedTreeNodeInfo.key; + let params = { + data: JSON.stringify(dataObj) + } + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key; + + const checkRs = this.editTable['fieldDef'] && this.editTable['fieldDef'].refs.edit.doRequiredCheck() || {pass: true}; + if(!checkRs.pass){ + this.spinning = false; + return; + } + + api.saveFieldDefinedInfo(this.moduleName, params).then(data => { + if (data.status === '1') { + message.success(i18n.message.saveSuccess()); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + } else { + message.error(data.message); + } + this.spinning = false; + }, error => {this.spinning = false;}) + } else { + message.error(i18n.confirm.displayOrDBFieldExist()); + this.spinning = false; + } + } + + @action onEdit = (keys, datas, c, dataIndex) => { + if(dataIndex === 'fieldlabel' && this.moduleName != 'resourcefielddefined'){ + const oldRecord = this.tableEditConfig.fieldDef.datas[keys[0]]; + if(has(oldRecord, 'com') && has(oldRecord.com, 'fieldname') && oldRecord.com.fieldname.length > 0 && oldRecord.com.fieldname[0].type === 'TEXT'){ + return; + } + this.getPinYin({labelName: getCurrentLabel(datas[0].fieldlabel)}).then(data => { + const {pinyin} = data; + oldRecord.fieldname = pinyin; + const arr = filter(this.tableEditConfig.fieldDef.datas, {fieldname: pinyin}); + if(arr.length > 1 && pinyin != ''){ + oldRecord.fieldname = pinyin + '1'; + } + this.refreshFeildDef = new Date().getTime(); + }); + } + } + @action onAdd = (keys, datas) => { + try{ + this.tableEditConfig.fieldDef.datas[keys[0] - 1].enable = '1'; + (this.tableEditConfig.fieldDef.selectedData.enable || []).push(keys[0] - 1); + this.refreshFeildDef = new Date().getTime(); + }catch(e){ + + } + } + + @action onFieldDefChange = (datas) => { + let selectedData = { + enable: [], + required: [] + } + if (this.moduleName === 'resourcefielddefined') { + Object.assign(selectedData,{ + isModify:[] + }); + } + datas.map((data, index) => { + if (data['enable'] === '1') + selectedData.enable.push(index); + if (data['required'] === '1') + selectedData.required.push(index); + if (data['isModify'] && data['isModify'] === '1' && this.moduleName === 'resourcefielddefined') { + selectedData.isModify.push(index); + } + }) + this.tableEditConfig.fieldDef.datas = datas; + this.tableEditConfig.fieldDef.selectedData = selectedData; + this._feildDefSaveable = datas.length === 0; + if (datas.length === 0) { + // this.initData(); + } else + this.refreshFeildDef = new Date().getTime() + } + + @action onFieldDefRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => { + if (dataIndex == null) { + this.feildDefTableSelectedRows = sRowKeys; + this.tableEditConfig.fieldDef.selectedRowKeys = sRowKeys; + } else { + if (selectedDatas != null && selectedDatas.hasOwnProperty(dataIndex)) { + const arr = selectedDatas[dataIndex]; + this.tableEditConfig.fieldDef.datas.map((data, index) => { + if(dataIndex === 'enable'){ + data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; + if(data[dataIndex] === '0'){ + data['required'] = '0'; + remove(selectedDatas['required'], v => v === index); + data['isModify'] = '0'; + remove(selectedDatas['isModify'], v => v === index); + } + }else if(dataIndex === 'required'){ + data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; + if (data[dataIndex] === '1') { + data['enable'] = '1'; + if (selectedDatas['enable'].indexOf(index) < 0) + selectedDatas['enable'].push(index); + } + } else if (dataIndex === 'isModify') { + data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; + if (data[dataIndex] === '1') { + data['enable'] = '1'; + if (selectedDatas['enable'].indexOf(index) < 0) + selectedDatas['enable'].push(index); + } + + } else + data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; + }) + + this.tableEditConfig.fieldDef.selectedData = selectedDatas; + } + } + this.processLinkage(selectedDatas); + this.refreshFeildDef = new Date().getTime() + } + + //处理账号类型和主账号的联动(允许个人修改):账号类型选中,主账号也会选中,反之亦然。 + processLinkage = (selectedDatas) => { + const {datas} = this.tableEditConfig.fieldDef; + + const target = datas.find(data => data.fieldname === 'accounttype'); + + if (!target) return; + + const accounttype = target.isModify; + + const belongto = datas.find(data => data.fieldname === 'belongto').isModify; + + if (belongto !== accounttype) { + datas.find(data => data.fieldname === 'belongto').isModify = accounttype; + + const belongtoIndex = datas.findIndex(data => data.fieldname === 'belongto'); + + if (accounttype === '1') { + selectedDatas['isModify'].push(belongtoIndex); + }else{ + remove(selectedDatas['isModify'], v => v === belongtoIndex); + } + } + + } + + @action onFieldDefRowSelection = (rowSelection) => { + let sel = { + ...rowSelection + } + sel.getCheckboxProps = (record) => { + let disabled = false; + switch(this.dropdownSelectedKey){ + case '2': + disabled = false;//复制时,checkbox全部启用 + break; + case '3': + disabled = record.id == null || record.checkProps.enable.viewAttr === 1;//移动到组时,checkbox根据id是否为空或是否引用启用按钮状态赋值 + break; + default: + disabled = record.viewAttr === 1;//删除时,checkbox根据record.viewAttr赋值 + break + } + return { + disabled + }; + } + return sel; + } + + @action onFieldDefDeleteOpr = (ks, ds) => { + let ids = []; + ds.map(d => { + if (has(d, 'id')) + ids.push(d.id) + }); + let params = { + id: ids.join(',') + } + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key; + params.groupId = this.activeTabInfo.tabInfo.groupid; + if(ids.length > 0){ + api.removeFieldDefinedInfo(this.moduleName, params).then(data => { + if (data.status === '1') { + // this.initData(); + this.tableEditConfig.fieldDef.selectedRowKeys.length = 0; + message.success(i18n.message.deleteSuccess()); + } else + message.error(data.message); + }, error => { + + }) + }else{ + this.tableEditConfig.fieldDef.selectedRowKeys.length = 0; + } + + this.feildDefTableSelectedRows.length = 0; + } + + @action onGroupSettingChange = (datas, type) => { + this.tableEditConfig[type === 'group' ? 'groupSetting' : 'childInfoSetting'].datas = datas; + } + + @action onGroupSettingRowSelect = (sRowKeys, rows, dataIndex, selectedDatas, type) => { + if (dataIndex == null) { + this.groupSettingTableSelectedRows = sRowKeys; + } else { + if (selectedDatas != null && selectedDatas.hasOwnProperty(dataIndex)) { + const arr = selectedDatas[dataIndex]; + this.tableEditConfig[type === 'group' ? 'groupSetting' : 'childInfoSetting'].datas.map((data, index) => { + data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; + }) + } + } + } + + @action onGroupSettingRowSelection = (rowSelection) => { + let sel = { + ...rowSelection + } + sel.getCheckboxProps = (record) => { + return { + disabled: record.editable === false // ? true : has(record, 'editable') ? !record.editable : false + }; + } + return sel; + } + + doSaveGroupSetting = () => { + this.recordOP(this.editTable['groupSetting'], 'valid'); + let groupNameArr = [], + tabArr = []; + const invalidEmpty = this.tableEditConfig.groupSetting.datas.some(group => { + groupNameArr.push(getCurrentLabel(group.groupName)); + tabArr.push({ + id: group.id, + isShow: group.isShow == null ? '0' : group.isShow, + groupName: group.groupName + }) + return group.groupName === ''; + }) + if (invalidEmpty) { + // message.error(i18n.confirm.groupNameIsEmpty()); + return; + } else if (uniq(groupNameArr).length === this.tableEditConfig.groupSetting.datas.length) { + let dataObj = { + records: tabArr + } + let params = {} + if (this.selectedTreeNodeInfo != null) { + dataObj.groupType = this.selectedTreeNodeInfo.key; + params.groupType = this.selectedTreeNodeInfo.key; + } + params.data = JSON.stringify(dataObj); + api.saveGroupInfo(this.moduleName, params).then(data => { + if (data.status === '1') { + this.setDialogVisible('groupInfoSetting', false, ''); + + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(false, true); + else + this.initData(false, true); + message.success(i18n.message.saveSuccess()); + } else + message.error(data.message); + }, error => { + message.error(i18n.message.actionError()); + }); + } else { + message.error(i18n.confirm.groupNameExist()); + } + } + + @action onGroupSettingDeleteOpr = (ks, ds, type) => { + let ids = []; + ds.map(d => { + if (has(d, 'id')) + ids.push(d.id) + }); + let params = { + id: ids.join(',') + } + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key; + if (type === 'group') { + ids.length > 0 && api.removeGroupInfo(this.moduleName, params).then(data => { + if (data.status === '1') { + message.success(i18n.message.deleteSuccess()); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(false, true); + else + this.initData(false, true); + } else { + message.error(data.message); + } + }) + } else {} + } + + //人员卡片字段定义部分 + @observable refreshTree = new Date().getTime(); + @observable treeConfig = { + data: [], + selectedKeys: [], + treeExpandKeys: [], + onExpand: (keys) => { + this.treeConfig.treeExpandKeys = keys; + }, + onSelectedTreeNode: (key, count, countType) => { + this.treeConfig.selectedKeys = [key]; + this.selectedTreeNodeInfo = countType.node.props.data; + this.getTabInfoByTreeNode(null, true); + } + } + //人员卡片字段定义-选中树节点的信息 + @observable selectedTreeNodeInfo; + + //计算【工作信息】树节点以及子节点的domid + @computed get jobTreeNodeDomids() { + const { + data + } = this.treeConfig; + const domids = ['3']; + data && data.forEach(obj => { + const { + key, + childs + } = obj; + if (key === '3') { + childs.forEach(child => { + const { + domid + } = child; + domids.push(domid); + }) + } + }); + return domids; + } + + //当前树节点是否为【工作信息】 + @computed get isJobTreeNode() { + if (this.selectedTreeNodeInfo) { + const { + domid, + } = this.selectedTreeNodeInfo; + + return this.jobTreeNodeDomids.includes(domid); + } + } + + @computed get childInfoOperability() { + return this.selectedTreeNodeInfo && this.selectedTreeNodeInfo.domid == '-1'; + } + + @action initResourceData = (module) => { + this.selectedTreeNodeInfo = null; + this.dropdownSelectedKey = '1'; + this.moduleName = module; + // let columns = cloneDeep(this.fieldDefColumns()) + // columns.splice(1, 1); + // columns[1].width = '65%'; + // this.tableEditConfig.fieldDef.columns = this.getColumns(); + this.treeConfig.treeExpandKeys.length = 0; + api.getTree().then(data => { + if (data.status === '1') { + this.containerInitFinished = { + ...this.containerInitFinished, + init: true + } + + // this.setTableEditColTitle(); + if (data.treejson.length > 0) { + this.treeConfig.data = data.treejson; + this.treeConfig.selectedKeys = [data.treejson[0].key]; + this.selectedTreeNodeInfo = data.treejson[0]; + this.getTabInfoByTreeNode(null, true); + } + } else { + message.error(data.message); + } + }, error => {}) + } + + getTree = (callback) => { + this.treeConfig.data.length = 0; + this.refreshTree = new Date().getTime(); + api.getTree().then(data => { + if (data.status === '1') { + this.treeConfig.data = data.treejson; + this.treeConfig.data.map(p => { + if (p.domid === this.treeConfig.selectedKeys[0]) + this.selectedTreeNodeInfo = p; + p.childs && p.childs.map(c => { + if (c.domid === this.treeConfig.selectedKeys[0]) + this.selectedTreeNodeInfo = c; + }) + }) + callback && callback(); + } else { + message.error(data.message); + } + this.refreshTree = new Date().getTime(); + }, error => {}) + } + + setBtn = (t) => { + if (!this.selectedTreeNodeInfo.hasGroup) { + t.topButtonDef.splice(1, 3); + } + if (this.selectedTreeNodeInfo.addChild) { + this.tableEditConfig.childInfoSetting.showTitle = true; + this.tableEditConfig.childInfoSetting.showAdd = true; + this.tableEditConfig.childInfoSetting.showDelete = true; + this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.doChildInfoSetting, + label: i18n.button.childInfoMaintain(), + icon: this.menuIconCollection.setting, + checkAction: 'childInfoOperability' + }); + } else { + this.tableEditConfig.childInfoSetting.showTitle = false; + this.tableEditConfig.childInfoSetting.showAdd = false; + this.tableEditConfig.childInfoSetting.showDelete = false; + this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: () => this.createChildInfo(false, { + name: this.selectedTreeNodeInfo.name, + multiName: this.selectedTreeNodeInfo.multiName + }), + label: i18n.button.editChildInfo(), + icon: this.menuIconCollection.setting + }) && t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.removeChildInfo, + label: i18n.button.delete(), + icon: this.menuIconCollection.setting + }); + } + + if (this.selectedTreeNodeInfo.domid === '-1' || this.selectedTreeNodeInfo.addChild) { + this.tableEditConfig.fieldDef.columns[2].com[0].options = remove(this.tableEditConfig.fieldDef.columns[1].com[0].options, (v) => v != 'upload'); + } else { + this.tableEditConfig.fieldDef.columns[2].com[0].options.push('upload'); + } + } + + addEmptyTab = (groupid) => { + let tabArr = []; + let t = cloneDeep(this.tabDef); + this.setBtn(t); + tabArr.push({ + ...t, + groupid, + viewCondition: '1' + }); + this.tabConfig.tabs = [...tabArr]; + } + + @action getTabInfoByTreeNode = (create = false, init = false, isLeaf) => { + api.getTabInfo(this.moduleName, { + groupType: this.treeConfig.selectedKeys[0] + }).then(data => { + if (data.status === '1') { + this._groupInfoOperability = data.tabs.length === 0; + let tabArr = []; + this.tabRecord = data.tabs; + data.tabs && data.tabs.map((tabInfo, index) => { + let t = cloneDeep(this.tabDef); + this.setBtn(t); + tabArr.push({ + ...t, + ...tabInfo, + viewCondition: `${tabArr.length + 1}` + }); + }); + this.tabConfig.tabs = [...tabArr]; + if (tabArr.length > 0) { + this.setActiveTab(this.tabConfig, init ? '1' : !create ? this.tabConfig.activeTabKey : `${tabArr.length}`); + } else { + this.addEmptyTab(this.treeConfig.selectedKeys[0]); + this.setActiveTab(this.tabConfig, '1'); + this.refreshMainTabComponent = new Date().getTime(); + } + } else { + message.error(data.message); + } + }) + } + + isCreateChildInfo = false; + @action createChildInfo = (create = true, data = {}) => { + this.isCreateChildInfo = create; + this.editChildInfoFormFields.map(f => { + if (typeof(f.title) == 'function') + f.title = f.title(); + f.items.map(item => { + if (typeof(item.label) == 'function') + item.label = item.label(); + if (item.conditionType === 'INPUT') + item.otherParams = {...window.inputType}; + }) + }) + let fields = [...this.editChildInfoFormFields], + dialogTitle = create ? i18n.button.createChildInfo() : i18n.button.editChildInfo(); + if (create) { + this.dialogParams.createChildInfo.height = 110; + } else { + fields[0].items.splice(1, 1); + this.dialogParams.createChildInfo.height = 70; + } + this.setFormData('childInfoForm', fields); + if (!create) { + this.formTarget.childInfoForm.updateFields({ + name: { + value: data.multiName || data.name || '' + }, + infoOrder: { + value: data.infoOrder + } + }) + } + this.setDialogVisible('createChildInfo', true, dialogTitle); + } + + @action doSaveChildInfo = () => { + this.formTarget.childInfoForm.validateForm().then(f => { + if (f.isValid) { + let record = { + ...this.formTarget.childInfoForm.getFormParams(), + isShow: 1 + } + + let cloneTree = cloneDeep(this.toJS(this.treeConfig.data)); + let parentId; + let nameArr = []; + if (this.isCreateChildInfo) { + this.selectedTreeNodeInfo.childs.map(c => { + nameArr.push(getCurrentLabel(c.name)); + }) + nameArr.push(getCurrentLabel(record.name)); + if (uniq(nameArr).length != nameArr.length) { + f.showError('name', i18n.confirm.childInfoNameExist()); + this.showError = new Date().getTime(); + return; + } + const i = findIndex(cloneTree, { + key: this.selectedTreeNodeInfo.key + }); + cloneTree[i].childs.push(record) + parentId = this.selectedTreeNodeInfo.domid; + } else { + let checked = true; + cloneTree.map(p => { + p.childs && p.childs.map(c => { + if (c.domid === this.selectedTreeNodeInfo.domid) { + p.childs.map(child => { + if (child.domid != c.domid) + nameArr.push(getCurrentLabel(child.name)); + else + nameArr.push(getCurrentLabel(record.name)); + }) + + if (uniq(nameArr).length != nameArr.length) { + f.showError('name', i18n.confirm.childInfoNameExist()); + this.showError = new Date().getTime(); + checked = false; + return; + } else { + Object.assign(c, { + name: record.name + }); + parentId = p.domid; + } + }else{ + Object.assign(c, { + name: c.multiName + }); + } + }) + }) + if (!checked) + return; + } + const params = { + data: JSON.stringify({ + records: this.convertAttr(cloneTree) + }), + parentId + } + api.saveTree(params).then(data => { + if (data.status === '1') { + this.setDialogVisible('createChildInfo', false, ''); + this.getTree(); + message.success(i18n.message.saveSuccess()); + } else + message.error(data.message); + }, error => { + message.error(i18n.message.actionError()); + }); + // } + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + }); + } + + @action doChildInfoSetting = () => { + this.tableEditConfig.childInfoSetting.datas.length = 0; + let arr = []; + if (!this.selectedTreeNodeInfo.addChild) { + arr.push({ + "record": { + "id": this.selectedTreeNodeInfo.key, + "viewAttr": this.selectedTreeNodeInfo.viewAttr, + "isShow": this.selectedTreeNodeInfo.isShow, + "name": this.selectedTreeNodeInfo.multiName || this.selectedTreeNodeInfo.name || '' + }, + "props": { + "checkProps": { + "isShow": { + "viewAttr": this.selectedTreeNodeInfo.viewAttr + } + } + } + }) + } else { + this.selectedTreeNodeInfo.childs.map(child => { + let viewAttr = child.viewAttr; + if (viewAttr != 1 && has(child, 'editable')) { + viewAttr = !child.editable ? 1 : 2; + } + arr.push({ + "record": { + "id": child.key, + "viewAttr": child.viewAttr, + "isShow": child.isShow, + "name": child.multiName || child.name || '' + }, + "props": { + "checkProps": { + "isShow": { + viewAttr + } + } + } + }) + }) + } + + Object.assign(this.tableEditConfig.childInfoSetting, { ...this.convertData(arr, 'childInfoSetting') + }); + this.tableEditConfig.childInfoSetting.columns = this.childInfoDefColumns(); + this.tableEditConfig.childInfoSetting.datas.map(d => { + Object.assign(d, { + com: { + name: [{ + label: '', + type: 'INPUT', + key: 'name', + viewAttr: d.viewAttr, + otherParams: { + ...window.inputType + } + }] + } + }) + }) + this.setDialogVisible('childInfoSetting', true, i18n.button.childInfoMaintain()); + } + + convertAttr = (cloneTree) => { + let arr = []; + cloneTree.map(root => { + let parent = { + id: root.key, + infoOrder: root.infoOrder, + name: root.name, + isShow: root.isShow + } + if (root.childs) { + parent.childs = []; + root.childs.map(c => { + parent.childs.push({ + id: c.key || c.id, + name: c.name, + isShow: c.isShow, + infoOrder: c.infoOrder + }) + }) + } + arr.push(parent); + }) + return arr; + } + + removeChildInfo = () => { + this.confirmInfo({ + content: i18n.confirm.deleteSelected(), + onOk: () => { + let parentId; + let cloneTree = cloneDeep(this.toJS(this.treeConfig.data)); + cloneTree.map(p => { + p.childs && p.childs.map((c, i) => { + if (c.domid === this.selectedTreeNodeInfo.domid) { + parentId = p.domid; + p.childs.splice(i, 1); + } + }) + }) + const params = { + data: JSON.stringify({ + records: this.convertAttr(cloneTree) + }), + parentId + } + api.saveTree(params).then(data => { + if (data.status === '1') { + message.success(i18n.message.deleteSuccess()); + this.getTree(() => { + this.treeConfig.selectedKeys = ['-1']; + this.selectedTreeNodeInfo = this.treeConfig.data[0]; + this.getTabInfoByTreeNode(null, true); + }); + // this.treeConfig.selectedKeys = [this.treeConfig.data[0].key]; + // this.selectedTreeNodeInfo = this.treeConfig.data[0]; + // this.getTabInfoByTreeNode(null, true); + } else + message.error(data.message); + }, error => { + message.error(i18n.message.actionError()); + }); + } + }); + } + + doSaveChildInfoSetting = () => { + this.recordOP(this.editTable['childInfoSetting'], 'valid'); + let infoNameArr = [], + infoArr = []; + const invalidEmpty = this.tableEditConfig.childInfoSetting.datas.some(group => { + infoNameArr.push(getCurrentLabel(group.name)); + infoArr.push({ + id: group.id, + isShow: group.isShow == null ? '0' : group.isShow, + name: group.name + }) + return group.name === ''; + }) + if (invalidEmpty) { + return; + } else if (uniq(infoNameArr).length === this.tableEditConfig.childInfoSetting.datas.length) { + let parentId; + let cloneTree = cloneDeep(this.toJS(this.treeConfig.data)); + if (!this.selectedTreeNodeInfo.addChild) { + cloneTree.map(p => { + p.childs && p.childs.map(c => { + if (c.domid === infoArr[0].id) { + Object.assign(c, infoArr[0]); + parentId = p.domid; + } + }) + }) + } else { + parentId = this.selectedTreeNodeInfo.key; + const i = findIndex(cloneTree, { + key: this.selectedTreeNodeInfo.key + }); + cloneTree[i].childs = []; + infoArr.map(info => { + cloneTree[i].childs.push({ ...info + }) + }) + } + + const params = { + data: JSON.stringify({ + records: this.convertAttr(cloneTree) + }), + parentId + } + api.saveTree(params).then(data => { + if (data.status === '1') { + this.setDialogVisible('childInfoSetting', false, ''); + this.getTree(); + this.getTabInfoByTreeNode(null, true); + message.success(i18n.message.saveSuccess()); + } else + message.error(data.message); + }, error => { + message.error(i18n.message.actionError()); + }); + } else { + message.error(i18n.confirm.groupNameExist()); + } + } + //移动到组 + @action dropdownClick = (e) => { + switch(e.key){ + case 'createAndMove': + this.editGroup(null, true); + break; + default: + const groupid = e.key; + const tabInfo = this.tabConfig.tabs[findIndex(this.tabConfig.tabs, {groupid})]; + let moveFieldConfirm = i18n.confirm.moveFieldConfirm().replace('{params}', tabInfo.title); + this.changeGroup(moveFieldConfirm, groupid); + } + } + + @action changeGroup = (moveFieldConfirm, groupid) => { + const params = {}; + let ids = []; + let names = []; + this.tableEditConfig.fieldDef.selectedRowKeys.map(idx => { + try{ + ids.push(this.tableEditConfig.fieldDef.datas[idx].id); + names.push(this.tableEditConfig.fieldDef.datas[idx].fieldname); + }catch(e){ + + } + }); + if(this.moduleName.indexOf('resource') > -1){ + Object.assign(params, { + fieldids: ids.join(','), + fieldnames: names.join(','), + groupid, + scopeid: this.selectedTreeNodeInfo.domid + }) + }else{ + Object.assign(params, { + ids: ids.join(','), + groupid + }); + } + moveFieldConfirm == null ? + this.doChangeGroup(params) : + this.confirmInfo({ + content:moveFieldConfirm, + onOk: () => { + this.doChangeGroup(params) + } + }); + } + + @action doChangeGroup = (params) => { + api.changeGroup(this.moduleName, params).then(data => { + if (data.status === '1') { + message.success(i18n.message.moveSuccess()); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + } else + message.error(data.message); + }, error => {message.error(i18n.message.actionError());}); + } + + @observable encryptDialogVisible = false; + @observable encryptDialogTitle = ""; + get encryptDialogButtons(){ + const buttonDef = [ + { + content: getLabel(30986, '保存'), + icon: 'icon-coms-Preservation', + onClickHandle: this.saveEncryptFieldSettingForm + } + ] + const buttons = [], moreBtnData = []; + buttonDef.map((btn, index) => { + const {content, icon, onClickHandle} = btn; + buttons.push( + () + ); + + moreBtnData.push({ + key: index.toString(), + content, + icon: , + onClick: onClickHandle + }); + }) + const {scopeId} = this.opParams; + let arr = []; + if(scopeId == '-1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEBASE', this.encryptParams.encryptId); + }else if(scopeId == '1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEPERSONAL', this.encryptParams.encryptId); + }else if(scopeId == '3'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEWORK', this.encryptParams.encryptId); + }else if(scopeId == 'subcompany'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SUBCOMPANY', this.encryptParams.encryptId); + }else if(scopeId == 'department'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_DEPARTEMENT', this.encryptParams.encryptId); + }else if(scopeId == 'salary'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SALARY'); + }else{} + moreBtnData.push(...arr); + return {buttons, moreBtn: {datas: moreBtnData}}; + } + + @computed get encryptDialogProps(){ + return { + title: this.encryptDialogTitle, + style: { + width: 600, + height: 350 + }, + ...ecCom.WeaTools.getIconBGC('currency'), + ...this.encryptDialogButtons, + visible: this.encryptDialogVisible, + onCancel: this.onEncryptDialogClose + } + } + + @computed get encryptFormItemRender(){ + return { + desensitization: (field, textAreaProps, form, formParams) => { + return ( + + ) + }, + secondauth: (field, textAreaProps, form, formParams) => { + return ( + + ) + }, + viewscope: (field, textAreaProps, form, formParams) => { + if(formParams.desensitization == '1') + return ( +
+
+ +
+ { + formParams.viewscope == '1' && + {getLabel(30747, '设置')} + } +
+ ) + return null; + }, + } + } + + @action onDesensitizationChangeHandle = data => { + const desensitization = data.desensitization.value; + desensitization == '0' && this.formTarget.encryptForm.updateFields({ + secondauth: { + value: '0' + } + }) + } + + @action onEncryptDialogClose = () => this.encryptDialogVisible = false; + + encryptParams = {}; + @action onEncryptHandle = async record => { + const {fieldname, tablename, fieldlabel, encryptId} = record; + this.encryptParams = {fieldname, tablename, encryptId}; + const label = getCurrentLabel(fieldlabel); + const data = await api.getEncryptFieldSettingForm({...this.encryptParams, ...this.opParams}); + if(data.status == '1'){ + this.setFormData('encryptForm', data.conditions); + if(this.formTarget.encryptForm.isFormInit){ + this.encryptDialogTitle = `${getLabel('526997','加密设置')}(${getLabel('261','字段')}:${label})`; + this.encryptDialogVisible = true; + } + }else{ + message.error(data.message); + } + } + + @observable needInitData = '1'; + get encrypt(){ + const {isencrypt} = this.formTarget.encryptForm.getFormParams(); + const fields = this.formTarget.encryptFormFields; + const col = find(fields[0].items, {domkey: ['isencrypt']}); + const {otherParams} = col || {}; + const {disabled} = otherParams || {}; + return isencrypt == '1' && !disabled; + } + @action saveEncryptFieldSettingForm = async () => { + const f = await this.formTarget.encryptForm.validateForm(); + if (f.isValid) { + if(this.encrypt){ + this.confirmInfo({ + width: 500, + content: ( +
+
1.{getLabel('524355','提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!')}

+
+ 2.{getLabel('531157','历史数据量可能较大, 此操作可能需要较长时间,对系统性能也可能会造成一定影响,请确认是否处理历史数据:')} + + { + this.needInitData = v; + }} + /> + +
+
+ ), + onOk: this.doSaveEncryptFieldSettingForm + }) + }else{ + this.needInitData = '0'; + this.doSaveEncryptFieldSettingForm(); + } + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + } + + @action doSaveEncryptFieldSettingForm = async () => { + if(this.spinning) + return; + this.spinning = true; + const params = {...this.formTarget.encryptForm.getFormParams(), ...this.encryptParams, needInitData: this.needInitData, ...this.opParams} + if (this.selectedTreeNodeInfo != null) { + Object.assign(params, { + scopeid: this.selectedTreeNodeInfo.key + }) + } + try{ + const data = await api.saveEncryptFieldSettingForm(params); + if(data.status == '1'){ + this.encryptDialogVisible = false; + message.success(i18n.message.saveSuccess()); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + }else{ + message.error(data.message); + } + this.spinning = false; + }catch(e){ + this.spinning = false; + } + } + + //#region 查看范围设置 + target = {}; + @observable dialogVisible = false; + @observable table = new TableStore(); + @observable canAdd = false; + @observable canDel = false; + + @computed get tableMultiDelete() { + return this.table.selectedRowKeys.length === 0 || !this.canDel; } - setTabKey(tabKey) { - this.tabKey = tabKey; + @computed get rangeViewTabProps(){ + return { + datas: [], + buttons: [ + , + , + ] + } } - setTopMenu(topMenu) { - this.topMenu = topMenu; + @action onDialogCancleHandle = () => this.dialogVisible = false; + + get dialogButtons(){ + const buttonDef = [ + { + content: getLabel(30986, '保存'), + icon: 'icon-coms-Preservation', + onClickHandle: this.saveViewRange + } + ] + const buttons = [], moreBtnData = []; + buttonDef.map((btn, index) => { + const {content, icon, onClickHandle} = btn; + buttons.push( + () + ); + + moreBtnData.push({ + key: index.toString(), + content, + icon: , + onClick: onClickHandle + }); + }) + + const {scopeId} = this.opParams; + let arr = []; + if(scopeId == '-1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEBASE', this.encryptParams.encryptId); + }else if(scopeId == '1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEPERSONAL', this.encryptParams.encryptId); + }else if(scopeId == '3'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEWORK', this.encryptParams.encryptId); + }else if(scopeId == 'subcompany'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SUBCOMPANY', this.encryptParams.encryptId); + }else if(scopeId == 'department'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_DEPARTEMENT', this.encryptParams.encryptId); + }else if(scopeId == 'salary'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SALARY'); + }else{} + moreBtnData.push(...arr); + return {buttons, moreBtn: {datas: moreBtnData}}; } - - setRightMenu(rightMenu) { - this.rightMenu = rightMenu; + @computed get dialogProps(){ + return { + title: getLabel('125012','查看范围设置'), + style: { + width: 800, + height: 600 + }, + ...ecCom.WeaTools.getIconBGC('currency'), + ...this.dialogButtons, + visible: this.dialogVisible, + onCancel: this.onDialogCancleHandle, + } } + @computed get rangeViewTableProps(){ + return { + comsWeaTableStore: this.table, + hasOrder: true, + needScroll: true, + scroll: { + y: 550 + }, + onOperatesClick: this.onOperatesClickHandle + } + } + + @action showSettingDialog = async () => { + if(this.encryptParams.encryptId == null || this.encryptParams.encryptId == ''){ + this.confirmInfo({ + content: getLabel('524355','提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!'), + onOk: async () => { + const rs = await api.saveEncryptFieldSettingForm({...this.formTarget.encryptForm.getFormParams(), ...this.encryptParams, ...this.opParams}); + if(rs.status == '1'){ + this.encryptParams.encryptId = rs.encryptId; + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + this.dialogVisible = this.getEncryptFieldScopeList(); + }else{ + message.error(data.message); + } + } + }); + }else + this.dialogVisible = this.getEncryptFieldScopeList(); + } + + @action getEncryptFieldScopeList = async () => { + const d = await api.getEncryptFieldScopeList({id: this.encryptParams.encryptId}); + if(d.status == '1'){ + const {canAdd, canDel, sessionkey} = d; + this.canAdd = canAdd; + this.canDel = canDel; + this.table = new TableStore(); + this.table.getDatas(sessionkey); + return true; + }else{ + message.error(d.message); + return false; + } + } + + @action onOperatesClickHandle = (record, index, operate) => { + const func = operate.href ? operate.href.split(':')[1].split('(')[0] : ''; + const id = record.id || ''; + this[func] && this[func](id, record); + } + + @action doMultiDel = () => this.doDel(); + + @action doDel = ids => { + const params = { + fieldid: this.encryptParams.encryptId, + ids: ids || this.table.selectedRowKeys + }; + let content = isEmpty(ids) ? getLabel(385625, '确定要删除选择的记录吗?') : getLabel(83877, '确定要删除吗?'); + this.confirmInfo({ + content, + onOk: async () => { + const data = await api.delEncryptFieldScopeSetting({...params, ...this.opParams}); + if (data.status === "1") { + message.success(getLabel(83472, '删除成功!')); + this.table.getDatas(null, 1); + }else{ + message.error(data.message); + } + } + }); + } + + @action saveViewRange = async () => { + this.onDialogCancleHandle(); + } + //#endregion + + //#region 范围form + @observable conditions = []; + + @observable viewRangeAuthVisible = false; + + @computed get viewRangeAuthProps(){ + return { + title: getLabel('383694','添加人员'), + conditions: this.toJS(this.conditions), + ...ecCom.WeaTools.getIconBGC('currency'), + visible: this.viewRangeAuthVisible, + onOk: this.onOKHandle, + onCancel: this.onViewRangeAuthCancleHandle, + } + } + + @action getViewRangeForm = async () => { + const data = await api.getEncryptFieldScopeForm(); + if(data.status == "1"){ + this.conditions = data.conditions; + this.viewRangeAuthVisible = true; + } + } + + @action onOKHandle = async data => { + const d = await api.saveEncryptFieldScopeSetting({id: this.encryptParams.encryptId, ...data, ...this.opParams}); + if(d.status == '1'){ + message.success(getLabel(83551, '保存成功!')); + this.getEncryptFieldScopeList(); + }else{ + message.error(d.message); + } + this.viewRangeAuthVisible = false; + } + + @action onViewRangeAuthCancleHandle = () => { + this.viewRangeAuthVisible = !this.viewRangeAuthVisible; + } + + get opParams(){ + const obj = { + fieldname: this.encryptParams.fieldname + } + const name = (this.moduleName || '').toLocaleLowerCase(); + if(name.indexOf('subcompany') > -1){ + Object.assign(obj, { + scopeId: 'subcompany' + }); + }else if(name.indexOf('department') > -1){ + Object.assign(obj, { + scopeId: 'department' + }); + } + this.selectedTreeNodeInfo != null && Object.assign(obj, { + scopeId: this.selectedTreeNodeInfo.key + }); + + return obj; + } + //#endregion + /********************* action list *********************/ + } \ No newline at end of file diff --git a/pc4mobx/organization/style/index.less b/pc4mobx/organization/style/index.less index 683be40..5dd610b 100644 --- a/pc4mobx/organization/style/index.less +++ b/pc4mobx/organization/style/index.less @@ -52,6 +52,18 @@ html { } } +.tabBtn-active { + color: #34a2ff; +} + +.tabBtn { + cursor: pointer; + font-size: 20px; + position: relative; + top: 6px; + right: 15px; +} + //组织架构图 #node { diff --git a/pc4mobx/organization/util/index.js b/pc4mobx/organization/util/index.js index 341d13c..ebe5892 100644 --- a/pc4mobx/organization/util/index.js +++ b/pc4mobx/organization/util/index.js @@ -72,4 +72,21 @@ export const renderNoData = () => ( export const isEmpty = (obj) =>{ for(var n in obj){return false} return true; +} + + +export const calFormHeight = (groupLength, children) => { + let childrenLength = 0; + children.map(c => { + if (c.colSpan != null) { + childrenLength += c.colSpan == 2 ? 1 : 2; + } else + childrenLength += 1; + }) + let height = (childrenLength / 2 + childrenLength % 2) * 52 + 10; + if (groupLength > 1) + height += groupLength * 45; + if (height > 300) + return 300; + return height; } \ No newline at end of file