diff --git a/pc4mobx/organization/apis/fieldDefined.js b/pc4mobx/organization/apis/fieldDefined.js new file mode 100644 index 0000000..8306fbb --- /dev/null +++ b/pc4mobx/organization/apis/fieldDefined.js @@ -0,0 +1,103 @@ +import { + WeaTools +} from 'ecCom'; + +/** + * 获取tab数据 + * @param {Object} params [description] + * @return {[type]} [description] + */ +export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTabInfo`, 'GET', params) + +export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getFieldDefinedInfo`, 'GET', params) + +export const saveFieldDefinedInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const removeFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/del`, 'POST', params) + +export const saveGroupInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + + +export const saveGroupSettingInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveGroup`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const changeTypeInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/changeTree`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const removeGroupInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/deleteTitle`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + + +export const getTree = (moduleName,params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTree`, 'GET', params) + +export const saveTree = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTree`, { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const changeGroup = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/changeGroup`, 'POST', params) + +export const getEncryptFieldSettingForm = (params = {}) => WeaTools.callApi(`/api/encrypt/fieldsetting/getEncryptFieldSettingForm`, 'GET', params) + +export const saveEncryptFieldSettingForm = (params = {}) => WeaTools.callApi(`/api/encrypt/fieldsetting/saveEncryptFieldSettingForm`, 'POST', params) + +//获取字段可查看范围列表 +export const getEncryptFieldScopeList = (params = {}) => WeaTools.callApi('/api/encrypt/fieldsetting/getEncryptFieldScopeList', 'POST', params); + +//获取字段可查看范围表单 +export const getEncryptFieldScopeForm = (params = {}) => WeaTools.callApi('/api/encrypt/fieldsetting/getEncryptFieldScopeForm', 'GET', params); + +//保存字段可查看范围 +export const saveEncryptFieldScopeSetting = (params = {}) => WeaTools.callApi('/api/encrypt/fieldsetting/saveEncryptFieldScopeSetting', 'POST', params); + +//删除字段可查看范围 +export const delEncryptFieldScopeSetting = (params = {}) => WeaTools.callApi('/api/encrypt/fieldsetting/delEncryptFieldScopeSetting', 'POST', params); + 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..1bf4129 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js @@ -0,0 +1,195 @@ +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, + typeInfoFrom, + typeInfoFromFields, + childInfoForm, + childInfoFormFields + } = formTarget; + const { + editGroupInfo, + editTypeInfo, + 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('editTypeInfo', 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 new file mode 100644 index 0000000..c2812e6 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js @@ -0,0 +1,194 @@ +import '../../style/index.less'; +import React, { + Component +} from 'react'; +import { + inject, + observer +} from 'mobx-react'; +import { + WeaTop, + WeaAlertPage, + WeaLeftTree, + WeaLeftRightLayout, + WeaDropdown +} from 'ecCom'; +import { Spin } from 'antd'; +import Tabs from './Tabs'; +import FieldDef from './FieldDef'; +import { + i18n +} from '../../public/i18n'; +const { ButtonSelect } = WeaDropdown; + + +@inject('fieldDefined') +@observer +export default class FieldDefined extends Component { + constructor(props) { + super(props); + this.state = { + logSmallType: '' + } + } + + componentDidMount() { + this.init(this.props); + } + + 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'; + } else if (moduleType === 'department') { + moduleName = 'departmentfielddefined'; + } else if(moduleType === 'job') { + moduleName = 'jobfielddefined'; + }else { + moduleName = 'resourcefielddefined'; + } + // let callbackFunc = () => initData(false, true, moduleName); + // if (moduleType === 'resource') + //let callbackFunc = () => initResourceData(moduleName); + //checkAuthorized(moduleName, null, callbackFunc); + initResourceData(moduleName); + this.setState({ logSmallType }) + } + + tabChangeHandle = (key) => { + const { + fieldDefined: store + } = this.props, { + tabConfig + } = store; + store.setActiveTab(tabConfig, key); + } + + 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 = []; + const hasRight = true;//todo + if (hasRight) { + const { + data, + onSelectedTreeNode, + selectedKeys, + onExpand, + treeExpandKeys + } = store.toJS(treeConfig); + const treeCom = ( + + ) + children = [ + ( + + + + { + + + + } + + + + ) + ] + } else { + children = [ + ( + +
{i18n.message.authFailed()}
+
+ ) + ]; + } + + return ( +
+ {children} +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/FormInfo.js b/pc4mobx/organization/components/fieldDefinedSet/FormInfo.js new file mode 100644 index 0000000..0c626ba --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/FormInfo.js @@ -0,0 +1,151 @@ +import React, { + Component +} from 'react'; +import { + observer +} from 'mobx-react'; +import { + Button +} from 'antd'; +import { + WeaFormItem, + WeaSearchGroup, + WeaCheckbox +} from 'ecCom'; +import { + WeaSwitch +} from 'comsMobx'; +import findIndex from 'lodash/findIndex'; + +@observer +export default class FormInfo extends Component { + renderForm = () => { + const { + formFields, + form, + colCount, + itemRender, + onSelectedChangeHandle, + showLabel, + multiColumn, + custLabelCol, + childrenComponents, + onSwitchChange, + } = this.props; + + let groupArr = []; + const formParams = form.getFormParams(); + const labelVisible = showLabel == null || showLabel == true; + const col = colCount ? colCount : 1; + const labelCol = labelVisible ? (custLabelCol || `${window.HrmEngineLabelCol}`) : 0; + const itemProps = { + ratio1to2: labelVisible && custLabelCol == null, + style: { + marginLeft: 0 //labelVisible ? -30 : 0 + }, + tipPosition: 'bottom', + labelCol: { + span: labelCol + }, + wrapperCol: { + span: 24 - labelCol + } + } + + const textAreaProps = { + minRows: 4, + maxRows: 4 + } + + formFields.map((fields, i) => { + let formItems = []; + fields.items.map((field, index) => { + const customerRender = itemRender != null ? itemRender[field.domkey[0]] : null; + const showCheckbox = field.checkbox || false; + let label = field.label; + if (showCheckbox) + label = {field.checkboxValue = v === '1'; onSelectedChangeHandle && onSelectedChangeHandle(field, v)}}/> + + let coms; + if (customerRender == null) { + coms = onSwitchChange && onSwitchChange(datas)}/>; + } else { + coms = customerRender(field, textAreaProps, form, formParams); + } + Object.assign(itemProps, { + label, + error: form.getError(field) + }) + let col = 1; + if (multiColumn != null) { //检查有哪些字段需要一行显示多个 + const idx = findIndex(multiColumn, item => item.key === field.domkey[0]); + if (idx > -1) { + col = field.colSpan || 1; + if (multiColumn[idx].labelCol != null) //检查字段是否有配置标题宽度 + Object.assign(itemProps, { + labelCol: { + span: multiColumn[idx].labelCol + }, + wrapperCol: { + span: 24 - multiColumn[idx].labelCol + } + }) + } else { + Object.assign(itemProps, { + labelCol: { + span: labelCol + }, + wrapperCol: { + span: 24 - labelCol + } + }) + } + } + + coms != null && formItems.push({ + com: ( + + {coms} + + ), + col + }) + + if (childrenComponents && childrenComponents[field.domkey[0]]) { + childrenComponents[field.domkey[0]]().map(child => formItems.push(child)); + } + }) + + groupArr.push( + ( + + ) + ) + }); + + return groupArr; + } + + render() { + const { + formFields, + className, + showError + } = this.props; + if (formFields == null) + return (
) + + return ( +
+ {this.renderForm()} +
+ ) + } +} \ 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/index.js b/pc4mobx/organization/index.js index e51c7ef..475b598 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -22,6 +22,7 @@ import Job from "./components/job/Job"; import JobExtend from "./components/job/JobExtend"; import Department from "./components/department/department"; import DepartmentExtendStore from "./components/department/departmentExtend"; +import FieldDefined from "./components/fieldDefinedSet/FieldDefined"; import stores from "./stores"; import "./style/index"; @@ -77,6 +78,8 @@ const Routes = ( + + ); diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index dc077a5..fad5e61 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -147,7 +147,7 @@ export const i18n = { newDept: () => getLabel(386246, '新建部门'), mergeDept:()=> getLabel(386246, '合并部门'), transferDept:()=> getLabel(386246, '转移部门'), - + typeName: () => getLabel(129927, '类型名称'), authorizationGroup: () => getLabel(492, '权限组'), @@ -842,6 +842,8 @@ export const i18n = { }, button: { back: () => getLabel(1290, '返回'), + createType: () => getLabel(30131, '新建类型'), + editTypeInfo: () => getLabel(32732, '编辑类型'), batchOpen: () => getLabel(534249, '批量解锁'), collect: () => getLabel(28111, '收藏'), diff --git a/pc4mobx/organization/stores/baseStore.js b/pc4mobx/organization/stores/baseStore.js new file mode 100644 index 0000000..fe5b741 --- /dev/null +++ b/pc4mobx/organization/stores/baseStore.js @@ -0,0 +1,627 @@ +/** + * @Author: 程亮 + * @Date: 2022-06-09 10:14:20 + * @LastEditTime: 2022-06-16 18:26:17 + * @Description: + * @FilePath: /trunk/src4js/pc4mobx/organization/stores/baseStore.js + */ +import { + observable, + action, + computed, + extendObservable, + autorun +} from 'mobx'; +import { + Button, + message, + Modal +} from 'antd'; +import { + WeaForm, + WeaTableNew, + WeaLogView +} from 'comsMobx'; +import { + WeaTableEdit, + WeaBrowser, + WeaButtonIcon, + WeaCascader, + WeaLoadingGlobal +} from 'ecCom'; +import classnames from 'classnames'; +import * as mobx from 'mobx'; +import { + authorized, + detachable, + checkAuthAndDetach, + getPinYin +} from '../apis/common'; +import { + i18n +} from '../public/i18n'; +// import { +// logTypeDef +// } from '../public/logType'; +import has from 'lodash/has'; +import moment from 'moment'; + +const {OptionManage} = WeaCascader; + +const confirm = Modal.confirm; +const info = Modal.confirm; +const { + LogStore +} = WeaLogView; + +export default class HrmBaseStore { + /********************* unobservable list *********************/ + //logTypeDef = logTypeDef; + getPinYin = getPinYin; + toJS = mobx.toJS; + moment = moment; + tabConfig = { //模块主tab组件参数,通过继承来重写 + keyParam: 'viewCondition', + activeTabKey: '' + }; + basicDialogParams = { + icon: "icon-coms-hrm", + iconBgcolor: "#217346", + style: { + width: 520, + height: 300 + }, + visible: false, + title: '', + } + menuIconCollection = { + save: 'icon-coms-Preservation', + create: 'icon-coms-New-Flow', + modify: 'icon-coms-edit', + remove: 'icon-coms-Batch-delete', + copy: 'icon-coms-form-copy', + entry: 'icon-coms-edit', + setting: 'icon-coms-Flow-setting', + log: 'icon-coms-Print-log', + multiModify: 'icon-coms-BatchEditing', + import: ' icon-coms-leading-in', + export: 'icon-coms-export', + search: 'icon-coms-search', + sync: 'icon-coms-Update-synchronization', + done: 'icon-coms-Upload-successfully', + selectAll: 'icon-coms-batch' + } + getBasicMenus = (logTypeKey, targetId = null) => { + let arr = []; + // if(logTypeKey){ + // arr.push({ + // key: '99', + // content: i18n.button.log(), + // icon: , + // onClick: () => this.showLog({logSmallType: this.logTypeDef[logTypeKey], targetId}) + // }); + // } + return arr; + } + + generateLogMenu = (logType = '4', logTypeKey, targetId = null) => { + let arr = []; + if(logTypeKey){ + arr.push({ + key: '99', + content: i18n.button.log(), + icon: , + onClick: () => this.showLog({logType, logSmallType: this.logTypeDef[logTypeKey], targetId}) + }); + } + return arr; + } + + dialogPropsDef = { + moduleName: 'hrm', + visible: false, + title: '', + moreBtn: { + datas: [] + }, + // hasScroll: true + } + refsDialogPropsDef = { + moduleName: 'hrm', + visible: false, + title: '', + } + dateSwitchTypeList = ['year', 'month', 'week', 'day']; + formTarget = {}; //form collection + opId = null; //数据操作对象主键ID + authorizationInfo = {}; + + /** + * 权限验证 + * @param {String} moduleName [模块名] + * @param {Object} params [restful request url params] + * @param {Function} callback [验证通过后的callback function] + * @return {null} + */ + checkAuthorized = (moduleName, params, callback, apiMethod, needCheckDetachable = false) => { + if (needCheckDetachable) { + checkAuthAndDetach(moduleName, params, apiMethod).then(rs => { + rs.map((result, index) => { + if (result.status === '1') { + switch (index) { + case 0: + const init = !result.hasRight; + this.authorizationInfo = result; + this.containerInitFinished = { + ...this.containerInitFinished, + init, + authorized: result.hasRight, + userId: result.userId + } + this.containerInitFinished.authorized && callback && callback(); + break; + case 1: + this.containerInitFinished.detachable = result.detachable === '0' ? false : true + break; + } + } + }) + }) + } else { + authorized(moduleName, params, apiMethod).then((data) => { + if (data.status === '1') { + const init = !data.hasRight; + this.authorizationInfo = data; + this.containerInitFinished = { + init, + authorized: data.hasRight + } + this.containerInitFinished.authorized && callback && callback(); + } + }, error => { + this.containerInitFinished = { + init: true, + authorized: false + } + }); + } + } + + /** + * 获取激活的tab页下标 + * @param {Array} tabs [tabData数组] + * @param {String} key [tabKey] + * @return {Integer} [tab下标] + */ + getTabIndex(tabs, key) { + if (tabs != null && tabs.length > 0) { + return _.findIndex(tabs, { + viewCondition: key + }) + } + return -1; + } + + /** + * 获取WeaTop按钮、WeaTab按钮以及右键菜单列表 + * @param {Object} tabConfig [description] + * @return {Object} [description] + */ + btnsAndMenus = (tabConfig) => { + let topBtnDef = [], //WeaTop按钮 + menuDef = [], //右键菜单 + tabBtnDef = []; //WeaTab按钮 + + const activeTabIndex = this.getTabIndex(tabConfig.tabs, tabConfig.activeTabKey); + if (tabConfig.activeTabKey === '' || activeTabIndex < 0) { + return { + btns: topBtnDef, + menus: menuDef, + tabBtnDef: tabBtnDef + } + } + const tab = tabConfig.tabs[activeTabIndex]; + const { + topButtonDef, + tabButtonDef + } = tab; + topButtonDef && topButtonDef.map((def, idx) => { //组织WeaTop按钮 + const lbl = (typeof(def.label) == 'function' ? def.label() : def.label); + switch (def.comType) { + case 'button': + let disabled = false; + if (def.checkAction) + disabled = this[def.checkAction]; + topBtnDef.push(); + menuDef.push({ //组织右键菜单 + key: `$top-btn-${idx}`, + content: lbl, + icon: , + onClick: def.onClickHandle, + disabled: disabled || def.disabled || false + }) + break; + default: + break; + } + }); + tabButtonDef && tabButtonDef.map((def, idx) => { //组织WeaTab按钮 + const lab = (typeof(def.label) == 'function' ? def.label() : def.label); + let disabled = false; + if (def.checkAction) + disabled = this[def.checkAction]; + switch (def.comType) { + case 'button': + const classes = classnames({ + [def.icon]: true, + 'tabBtn': true, + 'tabBtn-active': !disabled, + 'tabBtn-disable': disabled + }); + if (def.brower == null) { + tabBtnDef.push( + + ); + } else { + switch (def.brower) { + case 'authorization': + tabBtnDef.push( + def.onClickHandle(ids, names, datas)} + isSingle={false} + > + + + ); + break; + } + } + break; + case 'WeaButtonIcon': + tabBtnDef.push( + + ); + break; + case 'customer': + tabBtnDef.push(def.coms) + break; + default: + tabBtnDef.push( + + ); + break; + } + }); + // menuDef.push(...this.getBasicMenus()); //组织右键菜单 + return { + btns: topBtnDef, + menus: menuDef, + tabBtnDef: tabBtnDef + } + } + + /** + * [description] + * @param {String} com [dialog's name] + * @param {Boolean} val [visible: true or false] + * @param {String} title [dialog's title] + * @param {Function} callback [callback function] + * @return {null} + */ + setDialogVisible = (com, val, title = '', callback) => { + this.dialogParams[com] = { + ...this.dialogParams[com], + visible: val, + title: title + }; + callback && callback(); + } + + confirmInfo = (props) => { + confirm({ ...props, + title: props.title || i18n.confirm.defaultTitle(), + okText: i18n.button.ok(), + cancelText: i18n.button.cancel() + }); + } + + hint = (props) => { + info({ ...props, + title: i18n.confirm.defaultTitle(), + okText: i18n.button.ok(), + }); + } + + /** + * 初始化formStore + * @param {String} formName [form's name] + * @param {Array} fields [form field definition] + * @return {null} + */ + setFormData = (formName, fields) => { + this.formTarget[`${formName}Fields`] = fields; + this.formTarget[formName] = new WeaForm(); + this.formTarget[formName].initFormFields(fields); + //this.formTarget[formName].setCondition(fields); + } + + /** + * 请求高级搜索表单的通用方法 + * @param {String} form [form's name] + * @param {Function} api [restful api function] + * @param {Object} params [restful request url params] + * @param {Function} callback [callback function] + * @return {null} + */ + requestFormData = (form, api, params = {}, callback) => { + api(params).then((data) => { + if (data.status === '1') { + this.setFormData(form, data.formField); + callback && callback(); + } + }, error => { + + }); + } + + /** + * 获取表格数据的通用方法 + * @param {String} tableStore [tableStore's name] + * @param {Function} api [restful api function] + * @param {Object} params [restful request url params] + * @return {null} + */ + requestTableData = (tableStore, api, params = {}, callback) => { + api(params).then(data => { + if (data.status === '1') { + tableStore.getDatas(data.sessionkey, 1); + callback && callback(); + } else + message.error(data.message); + }, error => { + message.error(i18n.message.actionError()); + }); + } + + showLog = (logTypeParams) => { + window.setLogViewProps({ + ...logTypeParams + }); + } + /********************* unobservable list *********************/ + + /********************* observable list *********************/ + @observable containerInitFinished = { //模块初始化状态 + init: false, + authorized: false, + detachable: false + } + @observable topTabCount = {}; //WeaTab统计值 + @observable rDate = new Date().getTime(); //状态刷新,组件引用该值监听变化重新render + @observable showError = new Date().getTime(); //状态刷新,组件引用该值监听变化重新render + @observable dialogParams = {}; //模态框参数 + @observable i18nLoaded = false; + + monitorI18n = () => { + this.i18nLoaded; + } + + monitor = autorun(this.monitorI18n) + /********************* observable list *********************/ + + /********************* action list *********************/ + @action definedColumn = (table, callback) => {//显示列定义 + table.setColSetVisible(true); + table.tableColSet(true, callback); + } + /********************* action list *********************/ + + /********************* tableEdit props & functions *********************/ + editTable = {}; //可编辑表格refs对象 + editTableConfig = { //WeaTableEdit参数定义,通过继承来重写 + showTitle: false, + draggable: true, + showAdd: false, + showDelete: false, + showCopy: false, + deleteConfirm: true + } + + /** + * 设置WeaTableEdit的refs对象 + * @param {Object} refs [WeaTableEdit] + */ + setEditTable = (refs, name) => { + this.editTable[name] = refs; + } + + /** + * 通过refs对WeaTableEdit进行添加行、删除行、复制行操作 + * @param {String} type [action] + */ + @action + recordOP = (target, type, callback = null) => { + switch (type) { + case 'add': + target.refs.edit.doAdd() + break; + case 'remove': + target.refs.edit.doDelete() + break; + case 'copy': + target.refs.edit.doCopy() + break; + case 'valid': + return target.refs.edit.doRequiredCheck() + default: + break; + } + } + + generateTableEditRightMenuInfo = (tableConfig) => { + let rightMenuInfo = []; + const keys = Object.keys(tableConfig); + keys.map((key, index) => { + rightMenuInfo.push({ + key: `8${index + 1}`, + disabled: tableConfig[key].disabled, + content: tableConfig[key].content, + icon: , + onClick: tableConfig[key].callback + }) + }) + return rightMenuInfo; + } + + generateTableSelectedData = (target) => { + let selectedData = {}; + this.tableEditConfig[target].columns.map(column => { + column.hasOwnProperty('checkType') && column.checkType === 'checkbox' && Object.assign(selectedData, { + [column.dataIndex]: [] + }) + }) + return selectedData; + } + + generateOtherParams = (componentType, used, domkey) => { + let otherParams = { + customProps: { + 'root': { + viewAttr: 1 + } + }, + optionManageProps: { + dialogProps: { + icon: "icon-coms-hrm", + iconBgcolor: "#217346", + }, + showAdd: !used, + showCopy: !used, + showDelete: !used, + tableEditDraggable: !used + } + } + switch (componentType) { + case 'input': + Object.assign(otherParams.customProps, { + 'input': { + viewAttr: 1 + }, + 'input.text': { + viewAttr: 1 + } + }); + break; + case 'select': + Object.assign(otherParams.customProps, { + 'select': { + viewAttr: 1, + }, + // 'select.*': { + // parent: { type: "span", className: `${domkey}-clz` } + // }, + }); + break; + } + return otherParams; + } + + //重新计算列 + convertData = (datas, target) => { + let tData = [], + selectedData = this.generateTableSelectedData(target); + datas.map((data, index) => { + let d = {}; + Object.assign(d, { + ...data.record, + ...data.props, + isSysField: data.isSysField + }); + delete d.key; + const selectedDataKey = Object.keys(selectedData); + selectedDataKey.map(key => { + data.record.hasOwnProperty(key) && data.record[key] === '1' && selectedData[key].push(index); + }) + + if (data.hasOwnProperty('com')) { + const keys = Object.keys(data.com); + keys.map(key => { + if (data.com[key].length > 0) { + let comDef = data.com[key][0]; + if (comDef.type === 'CUSTOMFIELD' && data.hasOwnProperty(comDef.key) && data[comDef.key].length > 0) { + Object.assign(d, { + [comDef.key]: data[comDef.key], + }); + Object.assign(comDef, { + viewAttr: 1, + otherParams: this.generateOtherParams(data[comDef.key][0], d.isSysField, d.fieldname), + }) + } else if (comDef.type === 'INPUT' && key != 'fieldname') { + comDef.otherParams = { + ...window.inputType + } + } + } + }) + Object.assign(d, { + com: data.com + }); + } + + tData.push(d); + }) + return { + datas: tData, + selectedData + } + } + + getLocale() { + return { + firstDayOfWeek: 0, + lang: { + format: { + eras: [getLabel(383357, "公元前"), getLabel(383358, "公元")], + months: [getLabel(1492, "一月"), getLabel(1493, "二月"), getLabel(383385, "三月"), getLabel(383387, "四月"), getLabel(1496, "五月"), getLabel(383392, "六月"), + getLabel(383393, "七月"), getLabel(383394, "八月"), getLabel(383395, "九月"), getLabel(383396, "十月"), getLabel(383397, "十一月"), getLabel(383398, "十二月") + ], + shortMonths: [getLabel(1492, "一月"), getLabel(1493, "二月"), getLabel(383385, "三月"), getLabel(383387, "四月"), getLabel(1496, "五月"), getLabel(383392, "六月"), + getLabel(383393, "七月"), getLabel(383394, "八月"), getLabel(383395, "九月"), getLabel(383396, "十月"), getLabel(383397, "十一月"), getLabel(383398, "十二月") + ], + weekdays: [getLabel(24626, "星期天"), getLabel(383399, "星期一"), getLabel(383400, "星期二"), getLabel(383402, "星期三"), getLabel(383403, "星期四"), + getLabel(383404, "星期五"), getLabel(383405, "星期六") + ], + shortWeekdays: [getLabel(16106, "周日"), getLabel(16100, "周一"), getLabel(16101, "周二"), getLabel(16102, "周三"), getLabel(16103, "周四"), getLabel(16104, "周五"), + getLabel(16105, "周六") + ], + veryShortWeekdays: [getLabel(16106, "周日"), getLabel(16100, "周一"), getLabel(16101, "周二"), getLabel(16102, "周三"), getLabel(16103, "周四"), getLabel(16104, "周五"), getLabel(16105, "周六")], + ampms: [getLabel(383408, "上午"), getLabel(383409, "下午")], + datePatterns: [`yyyy'${getLabel(383372,"年")}'M'${getLabel(383373,"月")}'d'${getLabel(383374,"日")}' EEEE`, `yyyy'${getLabel(383372,"年")}'M'${getLabel(383373,"月")}'d'${getLabel(383374,"日")}'`, "yyyy-M-d", "yy-M-d"], + timePatterns: [`ahh'${getLabel(383411,"时")}'mm'${getLabel(383412,"分")}'ss'${getLabel(383414,"秒")}' 'GMT'Z`, `ahh'${getLabel(383411,"时")}'mm'${getLabel(383412,"分")}'ss'${getLabel(383414,"秒")}'`, "H:mm:ss", "ah:mm"], + dateTimePattern: '{date} {time}' + } + }, + } + } + + @action showWeaLoadingGlobal = (tip = '') => WeaLoadingGlobal.start({tip}); + @action hideWeaLoadingGlobal = () => { + WeaLoadingGlobal.end(); // 停止遮罩loading + WeaLoadingGlobal.destroy(); // 销毁遮罩loading + } + /********************* tableEdit props & functions *********************/ +} \ No newline at end of file diff --git a/pc4mobx/organization/stores/companyextend.js b/pc4mobx/organization/stores/companyextend.js index 95ba257..8079896 100644 --- a/pc4mobx/organization/stores/companyextend.js +++ b/pc4mobx/organization/stores/companyextend.js @@ -56,9 +56,9 @@ export class CompanyExtendStore { save = () => { if (this.loading) return; - this.loading = true; this.form.validateForm().then(f => { if (f.isValid) { + this.loading = true; if (this.personalEditTables) { const targetDatas = this.tableInfo[this.detailSelectedKey].tabinfo.datas, isPass = (targetDatas.length > 0) ? this.personalEditTables.refs.edit.doRequiredCheck().pass : true diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js new file mode 100644 index 0000000..c2950f2 --- /dev/null +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -0,0 +1,2328 @@ +/** + * @Author: 程亮 + * @Date: 2022-06-09 10:16:00 + * @LastEditTime: 2022-06-16 18:34:18 + * @Description: + * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js + */ +import { + observable, + action, + computed +} from 'mobx'; +import { + WeaForm, + WeaTableNew, + WeaSwitch +} from 'comsMobx'; +import { WeaLocaleProvider, WeaInputLocale, WeaButtonIcon, WeaSelect } from 'ecCom'; +import { + Button, + message, + Menu +} from 'antd'; +import HrmBaseStore from './baseStore'; +import * as api from '../apis/fieldDefined'; +import { + cloneDeep, + indexOf, + findIndex, + uniq, + has, + remove, + filter +} from 'lodash'; +import find from 'lodash/find'; +import isEmpty from 'lodash/isEmpty'; +import { + validDBKeys +} from '../util/index'; +import { + i18n +} from '../public/i18n'; +const getLabel = WeaLocaleProvider.getLabel; +const getCurrentLabel = WeaInputLocale.getCurrentLabel; +const { TableStore } = WeaTableNew; + +export class FieldDefinedStore extends HrmBaseStore { + + /********************* unobservable list *********************/ + //override baseStore.tabConfig + tabDef = { + color: '#000000', + groupId: '', + viewCondition: '1', + topButtonDef: [{ + comType: 'button', + type: 'primary', + onClickHandle: this.saveFieldDefine, + label: i18n.button.save, + icon: this.menuIconCollection.save + }, { + comType: 'button', + type: 'primary', + onClickHandle: () => this.editGroup(), + label: i18n.button.createGroup, + icon: this.menuIconCollection.create + }, { + comType: 'button', + type: 'primary', + onClickHandle: () => this.editTypeInfo(true, { + name: this.selectedTreeNodeInfo.name, + }), + label: i18n.button.createType, + icon: this.menuIconCollection.create + }, { + comType: 'button', + type: 'primary', + onClickHandle: this.doGroupSetting, + label: i18n.button.groupMaintain, + icon: this.menuIconCollection.setting, + checkAction: 'groupInfoOperability' + }], + tabButtonDef: [{ + comType: 'button', + icon: 'icon-coms-Add-to-hot', + label: i18n.button.create, + rightMenuIcon: this.menuIconCollection.create, + onClickHandle: () => this.recordOP(this.editTable['fieldDef'], 'add') + }] + } + tabConfig = { + tabs: [], + keyParam: 'viewCondition', + activeTabKey: '1', + onTabEdit: this.onTabEdit + }; + 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 = () => { + const columns = [{ + title: i18n.label.fieldLabel(), //列名 + dataIndex: 'fieldlabel', //列的id 对应数据 + key: 'fieldlabel', //前端渲染key值 + useRecord: true, + colSpan: 1, + width: '15%', + com: [{ + label: '', + type: 'INPUT', + key: 'fieldlabel', + viewAttr: '3', + otherParams: { + ...window.inputType + } + }], + }, { + title: i18n.label.fieldName(), + dataIndex: 'fieldname', + key: 'fieldname', + useRecord: true, + colSpan: 1, + width: '15%', + com: [{ + label: '', + type: 'INPUT', + key: 'fieldname', + viewAttr: '3', + otherParams: { + length: 25, + regExp: /^[a-zA-Z][a-zA-Z0-9]*$/, + filter: (val) => { + const { + isValid, + value + } = validDBKeys(val); + this.isDBKeyValid = isValid; + return value; + } + } + }], + }, { + title: i18n.label.fieldType(), + dataIndex: 'fieldType', + key: 'fieldType', + useRecord: true, + colSpan: 1, + width: (this.moduleName === 'resourcefielddefined' && !this.isJobTreeNode) ? "30%" : "40%", + com: [{ + label: '', + type: 'CUSTOMFIELD', + key: 'fieldType', + viewAttr: '3', + options: ['peculiar'], + otherParams: { + customProps: { + 'input.text': { + viewAttr: 3 + }, + 'textarea': { + parent: { + type: "div", + style: { + display: "none" + } + }, + style: { + display: "none" + } + }, + 'textarea.*': { + parent: { + type: "div", + style: { + display: "none" + } + }, + style: { + display: "none" + } + }, + 'textarea.*.*': { + style: { + display: "none" + } + }, + "select": { + options: [{ + key: 'select', + selected: true, + showname: i18n.label.selectComponent() + }] + }, + "upload": { + options: [{ + key: 'file', + selected: true, + showname: i18n.label.uploadFile() + }] + } + } + } + }], + }, { + title: i18n.label.enable(), + dataIndex: 'enable', + key: 'enable', + checkType: 'checkbox', + colSpan: 1, + width: '7%' + }, { + title: i18n.label.required(), + dataIndex: 'required', + key: 'required', + checkType: 'checkbox', + colSpan: 1, + width: '8%' + }]; + + //人员卡片字段定义-添加【允许个人修改】列 + if (this.moduleName === 'resourcefielddefined') { + if (this.isJobTreeNode) {//【工作信息】列表不添加【允许个人修改】列 + } else { + columns.push({ + title: getLabel(510359, '允许个人修改'), + dataIndex: 'isModify', + key: 'isModify', + checkType: 'checkbox', + colSpan: 1, + width: '11%' + }); + } + } + this.encryptEnable && columns.push({ + title: getLabel('526997', '加密设置'), + dataIndex: 'canEncrypt', + key: 'canEncrypt', + com: [ + { + type: 'custom', + key: 'custom', + render: (text, record, index, onEdit) => { + const { canEncrypt } = record; + if (canEncrypt == '1') + return ( + this.onEncryptHandle(record)}>{getLabel('526997', '加密设置')} + ) + return null; + } + } + ], + colSpan: 1, + width: '8%' + }); + return columns; + } + + groupDefColumns = () => [{ + title: i18n.label.groupName(), //列名 + dataIndex: 'groupName', //列的id 对应数据 + key: 'groupName', //前端渲染key值 + colSpan: 1, + width: '70%', + useRecord: true, + com: [{ + label: '', + type: 'INPUT', + key: 'groupName', + viewAttr: '3', + otherParams: { + ...window.inputType + } + }], + }, { + title: i18n.label.show(), + dataIndex: 'isShow', + key: 'isShow', + checkType: 'checkbox', + colSpan: 1, + useRecord: true, + width: '30%' + }]; + + childInfoDefColumns = () => [{ + title: i18n.label.childInfoName(), //列名 + dataIndex: 'name', //列的id 对应数据 + key: 'name', //前端渲染key值 + colSpan: 1, + width: '70%', + useRecord: true, + com: [{ + label: '', + type: 'INPUT', + key: 'name', + viewAttr: '3', + otherParams: { + ...window.inputType + } + }], + }, { + title: i18n.label.show(), + dataIndex: 'isShow', + key: 'isShow', + checkType: 'checkbox', + colSpan: 1, + useRecord: true, + width: '30%' + }]; + + getColumns = () => { + let columns = cloneDeep(this.fieldDefColumns()) + if (this.moduleName.indexOf('resource') >= 0) { + columns[1].com = [{ + label: '', + type: 'TEXT', + key: 'fieldname', + }] + } + return columns; + } + + tableEditConfig = { + fieldDef: { + ...this.editTableConfig, + showAdd: false, + showDelete: false, + showCopy: false, + columns: this.getColumns(), + copyFilterProps: ['id', 'fieldlabel', 'fieldname', 'com.fieldname', 'com.fieldlabel'], + datas: [], + selectedData: {}, + onChange: this.onFieldDefChange, + onRowSelect: this.onFieldDefRowSelect, + getRowSelection: this.onFieldDefRowSelection, + onDelete: this.onFieldDefDeleteOpr, + onEdit: this.onEdit, + onAdd: this.onAdd + }, + groupSetting: { + ...this.editTableConfig, + showTitle: true, + showAdd: true, + showDelete: true, + showCopy: false, + columns: this.groupDefColumns(), + copyFilterProps: ['id', 'groupName', 'isShow'], + datas: [], + selectedData: {}, + onChange: (datas) => this.onGroupSettingChange(datas, 'group'), + onRowSelect: (sRowKeys, rows, dataIndex, selectedDatas) => this.onGroupSettingRowSelect(sRowKeys, rows, dataIndex, selectedDatas, 'group'), + getRowSelection: this.onGroupSettingRowSelection, + onDelete: (ks, ds) => this.onGroupSettingDeleteOpr(ks, ds, 'group') + }, + childInfoSetting: { + ...this.editTableConfig, + showTitle: true, + showAdd: true, + showDelete: true, + showCopy: false, + columns: this.childInfoDefColumns(), + copyFilterProps: ['id', 'name', 'isShow'], + datas: [], + selectedData: {}, + onChange: (datas) => this.onGroupSettingChange(datas, 'childInfo'), + onRowSelect: (sRowKeys, rows, dataIndex, selectedDatas) => this.onGroupSettingRowSelect(sRowKeys, rows, dataIndex, selectedDatas, 'childInfo'), + getRowSelection: this.onGroupSettingRowSelection, + onDelete: (ks, ds) => this.onGroupSettingDeleteOpr(ks, ds, 'childInfo') + } + } + + activeTabInfo = {} + tabRecord = []; + isDBKeyValid = true; + /********************* unobservable list *********************/ + + /********************* dialog info setting *********************/ + editorDialogRightMenu = []; + getDialogOpButtons = () => { //获取权限组编辑对话框按钮列表 + this.editorDialogRightMenu.length = 0; + let buttons = []; + this.editorDialogRightMenu.push({ + key: '1', + content: i18n.button.save(), + icon: , + onClick: () => this.dialogSaveOp(false) + }); + + 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; + } + this.editorDialogRightMenu.push(...this.getBasicMenus(logType)); + } + + return buttons; + } + /********************* dialog info setting *********************/ + + /***** form ****/ + editGroupInfoFormFields = [{ + "title": i18n.label.basicSetting(), + "items": [{ + "colSpan": 2, + "conditionType": "INPUT", + "domkey": ["groupName"], + "fieldcol": 12, + "isQuickSearch": false, + "label": i18n.label.groupName, + "labelcol": 6, + "precision": 0, + "rules": "required|string", + "value": "", + "viewAttr": 3, + }], + "defaultshow": true + }] + + editTypeInfoFormFields = [{ + "title": i18n.label.basicSetting(), + "items": [{ + "colSpan": 2, + "conditionType": "INPUT", + "domkey": ["name"], + "fieldcol": 12, + "isQuickSearch": false, + "label": i18n.label.typeName, + "labelcol": 6, + "precision": 0, + "rules": "required|string", + "value": "", + "viewAttr": 3, + }], + "defaultshow": true + }] + + editChildInfoFormFields = [{ + "title": i18n.label.basicSetting, + "items": [{ + "colSpan": 2, + "conditionType": "INPUT", + "domkey": ["name"], + "fieldcol": 12, + "isQuickSearch": false, + "label": i18n.label.childInfoName, + "labelcol": 6, + "precision": 0, + "rules": "required|string", + "value": "", + "viewAttr": 3 + }, { + "colSpan": 2, + "conditionType": "INPUTNUMBER", + "domkey": ["infoOrder"], + "fieldcol": 12, + "isQuickSearch": false, + "label": i18n.label.displayOrder, + "labelcol": 6, + "precision": 0, + "value": "0", + "viewAttr": 2 + }], + "defaultshow": true + }] + + /********************* observable list *********************/ + dialogParams = { //override baseStore.dialogParams + editGroupInfo: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + }, + editTypeInfo: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + }, + groupInfoSetting: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + }, + createChildInfo: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + }, + childInfoSetting: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + } + } + + @observable dropdownSelectedKey = '1'; + @observable _groupInfoOperability = true; + @observable feildDefTableSelectedRows = []; + @observable groupSettingTableSelectedRows = []; + @observable _feildDefSaveable = 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; + } + + @computed get groupInfoRemoveable() { //字段定义表是否有选中行 + return this.groupSettingTableSelectedRows.length === 0; + } + + @computed get feildDefSaveable() { //字段定义表是否有记录 + return this._feildDefSaveable; + } + + @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') { + 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 => { + + }) + } + + 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; + }) + }) + } + + /** + * 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(response => { + return response.json() + }).then(res => { + if (res.code === 200) { + const { + datas, + selectedData + } = this.convertData(res.data.data, 'fieldDef'); + this.encryptEnable = res.data.encryptEnable; + this.tableEditConfig.fieldDef.datas = datas; + this.tableEditConfig.fieldDef.columns = this.getColumns(); + this.tableEditConfig.fieldDef.selectedData = selectedData; + + if (this.tabRecord.length > 0) { + this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (res.data.data.length === 0); + this.activeTabInfo.tabInfo.editable = (res.data.data.length === 0); + } + } else { + message.warning(res.msg); + } + this.spinning = false; + this.refreshMainTabComponent = new Date().getTime(); + }).catch(error => { + this.spinning = false; + message.warning(error.msg); + }) + + + } + + @action("分组tab删除") onTabEdit = (targetKey, action) => { + const tabIndex = this.getTabIndex(this.tabConfig.tabs, targetKey); + if (tabIndex < 0) return; + const tabInfo = this.tabConfig.tabs[tabIndex]; + switch (action) { + case 'remove': + this.confirmInfo({ + content: i18n.confirm.delete(), + onOk: () => { + let params = { + id: tabInfo.groupid + } + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key + + api.removeGroupInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(i18n.message.deleteSuccess()); + this.tabConfig.activeTabKey = '1'; + this.getTabInfoByTreeNode(); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + }); + break; + default: + break; + } + } + + @action dialogSaveOp = () => { + this.dialogParams.editGroupInfo.visible && this.doSaveGroupInfo(); + this.dialogParams.editTypeInfo.visible && this.doSaveTypeInfo(); + this.dialogParams.groupInfoSetting.visible && this.doSaveGroupSetting(); + this.dialogParams.createChildInfo.visible && this.doSaveChildInfo(); + this.dialogParams.childInfoSetting.visible && this.doSaveChildInfoSetting(); + } + + @action("新建分组") editGroup = (group, moveToGroup = false) => { + this.moveToGroup = moveToGroup; + this.editGroupInfoFormFields.map(f => { + if (typeof (f.title) == 'function') + f.title = f.title(); + f.items.map(item => { + if (typeof (item.label) == 'function') + item.label = item.label(); + item.otherParams = { ...window.inputType }; + }) + }) + let fields = [...this.editGroupInfoFormFields], + dialogTitle = ''; + this.setFormData('groupInfoFrom', fields); + if (group) { + this.formTarget.groupInfoFrom.updateFields({ + groupName: { value: group.multiTitle || group.title || '' } + }); + this.opId = group.groupid; + dialogTitle = i18n.button.editGroup(); + } else { + this.formTarget.groupInfoFrom.updateFields({ + groupName: { value: '' } + }); + this.opId = null; + dialogTitle = i18n.button.createGroup(); + } + this.setDialogVisible('editGroupInfo', true, dialogTitle); + } + + isCreateTypeInfo = false; + @action("新增或创建类型") editTypeInfo = (create = true, data = {}) => { + this.isCreateTypeInfo = create; + this.editTypeInfoFormFields.map(f => { + if (typeof (f.title) == 'function') + f.title = f.title(); + f.items.map(item => { + if (typeof (item.label) == 'function') + item.label = item.label(); + item.otherParams = { ...window.inputType }; + }) + }) + let fields = [...this.editTypeInfoFormFields], + dialogTitle = create ? i18n.button.createType() : i18n.button.editTypeInfo(); + this.setFormData('typeInfoFrom', fields); + if (!create) { + this.formTarget.typeInfoFrom.updateFields({ + name: { value: data.name } + }); + } else { + this.selectedTreeNodeInfo.domid = null; + } + + this.setDialogVisible('editTypeInfo', true, dialogTitle); + } + + @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()); + } + + + @action("保存类型") doSaveTypeInfo = () => { + this.formTarget.typeInfoFrom.validateForm().then(f => { + if (f.isValid) { + let params = { + ... this.formTarget.typeInfoFrom.getFormParams(), + id: this.selectedTreeNodeInfo.domid + } + api.changeTypeInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + this.setDialogVisible('editTypeInfo', false, ''); + this.getTree() + message.success(i18n.message.saveSuccess()); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + }); + } + + @action("分组保存") doSaveGroupInfo = () => { + this.formTarget.groupInfoFrom.validateForm().then(f => { + if (f.isValid) { + let record = { + ...this.formTarget.groupInfoFrom.getFormParams(), + isShow: 1 + } + const recordIndex = findIndex(this.tabConfig.tabs, { + title: getCurrentLabel(record.groupName) + }); + if (recordIndex >= 0) { + f.showError('groupName', i18n.confirm.groupNameExist()); + this.showError = new Date().getTime(); + return; + } + let params = { + ...this.formTarget.groupInfoFrom.getFormParams(), + isShow: 1 + } + + if (this.selectedTreeNodeInfo != null) + params.groupType = this.selectedTreeNodeInfo.key + + api.saveGroupInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + this.setDialogVisible('editGroupInfo', false, ''); + if (this.moveToGroup) { + const ids = data.data.groupid.split(','); + this.changeGroup(null, ids[ids.length - 1]); + } else { + this.getTabInfoByTreeNode(); + message.success(i18n.message.saveSuccess()); + } + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + }); + } + + @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(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(i18n.message.saveSuccess()); + this.getTabInfoByTreeNode(); + } else { + message.warning(data.msg); + } + this.spinning = false; + }).catch(error => { + message.warning(error.msg); + }) + + } 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; + } + + @action("分组维护保存") 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 = dataObj; + + api.saveGroupSettingInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + this.setDialogVisible('groupInfoSetting', false, ''); + this.getTabInfoByTreeNode(false, true); + message.success(i18n.message.saveSuccess()); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + + } else { + message.error(i18n.confirm.groupNameExist()); + } + } + + @action("分组维护中删除") onGroupSettingDeleteOpr = (ks, ds, type) => { + debugger + 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; + this.treeConfig.treeExpandKeys.length = 0; + api.getTree(this.moduleName).then(res => { + if (res.code === 200) { + // this.containerInitFinished = { + // ...this.containerInitFinished, + // init: true + // } + if (res.data.length > 0) { + this.treeConfig.data = res.data; + this.treeConfig.selectedKeys = [res.data[0].key]; + this.selectedTreeNodeInfo = res.data[0]; + this.getTabInfoByTreeNode(null, true); + } + } else { + message.error(res.msg); + } + }, error => { }) + } + + getTree = (callback) => { + this.treeConfig.data.length = 0; + this.refreshTree = new Date().getTime(); + api.getTree(this.moduleName).then(res => { + if (res.code === 200) { + this.treeConfig.data = res.data; + 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(res.msg); + } + this.refreshTree = new Date().getTime(); + }, error => { }) + } + + setBtn = (t) => { + if (!this.selectedTreeNodeInfo.hasGroup) { + t.topButtonDef.splice(1, 3); + } + t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: () => this.editTypeInfo(false, { + name: this.selectedTreeNodeInfo.name, + }), + label: i18n.button.editTypeInfo(), + icon: this.menuIconCollection.setting + }) + if (this.selectedTreeNodeInfo.addChild) { //非子节点 + this.tableEditConfig.childInfoSetting.showTitle = true; + this.tableEditConfig.childInfoSetting.showAdd = true; + this.tableEditConfig.childInfoSetting.showDelete = true; + let domid = this.selectedTreeNodeInfo.domid; + t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.doChildInfoSetting, + label: i18n.button.childInfoMaintain(), + icon: this.menuIconCollection.setting + //checkAction: 'childInfoOperability' + }); + //非基本类型() + (domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.removeTypeInfo, + label: i18n.button.delete(), + icon: this.menuIconCollection.setting + }); + + } else { + this.tableEditConfig.childInfoSetting.showTitle = false; + this.tableEditConfig.childInfoSetting.showAdd = false; + this.tableEditConfig.childInfoSetting.showDelete = false; + t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.removeTypeInfo, + 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(res => { + if (res.code === 200) { + this._groupInfoOperability = res.data.tabs.length === 0; + let tabArr = []; + this.tabRecord = res.data.tabs; + res.data.tabs && res.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("编辑子信息保存(f)") 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 = this.selectedTreeNodeInfo.childs ? this.selectedTreeNodeInfo.childs : []; + 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()); + }); + } + }); + } + + @action("保存子信息维护") doSaveChildInfoSetting = () => { + debugger + 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, + groupName: 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) + // }), + data: JSON.stringify(infoArr), + parentId + } + + api.saveTree(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + this.setDialogVisible('childInfoSetting', false, ''); + this.getTree(); + this.getTabInfoByTreeNode(null, true); + message.success(i18n.message.saveSuccess()); + } else { + message.warning(data.msg); + } + }).catch(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; + } + + @computed get rangeViewTabProps() { + return { + datas: [], + buttons: [ + , + , + ] + } + } + + @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 } }; + } + + @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/stores/index.js b/pc4mobx/organization/stores/index.js index d42be77..ca229ff 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -15,6 +15,7 @@ import { StaffStore } from "./staff"; import { JobStore } from "./job"; import { JobExtendStore } from "./jobextend"; import { NumberSetStore } from "./numberSet"; +import {FieldDefinedStore} from "./fieldDefined"; module.exports = { simpleOrgStore: new SimpleOrgStore(), @@ -34,4 +35,5 @@ module.exports = { job: new JobStore(), jobExtend: new JobExtendStore(), numberSet: new NumberSetStore(), + fieldDefined: new FieldDefinedStore() }; diff --git a/pc4mobx/organization/style/index.less b/pc4mobx/organization/style/index.less index f661c00..5dd610b 100644 --- a/pc4mobx/organization/style/index.less +++ b/pc4mobx/organization/style/index.less @@ -35,6 +35,35 @@ html { background-color: transparent; } +//自定义设置 +.fieldDef{ + width: 100%; + height: 100%; + .wea-tab .wea-search-tab{ + &>span{ + margin-left: 0px !important; + } + } + + .status-clz, .sex-clz, .accounttype-clz{ + a { + display: none; + } + } +} + +.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..b6482dd 100644 --- a/pc4mobx/organization/util/index.js +++ b/pc4mobx/organization/util/index.js @@ -2,8 +2,36 @@ import { Spin } from 'antd'; import { WeaSwitch } from 'comsMobx'; import { WeaLocaleProvider, WeaAlertPage, WeaSearchGroup, WeaFormItem } from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; +import { + indexOf +} from 'lodash'; import '../style/index.less' +const dbKeys = ["PERCENT", "PLAN", "PRECISION", "PRIMARY", "PRINT", "PROC", "PROCEDURE", "PUBLIC", "RAISERROR", + "READ", "READTEXT", "RECONFIGURE", "REFERENCES", "REPLICATION", "RESTORE", "RESTRICT", "RETURN", "REVOKE", + "RIGHT", "ROLLBACK", "ROWCOUNT", "ROWGUIDCOL", "RULE", "SAVE", "SCHEMA", "SELECT", "SESSION_USER", "SET", + "SETUSER", "SHUTDOWN", "SOME", "STATISTICS", "SYSTEM_USER", "TABLE", "TEXTSIZE", "THEN", "TO", "TOP", "TRAN", + "TRANSACTION", "TRIGGER", "TRUNCATE", "TSEQUAL", "UNION", "UNIQUE", "UPDATE", "UPDATETEXT", "USE", "USER", + "VALUES", "VARYING", "VIEW", "WAITFOR", "WHEN", "WHERE", "WHILE", "WITH", "WRITETEXT", "EXCEPT", "EXEC", "EXECUTE", + "EXISTS", "EXIT", "FETCH", "FILE", "FILLFACTOR", "FOR", "FOREIGN", "FREETEXT", "FREETEXTTABLE", "FROM", "FULL", + "FUNCTION", "GOTO", "GRANT", "GROUP", "HAVING", "HOLDLOCK", "IDENTITY", "IDENTITY_INSERT", "IDENTITYCOL", "IF", "IN", + "INDEX", "INNER", "INSERT", "INTERSECT", "INTO", "IS", "JOIN", "KEY", "KILL", "LEFT", "LIKE", "LINENO", "LOAD", "NATIONAL", + "NOCHECK", "NONCLUSTERED", "NOT", "NULL", "NULLIF", "OF", "OFF", "OFFSETS", "ON", "OPEN", "OPENDATASOURCE", "OPENQUERY", + "OPENROWSET", "OPENXML", "OPTION", "OR", "ORDER", "OUTER", "OVER", "ADD", "ALL", "ALTER", "AND", "ANY", "AS", "ASC", "AUTHORIZATION", + "BACKUP", "BEGIN", "BETWEEN", "BREAK", "BROWSE", "BULK", "BY", "CASCADE", "CASE", "CHECK", "CHECKPOINT", "CLOSE", "CLUSTERED", + "COALESCE", "COLLATE", "COLUMN", "COMMIT", "COMPUTE", "CONSTRAINT", "CONTAINS", "CONTAINSTABLE", "CONTINUE", "CONVERT", "CREATE", + "CROSS", "CURRENT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DATABASE", "DBCC", "DEALLOCATE", + "DECLARE", "DEFAULT", "DELETE", "DENY", "DESC", "DISK", "DISTINCT", "DISTRIBUTED", "DOUBLE", "DROP", "DUMMY", "DUMP", "ELSE", "END", "ERRLVL", + "ESCAPE", "ACCESS", "ADD", "ALL", "ALTER", "AND", "ANY", "AS", "ASC", "AUDIT", "BETWEEN", "BY", "CHAR", "CHECK", "CLUSTER", "COLUMN", "COMMENT", + "COMPRESS", "CONNECT", "CREATE", "CURRENT", "DATE", "DECIMAL", "DEFAULT", "DELETE", "DESC", "DISTINCT", "DROP", "ELSE", "EXCLUSIVE", "EXISTS", + "FILE", "FLOAT", "FOR", "FROM", "GRANT", "GROUP", "HAVING", "IDENTIFIED", "IMMEDIATE", "IN", "INCREMENT", "INDEX", "INITIAL", "INSERT", "INTEGER", + "INTERSECT", "INTO", "IS", "LEVEL", "LIKE", "LOCK", "LONG", "MAXEXTENTS", "MINUS", "MLSLABEL", "MODE", "MODIFY", "NOAUDIT", "NOCOMPRESS", "NOT", + "NOWAIT", "NULL", "NUMBER", "OF", "OFFLINE", "ON", "ONLINE", "OPTION", "OR", "ORDER", "PCTFREE", "PRIOR", "PRIVILEGES", "PUBLIC", "RAW", "RENAME", + "RESOURCE", "REVOKE", "ROW", "ROWID", "ROWNUM", "ROWS", "SELECT", "SESSION", "SET", "SHARE", "SIZE", "SMALLINT", "START", "SUCCESSFUL", "SYNONYM", + "SYSDATE", "TABLE", "THEN", "TO", "TRIGGER", "UID", "UNION", "UNIQUE", "UPDATE", "USER", "VALIDATE", "VALUES", "VARCHAR", "VARCHAR2", "VIEW", "WHENEVER", + "WHERE", "WITH" +] + // 渲染form表单: 一般对form的渲染都统一使用该方法 export const getSearchs = (form, condition, col, isCenter) => { const { isFormInit } = form; @@ -72,4 +100,35 @@ 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; +} + +export const validDBKeys = (value) => { + if (indexOf(dbKeys, value.toUpperCase()) >= 0) { + message.error("不能使用数据库保留字作为字段名!"); + return { + isValid: false, + value: '' + }; + } + return { + isValid: true, + value + }; } \ No newline at end of file