From 1bf9f9aa81f23cd14fac6c26b46143b3483626fa Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 16 May 2022 17:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=8F=B8/=E5=88=86=E9=83=A8=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 1 + package.json | 1 + pc4mobx/organization/apis/group.js | 29 ++ .../components/company/CompanyExtend.js | 254 ++++++++++++ pc4mobx/organization/index.js | 2 + pc4mobx/organization/stores/company.js | 2 +- pc4mobx/organization/stores/companyextend.js | 192 +++++++++ pc4mobx/organization/stores/group.js | 379 ++---------------- 8 files changed, 523 insertions(+), 337 deletions(-) create mode 100644 pc4mobx/organization/components/company/CompanyExtend.js create mode 100644 pc4mobx/organization/stores/companyextend.js diff --git a/package-lock.json b/package-lock.json index 9062307..c1b56dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index cd91aba..1c4b3b4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pc4mobx/organization/apis/group.js b/pc4mobx/organization/apis/group.js index e69de29..ffabd63 100644 --- a/pc4mobx/organization/apis/group.js +++ b/pc4mobx/organization/apis/group.js @@ -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); +} \ No newline at end of file diff --git a/pc4mobx/organization/components/company/CompanyExtend.js b/pc4mobx/organization/components/company/CompanyExtend.js new file mode 100644 index 0000000..22e6706 --- /dev/null +++ b/pc4mobx/organization/components/company/CompanyExtend.js @@ -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( + 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:( + + ), + colSpan: 1 + }); + } + }); + group.push() + }); + 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: , + content: i18n.button.save(), + key: 'save', + onClick: key =>{ + this.saveEditCard(); + } + }, { + icon: , + content: i18n.button.back(), + key: 'back', + onClick: key =>{ + this.backCard(); + } + }] + } else { + arr = [{ + icon: , + 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 = ; + const back = ; + const edit = ; + 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 ( + // + //
{i18n.message.authFailed()}
+ //
+ // ) + // } + + try{ + return ( +
+ + {this.getSearchs()} + { + !isEmpty(tabInfo) &&
+ { + companyExtend.updateDetailSelectedKey(v); + }} + /> + {this.getTabChildren()} +
+ } +
+
+ ) + }catch(e){ + return +
{i18n.message.authFailed()}
+
+ } + } +} + diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index d6a86bc..a89f3ba 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -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 = ( + ); diff --git a/pc4mobx/organization/stores/company.js b/pc4mobx/organization/stores/company.js index 39b39b6..7c66a74 100644 --- a/pc4mobx/organization/stores/company.js +++ b/pc4mobx/organization/stores/company.js @@ -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 = []; diff --git a/pc4mobx/organization/stores/companyextend.js b/pc4mobx/organization/stores/companyextend.js new file mode 100644 index 0000000..72ff6ba --- /dev/null +++ b/pc4mobx/organization/stores/companyextend.js @@ -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; + } + + + +} diff --git a/pc4mobx/organization/stores/group.js b/pc4mobx/organization/stores/group.js index 624ac6f..57a5ac6 100644 --- a/pc4mobx/organization/stores/group.js +++ b/pc4mobx/organization/stores/group.js @@ -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; } - + } \ No newline at end of file