diff --git a/pc4mobx/organization/apis/staff.js b/pc4mobx/organization/apis/staff.js new file mode 100644 index 0000000..c3fff25 --- /dev/null +++ b/pc4mobx/organization/apis/staff.js @@ -0,0 +1,64 @@ + +import { + WeaTools +} from 'ecCom' + +export const getSearchList = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/scheme/getTable', 'GET', params); +} + +export const deleteTableData = (params) => { + return fetch('/api/bs/hrmorganization/scheme/deleteByIds', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const getAdvanceSearchCondition = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/scheme/getSearchCondition', 'GET', params); +} + +export const add = (params) => { + return fetch('/api/bs/hrmorganization/scheme/save', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const edit = (params) => { + return fetch('/api/bs/hrmorganization/scheme/updateScheme', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const updateForbiddenTag = (params) => { + return fetch('/api/bs/hrmorganization/scheme/updateForbiddenTagById', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const getSchemeForm = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/scheme/getSchemeForm', 'GET', params); +} + +export const getHasRight = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/scheme/getTableBtn', 'GET', params); +} \ No newline at end of file diff --git a/pc4mobx/organization/components/company/company.js b/pc4mobx/organization/components/company/company.js index 279c8e5..5f0a65f 100644 --- a/pc4mobx/organization/components/company/company.js +++ b/pc4mobx/organization/components/company/company.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-05-18 16:23:32 - * @LastEditTime: 2022-05-25 11:00:00 + * @LastEditTime: 2022-05-25 13:52:21 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/components/company/company.js */ @@ -362,7 +362,6 @@ export default class Company extends React.Component { tableStore, dataSource, columns, loading, date, nEdialogTitle, dialogLoading, form1, isEdit, newVisible, deptDataSource, deptColumns, selectedRowKeys, total,current,pageSize,init } = company; - console.log("init",total) const rowSelection = { onChange(selectedRowKeys, selectedRows) { diff --git a/pc4mobx/organization/components/office/officeManage.js b/pc4mobx/organization/components/office/officeManage.js index afdf3bf..97995bf 100644 --- a/pc4mobx/organization/components/office/officeManage.js +++ b/pc4mobx/organization/components/office/officeManage.js @@ -58,7 +58,7 @@ export default class OfficeManage extends Component { handleMenuClick = (key) => { const { officeManageStore } = this.props; - const { isPanelShow } = officeManageStore; + const { isPanelShow,tableStore} = officeManageStore; isPanelShow && officeManageStore.setPanelStatus(false); switch (key) { case "new": @@ -66,6 +66,10 @@ export default class OfficeManage extends Component { officeManageStore.setVisible(true); officeManageStore.setNeDialogTitle(i18n.label.newOfficeName()); break; + case "custom": + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + break; default: break; } @@ -239,6 +243,17 @@ export default class OfficeManage extends Component { officeManageStore.setNeDialogTitle(i18n.label.editOfficeName()); }; + custom = () => { + debugger + const { + officeManageStore + } = this.props, { + tableStore, + } = officeManageStore; + + +} + getPanelComponents = () => { const { officeManageStore } = this.props; const { searchCondition, form2, searchConditionLoading } = diff --git a/pc4mobx/organization/components/postionrank/JobGrade.js b/pc4mobx/organization/components/postionrank/JobGrade.js index 39ef1cb..3e286bf 100644 --- a/pc4mobx/organization/components/postionrank/JobGrade.js +++ b/pc4mobx/organization/components/postionrank/JobGrade.js @@ -116,6 +116,19 @@ export default class JobGrade extends React.Component { jobGrade.getForm(); } + + custom = () => { + const { + jobGrade + } = this.props, { + tableStore, + } = jobGrade; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + + batchDelete() { const { jobGrade diff --git a/pc4mobx/organization/components/postionrank/JobLevel.js b/pc4mobx/organization/components/postionrank/JobLevel.js index b570e57..7c3cfdd 100644 --- a/pc4mobx/organization/components/postionrank/JobLevel.js +++ b/pc4mobx/organization/components/postionrank/JobLevel.js @@ -245,7 +245,17 @@ export default class JobLevel extends React.Component { } = operate; (index == '0') && this.doEdit(record.randomFieldId); (index == '1') && this.doDel(record.randomFieldId); + } + custom = () => { + const { + jobLevel + } = this.props, { + tableStore, + } = jobLevel; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); } doEdit(id) { diff --git a/pc4mobx/organization/components/postionrank/RankScheme.js b/pc4mobx/organization/components/postionrank/RankScheme.js index 2cb6601..f953511 100644 --- a/pc4mobx/organization/components/postionrank/RankScheme.js +++ b/pc4mobx/organization/components/postionrank/RankScheme.js @@ -202,6 +202,17 @@ export default class RankScheme extends React.Component { return btn; } + custom = () => { + const { + rankScheme + } = this.props, { + tableStore, + } = rankScheme; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + onSearchChange(val) { const { rankScheme diff --git a/pc4mobx/organization/components/sequence/Sequence.js b/pc4mobx/organization/components/sequence/Sequence.js index 78f702c..1cb9bde 100644 --- a/pc4mobx/organization/components/sequence/Sequence.js +++ b/pc4mobx/organization/components/sequence/Sequence.js @@ -232,6 +232,17 @@ export default class Sequence extends React.Component { }) } + custom = () => { + const { + sequence + } = this.props, { + tableStore, + } = sequence; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + updateForbiddenTag(checked,id) { const { sequence diff --git a/pc4mobx/organization/components/staff/Staff.js b/pc4mobx/organization/components/staff/Staff.js new file mode 100644 index 0000000..2a28493 --- /dev/null +++ b/pc4mobx/organization/components/staff/Staff.js @@ -0,0 +1,414 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer +} from 'mobx-react' +import { + WeaTop, + WeaTab, + WeaFormItem, + WeaRightMenu, +} 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'; + + + +const toJS = mobx.toJS; +const confirm = Modal.confirm; +const WeaTable = WeaTableNew.WeaTable; + + +@inject('staff') +@observer +export default class Staff extends React.Component { + constructor(props) { + super(props); + } + + componentWillMount() { + } + + componentDidMount() { + this.init(); + } + + componentWillReceiveProps(nextProps) { + const { + staff + } = this.props; + + if (this.props.location.key !== nextProps.location.key) { + this.init(); + } + } + + init() { + const { + staff + } = this.props; + staff.getTableInfo(); + staff.getHasRight(); + } + + getTopMenuBtns() { + const { + staff + } = this.props; + const { + topMenu, + tableStore + } = staff; + + let btns = []; + topMenu.map((item, i) => { + if (item.menuFun !== 'batchDelete') { + btns.push(); + } else { + btns.push(); + } + + }); + + return btns; + } + + handleClick(item) { + const { + staff + } = this.props; + const { + isPanelShow + } = staff; + + isPanelShow && staff.setPanelStatus(false); + this[item.menuFun] && this[item.menuFun](); + } + + new() { + const { + staff + } = this.props; + + staff.setNeDialogTitle(i18n.label.newStaff()); + staff.setIsNew(true); + staff.setVisible(true); + staff.getForm(); + } + + batchDelete() { + const { + staff + } = this.props; + const { + tableStore + } = staff; + + let keys = toJS(tableStore.selectedRowKeys).toString(); + staff.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 { + staff + } = this.props; + staff.delete(); + } + + + getDropMenuDatas() { + const { + staff + } = this.props; + const { + rightMenu + } = staff; + + 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 { + staff + } = this.props; + const { + isPanelShow + } = staff; + + isPanelShow && staff.setPanelStatus(false); + this[key] && this[key](); + } + + getTabBtn() { + const { + staff + } = this.props; + const { + form2 + } = staff; + + const btn = [ + (), + (), + (), + ]; + + return btn; + } + + onSearchChange(val) { + const { + staff + } = this.props; + const { + form2 + } = staff; + + staff.setSchemeName(val); + !this.isEmptyObject(form2.getFormParams()) && staff.updateFields(val); + } + + 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 { + staff + } = this.props; + staff.updateForbiddenTag(checked,id); + } + + onOperatesClick(record, rowIndex, operate) { + const { + index + } = operate; + (index == '0') && this.doEdit(record.randomFieldId); + (index == '1') && this.doDel(record.randomFieldId); + + } + + doEdit(id) { + const { + staff + } = this.props; + + staff.setNeDialogTitle(i18n.label.ediStaff()); + staff.setSchemeId(id); + staff.setIsNew(false); + staff.setVisible(true); + staff.getForm(); + } + + + custom = () => { + const { + staff + } = this.props, { + tableStore, + } = staff; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + + + doDel(id) { + const { + staff + } = this.props; + staff.setIds(id); + this.showConfirm('del'); + } + + + handleSave() { + const { + staff + } = this.props; + const { + isNew + } = staff; + + isNew && staff.save(); + !isNew && staff.edit(); + } + + getPanelComponents() { + const { + staff + } = this.props; + const { + searchCondition, + form2, + searchConditionLoading + } = staff; + + 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") { + staff.getTableInfo(); + staff.setPanelStatus(false) + } + }}>{arr} + } + + } + + //非空判断 + isEmptyObject(obj) { + for (let key in obj) { + return false; + } + return true; + } + + + + + render() { + + const { + staff + } = this.props; + const { + isPanelShow, form2, staffName, conditionNum, tableStore,nEdialogTitle,visible,condition, + form,dialogLoading,isEdit,date + } = staff; + + return ( +
+ this.handleMenuClick(key)} + > + } + iconBgcolor='#217346' + loading={true} + buttons={this.getTopMenuBtns()} + showDropIcon={true} + dropMenuDatas={this.getDropMenuDatas()} + onDropMenuClick={(e) => this.handleMenuClick(e)} + > + staff.setPanelStatus(bool)} + hideSearchAd={() => staff.setPanelStatus(false)} + searchsAd= {isPanelShow ? this.getPanelComponents() :
} + advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20} + hasMask={false} + buttonsAd={this.getTabBtn()} + onSearch={() => staff.getTableInfo()} + onSearchChange={val => this.onSearchChange(val)} + /> + this.reRenderColumns(c)} + onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)} + /> +
+
+ this.handleSave()} + onCancel={() => staff.setVisible(false)} + enable={false} //是否开启字段联动 + /> +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/staff/StaffScheme.js b/pc4mobx/organization/components/staff/StaffScheme.js index 385fd10..9751373 100644 --- a/pc4mobx/organization/components/staff/StaffScheme.js +++ b/pc4mobx/organization/components/staff/StaffScheme.js @@ -253,6 +253,19 @@ export default class StaffScheme extends React.Component { staffScheme.getForm(); } + + custom = () => { + const { + staffScheme + } = this.props, { + tableStore, + } = staffScheme; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + + doDel(id) { const { staffScheme @@ -350,7 +363,7 @@ export default class StaffScheme extends React.Component { onClick={key => this.handleMenuClick(key)} > } iconBgcolor='#217346' loading={true} diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index 2d85f12..c45c054 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -13,6 +13,7 @@ import CompanyExtend from "./components/company/CompanyExtend" import BranchNumSetting from "./components/branchNumSetting" import Company from "./components/company/company"; import StaffScheme from "./components/staff/StaffScheme"; +import Staff from "./components/staff/Staff"; import stores from "./stores"; import "./style/index"; @@ -49,6 +50,7 @@ const Routes = ( + ); diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index 0642645..58054a5 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -131,9 +131,12 @@ export const i18n = { branchNumSetting: () => getLabel(386246, '分部编号设置'), companyName: () => getLabel(385937, '分部'), - staffName: () => getLabel(385936, '编制方案'), + staffSchemeName: () => getLabel(385936, '编制方案'), newStaffScheme: () => getLabel(386246, '新建编制方案'), ediStaffScheme: () => getLabel(386247, '编辑编制方案'), + staffName: () => getLabel(385936, '编制上报'), + newStaff: () => getLabel(386246, '新建编制'), + ediStaff: () => getLabel(386247, '编辑编制'), authorizationGroup: () => getLabel(492, '权限组'), diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js index 38d1d82..99abe88 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -9,6 +9,7 @@ import { GroupStore } from "./group"; import {CompanyExtendStore} from "./companyextend"; import {CompanyStore} from "./company" import {StaffSchemeStore} from "./staffscheme"; +import {StaffStore} from "./staff"; module.exports = { simpleOrgStore: new SimpleOrgStore(), @@ -21,5 +22,6 @@ module.exports = { group: new GroupStore(), companyExtend: new CompanyExtendStore(), company: new CompanyStore(), - staffScheme: new StaffSchemeStore() + staffScheme: new StaffSchemeStore(), + staff: new StaffStore() }; diff --git a/pc4mobx/organization/stores/staff.js b/pc4mobx/organization/stores/staff.js new file mode 100644 index 0000000..d22ec9a --- /dev/null +++ b/pc4mobx/organization/stores/staff.js @@ -0,0 +1,308 @@ +import { + observable, + action +} from 'mobx'; +import * as mobx from 'mobx'; +import * as Api from '../apis/staff'; // 引入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 StaffStore { + @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 staffName = ''; + @observable conditionNum = 2; + @observable ids = ''; //选择行id + @observable searchConditionLoading = true; + @observable nEdialogTitle = ''; + @observable visible = false; + @observable dialogLoading = true; + @observable staffId = ''; + @observable date = ''; + + + + + + @action + getTableInfo() { + let params; + this.tableStore = new TableStore(); + if (this.isEmptyObject(this.form2.getFormParams())) { + params = { + ...this.form2.getFormParams(), + staffName: this.staffName + }; + } else { + params = { + ...this.form2.getFormParams() + }; + } + Api.getSearchList(params).then(res => { + if (res.code === 200) { + 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.staffId }; + 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()); + } + }); + } + + 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); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + + } + + getForm() { + let params = this.isNew ? {} : { + id: this.staffId + } + this.setDialogLoadingStatus(true); + + Api.getSchemeForm(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 + 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({ + staffName: { + value: val + } + }); + } + + setSearchCondition(condition) { + this.searchCondition = condition; + } + + setScLoadingStatus(bool) { + this.searchConditionLoading = bool; + } + + setPanelStatus(bool) { + this.isPanelShow = bool; + bool && this.getSearchCondition(); + if (!bool) { + this.scLoadingReset(); + } + } + + setStaffName(staffName) { + this.staffName = staffName; + } + + 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; + } + + setStaffId(staffId) { + this.staffId = staffId; + } + + @action + setDate(date) { + this.date = date; + } + + setTopMenu(topMenu) { + this.topMenu = topMenu; + } + + setRightMenu(rightMenu) { + this.rightMenu = rightMenu; + } + +} \ No newline at end of file