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] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=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