diff --git a/pc4mobx/organization/apis/resourceBasicInfo.js b/pc4mobx/organization/apis/resourceBasicInfo.js new file mode 100644 index 0000000..e69de29 diff --git a/pc4mobx/organization/components/group/Group.js b/pc4mobx/organization/components/group/Group.js index 60ee893..7880bfb 100644 --- a/pc4mobx/organization/components/group/Group.js +++ b/pc4mobx/organization/components/group/Group.js @@ -175,7 +175,7 @@ export default class Group extends React.Component { group } = this.props; const { - nEdialogTitle, visible, condition, form, dialogLoading, isEdit, topTab, selectedKey,date,hasRight + nEdialogTitle, visible, condition, form, dialogLoading, isEdit, topTab, selectedKey, date, hasRight,loading } = group; if (hasRight === false) { @@ -205,7 +205,10 @@ export default class Group extends React.Component { onChange={this.changeData.bind(this)} />
- {this.getFormField()} + { + loading ?
+ +
: this.getFormField()}
diff --git a/pc4mobx/organization/components/postionrank/JobLevel.js b/pc4mobx/organization/components/postionrank/JobLevel.js index bdc99c2..0b1a491 100644 --- a/pc4mobx/organization/components/postionrank/JobLevel.js +++ b/pc4mobx/organization/components/postionrank/JobLevel.js @@ -51,6 +51,7 @@ export default class JobLevel extends React.Component { } componentDidMount() { + this.init(); } componentWillReceiveProps(nextProps) { diff --git a/pc4mobx/organization/components/postionrank/RankScheme.js b/pc4mobx/organization/components/postionrank/RankScheme.js index 24883d9..a569b53 100644 --- a/pc4mobx/organization/components/postionrank/RankScheme.js +++ b/pc4mobx/organization/components/postionrank/RankScheme.js @@ -54,6 +54,12 @@ export default class RankScheme extends React.Component { this.init(); } + componentWillUnmount() { + debugger + alert('组件销毁?') + } + + componentWillReceiveProps(nextProps) { const { rankScheme diff --git a/pc4mobx/organization/components/resource/ResourceBasicInfo.js b/pc4mobx/organization/components/resource/ResourceBasicInfo.js new file mode 100644 index 0000000..1dbb5b7 --- /dev/null +++ b/pc4mobx/organization/components/resource/ResourceBasicInfo.js @@ -0,0 +1,467 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer, +} from 'mobx-react' +import { + WeaTop, + WeaTab, + WeaFormItem, + WeaRightMenu, + WeaLeftRightLayout, + WeaLeftTree +} from 'ecCom' +import { + Row, + Col, + Spin, + Modal, + Button, + message, + Switch +} from 'antd' +import { + WeaSwitch, + WeaTableNew +} from 'comsMobx' +import { + i18n +} from '../../public/i18n'; + +import '../../style/common.less'; + +import NewAndEditDialog from '../NewAndEditDialog'; +import { renderNoright } from '../../util'; + + +const toJS = mobx.toJS; +const confirm = Modal.confirm; +const WeaTable = WeaTableNew.WeaTable; + + +@inject('resourceBasicInfo') +@observer +export default class ResourceBasicInfo extends React.Component { + constructor(props) { + super(props); + } + + componentWillMount() { + } + + componentDidMount() { + this.init(); + } + + componentWillReceiveProps(nextProps) { + const { + resourceBasicInfo + } = this.props; + + if (this.props.location.key !== nextProps.location.key) { + this.init(); + } + } + + init() { + const { + resourceBasicInfo + } = this.props; + resourceBasicInfo.getHasRight(); + resourceBasicInfo.initData(); + } + + getTopMenuBtns() { + const { + resourceBasicInfo + } = this.props; + const { + topMenu, + tableStore + } = resourceBasicInfo; + + let btns = []; + topMenu.map((item, i) => { + if (item.menuFun !== 'batchDelete') { + btns.push(); + } else { + btns.push(); + } + + }); + + return btns; + } + + handleClick(item) { + const { + resourceBasicInfo + } = this.props; + const { + isPanelShow + } = resourceBasicInfo; + + isPanelShow && resourceBasicInfo.setPanelStatus(false); + this[item.menuFun] && this[item.menuFun](); + } + + new() { + const { + resourceBasicInfo + } = this.props; + + resourceBasicInfo.setNeDialogTitle(i18n.label.newJobLevel()); + resourceBasicInfo.setIsNew(true); + resourceBasicInfo.setVisible(true); + resourceBasicInfo.getForm(); + } + + batchDelete() { + const { + resourceBasicInfo + } = this.props; + const { + tableStore + } = resourceBasicInfo; + + let keys = toJS(tableStore.selectedRowKeys).toString(); + resourceBasicInfo.setIds(keys); + this.showConfirm('batchDel'); + } + showConfirm(v) { + let _this = this; + confirm({ + title: i18n.confirm.defaultTitle(), + content: (v == 'del') ? i18n.confirm.delete() : i18n.confirm.batchDeleteConfirm(), + okText: i18n.button.ok(), + cancelText: i18n.button.cancel(), + onOk() { + _this.onOk(); + }, + onCancel() { + return false; + }, + }); + } + onOk() { + const { + resourceBasicInfo + } = this.props; + resourceBasicInfo.delete(); + } + + + getDropMenuDatas() { + const { + resourceBasicInfo + } = this.props; + const { + rightMenu + } = resourceBasicInfo; + + 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; + } + + handleMenuClick(key) { + const { + resourceBasicInfo + } = this.props; + const { + isPanelShow + } = resourceBasicInfo; + + isPanelShow && resourceBasicInfo.setPanelStatus(false); + this[key] && this[key](); + } + + getTabBtn() { + const { + resourceBasicInfo + } = this.props; + const { + form2 + } = resourceBasicInfo; + + const btn = [ + (), + (), + (), + ]; + + return btn; + } + + onSearchChange(val) { + const { + resourceBasicInfo + } = this.props; + const { + form2 + } = resourceBasicInfo; + + resourceBasicInfo.setLevelName(val); + !this.isEmptyObject(form2.getFormParams()) && resourceBasicInfo.updateFields(val); + } + + changeData(key) { + const { + resourceBasicInfo + } = this.props; + resourceBasicInfo.changeData(key); + } + + reRenderColumns(columns) { + let _this = this; + columns.forEach((c, index) => { + if (c.dataIndex == 'forbidden_tag') { + c.render = function (text, record) { + return _this.updateForbiddenTag(checked, record.id)} /> + } + }; + }) + } + + updateForbiddenTag(checked, id) { + const { + resourceBasicInfo + } = this.props; + confirm({ + title: i18n.confirm.defaultTitle(), + content: (checked == true) ? i18n.confirm.enableTag() : i18n.confirm.forbiddenTag(), + okText: i18n.button.ok(), + cancelText: i18n.button.cancel(), + onOk() { + resourceBasicInfo.updateForbiddenTag(checked, id); + }, + onCancel() { + return false; + }, + }); + } + + onOperatesClick(record, rowIndex, operate) { + const { + index + } = operate; + (index == '0') && this.doEdit(record.randomFieldId); + (index == '1') && this.doDel(record.randomFieldId); + } + + custom = () => { + const { + resourceBasicInfo + } = this.props, { + tableStore, + } = resourceBasicInfo; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + + doEdit(id) { + const { + resourceBasicInfo + } = this.props; + + resourceBasicInfo.setNeDialogTitle(i18n.label.editJobLevel()); + resourceBasicInfo.setLevelId(id); + resourceBasicInfo.setIsNew(false); + resourceBasicInfo.setVisible(true); + resourceBasicInfo.getForm(); + } + + doDel(id) { + const { + resourceBasicInfo + } = this.props; + resourceBasicInfo.setIds(id); + this.showConfirm('del'); + } + + + handleSave() { + const { + resourceBasicInfo + } = this.props; + const { + isNew + } = resourceBasicInfo; + + isNew && resourceBasicInfo.save(); + !isNew && resourceBasicInfo.edit(); + } + + getPanelComponents() { + const { + resourceBasicInfo + } = this.props; + const { + searchCondition, + form2, + searchConditionLoading + } = resourceBasicInfo; + + let arr = []; + let formParams = form2.getFormParams(); + const { + isFormInit + } = form2; + + isFormInit && searchCondition.map(c => { + c.items.map((field, index) => { + arr.push( +
+ + {} + +
+ ) + }) + }) + + if (searchConditionLoading) { + return ( +
+ +
+ ) + } else { + return { + if (e.keyCode == 13 && e.target.tagName === "INPUT") { + resourceBasicInfo.getTableInfo(); + resourceBasicInfo.setPanelStatus(false) + } + }}>{arr} + } + + } + + //非空判断 + isEmptyObject(obj) { + for (let key in obj) { + return false; + } + return true; + } + + + log = () => { + window.setLogViewProp({ + logMoudleType: 2, + keys: new Date().getTime(), + }); + } + + + render() { + + const { + resourceBasicInfo + } = this.props; + const { + isPanelShow, form2, levelName, conditionNum, tableStore, nEdialogTitle, visible, condition, + form, dialogLoading, isEdit, selectedKey, topTab, topTabCount, date, hasRight, treeConfig, treeLoading + } = resourceBasicInfo; + + if (hasRight === false) { + return renderNoright(); + } + + const { + data, + onSelectedTreeNode, + selectedKeys, + onExpand, + treeExpandKeys + } = toJS(treeConfig); + const treeCom = ( + + ) + + return ( + hasRight &&
+ this.handleMenuClick(key)} + > + } + iconBgcolor='#217346' + loading={true} + buttons={this.getTopMenuBtns()} + showDropIcon={true} + dropMenuDatas={this.getDropMenuDatas()} + onDropMenuClick={(e) => this.handleMenuClick(e)} + > + + + resourceBasicInfo.setPanelStatus(bool)} + hideSearchAd={() => resourceBasicInfo.setPanelStatus(false)} + searchsAd={isPanelShow ? this.getPanelComponents() :
} + advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20} + hasMask={false} + buttonsAd={this.getTabBtn()} + onSearch={() => resourceBasicInfo.getTableInfo()} + onSearchChange={val => this.onSearchChange(val)} + /> + this.reRenderColumns(c)} + onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)} + /> +
+
+
+ this.handleSave()} + onCancel={() => resourceBasicInfo.setVisible(false)} + /> +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index 0819a6d..b77ee0c 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -30,6 +30,7 @@ import BasicInfoImport from "./components/import"; import HrmInfoExtend from "./components/resource/HrmInfoExtend"; import NewImport from "./components/newImport" import StaffWorkflowSet from "./components/staff/StaffWorkflowSet" +import ResourceBasicInfo from "./components/resource/ResourceBasicInfo"; import stores from "./stores"; import "./style/index"; @@ -92,6 +93,7 @@ const Routes = ( + ); diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index 655e455..05779cc 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -157,7 +157,8 @@ export const i18n = { ResourceName: () => getLabel(385936, '人员'), newPeople: () => getLabel(386246, '新建人员'), resourceMange: () => getLabel(386246, '人员管理'), - + resourceBasicInfo: () => getLabel(386246, '人员信息'), + authorizationGroup: () => getLabel(492, '权限组'), allAuthorization: () => getLabel(33363, '全部权限'), diff --git a/pc4mobx/organization/stores/group.js b/pc4mobx/organization/stores/group.js index e8eb1d7..8cbaed4 100644 --- a/pc4mobx/organization/stores/group.js +++ b/pc4mobx/organization/stores/group.js @@ -32,6 +32,7 @@ export class GroupStore { @observable topTab = []; @observable date = ''; @observable hasRight = ''; + @observable loading = true; @action getGroupForm() { @@ -39,10 +40,13 @@ export class GroupStore { viewattr: 1, id: 1 } + this.setLoading(true); + this.form1 = new WeaForm(); Api.getGroupForm(params).then(res => { if (res.code === 200) { res.data.condition && this.setGroupCondition(res.data.condition); res.data.condition && this.form1.initFormFields(res.data.condition); + this.setLoading(false); } else { message.warning(res.msg); } @@ -90,8 +94,8 @@ export class GroupStore { return response.json() }).then(data => { if (data.code === 200) { - message.success(data.msg); this.getGroupForm(); + message.success(data.msg); this.setVisible(false); } else { message.warning(data.msg); @@ -165,4 +169,12 @@ export class GroupStore { this.hasRight = bool; } + setDate(date) { + this.date = date; + } + + setLoading(bool) { + this.loading = bool; + } + } \ No newline at end of file diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js index 45a7974..9648672 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -23,6 +23,7 @@ import {HrmImportResource} from "./importresource"; import {HrmImportCommon} from "./importCommon"; import {HrmBasicDataImport} from "./import"; import {newImportStore} from "./newImport"; +import {ResourceBasicInfoStore} from "./reserouseBasicInfo" module.exports = { @@ -50,5 +51,6 @@ module.exports = { hrmImportResource:new HrmImportResource(), hrmImportCommon:new HrmImportCommon(), hrmBasicDataImport:new HrmBasicDataImport(), - newImport: new newImportStore() + newImport: new newImportStore(), + resourceBasicInfo: new ResourceBasicInfoStore(), }; diff --git a/pc4mobx/organization/stores/reserouseBasicInfo.js b/pc4mobx/organization/stores/reserouseBasicInfo.js new file mode 100644 index 0000000..5078808 --- /dev/null +++ b/pc4mobx/organization/stores/reserouseBasicInfo.js @@ -0,0 +1,385 @@ +import { + observable, + action +} from 'mobx'; +import * as mobx from 'mobx'; +import * as Api from '../apis/joblevel'; // 引入API接口文件 +import { + WeaForm +} from 'comsMobx'; +import { + WeaTableNew +} from 'comsMobx'; +import { + Modal, + message, +} from 'antd' +import { + i18n +} from '../public/i18n'; + +const toJS = mobx.toJS; +const { + TableStore +} = WeaTableNew; + +export class ResourceBasicInfoStore { + @observable tableStore = new TableStore(); + @observable topMenu = [] + @observable rightMenu = []; + @observable condition = []; + @observable searchCondition = []; + @observable isEdit = true; + @observable isNew = true; + @observable isPanelShow = false; //高级搜索面板 + @observable form2 = new WeaForm(); + @observable form = new WeaForm(); + @observable form1 = new WeaForm(); + @observable levelName = ''; + @observable conditionNum = 2; + @observable ids = ''; //选择行id + @observable searchConditionLoading = true; + @observable nEdialogTitle = ''; + @observable visible = false; + @observable dialogLoading = true; + @observable levelId = ''; + @observable date = ''; + @observable selectedKey = -1; + @observable topTab = []; + @observable topTabCount = {}; + @observable hasRight = ''; + @observable treeLoading = true; + + @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.getTableInfo(); + } + } + //选中树节点的信息 + @observable selectedTreeNodeInfo; + + @action initData = () => { + this.selectedTreeNodeInfo = null; + this.treeConfig.treeExpandKeys.length = 0; + Api.getTree().then(res => { + if (res.code === 200) { + if (res.data.length > 0) { + this.treeConfig.data = res.data; + this.treeConfig.selectedKeys = [res.data[0].key]; + this.treeConfig.treeExpandKeys = "-1"; + this.selectedTreeNodeInfo = res.data[0]; + this.getTableInfo(); + this.setTreeLoading(false); + } + } else { + message.error(res.msg); + } + }, error => { }) + } + + + @action + getTableInfo() { + let params = { + schemeId: this.selectedTreeNodeInfo && this.selectedTreeNodeInfo.domid, + } + this.tableStore = new TableStore(); + if (this.isEmptyObject(this.form2.getFormParams())) { + params = { + ...params, + levelName: this.levelName, + }; + } else { + params = { + ...params, + ...this.form2.getFormParams(), + }; + } + Api.getSearchList(params).then(res => { + if (res.code === 200) { + this.setHasRight(res.data.hasRight); + res.data.datas && this.tableStore.getDatas(res.data.datas, 1); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + + } + + //删除 + delete() { + let params = { + ids: this.ids + }; + Api.deleteTableData(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(i18n.message.deleteSuccess()); + this.getTableInfo(); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + save() { + let params = { + ...this.form.getFormParams() + }; + this.form.validateForm().then(f => { + if (f.isValid) { + Api.add(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.getTableInfo(); + this.setVisible(false); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } else { + f.showErrors(); + this.setDate(new Date()); + } + }); + } + + edit() { + let params = { ...this.form.getFormParams(), id: this.levelId }; + this.form.validateForm().then(f => { + if (f.isValid) { + Api.edit(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.getTableInfo(); + this.setVisible(false); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } else { + f.showErrors(); + this.setDate(new Date()); + } + }); + } + + changeData(key) { + this.setSelectedKey(key); + this.getTableInfo(); + } + + updateForbiddenTag(checked, id) { + let params = { + forbiddenTag: checked, + id: id + } + Api.updateForbiddenTag(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.getTableInfo(); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + getForm() { + let params = this.isNew ? {} : { + id: this.levelId + } + this.setDialogLoadingStatus(true); + Api.getLevelForm(params).then(res => { + if (res.code === 200) { + this.setDialogLoadingStatus(false); + res.data.condition && this.setCondition(res.data.condition); + res.data.condition && this.form.initFormFields(res.data.condition); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + + } + + getSearchCondition() { + this.setScLoadingStatus(false); + Api.getAdvanceSearchCondition().then(res => { + if (res.code === 200) { + this.setScLoadingStatus(false); + res.data.conditions && this.setSearchCondition(res.data.conditions); + res.data.conditions && this.form2.initFormFields(res.data.conditions); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + @action + getTabInfo() { + Api.getTabInfo().then(res => { + if (res.code === 200) { + res.data.topTabs && this.setTopTab(res.data.topTabs); + res.data.topTabCount && this.setTopTabCount(res.data.topTabCount); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + + @action + getHasRight() { + Api.getHasRight().then(res => { + if (res.code === 200) { + res.data.rightMenu && this.setRightMenu(res.data.rightMenu); + res.data.topMenu && this.setTopMenu(res.data.topMenu); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + updateFields(val) { + this.form2.updateFields({ + levelName: { + value: val + } + }); + } + + setSearchCondition(condition) { + this.searchCondition = condition; + } + + setScLoadingStatus(bool) { + this.searchConditionLoading = bool; + } + + setPanelStatus(bool) { + this.isPanelShow = bool; + bool && this.getSearchCondition(); + if (!bool) { + this.scLoadingReset(); + } + } + + setLevelName(val) { + this.levelName = val; + } + + isEmptyObject(obj) { + for (let key in obj) { + return false; + } + return true; + } + + setIds(ids) { + this.ids = ids; + } + + scLoadingReset() { + this.searchConditionLoading = true; + } + + + formReset() { + this.form = new WeaForm(); + } + + dialogLoadingReset() { + this.dialogLoading = true; + } + + setVisible(bool) { + this.visible = bool; + this.formReset(); + !bool && this.dialogLoadingReset(); + } + + setDialogLoadingStatus(bool) { + this.dialogLoading = bool; + } + + setNeDialogTitle(title) { + this.nEdialogTitle = title; + } + + setIsNew(bool) { + this.isNew = bool; + } + + setCondition(condition) { + this.condition = condition; + } + + setLevelId(levelId) { + this.levelId = levelId; + } + + setDate(date) { + this.date = date; + } + + setSelectedKey(selectedKey) { + this.selectedKey = selectedKey; + } + + setTopTab(topTab) { + this.topTab = topTab; + } + + setTopTabCount(topTabCount) { + this.topTabCount = topTabCount; + } + + setTopMenu(topMenu) { + this.topMenu = topMenu; + } + + setRightMenu(rightMenu) { + this.rightMenu = rightMenu; + } + + setHasRight(bool) { + this.hasRight = bool; + } + + setTreeLoading(bool) { + this.treeLoading = bool; + } + +} \ No newline at end of file diff --git a/pc4mobx/organization/style/common.less b/pc4mobx/organization/style/common.less index 5f506ee..411086b 100644 --- a/pc4mobx/organization/style/common.less +++ b/pc4mobx/organization/style/common.less @@ -46,6 +46,10 @@ overflow: auto; } +.organization-group-loading{ + text-align: center; +} + //公司、分部管理 .hrm-my-cardInfo { padding-bottom: 20px;