Merge branch 'dev' of gitee.com:jmlcl/trunk into dev

This commit is contained in:
liyongshun 2022-05-17 14:11:59 +08:00
commit 89aab7a742
8 changed files with 523 additions and 337 deletions

1
package-lock.json generated
View File

@ -7,6 +7,7 @@
"dependencies": {
"dom-to-image": "^2.6.0",
"file-saver": "^2.0.5",
"lodash": "^4.17.21",
"orgchart": "^3.1.1",
"rc-org-chart": "^1.0.6",
"react-org-tree": "^1.0.0",

View File

@ -2,6 +2,7 @@
"dependencies": {
"dom-to-image": "^2.6.0",
"file-saver": "^2.0.5",
"lodash": "^4.17.21",
"orgchart": "^3.1.1",
"rc-org-chart": "^1.0.6",
"react-org-tree": "^1.0.0",

View File

@ -0,0 +1,29 @@
import {
WeaTools
} from 'ecCom'
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 getTabInfo = (params) => {
return WeaTools.callApi('/api/bs/hrmorganization/group/getTabInfo', 'GET', params);
}
export const getGroupForm = (params) => {
return WeaTools.callApi('/api/bs/hrmorganization/group/getCompanyFormField', 'GET', params);
}
export const getHasRight = (params) => {
return WeaTools.callApi('/api/bs/hrmorganization/group/getHasRight', 'GET', params);
}

View File

@ -0,0 +1,254 @@
import { Button, Modal,message,Row,Col, Spin} from 'antd';
import isEmpty from 'lodash/isEmpty'
import cloneDeep from 'lodash/cloneDeep'
import forEach from 'lodash/forEach'
import { WeaAlertPage, WeaTools,WeaTableEdit,WeaSearchGroup,WeaRightMenu, WeaFormItem, WeaTab} from 'ecCom'
import {WeaSwitch} from 'comsMobx';
import { inject, observer} from 'mobx-react';
import * as mobx from 'mobx';
import {i18n} from '../../public/i18n';
const toJS = mobx.toJS;
@inject('companyExtend')
@inject('company')
@observer
export default class CompanyExtend extends React.Component {
componentDidMount(){
const {companyExtend} = this.props;
companyExtend.setTopButtons(this.getTopButtons.bind(this));
companyExtend.setTopRightMenus(this.getRightMenu.bind(this));
companyExtend.setTopShowDropIcon(true);
this.init();
}
init = () => {
// const {companyExtend, companyExtend, setParentRightMenu} = this.props;
companyExtend.init();
// companyExtend.hrmId=hrmId;
companyExtend.getData();
}
getTabChildren = () => {
const {companyExtend} = this.props;
let {tableInfo, isEditor, tabkey,onRowSelect,selectedRowKeys} = companyExtend;
let tabChildren = [];
tableInfo = toJS(tableInfo);
tableInfo && tableInfo.map((t,i)=>{
if(tabkey==i){
tabChildren.push(
<WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@b813my@${i}`}
//ref={(ref)=>companyExtend.setPersonalEditTables(ref)}
showTitle={isEditor}
// title={'列表信息'}
// addFirstRow={isEditor}
columns={t.tabinfo.columns}
datas={t.tabinfo.datas}
onChange={this.tableEditChange}
selectedRowKeys={toJS(selectedRowKeys)}
onRowSelect={keys => onRowSelect(keys)}
onBtnsSelect={key=>this.onBtnsSelect(key,i)}
viewAttr={isEditor?2: 1}
getRowSelection={isEditor? (rowSelection)=>{
Object.assign(rowSelection,{
getCheckboxProps: record => ({
disabled: record.viewAttr === 1, // 配置无法勾选的列
})
})
return rowSelection;
}: ()=>null}
/>
);
}
})
return tabChildren;
}
onBtnsSelect = (key, index) => {
const {
companyExtend
} = this.props, {
tableInfo,
selectedRows,
setSelectedRowKeys,
selectedRowKeys
} = companyExtend;
const datas = tableInfo[index].tabinfo.datas;
if (key === 'copy') {
tableInfo[index].tabinfo.datas = datas.map( (data,i) => {
if (!selectedRows[index].includes(i)) {
data.viewAttr = 2;
}
return data
})
}
if (key === 'delete') {
tableInfo[index].tabinfo.datas = datas.map( (data,i) => {
if (selectedRows[index].includes(i)) {
data.viewAttr = 1;
}
return data
});
setSelectedRowKeys(selectedRowKeys.filter(row => !selectedRows[index].includes(row)))
}
}
getSearchs = () => {
const {companyExtend} = this.props;
let {form, conditions, isEditor} = companyExtend;
const {isFormInit} = form;
let group = [];
let tipPosition = 'bottom';
window.e9HideFormFieldKeys = [];
isFormInit && conditions.forEach((c, i) =>{
let items = [];
c.items.forEach( (field, j) => {
if(c.hide || (!isEmpty(field.otherParams) && field.otherParams.hide)){
window.e9HideFormFieldKeys.push(field.domkey[0]);
}else{
items.push({
com:(<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@vh6j67@${j}`}
underline={!isEditor}
label={`${field.label}`}
error={form.getError(field)}
tipPosition={tipPosition}
labelCol={{span: `${window.HrmLabelCol}`}}
wrapperCol={{span: `${window.HrmWrapperCol}`}}>
<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@d4vaqk@${j}`} fieldConfig={field} form={form}/>
</WeaFormItem>),
colSpan: 1
});
}
});
group.push(<WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@x9hby9@${i}`} className={`${isEditor?'hrm-center':''}`}
needTigger={true} hide={c.hide} title={c.title} showGroup={c.defaultshow} items={items} />)
});
return group;
}
tableEditChange = (data) => {
const {companyExtend} = this.props;
let {tabkey = '0', tableInfo} = companyExtend;
tableInfo = toJS(tableInfo);
let d = cloneDeep(tableInfo);
d[Number(tabkey)].tabinfo.datas = data;
companyExtend.updateTableInfo(d);
}
getRightMenu = () => {
const {companyExtend} = this.props;
const {isEditor, buttons} = companyExtend;
let arr = [];
try{
if(buttons.hasEdit){
if (isEditor){
arr = [{
icon: <i className='icon-coms-common'/>,
content: i18n.button.save(),
key: 'save',
onClick: key =>{
this.saveEditCard();
}
}, {
icon: <i className='icon-coms-go-back'/>,
content: i18n.button.back(),
key: 'back',
onClick: key =>{
this.backCard();
}
}]
} else {
arr = [{
icon: <i className='icon-coms-edit'/>,
content:i18n.button.modify(),
key: 'editCard',
onClick: key =>{
this.editCard();
}
}
]
}
}
}catch(e){}
return arr;
}
getTopButtons = () => {
const {companyExtend} = this.props;
const {isEditor, buttons} = companyExtend;
const save = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pkes6y`} type="primary" onClick={this.saveEditCard} >{i18n.button.save()}</Button>;
const back = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pl1fw8`} type="primary" onClick={this.backCard} >{i18n.button.back()}</Button>;
const edit = <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vkeda5`} type="primary" onClick={this.editCard} >{i18n.button.modify()}</Button>;
const btns = [];
try{
if (isEditor) {
if (buttons.hasSave) {
btns.push(save);
btns.push(back);
}
} else {
if (buttons.hasEdit) {
btns.push(edit);
}
}
}catch(e){}
return btns;
}
editCard = () => {
const {companyExtend} = this.props;
companyExtend.edit();
}
saveEditCard = () => {
const {companyExtend} = this.props;
companyExtend.save();
}
backCard = () => {
this.init();
}
render() {
const {companyExtend} = this.props;
const {loading, detailSelectedKey, tabInfo} = companyExtend;
// if(!hasRight && !loading){
// return (
// <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@387kx5`}>
// <div style={{ color: '#000' }}>{i18n.message.authFailed()}</div>
// </WeaAlertPage>
// )
// }
try{
return (
<div className='hrm-my-cardInfo' style={{height:'100%', position: 'relative'}}>
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@4fj4z2`} spinning={loading}>
{this.getSearchs()}
{
!isEmpty(tabInfo) && <div className='hrm-my-cardInfo_detial_tabs'>
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@vjrq63`}
type='card'
keyParam='key'
datas={toJS(tabInfo)}
selectedKey={detailSelectedKey}
onChange={ v => {
companyExtend.updateDetailSelectedKey(v);
}}
/>
{this.getTabChildren()}
</div>
}
</Spin>
</div>
)
}catch(e){
return <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@h1wgnu`}>
<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div>
</WeaAlertPage>
}
}
}

View File

@ -9,6 +9,7 @@ import JobGrade from "./components/postionrank/JobGrade";
import Sequence from "./components/sequence/Sequence";
import Group from "./components/group/Group";
import OfficeManage from "./components/office/officeManage";
import CompanyExtend from "./components/company/CompanyExtend"
import stores from "./stores";
import "./style/index";
@ -39,6 +40,7 @@ const Routes = (
<Route key="sequence" path="sequence" component={Sequence} />
<Route key="group" path="group" component={Group} />
<Route key="officeManage" path="officeManage" component={OfficeManage} />
<Route key="companyExtend" path="companyExtend" component={CompanyExtend} />
</Route>
);

View File

@ -6,7 +6,7 @@ import { i18n } from "../public/i18n";
const { TableStore } = WeaTableNew;
export class RankSchemeStore {
export class CompanyStore {
@observable tableStore = new TableStore();
@observable topMenu = [];
@observable rightMenu = [];

View File

@ -0,0 +1,192 @@
import { observable, action, toJS } from "mobx";
import { WeaForm } from "comsMobx";
import { WeaTableNew } from "comsMobx";
import { Modal, message } from "antd";
import { i18n } from "../public/i18n";
export class CompanyExtendStore {
@observable form = new WeaForm();
@observable tableInfo = []
@observable conditions = [];
@observable isEditor = false;
@observable isNew = true;
@observable loading = true;
@observable tabInfo = [];
@observable selectedKey = 0;
@observable detailSelectedKey = 0;
@observable buttons = {}
@observable date;
@observable personalEditTables;
@observable selectedRowKeys = [];
@observable selectedRows = [];
@action onRowSelect = (keys) => {
this.setSelectedRowKeys(keys);
}
@action setSelectedRowKeys =(keys)=>{
this.selectedRowKeys = keys;
}
@action
edit = () => {
this.isEditor = true;
this.getData();
this.getTabInfo();
//this.tabkey = '0';
}
init = () => {
//this.tabkey = '0';
this.isEditor = false;
}
save = () => {
if(this.loading)
return;
this.loading = true;
this.form.validateForm().then(f => {
if (f.isValid) {
if(this.personalEditTables){
// const targetDatas = this.tableInfo[this.tabkey].tabinfo.datas,
// isPass = (targetDatas.length > 0) ? this.personalEditTables.refs.edit.doRequiredCheck().pass : true
let isPass = true;
if(isPass){
this.editResource()
}else{
this.loading = false;
}
}else{
this.editResource();
}
} else {
f.showErrors();
this.setDate(new Date());
this.loading = false;
}
})
}
editResource = () => {
let pDatas = this.form.getFormParams();
// API.editResource({ ...{
// operation: 'editpersonalinfo',
// id: this.hrmId
// },
// ...pDatas,
// ...this.getTableEditParams()
// }).
// then(data => {
// if (data.status == '1') {
// message.success(i18n.message.saveSuccess());
// this.init();
// this.getData();
// this.selectedRowKeys = [];
// } else {
// message.warning(data.message);
// }
// this.loading = false;
// }, error => {
// message.warning(error.message);
// this.loading = false;
// })
}
getTableEditParams = () => {
const params = {};
this.tableInfo && this.tableInfo.forEach(t => {
t.tabinfo.datas = t.tabinfo.datas || [];
params[t.tabinfo.rownum] = t.tabinfo.datas.length;
t.tabinfo && t.tabinfo.datas && t.tabinfo.datas.forEach((item, index) => {
!isEmpty(item) && forEach(item, (value, key) => {
Object.assign(params,{
[`${key}_${index}`]: value
});
})
})
})
return params
}
getData = (params={}) => {
// this.loading = true;
// params.id=this.hrmId;
// params.viewAttr=this.isEditor?2:1;
// params.is_multilang_set=this.isEditor;
// params.operation = 'getResourcePesonalView';
// API.getResourceCard(params).then((data) => {
// this.hasRight = has(data, 'hasRight') ? data.hasRight : true;
// this.loading = false;
// this.form.initFormFields(data.result.conditions);
// this.conditions = data.result.conditions;
// this.tableInfo = this.handleTable(data.result.tables);
// this.getTabInfo();
// this.buttons = data.result.buttons;
// this.hrmId = data.result.id;
// this.isEditor && this.getSelectedRows();
// })
}
handleTable = (datas) => {
// return datas && datas.map(data => {
// const {tabinfo:{columns}} = data;
// const length = columns.length;
// columns.map(c => {
// c.width = `${95/length}%`
// })
// return data
// })
}
getTabInfo = () => {
this.tabInfo = [];
this.tableInfo && this.tableInfo.forEach((c, idx)=>{
if(!c.hide){
this.tabInfo.push({
key: `${idx}`,
title: c.tabname,
})
}
})
if(!isEmpty(this.tabInfo)) this.tabkey = this.tabInfo[0].key;
}
setLoading(val) {
this.loading(false);
}
updateDetailSelectedKey = (key) => {
this.detailSelectedKey = key;
}
updateSelectedKey = (key) => {
this.selectedKey = key;
}
getSelectedRows = () => {
const selectedRows = [];
this.tableInfo.forEach(t => {
const singleTableRows = [];
t.tabinfo.datas.forEach((data, i) => {
if (data.viewAttr === 1) {
singleTableRows.push(i);
}
});
selectedRows.push(singleTableRows);
})
this.selectedRows = selectedRows;
}
}

View File

@ -35,207 +35,53 @@ export class GroupStore {
@action
getGroupForm() {
let params = {
viewattr: 1
viewattr: 1,
id: 1
}
//api
let condition = [
{
"title": "总部信息",
"defaultshow": true,
"items": [
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyname"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部名称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 1
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companydesc"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部全称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 1
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyweb"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "公司网站",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "",
"valueList": [],
"viewAttr": 1
}
]
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);
} else {
message.warning(res.msg);
}
]
}, error => {
message.warning(error.msg);
})
this.setGroupCondition(condition);
this.form1.initFormFields(condition);
this.getTabInfo();
}
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);
// })
const topTab = [
{
"title": "总部信息",
"viewCondition": "1"
Api.getTabInfo().then(res => {
if (res.code === 200) {
res.data.topTabs && this.setTopTab(res.data.topTabs);
} else {
message.warning(res.msg);
}
]
this.setTopTab(topTab)
}, error => {
message.warning(error.msg);
})
}
@action
getHasRight() {
const rightMenu = [
{
"isTop": "1",
"menuFun": "doEdit",
"menuIcon": "icon-coms-edit",
"menuName": "编辑",
"type": "BTN_EDIT"
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);
}
]
const topMenu = [
{
"isTop": "1",
"menuFun": "doEdit",
"menuIcon": "icon-coms-edit",
"menuName": "编辑",
"type": "BTN_EDIT"
}
]
this.setTopMenu(topMenu);
this.setRightMenu(rightMenu);
// 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);
// })
}, error => {
message.warning(error.msg);
})
}
edit() {
// let params = { ...this.form.getFormParams(), id: this.schemeId };
// this.form.validateForm().then(f => {
// if (f.isValid) {
@ -261,159 +107,20 @@ export class GroupStore {
getForm() {
let params = {
viewattr: 2
viewattr: 2,
id:1
}
const condition = [
{
"title": "总部信息",
"defaultshow": true,
"items": [
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyname"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部名称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 3
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companydesc"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部全称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 3
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyweb"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "公司网站",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "",
"valueList": [],
"viewAttr": 2
}
]
Api.getGroupForm(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);
}
]
this.setCondition(condition);
this.form.initFormFields(condition);
this.setDialogLoadingStatus(false);
// 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);
// })
}, error => {
message.warning(error.msg);
})
}
changeData(key) {
@ -453,6 +160,6 @@ export class GroupStore {
this.dialogLoading = bool;
}
}