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

+
+ 2.{getLabel('531157','历史数据量可能较大, 此操作可能需要较长时间,对系统性能也可能会造成一定影响,请确认是否处理历史数据:')} + + { + this.needInitData = v; + }} + /> + +
+
+ ), + onOk: this.doSaveEncryptFieldSettingForm + }) + }else{ + this.needInitData = '0'; + this.doSaveEncryptFieldSettingForm(); + } + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + } + + @action doSaveEncryptFieldSettingForm = async () => { + if(this.spinning) + return; + this.spinning = true; + const params = {...this.formTarget.encryptForm.getFormParams(), ...this.encryptParams, needInitData: this.needInitData, ...this.opParams} + if (this.selectedTreeNodeInfo != null) { + Object.assign(params, { + scopeid: this.selectedTreeNodeInfo.key + }) + } + try{ + const data = await api.saveEncryptFieldSettingForm(params); + if(data.status == '1'){ + this.encryptDialogVisible = false; + message.success(i18n.message.saveSuccess()); + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + }else{ + message.error(data.message); + } + this.spinning = false; + }catch(e){ + this.spinning = false; + } + } + + //#region 查看范围设置 + target = {}; + @observable dialogVisible = false; + @observable table = new TableStore(); + @observable canAdd = false; + @observable canDel = false; + + @computed get tableMultiDelete() { + return this.table.selectedRowKeys.length === 0 || !this.canDel; } - setTabKey(tabKey) { - this.tabKey = tabKey; + @computed get rangeViewTabProps(){ + return { + datas: [], + buttons: [ + , + , + ] + } } - setTopMenu(topMenu) { - this.topMenu = topMenu; + @action onDialogCancleHandle = () => this.dialogVisible = false; + + get dialogButtons(){ + const buttonDef = [ + { + content: getLabel(30986, '保存'), + icon: 'icon-coms-Preservation', + onClickHandle: this.saveViewRange + } + ] + const buttons = [], moreBtnData = []; + buttonDef.map((btn, index) => { + const {content, icon, onClickHandle} = btn; + buttons.push( + () + ); + + moreBtnData.push({ + key: index.toString(), + content, + icon: , + onClick: onClickHandle + }); + }) + + const {scopeId} = this.opParams; + let arr = []; + if(scopeId == '-1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEBASE', this.encryptParams.encryptId); + }else if(scopeId == '1'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEPERSONAL', this.encryptParams.encryptId); + }else if(scopeId == '3'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_RESOURCEWORK', this.encryptParams.encryptId); + }else if(scopeId == 'subcompany'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SUBCOMPANY', this.encryptParams.encryptId); + }else if(scopeId == 'department'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_DEPARTEMENT', this.encryptParams.encryptId); + }else if(scopeId == 'salary'){ + arr = this.generateLogMenu('38', 'HRM_RSOURCE_SALARY'); + }else{} + moreBtnData.push(...arr); + return {buttons, moreBtn: {datas: moreBtnData}}; } - - setRightMenu(rightMenu) { - this.rightMenu = rightMenu; + @computed get dialogProps(){ + return { + title: getLabel('125012','查看范围设置'), + style: { + width: 800, + height: 600 + }, + ...ecCom.WeaTools.getIconBGC('currency'), + ...this.dialogButtons, + visible: this.dialogVisible, + onCancel: this.onDialogCancleHandle, + } } + @computed get rangeViewTableProps(){ + return { + comsWeaTableStore: this.table, + hasOrder: true, + needScroll: true, + scroll: { + y: 550 + }, + onOperatesClick: this.onOperatesClickHandle + } + } + + @action showSettingDialog = async () => { + if(this.encryptParams.encryptId == null || this.encryptParams.encryptId == ''){ + this.confirmInfo({ + content: getLabel('524355','提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!'), + onOk: async () => { + const rs = await api.saveEncryptFieldSettingForm({...this.formTarget.encryptForm.getFormParams(), ...this.encryptParams, ...this.opParams}); + if(rs.status == '1'){ + this.encryptParams.encryptId = rs.encryptId; + if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + else + this.initData(); + this.dialogVisible = this.getEncryptFieldScopeList(); + }else{ + message.error(data.message); + } + } + }); + }else + this.dialogVisible = this.getEncryptFieldScopeList(); + } + + @action getEncryptFieldScopeList = async () => { + const d = await api.getEncryptFieldScopeList({id: this.encryptParams.encryptId}); + if(d.status == '1'){ + const {canAdd, canDel, sessionkey} = d; + this.canAdd = canAdd; + this.canDel = canDel; + this.table = new TableStore(); + this.table.getDatas(sessionkey); + return true; + }else{ + message.error(d.message); + return false; + } + } + + @action onOperatesClickHandle = (record, index, operate) => { + const func = operate.href ? operate.href.split(':')[1].split('(')[0] : ''; + const id = record.id || ''; + this[func] && this[func](id, record); + } + + @action doMultiDel = () => this.doDel(); + + @action doDel = ids => { + const params = { + fieldid: this.encryptParams.encryptId, + ids: ids || this.table.selectedRowKeys + }; + let content = isEmpty(ids) ? getLabel(385625, '确定要删除选择的记录吗?') : getLabel(83877, '确定要删除吗?'); + this.confirmInfo({ + content, + onOk: async () => { + const data = await api.delEncryptFieldScopeSetting({...params, ...this.opParams}); + if (data.status === "1") { + message.success(getLabel(83472, '删除成功!')); + this.table.getDatas(null, 1); + }else{ + message.error(data.message); + } + } + }); + } + + @action saveViewRange = async () => { + this.onDialogCancleHandle(); + } + //#endregion + + //#region 范围form + @observable conditions = []; + + @observable viewRangeAuthVisible = false; + + @computed get viewRangeAuthProps(){ + return { + title: getLabel('383694','添加人员'), + conditions: this.toJS(this.conditions), + ...ecCom.WeaTools.getIconBGC('currency'), + visible: this.viewRangeAuthVisible, + onOk: this.onOKHandle, + onCancel: this.onViewRangeAuthCancleHandle, + } + } + + @action getViewRangeForm = async () => { + const data = await api.getEncryptFieldScopeForm(); + if(data.status == "1"){ + this.conditions = data.conditions; + this.viewRangeAuthVisible = true; + } + } + + @action onOKHandle = async data => { + const d = await api.saveEncryptFieldScopeSetting({id: this.encryptParams.encryptId, ...data, ...this.opParams}); + if(d.status == '1'){ + message.success(getLabel(83551, '保存成功!')); + this.getEncryptFieldScopeList(); + }else{ + message.error(d.message); + } + this.viewRangeAuthVisible = false; + } + + @action onViewRangeAuthCancleHandle = () => { + this.viewRangeAuthVisible = !this.viewRangeAuthVisible; + } + + get opParams(){ + const obj = { + fieldname: this.encryptParams.fieldname + } + const name = (this.moduleName || '').toLocaleLowerCase(); + if(name.indexOf('subcompany') > -1){ + Object.assign(obj, { + scopeId: 'subcompany' + }); + }else if(name.indexOf('department') > -1){ + Object.assign(obj, { + scopeId: 'department' + }); + } + this.selectedTreeNodeInfo != null && Object.assign(obj, { + scopeId: this.selectedTreeNodeInfo.key + }); + + return obj; + } + //#endregion + /********************* action list *********************/ + } \ No newline at end of file diff --git a/pc4mobx/organization/style/index.less b/pc4mobx/organization/style/index.less index 683be40..5dd610b 100644 --- a/pc4mobx/organization/style/index.less +++ b/pc4mobx/organization/style/index.less @@ -52,6 +52,18 @@ html { } } +.tabBtn-active { + color: #34a2ff; +} + +.tabBtn { + cursor: pointer; + font-size: 20px; + position: relative; + top: 6px; + right: 15px; +} + //组织架构图 #node { diff --git a/pc4mobx/organization/util/index.js b/pc4mobx/organization/util/index.js index 341d13c..ebe5892 100644 --- a/pc4mobx/organization/util/index.js +++ b/pc4mobx/organization/util/index.js @@ -72,4 +72,21 @@ export const renderNoData = () => ( export const isEmpty = (obj) =>{ for(var n in obj){return false} return true; +} + + +export const calFormHeight = (groupLength, children) => { + let childrenLength = 0; + children.map(c => { + if (c.colSpan != null) { + childrenLength += c.colSpan == 2 ? 1 : 2; + } else + childrenLength += 1; + }) + let height = (childrenLength / 2 + childrenLength % 2) * 52 + 10; + if (groupLength > 1) + height += groupLength * 45; + if (height > 300) + return 300; + return height; } \ No newline at end of file From 1a35ec1bd5cf8e2d046c2060c63b8eb5796012b9 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 13 Jun 2022 15:38:26 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/fieldDefinedSet/FieldDef.js | 71 +- .../fieldDefinedSet/FieldDefined.js | 123 +-- pc4mobx/organization/public/i18n.js | 3 +- pc4mobx/organization/stores/baseStore.js | 18 +- pc4mobx/organization/stores/fieldDefined.js | 924 ++++++++++-------- pc4mobx/organization/util/index.js | 42 + 6 files changed, 687 insertions(+), 494 deletions(-) diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js index b5f613f..1bf4129 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js @@ -70,11 +70,14 @@ export default class FieldDef extends Component { const { groupInfoFrom, groupInfoFromFields, + typeInfoFrom, + typeInfoFromFields, childInfoForm, childInfoFormFields } = formTarget; const { editGroupInfo, + editTypeInfo, groupInfoSetting, createChildInfo, childInfoSetting @@ -101,10 +104,10 @@ export default class FieldDef extends Component { } } - const rMenu = [...rightMenu, ...store.getBasicMenus(this.props.logSmallType, this.props.targetId)] + const rMenu = [...rightMenu, ...store.getBasicMenus(this.props.logSmallType, this.props.targetId)] return ( -
{this.tabDom = dom}}> +
{ this.tabDom = dom }}> setEditTable(editTable, 'fieldDef')} @@ -114,62 +117,76 @@ export default class FieldDef extends Component { + {/* 新增分组 */} setDialogVisible('editGroupInfo', false)} buttons={getDialogOpButtons()} - moreBtn={{datas:editorDialogRightMenu}} - > - - + moreBtn={{ datas: editorDialogRightMenu }} + > + + + {/* 新增类型 */} + setDialogVisible('editTypeInfo', false)} + buttons={getDialogOpButtons()} + moreBtn={{ datas: editorDialogRightMenu }} + > + + setDialogVisible('groupInfoSetting', false, '')} buttons={getDialogOpButtons()} - moreBtn={{datas:editorDialogRightMenu}} + moreBtn={{ datas: editorDialogRightMenu }} > setEditTable(editTable, 'groupSetting')} - tableProps={{scroll: {y: 360}}} - {...tableEditConfig['groupSetting']}/> + tableProps={{ scroll: { y: 360 } }} + {...tableEditConfig['groupSetting']} /> - setDialogVisible('createChildInfo', false)} - buttons={getDialogOpButtons()} - moreBtn={{datas:editorDialogRightMenu}} - > - - + setDialogVisible('createChildInfo', false)} + buttons={getDialogOpButtons()} + moreBtn={{ datas: editorDialogRightMenu }} + > + + setDialogVisible('childInfoSetting', false, '')} buttons={getDialogOpButtons()} - moreBtn={{datas:editorDialogRightMenu}} + moreBtn={{ datas: editorDialogRightMenu }} > setEditTable(editTable, 'childInfoSetting')} - tableProps={{scroll: {y: 360}}} - {...tableEditConfig['childInfoSetting']}/> + tableProps={{ scroll: { y: 360 } }} + {...tableEditConfig['childInfoSetting']} />
diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js index 7b71756..d835966 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js @@ -13,7 +13,7 @@ import { WeaLeftRightLayout, WeaDropdown } from 'ecCom'; -import {Spin} from 'antd'; +import { Spin } from 'antd'; import Tabs from './Tabs'; import FieldDef from './FieldDef'; import { @@ -25,7 +25,7 @@ const { ButtonSelect } = WeaDropdown; @inject('fieldDefined') @observer export default class FieldDefined extends Component { - constructor(props) { + constructor(props) { super(props); this.state = { logSmallType: '' @@ -54,21 +54,21 @@ export default class FieldDefined extends Component { type: moduleType } = params let moduleName, logSmallType; - if(moduleType === 'subCompany'){ + if (moduleType === 'subCompany') { moduleName = 'subcompanyfielddefined'; logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED'; - }else if(moduleType === 'department'){ + } else if (moduleType === 'department') { moduleName = 'departmentfielddefined'; logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED'; - }else{ + } else { moduleName = 'resourcefielddefined'; logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; } - let callbackFunc = () => initData(false, true, moduleName); - if (moduleType === 'resource') - callbackFunc = () => initResourceData(moduleName); + // let callbackFunc = () => initData(false, true, moduleName); + // if (moduleType === 'resource') + let callbackFunc = () => initResourceData(moduleName); checkAuthorized(moduleName, null, callbackFunc); - this.setState({logSmallType}) + this.setState({ logSmallType }) } tabChangeHandle = (key) => { @@ -116,87 +116,70 @@ export default class FieldDefined extends Component { conditionForm: form, conditionFormFields: fields, tabBtnDef: [ - ...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 - }; + topProps = { + title, + icon: , + iconBgcolor: '#217346', + showDropIcon: true, + buttons: btns, + dropMenuDatas: menus + }; let logType; - if(selectedTreeNodeInfo){ - if(selectedTreeNodeInfo.viewAttr == 1){ + if (selectedTreeNodeInfo) { + if (selectedTreeNodeInfo.viewAttr == 1) { logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; - }else{ + } else { logType = 'HRM_ENGINE_RESOURCEFIELDDEFINED_DETAIL'; } } let children = []; if (containerInitFinished.init && containerInitFinished.authorized) { - switch (moduleType) { - case 'resource': - const { - data, - onSelectedTreeNode, - selectedKeys, - onExpand, - treeExpandKeys - } = store.toJS(treeConfig); - const treeCom = ( - - ) - children = [ - ( - - - - { - - - - } - - - - ) - ] - break; - default: - children = [ - ( - - - - + const { + data, + onSelectedTreeNode, + selectedKeys, + onExpand, + treeExpandKeys + } = store.toJS(treeConfig); + const treeCom = ( + + ) + children = [ + ( + + + + { + + - - - ) - ] - break; - } + } + + + + ) + ] } else if (containerInitFinished.init && !containerInitFinished.authorized) { children = [ ( -
{i18n.message.authFailed()}
-
+
{i18n.message.authFailed()}
+ ) ]; } diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index dc077a5..567877f 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,7 @@ export const i18n = { }, button: { back: () => getLabel(1290, '返回'), + createType: () => getLabel(30131, '新建类型'), batchOpen: () => getLabel(534249, '批量解锁'), collect: () => getLabel(28111, '收藏'), diff --git a/pc4mobx/organization/stores/baseStore.js b/pc4mobx/organization/stores/baseStore.js index ad4852c..0a23a00 100644 --- a/pc4mobx/organization/stores/baseStore.js +++ b/pc4mobx/organization/stores/baseStore.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:14:20 - * @LastEditTime: 2022-06-09 10:41:31 + * @LastEditTime: 2022-06-13 14:50:36 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/baseStore.js */ @@ -93,14 +93,14 @@ export default class HrmBaseStore { } 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}) - }); - } + // if(logTypeKey){ + // arr.push({ + // key: '99', + // content: i18n.button.log(), + // icon: , + // onClick: () => this.showLog({logSmallType: this.logTypeDef[logTypeKey], targetId}) + // }); + // } return arr; } diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index 713d838..8ada3bd 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-10 16:32:02 + * @LastEditTime: 2022-06-13 15:06:29 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -15,7 +15,7 @@ import { WeaTableNew, WeaSwitch } from 'comsMobx'; -import {WeaLocaleProvider, WeaInputLocale, WeaButtonIcon, WeaSelect} from 'ecCom'; +import { WeaLocaleProvider, WeaInputLocale, WeaButtonIcon, WeaSelect } from 'ecCom'; import { Button, message, @@ -34,16 +34,19 @@ import { } 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; +const { TableStore } = WeaTableNew; export class FieldDefinedStore extends HrmBaseStore { - /********************* unobservable list *********************/ + /********************* unobservable list *********************/ //override baseStore.tabConfig tabDef = { color: '#000000', @@ -61,6 +64,12 @@ export class FieldDefinedStore extends HrmBaseStore { onClickHandle: () => this.editGroup(), label: i18n.button.createGroup, icon: this.menuIconCollection.create + }, { + comType: 'button', + type: 'primary', + onClickHandle: () => this.editType(), + label: i18n.button.createType, + icon: this.menuIconCollection.create }, { comType: 'button', type: 'primary', @@ -88,9 +97,9 @@ export class FieldDefinedStore extends HrmBaseStore { { filter(this.tabConfig.tabs, (d) => { - try{ + try { return d.groupid != this.activeTabInfo.tabInfo.groupid - }catch(e){ + } catch (e) { return true; } }).map((tab, index) => ( @@ -100,7 +109,7 @@ export class FieldDefinedStore extends HrmBaseStore { )) } - +
{i18n.label.createAndMoveGroup()}
@@ -114,20 +123,20 @@ export class FieldDefinedStore extends HrmBaseStore { selected: this.dropdownSelectedKey === '1' }, { - key: '2', - text: i18n.button.copy(), + key: '2', + text: i18n.button.copy(), show: , selected: this.dropdownSelectedKey === '2' }, { - key: '3', - text: i18n.button.moveToGroup(), + key: '3', + text: i18n.button.moveToGroup(), show: , selected: this.dropdownSelectedKey === '3', isDropBtn: true } ] - if(this.selectedTreeNodeInfo != null && this.selectedTreeNodeInfo.viewAttr != 1){ + if (this.selectedTreeNodeInfo != null && this.selectedTreeNodeInfo.viewAttr != 1) { datas.splice(2, 1); } return datas; @@ -144,7 +153,7 @@ export class FieldDefinedStore extends HrmBaseStore { } }, btnOnClick: key => { - switch(key){ + switch (key) { case '1': this.recordOP(this.editTable['fieldDef'], 'remove') break; @@ -288,7 +297,7 @@ export class FieldDefinedStore extends HrmBaseStore { if (this.isJobTreeNode) {//【工作信息】列表不添加【允许个人修改】列 } else { columns.push({ - title: getLabel(510359,'允许个人修改'), + title: getLabel(510359, '允许个人修改'), dataIndex: 'isModify', key: 'isModify', checkType: 'checkbox', @@ -298,7 +307,7 @@ export class FieldDefinedStore extends HrmBaseStore { } } this.encryptEnable && columns.push({ - title: getLabel('526997','加密设置'), + title: getLabel('526997', '加密设置'), dataIndex: 'canEncrypt', key: 'canEncrypt', com: [ @@ -306,10 +315,10 @@ export class FieldDefinedStore extends HrmBaseStore { type: 'custom', key: 'custom', render: (text, record, index, onEdit) => { - const {canEncrypt} = record; - if(canEncrypt == '1') + const { canEncrypt } = record; + if (canEncrypt == '1') return ( - this.onEncryptHandle(record)}>{getLabel('526997','加密设置')} + this.onEncryptHandle(record)}>{getLabel('526997', '加密设置')} ) return null; } @@ -447,13 +456,13 @@ export class FieldDefinedStore extends HrmBaseStore { this.editorDialogRightMenu.push({ key: '1', content: i18n.button.save(), - icon: , + icon: , onClick: () => this.dialogSaveOp(false) }); - if(this.dialogParams.groupInfoSetting.visible){ + if (this.dialogParams.groupInfoSetting.visible) { let logType = ''; - switch(this.moduleName){ + switch (this.moduleName) { case 'subcompanyfielddefined': logType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED_GROUP'; break; @@ -490,6 +499,77 @@ export class FieldDefinedStore extends HrmBaseStore { "defaultshow": true }] + editTypeInfoFormFields = [{ + "title": i18n.label.basicSetting(), + "items": [{ + "colSpan": 2, + "conditionType": "INPUT", + "domkey": ["typeName"], + "fieldcol": 12, + "isQuickSearch": false, + "label": i18n.label.typeName, + "labelcol": 6, + "precision": 0, + "rules": "required|string", + "value": "", + "viewAttr": 3, + }, { + "belong": "PC", + "checkbox": false, + "checkboxValue": false, + "colSpan": 2, + "conditionType": "SELECT", + "dateGroup": false, + "defaultDisplayInBar": false, + "detailtype": 3, + "domkey": [ + "tableType" + ], + "entSearch": false, + "fieldcol": 16, + "hasBorder": false, + "helpfulTipProps": {}, + "hide": false, + "isBase64": false, + "isQuickSearch": false, + "label": "新增到", + "labelcol": 6, + "length": 0, + "maxFilesNumber": 0, + "maxUploadSize": 0, + "multiSelection": false, + "multiple": false, + "options": [ + { + "disabled": false, + "key": "0", + "selected": false, + "showname": "主表", + "visible": true + }, + { + "disabled": false, + "key": "1", + "selected": false, + "showname": "明细表", + "visible": true + } + ], + "precision": 0, + "secretLimit": false, + "showOrder": 0, + "showTime": false, + "stringLength": 0, + "supportCancel": false, + "tipPosition": "bottom", + "value": "0", + "valueList": [], + "rules": "required|string", + "viewAttr": 3 + }], + "defaultshow": true + }] + editChildInfoFormFields = [{ "title": i18n.label.basicSetting, "items": [{ @@ -528,6 +608,13 @@ export class FieldDefinedStore extends HrmBaseStore { datas: [] } }, + editTypeInfo: { + visible: false, + title: '', + moreBtn: { + datas: [] + } + }, groupInfoSetting: { visible: false, title: '', @@ -559,7 +646,7 @@ export class FieldDefinedStore extends HrmBaseStore { @observable refreshMainTabComponent = new Date().getTime(); @observable refreshFeildDef = new Date().getTime(); //当需要刷新主页面tab时,变更此值 - @observable refreshForm = new Date().getTime(); + @observable refreshForm = new Date().getTime(); @observable refreshEditGroupTabComponent = new Date().getTime(); //当需要刷新权限组编辑tab时,变更此值 @observable spinning = false; @observable moduleName = ''; @@ -628,7 +715,7 @@ export class FieldDefinedStore extends HrmBaseStore { setTableEditColTitle = () => { [...Object.keys(this.tableEditConfig)].map(k => { this.tableEditConfig[k].columns.map(c => { - if (typeof(c.title) == 'function') + if (typeof (c.title) == 'function') c.title = c.title(); else c.title = c.title; @@ -688,7 +775,7 @@ export class FieldDefinedStore extends HrmBaseStore { message.error(data.message); this.spinning = false; this.refreshMainTabComponent = new Date().getTime(); - }, error => {this.spinning = false;}) + }, error => { this.spinning = false; }) } @action onTabEdit = (targetKey, action) => { @@ -709,10 +796,11 @@ export class FieldDefinedStore extends HrmBaseStore { if (data.status === '1') { message.success(i18n.message.deleteSuccess()); this.tabConfig.activeTabKey = '1'; - if (this.moduleName.indexOf('resource') >= 0) - this.getTabInfoByTreeNode(); - else - this.initData(); + // if (this.moduleName.indexOf('resource') >= 0) + // this.getTabInfoByTreeNode(); + // else + // this.initData(); + this.getTabInfoByTreeNode(); } else { message.error(data.message); } @@ -727,6 +815,7 @@ export class FieldDefinedStore extends HrmBaseStore { @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(); @@ -735,12 +824,12 @@ export class FieldDefinedStore extends HrmBaseStore { @action editGroup = (group, moveToGroup = false) => { this.moveToGroup = moveToGroup; this.editGroupInfoFormFields.map(f => { - if (typeof(f.title) == 'function') + if (typeof (f.title) == 'function') f.title = f.title(); f.items.map(item => { - if (typeof(item.label) == 'function') + if (typeof (item.label) == 'function') item.label = item.label(); - item.otherParams = {...window.inputType}; + item.otherParams = { ...window.inputType }; }) }) let fields = [...this.editGroupInfoFormFields], @@ -748,13 +837,13 @@ export class FieldDefinedStore extends HrmBaseStore { this.setFormData('groupInfoFrom', fields); if (group) { this.formTarget.groupInfoFrom.updateFields({ - groupName: {value: group.multiTitle || group.title || ''} + groupName: { value: group.multiTitle || group.title || '' } }); this.opId = group.groupid; dialogTitle = i18n.button.editGroup(); } else { this.formTarget.groupInfoFrom.updateFields({ - groupName: {value: ''} + groupName: { value: '' } }); this.opId = null; dialogTitle = i18n.button.createGroup(); @@ -762,6 +851,27 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('editGroupInfo', true, dialogTitle); } + @action editType = () => { + 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 = ''; + this.setFormData('typeInfoFrom', fields); + // this.formTarget.typeInfoFrom.updateFields({ + // typeName: { value: '' } + // }); + // this.opId = null; + dialogTitle = i18n.button.createType(); + this.setDialogVisible('editTypeInfo', true, dialogTitle); + } + @action doGroupSetting = () => { this.tableEditConfig.groupSetting.datas.length = 0; let arr = []; @@ -787,7 +897,8 @@ export class FieldDefinedStore extends HrmBaseStore { } }) }) - Object.assign(this.tableEditConfig.groupSetting, { ...this.convertData(arr, 'groupSetting') + Object.assign(this.tableEditConfig.groupSetting, { + ...this.convertData(arr, 'groupSetting') }); this.tableEditConfig.groupSetting.columns = this.groupDefColumns(); this.tableEditConfig.groupSetting.datas.map(d => { @@ -808,6 +919,44 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('groupInfoSetting', true, i18n.button.groupMaintain()); } + + @action doSaveTypeInfo = () => { + this.formTarget.typeInfoFrom.validateForm().then(f => { + if (f.isValid) { + let record = { + ...this.formTarget.typeInfoFrom.getFormParams(), + } + let params = { + data: JSON.stringify({ + record: record + }) + } + // api.saveTypeInfo(this.moduleName, params).then(data => { + // if (data.status === '1') { + // this.setDialogVisible('editGroupInfo', false, ''); + // if (this.moveToGroup) { + // const ids = data.groupid.split(','); + // this.changeGroup(null, ids[ids.length - 1]); + // } else { + // //if (this.moduleName.indexOf('resource') >= 0) + // this.getTabInfoByTreeNode(); + // // else + // // this.initData(this.opId == null); + // message.success(i18n.message.saveSuccess()); + // } + // } else + // message.error(data.message); + // }, error => { + // message.error(i18n.message.actionError()); + // }); + this.getTree() + } else { + f.showErrors(); + this.showError = new Date().getTime(); + } + }); + } + doSaveGroupInfo = () => { this.formTarget.groupInfoFrom.validateForm().then(f => { if (f.isValid) { @@ -853,14 +1002,14 @@ export class FieldDefinedStore extends HrmBaseStore { api.saveGroupInfo(this.moduleName, params).then(data => { if (data.status === '1') { this.setDialogVisible('editGroupInfo', false, ''); - if(this.moveToGroup){ + if (this.moveToGroup) { const ids = data.groupid.split(','); this.changeGroup(null, ids[ids.length - 1]); - }else{ - if (this.moduleName.indexOf('resource') >= 0) - this.getTabInfoByTreeNode(); - else - this.initData(this.opId == null); + } else { + //if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + // else + // this.initData(this.opId == null); message.success(i18n.message.saveSuccess()); } } else @@ -876,7 +1025,7 @@ export class FieldDefinedStore extends HrmBaseStore { } @action saveFieldDefine = () => { - if(this.spinning) + if (this.spinning) return; this.spinning = true; this.recordOP(this.editTable['fieldDef'], 'valid'); @@ -937,24 +1086,24 @@ export class FieldDefinedStore extends HrmBaseStore { 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){ + const checkRs = this.editTable['fieldDef'] && this.editTable['fieldDef'].refs.edit.doRequiredCheck() || { pass: true }; + if (!checkRs.pass) { this.spinning = false; return; } - + api.saveFieldDefinedInfo(this.moduleName, params).then(data => { if (data.status === '1') { message.success(i18n.message.saveSuccess()); - if (this.moduleName.indexOf('resource') >= 0) - this.getTabInfoByTreeNode(); - else - this.initData(); + // if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + // else + // this.initData(); } else { message.error(data.message); } this.spinning = false; - }, error => {this.spinning = false;}) + }, error => { this.spinning = false; }) } else { message.error(i18n.confirm.displayOrDBFieldExist()); this.spinning = false; @@ -962,16 +1111,16 @@ export class FieldDefinedStore extends HrmBaseStore { } @action onEdit = (keys, datas, c, dataIndex) => { - if(dataIndex === 'fieldlabel' && this.moduleName != 'resourcefielddefined'){ + 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'){ + 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; + 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 != ''){ + const arr = filter(this.tableEditConfig.fieldDef.datas, { fieldname: pinyin }); + if (arr.length > 1 && pinyin != '') { oldRecord.fieldname = pinyin + '1'; } this.refreshFeildDef = new Date().getTime(); @@ -979,11 +1128,11 @@ export class FieldDefinedStore extends HrmBaseStore { } } @action onAdd = (keys, datas) => { - try{ + 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){ + } catch (e) { } } @@ -994,8 +1143,8 @@ export class FieldDefinedStore extends HrmBaseStore { required: [] } if (this.moduleName === 'resourcefielddefined') { - Object.assign(selectedData,{ - isModify:[] + Object.assign(selectedData, { + isModify: [] }); } datas.map((data, index) => { @@ -1024,15 +1173,15 @@ export class FieldDefinedStore extends HrmBaseStore { if (selectedDatas != null && selectedDatas.hasOwnProperty(dataIndex)) { const arr = selectedDatas[dataIndex]; this.tableEditConfig.fieldDef.datas.map((data, index) => { - if(dataIndex === 'enable'){ + if (dataIndex === 'enable') { data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; - if(data[dataIndex] === '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'){ + } else if (dataIndex === 'required') { data[dataIndex] = indexOf(arr, index) >= 0 ? '1' : '0'; if (data[dataIndex] === '1') { data['enable'] = '1'; @@ -1060,7 +1209,7 @@ export class FieldDefinedStore extends HrmBaseStore { //处理账号类型和主账号的联动(允许个人修改):账号类型选中,主账号也会选中,反之亦然。 processLinkage = (selectedDatas) => { - const {datas} = this.tableEditConfig.fieldDef; + const { datas } = this.tableEditConfig.fieldDef; const target = datas.find(data => data.fieldname === 'accounttype'); @@ -1068,7 +1217,7 @@ export class FieldDefinedStore extends HrmBaseStore { const accounttype = target.isModify; - const belongto = datas.find(data => data.fieldname === 'belongto').isModify; + const belongto = datas.find(data => data.fieldname === 'belongto').isModify; if (belongto !== accounttype) { datas.find(data => data.fieldname === 'belongto').isModify = accounttype; @@ -1077,7 +1226,7 @@ export class FieldDefinedStore extends HrmBaseStore { if (accounttype === '1') { selectedDatas['isModify'].push(belongtoIndex); - }else{ + } else { remove(selectedDatas['isModify'], v => v === belongtoIndex); } } @@ -1090,7 +1239,7 @@ export class FieldDefinedStore extends HrmBaseStore { } sel.getCheckboxProps = (record) => { let disabled = false; - switch(this.dropdownSelectedKey){ + switch (this.dropdownSelectedKey) { case '2': disabled = false;//复制时,checkbox全部启用 break; @@ -1120,7 +1269,7 @@ export class FieldDefinedStore extends HrmBaseStore { if (this.selectedTreeNodeInfo != null) params.groupType = this.selectedTreeNodeInfo.key; params.groupId = this.activeTabInfo.tabInfo.groupid; - if(ids.length > 0){ + if (ids.length > 0) { api.removeFieldDefinedInfo(this.moduleName, params).then(data => { if (data.status === '1') { // this.initData(); @@ -1129,9 +1278,9 @@ export class FieldDefinedStore extends HrmBaseStore { } else message.error(data.message); }, error => { - + }) - }else{ + } else { this.tableEditConfig.fieldDef.selectedRowKeys.length = 0; } @@ -1196,11 +1345,10 @@ export class FieldDefinedStore extends HrmBaseStore { api.saveGroupInfo(this.moduleName, params).then(data => { if (data.status === '1') { this.setDialogVisible('groupInfoSetting', false, ''); - - if (this.moduleName.indexOf('resource') >= 0) - this.getTabInfoByTreeNode(false, true); - else - this.initData(false, true); + // if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(false, true); + // else + // this.initData(false, true); message.success(i18n.message.saveSuccess()); } else message.error(data.message); @@ -1227,15 +1375,15 @@ export class FieldDefinedStore extends HrmBaseStore { 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); + // if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(false, true); + // else + // this.initData(false, true); } else { message.error(data.message); } }) - } else {} + } else { } } //人员卡片字段定义部分 @@ -1320,7 +1468,7 @@ export class FieldDefinedStore extends HrmBaseStore { } else { message.error(data.message); } - }, error => {}) + }, error => { }) } getTree = (callback) => { @@ -1342,7 +1490,7 @@ export class FieldDefinedStore extends HrmBaseStore { message.error(data.message); } this.refreshTree = new Date().getTime(); - }, error => {}) + }, error => { }) } setBtn = (t) => { @@ -1437,13 +1585,13 @@ export class FieldDefinedStore extends HrmBaseStore { @action createChildInfo = (create = true, data = {}) => { this.isCreateChildInfo = create; this.editChildInfoFormFields.map(f => { - if (typeof(f.title) == 'function') + if (typeof (f.title) == 'function') f.title = f.title(); f.items.map(item => { - if (typeof(item.label) == 'function') + if (typeof (item.label) == 'function') item.label = item.label(); if (item.conditionType === 'INPUT') - item.otherParams = {...window.inputType}; + item.otherParams = { ...window.inputType }; }) }) let fields = [...this.editChildInfoFormFields], @@ -1517,7 +1665,7 @@ export class FieldDefinedStore extends HrmBaseStore { }); parentId = p.domid; } - }else{ + } else { Object.assign(c, { name: c.multiName }); @@ -1594,7 +1742,8 @@ export class FieldDefinedStore extends HrmBaseStore { }) } - Object.assign(this.tableEditConfig.childInfoSetting, { ...this.convertData(arr, 'childInfoSetting') + Object.assign(this.tableEditConfig.childInfoSetting, { + ...this.convertData(arr, 'childInfoSetting') }); this.tableEditConfig.childInfoSetting.columns = this.childInfoDefColumns(); this.tableEditConfig.childInfoSetting.datas.map(d => { @@ -1714,7 +1863,8 @@ export class FieldDefinedStore extends HrmBaseStore { }); cloneTree[i].childs = []; infoArr.map(info => { - cloneTree[i].childs.push({ ...info + cloneTree[i].childs.push({ + ...info }) }) } @@ -1742,13 +1892,13 @@ export class FieldDefinedStore extends HrmBaseStore { } //移动到组 @action dropdownClick = (e) => { - switch(e.key){ + 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})]; + const tabInfo = this.tabConfig.tabs[findIndex(this.tabConfig.tabs, { groupid })]; let moveFieldConfirm = i18n.confirm.moveFieldConfirm().replace('{params}', tabInfo.title); this.changeGroup(moveFieldConfirm, groupid); } @@ -1759,99 +1909,99 @@ export class FieldDefinedStore extends HrmBaseStore { let ids = []; let names = []; this.tableEditConfig.fieldDef.selectedRowKeys.map(idx => { - try{ + try { ids.push(this.tableEditConfig.fieldDef.datas[idx].id); names.push(this.tableEditConfig.fieldDef.datas[idx].fieldname); - }catch(e){ + } catch (e) { } }); - if(this.moduleName.indexOf('resource') > -1){ + if (this.moduleName.indexOf('resource') > -1) { Object.assign(params, { fieldids: ids.join(','), fieldnames: names.join(','), groupid, scopeid: this.selectedTreeNodeInfo.domid }) - }else{ + } else { Object.assign(params, { - ids: ids.join(','), + ids: ids.join(','), groupid }); } - moveFieldConfirm == null ? - this.doChangeGroup(params) : - this.confirmInfo({ - content:moveFieldConfirm, - onOk: () => { - this.doChangeGroup(params) - } - }); + 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(); + // if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + // else + // this.initData(); } else message.error(data.message); - }, error => {message.error(i18n.message.actionError());}); + }, 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( - () - ); + 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 - }); + moreBtnData.push({ + key: index.toString(), + content, + icon: , + onClick: onClickHandle + }); }) - const {scopeId} = this.opParams; + 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{} + 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}}; + return { buttons, moreBtn: { datas: moreBtnData } }; } - - @computed get encryptDialogProps(){ + + @computed get encryptDialogProps() { return { title: this.encryptDialogTitle, - style: { - width: 600, - height: 350 - }, + style: { + width: 600, + height: 350 + }, ...ecCom.WeaTools.getIconBGC('currency'), ...this.encryptDialogButtons, visible: this.encryptDialogVisible, @@ -1859,28 +2009,28 @@ export class FieldDefinedStore extends HrmBaseStore { } } - @computed get encryptFormItemRender(){ + @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') + if (formParams.desensitization == '1') return (
-
- +
+
{ formParams.viewscope == '1' && - {getLabel(30747, '设置')} + {getLabel(30747, '设置')} }
) @@ -1902,58 +2052,58 @@ export class FieldDefinedStore extends HrmBaseStore { encryptParams = {}; @action onEncryptHandle = async record => { - const {fieldname, tablename, fieldlabel, encryptId} = record; - this.encryptParams = {fieldname, tablename, encryptId}; + 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'){ + 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})`; + if (this.formTarget.encryptForm.isFormInit) { + this.encryptDialogTitle = `${getLabel('526997', '加密设置')}(${getLabel('261', '字段')}:${label})`; this.encryptDialogVisible = true; } - }else{ + } else { message.error(data.message); } } @observable needInitData = '1'; - get encrypt(){ - const {isencrypt} = this.formTarget.encryptForm.getFormParams(); + 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 || {}; + 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){ + if (this.encrypt) { this.confirmInfo({ width: 500, content: (
-
1.{getLabel('524355','提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!')}

+
1.{getLabel('524355', '提示: 字段一旦加密后无法取消,同时加密后的字段不支持查询,请谨慎操作!')}

- 2.{getLabel('531157','历史数据量可能较大, 此操作可能需要较长时间,对系统性能也可能会造成一定影响,请确认是否处理历史数据:')} + 2.{getLabel('531157', '历史数据量可能较大, 此操作可能需要较长时间,对系统性能也可能会造成一定影响,请确认是否处理历史数据:')} - { + onChange={(v, showname) => { this.needInitData = v; }} /> @@ -1963,7 +2113,7 @@ export class FieldDefinedStore extends HrmBaseStore { ), onOk: this.doSaveEncryptFieldSettingForm }) - }else{ + } else { this.needInitData = '0'; this.doSaveEncryptFieldSettingForm(); } @@ -1974,243 +2124,243 @@ export class FieldDefinedStore extends HrmBaseStore { } @action doSaveEncryptFieldSettingForm = async () => { - if(this.spinning) + if (this.spinning) return; this.spinning = true; - const params = {...this.formTarget.encryptForm.getFormParams(), ...this.encryptParams, needInitData: this.needInitData, ...this.opParams} + 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{ + try { const data = await api.saveEncryptFieldSettingForm(params); - if(data.status == '1'){ + if (data.status == '1') { this.encryptDialogVisible = false; message.success(i18n.message.saveSuccess()); - if (this.moduleName.indexOf('resource') >= 0) - this.getTabInfoByTreeNode(); - else - this.initData(); - }else{ + // if (this.moduleName.indexOf('resource') >= 0) + this.getTabInfoByTreeNode(); + // else + // this.initData(); + } else { message.error(data.message); } this.spinning = false; - }catch(e){ + } catch (e) { this.spinning = false; } } //#region 查看范围设置 - target = {}; - @observable dialogVisible = false; - @observable table = new TableStore(); - @observable canAdd = false; - @observable canDel = false; + 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; + @computed get tableMultiDelete() { + return this.table.selectedRowKeys.length === 0 || !this.canDel; } - - get opParams(){ + + @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){ + if (name.indexOf('subcompany') > -1) { Object.assign(obj, { scopeId: 'subcompany' }); - }else if(name.indexOf('department') > -1){ + } else if (name.indexOf('department') > -1) { Object.assign(obj, { scopeId: 'department' }); @@ -2224,5 +2374,5 @@ export class FieldDefinedStore extends HrmBaseStore { //#endregion /********************* action list *********************/ - + } \ No newline at end of file diff --git a/pc4mobx/organization/util/index.js b/pc4mobx/organization/util/index.js index ebe5892..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; @@ -89,4 +117,18 @@ export const calFormHeight = (groupLength, children) => { 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 From 88dd830ce35898a43a7578147a1a7b0c57120d7d Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 13 Jun 2022 17:35:34 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/stores/fieldDefined.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index 8ada3bd..d034da6 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-13 15:06:29 + * @LastEditTime: 2022-06-13 16:55:34 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -1501,14 +1501,14 @@ export class FieldDefinedStore extends HrmBaseStore { this.tableEditConfig.childInfoSetting.showTitle = true; this.tableEditConfig.childInfoSetting.showAdd = true; this.tableEditConfig.childInfoSetting.showDelete = true; - this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ - comType: 'button', - type: 'primary', - onClickHandle: this.doChildInfoSetting, - label: i18n.button.childInfoMaintain(), - icon: this.menuIconCollection.setting, - checkAction: 'childInfoOperability' - }); + // this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ + // comType: 'button', + // type: 'primary', + // onClickHandle: this.doChildInfoSetting, + // label: i18n.button.childInfoMaintain(), + // icon: this.menuIconCollection.setting, + // checkAction: 'childInfoOperability' + // }); } else { this.tableEditConfig.childInfoSetting.showTitle = false; this.tableEditConfig.childInfoSetting.showAdd = false; From 2d1c75698524c496bb7f5d829d7ff56782c621a6 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 16 Jun 2022 08:43:36 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=91=E5=92=8Ctab=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/fieldDefined.js | 29 +- .../fieldDefinedSet/FieldDefined.js | 10 +- pc4mobx/organization/public/i18n.js | 1 + pc4mobx/organization/stores/companyextend.js | 2 +- pc4mobx/organization/stores/fieldDefined.js | 272 +++++++----------- 5 files changed, 137 insertions(+), 177 deletions(-) diff --git a/pc4mobx/organization/apis/fieldDefined.js b/pc4mobx/organization/apis/fieldDefined.js index 5a5a66a..a642d7d 100644 --- a/pc4mobx/organization/apis/fieldDefined.js +++ b/pc4mobx/organization/apis/fieldDefined.js @@ -7,7 +7,7 @@ import { * @param {Object} params [description] * @return {[type]} [description] */ -export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/getTabInfo?is_multilang_set=true`, 'GET', params) +export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi('/api/bs/hrmorganization/fieldDefined/getTabInfo', 'GET', params) export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/getFieldDefinedInfo?is_multilang_set=true`, 'GET', params) @@ -15,11 +15,34 @@ export const saveFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callAp export const removeFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/del`, 'POST', params) -export const saveGroupInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/saveGroup`, 'POST', params) +export const saveGroupInfo = (moduleName,params) => { + return fetch('/api/bs/hrmorganization/fieldDefined/saveTitle', { + 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 = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/delGroup`, 'POST', params) -export const getTree = (params = {}) => WeaTools.callApi(`/api/hrm/resourcefielddefined/getTree`, 'GET', params) +export const getTree = (moduleName,params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTree`, 'GET', params) export const saveTree = (params = {}) => WeaTools.callApi(`/api/hrm/resourcefielddefined/saveTree`, 'POST', params) diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js index d835966..698ff79 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js @@ -56,13 +56,15 @@ export default class FieldDefined extends Component { let moduleName, logSmallType; if (moduleType === 'subCompany') { moduleName = 'subcompanyfielddefined'; - logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED'; + //logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED'; } else if (moduleType === 'department') { moduleName = 'departmentfielddefined'; - logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED'; - } else { + //logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED'; + } else if(moduleType === 'job') { + moduleName = 'jobfielddefined'; + }else { moduleName = 'resourcefielddefined'; - logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; + //logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; } // let callbackFunc = () => initData(false, true, moduleName); // if (moduleType === 'resource') diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index 567877f..fad5e61 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -843,6 +843,7 @@ 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/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 index d034da6..e64f25f 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-13 16:55:34 + * @LastEditTime: 2022-06-15 18:47:39 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -67,7 +67,9 @@ export class FieldDefinedStore extends HrmBaseStore { }, { comType: 'button', type: 'primary', - onClickHandle: () => this.editType(), + onClickHandle: () => this.editTypeInfo(true, { + name: this.selectedTreeNodeInfo.name, + }), label: i18n.button.createType, icon: this.menuIconCollection.create }, { @@ -504,7 +506,7 @@ export class FieldDefinedStore extends HrmBaseStore { "items": [{ "colSpan": 2, "conditionType": "INPUT", - "domkey": ["typeName"], + "domkey": ["name"], "fieldcol": 12, "isQuickSearch": false, "label": i18n.label.typeName, @@ -513,59 +515,6 @@ export class FieldDefinedStore extends HrmBaseStore { "rules": "required|string", "value": "", "viewAttr": 3, - }, { - "belong": "PC", - "checkbox": false, - "checkboxValue": false, - "colSpan": 2, - "conditionType": "SELECT", - "dateGroup": false, - "defaultDisplayInBar": false, - "detailtype": 3, - "domkey": [ - "tableType" - ], - "entSearch": false, - "fieldcol": 16, - "hasBorder": false, - "helpfulTipProps": {}, - "hide": false, - "isBase64": false, - "isQuickSearch": false, - "label": "新增到", - "labelcol": 6, - "length": 0, - "maxFilesNumber": 0, - "maxUploadSize": 0, - "multiSelection": false, - "multiple": false, - "options": [ - { - "disabled": false, - "key": "0", - "selected": false, - "showname": "主表", - "visible": true - }, - { - "disabled": false, - "key": "1", - "selected": false, - "showname": "明细表", - "visible": true - } - ], - "precision": 0, - "secretLimit": false, - "showOrder": 0, - "showTime": false, - "stringLength": 0, - "supportCancel": false, - "tipPosition": "bottom", - "value": "0", - "valueList": [], - "rules": "required|string", - "viewAttr": 3 }], "defaultshow": true }] @@ -821,7 +770,7 @@ export class FieldDefinedStore extends HrmBaseStore { this.dialogParams.childInfoSetting.visible && this.doSaveChildInfoSetting(); } - @action editGroup = (group, moveToGroup = false) => { + @action("新建分组") editGroup = (group, moveToGroup = false) => { this.moveToGroup = moveToGroup; this.editGroupInfoFormFields.map(f => { if (typeof (f.title) == 'function') @@ -851,7 +800,9 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('editGroupInfo', true, dialogTitle); } - @action editType = () => { + isCreateTypeInfo = false; + @action("新增或创建类型") editTypeInfo = (create = true, data = {}) => { + this.isCreateTypeInfo = create; this.editTypeInfoFormFields.map(f => { if (typeof (f.title) == 'function') f.title = f.title(); @@ -862,17 +813,20 @@ export class FieldDefinedStore extends HrmBaseStore { }) }) let fields = [...this.editTypeInfoFormFields], - dialogTitle = ''; + dialogTitle = create ? i18n.button.createType() : i18n.button.editTypeInfo(); this.setFormData('typeInfoFrom', fields); - // this.formTarget.typeInfoFrom.updateFields({ - // typeName: { value: '' } - // }); - // this.opId = null; - dialogTitle = i18n.button.createType(); + if (!create) { + this.formTarget.typeInfoFrom.updateFields({ + name: { value: data.name } + }); + }else { + this.selectedTreeNodeInfo.domid = null; + } + this.setDialogVisible('editTypeInfo', true, dialogTitle); } - @action doGroupSetting = () => { + @action("分组维护") doGroupSetting = () => { this.tableEditConfig.groupSetting.datas.length = 0; let arr = []; this.tabRecord.map(tabInfo => { @@ -920,36 +874,27 @@ export class FieldDefinedStore extends HrmBaseStore { } - @action doSaveTypeInfo = () => { + @action("保存类型") doSaveTypeInfo = () => { this.formTarget.typeInfoFrom.validateForm().then(f => { if (f.isValid) { - let record = { - ...this.formTarget.typeInfoFrom.getFormParams(), - } + debugger let params = { - data: JSON.stringify({ - record: record - }) + ... this.formTarget.typeInfoFrom.getFormParams(), + id: this.selectedTreeNodeInfo.domid } - // api.saveTypeInfo(this.moduleName, params).then(data => { - // if (data.status === '1') { - // this.setDialogVisible('editGroupInfo', false, ''); - // if (this.moveToGroup) { - // const ids = data.groupid.split(','); - // this.changeGroup(null, ids[ids.length - 1]); - // } else { - // //if (this.moduleName.indexOf('resource') >= 0) - // this.getTabInfoByTreeNode(); - // // else - // // this.initData(this.opId == null); - // message.success(i18n.message.saveSuccess()); - // } - // } else - // message.error(data.message); - // }, error => { - // message.error(i18n.message.actionError()); - // }); - this.getTree() + 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(); @@ -957,7 +902,7 @@ export class FieldDefinedStore extends HrmBaseStore { }); } - doSaveGroupInfo = () => { + @action("分组保存") doSaveGroupInfo = () => { this.formTarget.groupInfoFrom.validateForm().then(f => { if (f.isValid) { let record = { @@ -972,51 +917,33 @@ export class FieldDefinedStore extends HrmBaseStore { this.showError = new Date().getTime(); return; } - let found = false, - records = []; - this.opId != null && Object.assign(record, { - id: this.opId, - isShow: this.activeTabInfo.tabInfo.isShow - }); - this.tabConfig.tabs.map(tabInfo => { - if (tabInfo.groupid === this.opId) { - found = true; - records.push(record) - } else { - records.push({ - id: tabInfo.groupid, - isShow: tabInfo.isShow, - groupName: tabInfo.title - }) - } - }); - !found && records.push(record); let params = { - data: JSON.stringify({ - records: records - }) + ...this.formTarget.groupInfoFrom.getFormParams(), + isShow: 1 } + if (this.selectedTreeNodeInfo != null) params.groupType = this.selectedTreeNodeInfo.key - api.saveGroupInfo(this.moduleName, params).then(data => { - if (data.status === '1') { + 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.groupid.split(','); + const ids = data.data.groupid.split(','); this.changeGroup(null, ids[ids.length - 1]); } else { - //if (this.moduleName.indexOf('resource') >= 0) this.getTabInfoByTreeNode(); - // else - // this.initData(this.opId == null); message.success(i18n.message.saveSuccess()); } - } else - message.error(data.message); - }, error => { - message.error(i18n.message.actionError()); - }); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } else { f.showErrors(); this.showError = new Date().getTime(); @@ -1341,7 +1268,8 @@ export class FieldDefinedStore extends HrmBaseStore { dataObj.groupType = this.selectedTreeNodeInfo.key; params.groupType = this.selectedTreeNodeInfo.key; } - params.data = JSON.stringify(dataObj); + params.data = dataObj; + api.saveGroupInfo(this.moduleName, params).then(data => { if (data.status === '1') { this.setDialogVisible('groupInfoSetting', false, ''); @@ -1355,6 +1283,7 @@ export class FieldDefinedStore extends HrmBaseStore { }, error => { message.error(i18n.message.actionError()); }); + } else { message.error(i18n.confirm.groupNameExist()); } @@ -1446,27 +1375,21 @@ export class FieldDefinedStore extends HrmBaseStore { this.selectedTreeNodeInfo = null; this.dropdownSelectedKey = '1'; this.moduleName = module; - // let columns = cloneDeep(this.fieldDefColumns()) - // columns.splice(1, 1); - // columns[1].width = '65%'; - // this.tableEditConfig.fieldDef.columns = this.getColumns(); this.treeConfig.treeExpandKeys.length = 0; - api.getTree().then(data => { - if (data.status === '1') { + api.getTree(this.moduleName).then(res => { + if (res.code === 200) { this.containerInitFinished = { ...this.containerInitFinished, init: true } - - // this.setTableEditColTitle(); - if (data.treejson.length > 0) { - this.treeConfig.data = data.treejson; - this.treeConfig.selectedKeys = [data.treejson[0].key]; - this.selectedTreeNodeInfo = data.treejson[0]; + 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(data.message); + message.error(res.msg); } }, error => { }) } @@ -1474,9 +1397,9 @@ export class FieldDefinedStore extends HrmBaseStore { getTree = (callback) => { this.treeConfig.data.length = 0; this.refreshTree = new Date().getTime(); - api.getTree().then(data => { - if (data.status === '1') { - this.treeConfig.data = data.treejson; + 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; @@ -1487,7 +1410,7 @@ export class FieldDefinedStore extends HrmBaseStore { }) callback && callback(); } else { - message.error(data.message); + message.error(res.msg); } this.refreshTree = new Date().getTime(); }, error => { }) @@ -1497,38 +1420,46 @@ export class FieldDefinedStore extends HrmBaseStore { if (!this.selectedTreeNodeInfo.hasGroup) { t.topButtonDef.splice(1, 3); } - if (this.selectedTreeNodeInfo.addChild) { + 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; - // this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ - // comType: 'button', - // type: 'primary', - // onClickHandle: this.doChildInfoSetting, - // label: i18n.button.childInfoMaintain(), - // icon: this.menuIconCollection.setting, - // checkAction: 'childInfoOperability' - // }); + let domid = this.selectedTreeNodeInfo.domid; + //非基本类型() + (domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({ + comType: 'button', + type: 'primary', + onClickHandle: this.doChildInfoSetting, + label: i18n.button.childInfoMaintain(), + icon: this.menuIconCollection.setting, + checkAction: 'childInfoOperability' + }) && 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; - this.selectedTreeNodeInfo.domid != '-1' && t.topButtonDef.push({ + t.topButtonDef.push({ comType: 'button', type: 'primary', - onClickHandle: () => this.createChildInfo(false, { - name: this.selectedTreeNodeInfo.name, - multiName: this.selectedTreeNodeInfo.multiName - }), - label: i18n.button.editChildInfo(), - icon: this.menuIconCollection.setting - }) && t.topButtonDef.push({ - comType: 'button', - type: 'primary', - onClickHandle: this.removeChildInfo, + onClickHandle: this.removeTypeInfo, label: i18n.button.delete(), icon: this.menuIconCollection.setting - }); + }) } if (this.selectedTreeNodeInfo.domid === '-1' || this.selectedTreeNodeInfo.addChild) { @@ -1553,12 +1484,12 @@ export class FieldDefinedStore extends HrmBaseStore { @action getTabInfoByTreeNode = (create = false, init = false, isLeaf) => { api.getTabInfo(this.moduleName, { groupType: this.treeConfig.selectedKeys[0] - }).then(data => { - if (data.status === '1') { - this._groupInfoOperability = data.tabs.length === 0; + }).then(res => { + if (res.code === 200) { + this._groupInfoOperability = res.data.tabs.length === 0; let tabArr = []; - this.tabRecord = data.tabs; - data.tabs && data.tabs.map((tabInfo, index) => { + this.tabRecord = res.data.tabs; + res.data.tabs && res.data.tabs.map((tabInfo, index) => { let t = cloneDeep(this.tabDef); this.setBtn(t); tabArr.push({ @@ -1616,6 +1547,9 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('createChildInfo', true, dialogTitle); } + + + @action doSaveChildInfo = () => { this.formTarget.childInfoForm.validateForm().then(f => { if (f.isValid) { From 19e1d07e3c4153b3bf801d9aec9b990a63078e93 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 16 Jun 2022 18:35:17 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/fieldDefined.js | 59 ++++-- .../fieldDefinedSet/FieldDefined.js | 15 +- pc4mobx/organization/stores/baseStore.js | 3 +- pc4mobx/organization/stores/fieldDefined.js | 180 ++++++++++-------- 4 files changed, 155 insertions(+), 102 deletions(-) diff --git a/pc4mobx/organization/apis/fieldDefined.js b/pc4mobx/organization/apis/fieldDefined.js index a642d7d..8306fbb 100644 --- a/pc4mobx/organization/apis/fieldDefined.js +++ b/pc4mobx/organization/apis/fieldDefined.js @@ -7,16 +7,12 @@ import { * @param {Object} params [description] * @return {[type]} [description] */ -export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi('/api/bs/hrmorganization/fieldDefined/getTabInfo', 'GET', params) +export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTabInfo`, 'GET', params) -export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/getFieldDefinedInfo?is_multilang_set=true`, 'GET', params) +export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getFieldDefinedInfo`, 'GET', params) -export const saveFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/save`, 'POST', 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/saveTitle', { +export const saveFieldDefinedInfo = (moduleName,params) => { + return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, { method: 'POST', mode: 'cors', headers: { @@ -26,6 +22,30 @@ export const saveGroupInfo = (moduleName,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`, { @@ -38,13 +58,30 @@ export const changeTypeInfo = (moduleName,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 removeGroupInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/delGroup`, 'POST', params) - export const getTree = (moduleName,params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTree`, 'GET', params) -export const saveTree = (params = {}) => WeaTools.callApi(`/api/hrm/resourcefielddefined/saveTree`, 'POST', 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) diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js index 698ff79..c2812e6 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDefined.js @@ -56,20 +56,18 @@ export default class FieldDefined extends Component { let moduleName, logSmallType; if (moduleType === 'subCompany') { moduleName = 'subcompanyfielddefined'; - //logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED'; } else if (moduleType === 'department') { moduleName = 'departmentfielddefined'; - //logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED'; } else if(moduleType === 'job') { moduleName = 'jobfielddefined'; }else { moduleName = 'resourcefielddefined'; - //logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED'; } // let callbackFunc = () => initData(false, true, moduleName); // if (moduleType === 'resource') - let callbackFunc = () => initResourceData(moduleName); - checkAuthorized(moduleName, null, callbackFunc); + //let callbackFunc = () => initResourceData(moduleName); + //checkAuthorized(moduleName, null, callbackFunc); + initResourceData(moduleName); this.setState({ logSmallType }) } @@ -87,7 +85,7 @@ export default class FieldDefined extends Component { fieldDefined: store, params } = this.props, { - containerInitFinished, + //containerInitFinished,//权限验证 refreshMainTabComponent, spinning } = store, { @@ -145,7 +143,8 @@ export default class FieldDefined extends Component { } } let children = []; - if (containerInitFinished.init && containerInitFinished.authorized) { + const hasRight = true;//todo + if (hasRight) { const { data, onSelectedTreeNode, @@ -176,7 +175,7 @@ export default class FieldDefined extends Component { ) ] - } else if (containerInitFinished.init && !containerInitFinished.authorized) { + } else { children = [ ( diff --git a/pc4mobx/organization/stores/baseStore.js b/pc4mobx/organization/stores/baseStore.js index 0a23a00..fe5b741 100644 --- a/pc4mobx/organization/stores/baseStore.js +++ b/pc4mobx/organization/stores/baseStore.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:14:20 - * @LastEditTime: 2022-06-13 14:50:36 + * @LastEditTime: 2022-06-16 18:26:17 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/baseStore.js */ @@ -540,6 +540,7 @@ export default class HrmBaseStore { return otherParams; } + //重新计算列 convertData = (datas, target) => { let tData = [], selectedData = this.generateTableSelectedData(target); diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index e64f25f..c2950f2 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-09 10:16:00 - * @LastEditTime: 2022-06-15 18:47:39 + * @LastEditTime: 2022-06-16 18:34:18 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js */ @@ -648,10 +648,10 @@ export class FieldDefinedStore extends HrmBaseStore { this.tabConfig.tabs = [...tabArr]; // this.setTableEditColTitle(); this.setActiveTab(this.tabConfig, init ? '1' : !create ? this.tabConfig.activeTabKey : `${tabArr.length}`); - this.containerInitFinished = { - ...this.containerInitFinished, - init: true - } + // this.containerInitFinished = { + // ...this.containerInitFinished, + // init: true + // } } } else { message.error(data.message); @@ -696,38 +696,38 @@ export class FieldDefinedStore extends HrmBaseStore { if (this.selectedTreeNodeInfo != null) params.groupType = this.selectedTreeNodeInfo.key this.spinning = true; - api.getFieldDefinedInfo(this.moduleName, params).then(data => { - if (data.status === '1') { + + api.getFieldDefinedInfo(this.moduleName, params).then(response => { + return response.json() + }).then(res => { + if (res.code === 200) { const { datas, selectedData - } = this.convertData(data.data, 'fieldDef'); - this.encryptEnable = data.encryptEnable; + } = this.convertData(res.data.data, 'fieldDef'); + this.encryptEnable = res.data.encryptEnable; this.tableEditConfig.fieldDef.datas = datas; this.tableEditConfig.fieldDef.columns = this.getColumns(); - - //人员卡片字段定义columns是动态的,因此需要重新计算得出selectedData - if (this.moduleName === 'resourcefielddefined') { - const { - selectedData - } = this.convertData(data.data, 'fieldDef'); - this.tableEditConfig.fieldDef.selectedData = selectedData; - } else { - this.tableEditConfig.fieldDef.selectedData = selectedData; - } + this.tableEditConfig.fieldDef.selectedData = selectedData; if (this.tabRecord.length > 0) { - this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (data.data.length === 0); - this.activeTabInfo.tabInfo.editable = (data.data.length === 0); + this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (res.data.data.length === 0); + this.activeTabInfo.tabInfo.editable = (res.data.data.length === 0); } - } else - message.error(data.message); + } else { + message.warning(res.msg); + } this.spinning = false; this.refreshMainTabComponent = new Date().getTime(); - }, error => { this.spinning = false; }) + }).catch(error => { + this.spinning = false; + message.warning(error.msg); + }) + + } - @action onTabEdit = (targetKey, action) => { + @action("分组tab删除") onTabEdit = (targetKey, action) => { const tabIndex = this.getTabIndex(this.tabConfig.tabs, targetKey); if (tabIndex < 0) return; const tabInfo = this.tabConfig.tabs[tabIndex]; @@ -741,18 +741,19 @@ export class FieldDefinedStore extends HrmBaseStore { } if (this.selectedTreeNodeInfo != null) params.groupType = this.selectedTreeNodeInfo.key - api.removeGroupInfo(this.moduleName, params).then(data => { - if (data.status === '1') { + + 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'; - // if (this.moduleName.indexOf('resource') >= 0) - // this.getTabInfoByTreeNode(); - // else - // this.initData(); this.getTabInfoByTreeNode(); } else { - message.error(data.message); + message.warning(data.msg); } + }).catch(error => { + message.warning(error.msg); }) } }); @@ -819,10 +820,10 @@ export class FieldDefinedStore extends HrmBaseStore { this.formTarget.typeInfoFrom.updateFields({ name: { value: data.name } }); - }else { + } else { this.selectedTreeNodeInfo.domid = null; } - + this.setDialogVisible('editTypeInfo', true, dialogTitle); } @@ -877,7 +878,6 @@ export class FieldDefinedStore extends HrmBaseStore { @action("保存类型") doSaveTypeInfo = () => { this.formTarget.typeInfoFrom.validateForm().then(f => { if (f.isValid) { - debugger let params = { ... this.formTarget.typeInfoFrom.getFormParams(), id: this.selectedTreeNodeInfo.domid @@ -1019,18 +1019,20 @@ export class FieldDefinedStore extends HrmBaseStore { return; } - api.saveFieldDefinedInfo(this.moduleName, params).then(data => { - if (data.status === '1') { + api.saveFieldDefinedInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { message.success(i18n.message.saveSuccess()); - // if (this.moduleName.indexOf('resource') >= 0) this.getTabInfoByTreeNode(); - // else - // this.initData(); } else { - message.error(data.message); + message.warning(data.msg); } this.spinning = false; - }, error => { this.spinning = false; }) + }).catch(error => { + message.warning(error.msg); + }) + } else { message.error(i18n.confirm.displayOrDBFieldExist()); this.spinning = false; @@ -1243,7 +1245,7 @@ export class FieldDefinedStore extends HrmBaseStore { return sel; } - doSaveGroupSetting = () => { + @action("分组维护保存") doSaveGroupSetting = () => { this.recordOP(this.editTable['groupSetting'], 'valid'); let groupNameArr = [], tabArr = []; @@ -1270,26 +1272,27 @@ export class FieldDefinedStore extends HrmBaseStore { } params.data = dataObj; - api.saveGroupInfo(this.moduleName, params).then(data => { - if (data.status === '1') { + api.saveGroupSettingInfo(this.moduleName, params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { this.setDialogVisible('groupInfoSetting', false, ''); - // if (this.moduleName.indexOf('resource') >= 0) this.getTabInfoByTreeNode(false, true); - // else - // this.initData(false, true); message.success(i18n.message.saveSuccess()); - } else - message.error(data.message); - }, error => { - message.error(i18n.message.actionError()); - }); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) } else { message.error(i18n.confirm.groupNameExist()); } } - @action onGroupSettingDeleteOpr = (ks, ds, type) => { + @action("分组维护中删除") onGroupSettingDeleteOpr = (ks, ds, type) => { + debugger let ids = []; ds.map(d => { if (has(d, 'id')) @@ -1315,7 +1318,7 @@ export class FieldDefinedStore extends HrmBaseStore { } else { } } - //人员卡片字段定义部分 + //字段定义部分 @observable refreshTree = new Date().getTime(); @observable treeConfig = { data: [], @@ -1330,7 +1333,7 @@ export class FieldDefinedStore extends HrmBaseStore { this.getTabInfoByTreeNode(null, true); } } - //人员卡片字段定义-选中树节点的信息 + //选中树节点的信息 @observable selectedTreeNodeInfo; //计算【工作信息】树节点以及子节点的domid @@ -1378,10 +1381,10 @@ export class FieldDefinedStore extends HrmBaseStore { this.treeConfig.treeExpandKeys.length = 0; api.getTree(this.moduleName).then(res => { if (res.code === 200) { - this.containerInitFinished = { - ...this.containerInitFinished, - init: true - } + // this.containerInitFinished = { + // ...this.containerInitFinished, + // init: true + // } if (res.data.length > 0) { this.treeConfig.data = res.data; this.treeConfig.selectedKeys = [res.data[0].key]; @@ -1434,21 +1437,23 @@ export class FieldDefinedStore extends HrmBaseStore { this.tableEditConfig.childInfoSetting.showAdd = true; this.tableEditConfig.childInfoSetting.showDelete = true; let domid = this.selectedTreeNodeInfo.domid; - //非基本类型() - (domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({ + t.topButtonDef.push({ comType: 'button', type: 'primary', onClickHandle: this.doChildInfoSetting, label: i18n.button.childInfoMaintain(), - icon: this.menuIconCollection.setting, - checkAction: 'childInfoOperability' - }) && t.topButtonDef.push({ + 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; @@ -1462,6 +1467,8 @@ export class FieldDefinedStore extends HrmBaseStore { }) } + + 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 { @@ -1550,7 +1557,7 @@ export class FieldDefinedStore extends HrmBaseStore { - @action doSaveChildInfo = () => { + @action("编辑子信息保存(f)") doSaveChildInfo = () => { this.formTarget.childInfoForm.validateForm().then(f => { if (f.isValid) { let record = { @@ -1625,7 +1632,8 @@ export class FieldDefinedStore extends HrmBaseStore { }, error => { message.error(i18n.message.actionError()); }); - // } + + } else { f.showErrors(); this.showError = new Date().getTime(); @@ -1633,7 +1641,7 @@ export class FieldDefinedStore extends HrmBaseStore { }); } - @action doChildInfoSetting = () => { + @action("子信息维护") doChildInfoSetting = () => { this.tableEditConfig.childInfoSetting.datas.length = 0; let arr = []; if (!this.selectedTreeNodeInfo.addChild) { @@ -1653,6 +1661,7 @@ export class FieldDefinedStore extends HrmBaseStore { } }) } 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')) { @@ -1698,6 +1707,7 @@ export class FieldDefinedStore extends HrmBaseStore { this.setDialogVisible('childInfoSetting', true, i18n.button.childInfoMaintain()); } + convertAttr = (cloneTree) => { let arr = []; cloneTree.map(root => { @@ -1763,7 +1773,8 @@ export class FieldDefinedStore extends HrmBaseStore { }); } - doSaveChildInfoSetting = () => { + @action("保存子信息维护") doSaveChildInfoSetting = () => { + debugger this.recordOP(this.editTable['childInfoSetting'], 'valid'); let infoNameArr = [], infoArr = []; @@ -1772,7 +1783,7 @@ export class FieldDefinedStore extends HrmBaseStore { infoArr.push({ id: group.id, isShow: group.isShow == null ? '0' : group.isShow, - name: group.name + groupName: group.name }) return group.name === ''; }) @@ -1802,30 +1813,35 @@ export class FieldDefinedStore extends HrmBaseStore { }) }) } - const params = { - data: JSON.stringify({ - records: this.convertAttr(cloneTree) - }), + // data: JSON.stringify({ + // records: this.convertAttr(cloneTree) + // }), + data: JSON.stringify(infoArr), parentId } - api.saveTree(params).then(data => { - if (data.status === '1') { + + 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.error(data.message); - }, error => { + } else { + message.warning(data.msg); + } + }).catch(error => { message.error(i18n.message.actionError()); - }); + }) + } else { message.error(i18n.confirm.groupNameExist()); } } - //移动到组 - @action dropdownClick = (e) => { + + @action("移动到组") dropdownClick = (e) => { switch (e.key) { case 'createAndMove': this.editGroup(null, true);