From a884e58203601b51c6abeb5ffed880107cd1aef5 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 8 May 2024 16:31:15 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/drawer/index.jsx | 49 +++++++++++++++++++++----------- src/components/drawer/index.less | 8 ++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/components/drawer/index.jsx b/src/components/drawer/index.jsx index bea0e32..84ed0b6 100644 --- a/src/components/drawer/index.jsx +++ b/src/components/drawer/index.jsx @@ -31,14 +31,21 @@ export default class DrawerComponents extends React.Component { dataSource: [], columns: [], spinning: true, - showJob: true, + showJob: false, }; } componentDidMount() {} // 点击节点 - onNodeClick(node) {} + onNodeClick(node) { + if (node.ftype == '4') { + window.open( + `/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/${node.id}`, + '_blank', + ); + } + } onButtonClick(event, d) { if (d.children) { @@ -63,7 +70,7 @@ export default class DrawerComponents extends React.Component { //获取数据 getDeatilDatas(params, type = 'chart', showJob = '1') { - this.setState({ spinning: true }); + this.setState({ spinning: true, data: [], dataSource: [] }); d3.json( '/api/bs/hrmorganization/orgchart/getDepartmentDetail?' + qs.stringify({ detauleType: type, ...params, showJob }), @@ -72,7 +79,11 @@ export default class DrawerComponents extends React.Component { if (type == 'chart') { this.setState({ data: data.data, spinning: false }); } else { - this.setState({ dataSource: data.dataSource, columns: data.columns }); + this.setState({ + dataSource: data.dataSource, + columns: data.columns, + spinning: false, + }); } }); } @@ -299,13 +310,12 @@ export default class DrawerComponents extends React.Component { }; showDrawer = (params) => { - const showJob = params.fclass == '0' ? '1' : '0'; - this.getDeatilDatas(params, 'chart', showJob); + this.getDeatilDatas(params, 'chart', '0'); this.setState({ open: true, params: params }); }; onClose = () => { - this.setState({ open: false, detailType: 'chart', showJob: true }); + this.setState({ open: false, detailType: 'chart', showJob: false }); }; changeDetail = () => { @@ -372,17 +382,21 @@ export default class DrawerComponents extends React.Component { - + } > {detailType == 'chart' ? ( - data.length > 0 && ( - +
+ + {data.length > 0 && ( (orgChart = chart)} setClick={(click) => (addNodeChildFunc = click)} @@ -394,14 +408,15 @@ export default class DrawerComponents extends React.Component { nodeHeight={this.nodeHeightRender} nodeContent={this.nodeContentRender} /> - - ) + )} +
) : (
Date: Wed, 5 Jun 2024 16:01:37 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=E5=9B=BE=E5=A4=9A=E8=AF=AD=E8=A8=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dialog/copyDialog.jsx | 179 +++++++++++---------- src/components/dialog/mergeDialog.jsx | 199 +++++++++++------------ src/components/drawer/index.jsx | 85 +++++----- src/components/topBar/index.jsx | 64 ++++---- src/pages/company.jsx | 53 +++--- src/pages/dragTree.jsx | 221 ++++++++++++++------------ src/pages/statisticsTable.jsx | 130 ++++++++------- src/pages/user.jsx | 2 +- src/util/i18n.js | 15 ++ 9 files changed, 512 insertions(+), 436 deletions(-) create mode 100644 src/util/i18n.js diff --git a/src/components/dialog/copyDialog.jsx b/src/components/dialog/copyDialog.jsx index ac89253..de9f8c7 100644 --- a/src/components/dialog/copyDialog.jsx +++ b/src/components/dialog/copyDialog.jsx @@ -10,103 +10,106 @@ import * as d3 from 'd3'; import './index.less'; import { HomeOutlined } from '@ant-design/icons'; import './index.less'; +import { getLabel } from '../../util/i18n.js'; const layout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; -const CopyDialog = forwardRef(({ open, onCreate, onCancel }, ref) => { - const [treeData, setData] = useState([]); - const [form] = Form.useForm(); - const formRef = useRef(null); +const CopyDialog = forwardRef( + ({ open, onCreate, onCancel, labelData }, ref) => { + const [treeData, setData] = useState([]); + const [form] = Form.useForm(); + const formRef = useRef(null); - useImperativeHandle(ref, () => ({ - getTreeData() { - form.resetFields(); - d3.json('/api/bs/hrmorganization/orgchart/getSubCompanyTree').then( - (data) => { - data.companyTree.map((item, index) => { - item.icon = ; - }); - setData(data.companyTree); - }, - ); - }, - })); + useImperativeHandle(ref, () => ({ + getTreeData() { + form.resetFields(); + d3.json('/api/bs/hrmorganization/orgchart/getSubCompanyTree').then( + (data) => { + data.companyTree.map((item, index) => { + item.icon = ; + }); + setData(data.companyTree); + }, + ); + }, + })); - /** - * 根节点树异步加载 - * @param {} parentId - * @returns - */ - const onRootLoadData = (treeNode) => - new Promise((resolve) => { - const { id } = treeNode.props; - setTimeout(() => { - d3.json( - `/api/bs/hrmorganization/orgchart/getSubCompanyTree?subcompany=${id}`, - ).then((data) => { - data.companyTree.map((item, index) => { - item.icon = ; + /** + * 根节点树异步加载 + * @param {} parentId + * @returns + */ + const onRootLoadData = (treeNode) => + new Promise((resolve) => { + const { id } = treeNode.props; + setTimeout(() => { + d3.json( + `/api/bs/hrmorganization/orgchart/getSubCompanyTree?subcompany=${id}`, + ).then((data) => { + data.companyTree.map((item, index) => { + item.icon = ; + }); + let arr = [...treeData, ...data.companyTree]; + setData(arr); }); - let arr = [...treeData, ...data.companyTree]; - setData(arr); - }); - resolve(undefined); - }, 200); - }); + resolve(undefined); + }, 200); + }); - return ( - { - form - .validateFields() - .then((values) => { - onCreate(values); - }) - .catch((info) => { - console.log('Validate Failed:', info); - }); - }} - > -
- - - + return ( + { + form + .validateFields() + .then((values) => { + onCreate(values); + }) + .catch((info) => { + console.log('Validate Failed:', info); + }); + }} + > + + + + - - - - - - ); -}); + + + + +
+ ); + }, +); export default CopyDialog; diff --git a/src/components/dialog/mergeDialog.jsx b/src/components/dialog/mergeDialog.jsx index 1cb38e3..438a0b4 100644 --- a/src/components/dialog/mergeDialog.jsx +++ b/src/components/dialog/mergeDialog.jsx @@ -10,114 +10,117 @@ import * as d3 from 'd3'; import './index.less'; import { HomeOutlined, FolderOutlined } from '@ant-design/icons'; import './index.less'; +import { getLabel } from '../../util/i18n.js'; const layout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; -const MergeDialog = forwardRef(({ open, onCreate, onCancel }, ref) => { - const [treeData, setData] = useState([]); - const [form] = Form.useForm(); - const formRef = useRef(null); +const MergeDialog = forwardRef( + ({ open, onCreate, onCancel, labelData }, ref) => { + const [treeData, setData] = useState([]); + const [form] = Form.useForm(); + const formRef = useRef(null); - const [treeLine, setTreeLine] = useState(true); + const [treeLine, setTreeLine] = useState(true); - useImperativeHandle(ref, () => ({ - getTreeData() { - form.resetFields(); - d3.json('/api/bs/hrmorganization/orgchart/getDepartmentTree').then( - (data) => { - data.departmentTree.map((item, index) => { - item.icon = ; - }); - setData(data.departmentTree); - }, - ); - }, - })); - - /** - * 根节点树异步加载 - * @param {} parentId - * @returns - */ - const onRootLoadData = (treeNode) => - new Promise((resolve) => { - const { id } = treeNode.props; - setTimeout(() => { - d3.json( - `/api/bs/hrmorganization/orgchart/getDepartmentTree?subcompany=${id}`, - ).then((data) => { - data.departmentTree.map((item, index) => { - if (item.key.indexOf('d') > -1) { - item.icon = ; - } else { + useImperativeHandle(ref, () => ({ + getTreeData() { + form.resetFields(); + d3.json('/api/bs/hrmorganization/orgchart/getDepartmentTree').then( + (data) => { + data.departmentTree.map((item, index) => { item.icon = ; - } - }); - let arr = [...treeData, ...data.departmentTree]; - setData(arr); - }); - resolve(undefined); - }, 200); - }); + }); + setData(data.departmentTree); + }, + ); + }, + })); - return ( - { - form - .validateFields() - .then((values) => { - onCreate(values); - }) - .catch((info) => { - console.log('Validate Failed:', info); + /** + * 根节点树异步加载 + * @param {} parentId + * @returns + */ + const onRootLoadData = (treeNode) => + new Promise((resolve) => { + const { id } = treeNode.props; + setTimeout(() => { + d3.json( + `/api/bs/hrmorganization/orgchart/getDepartmentTree?subcompany=${id}`, + ).then((data) => { + data.departmentTree.map((item, index) => { + if (item.key.indexOf('d') > -1) { + item.icon = ; + } else { + item.icon = ; + } + }); + let arr = [...treeData, ...data.departmentTree]; + setData(arr); }); - }} - > -
- - - + resolve(undefined); + }, 200); + }); + + return ( + { + form + .validateFields() + .then((values) => { + onCreate(values); + }) + .catch((info) => { + console.log('Validate Failed:', info); + }); + }} + > + + + + - - - - - - ); -}); + + + + +
+ ); + }, +); export default MergeDialog; diff --git a/src/components/drawer/index.jsx b/src/components/drawer/index.jsx index 84ed0b6..def832f 100644 --- a/src/components/drawer/index.jsx +++ b/src/components/drawer/index.jsx @@ -16,6 +16,7 @@ import { message } from 'antd'; import jsPDF from 'jspdf'; import ExportJsonExcel from 'js-export-excel'; import './index.less'; +import { getLabel } from '../../util/i18n.js'; let addNodeChildFunc = null; let orgChart = null; @@ -175,6 +176,7 @@ export default class DrawerComponents extends React.Component { }; handleExport = (e) => { + const { labelData } = this.props; let type = e.key == '1' ? 'png' : e.key == '1' ? 'pdf' : 'excel'; if (type == 'png') { orgChart && orgChart.exportImg({ full: true }); @@ -201,30 +203,30 @@ export default class DrawerComponents extends React.Component { } } } - option.fileName = '组织信息'; + option.fileName = `${getLabel(547468, labelData)}`; option.datas = [ { sheetData: dataTable, sheetName: 'sheet', sheetFilter: [ - '序号', - '工号', - '姓名', - '性别', - '部门', - '分部', - '岗位', - '手机号', + `${getLabel(547327, labelData)}`, + `${getLabel(547328, labelData)}`, + `${getLabel(547329, labelData)}`, + `${getLabel(547330, labelData)}`, + `${getLabel(547331, labelData)}`, + `${getLabel(547332, labelData)}`, + `${getLabel(547333, labelData)}`, + `${getLabel(547334, labelData)}`, ], sheetHeader: [ - '序号', - '工号', - '姓名', - '性别', - '部门', - '分部', - '岗位', - '手机号', + `${getLabel(547327, labelData)}`, + `${getLabel(547328, labelData)}`, + `${getLabel(547329, labelData)}`, + `${getLabel(547330, labelData)}`, + `${getLabel(547331, labelData)}`, + `${getLabel(547332, labelData)}`, + `${getLabel(547333, labelData)}`, + `${getLabel(547334, labelData)}`, ], }, ]; @@ -237,6 +239,8 @@ export default class DrawerComponents extends React.Component { * 节点渲染 */ nodeContentRender = (d, i, arr, state) => { + const { labelData } = this.props; + if (d.data.ftype == 2) { return `
@@ -254,11 +258,13 @@ export default class DrawerComponents extends React.Component { ${d.data.fname}
- 负责人:${d.data.fleader} + ${getLabel(547322, labelData)}:${d.data.fleader}
- 在岗: ${d.data.fonjob} 人 + ${getLabel(547323, labelData)}: ${ + d.data.fonjob + } ${getLabel(547525, labelData)}
@@ -273,9 +279,13 @@ export default class DrawerComponents extends React.Component {
-
${d.data.fname}
+
${ + d.data.fname + }
- 在岗: ${d.data.fonjob} 人 + ${getLabel(547323, labelData)}: ${ + d.data.fonjob + } ${getLabel(547525, labelData)}
@@ -295,13 +305,15 @@ export default class DrawerComponents extends React.Component { }" style="width: 58px; height: 58px; border-radius: 50%; margin-top: 16px;margin-left: -6px;z-index:999" />
-
+
${ d.data.fname }
- 司龄: ${d.data.companyWorkYear} 年 + ${getLabel(547324, labelData)}: ${ + d.data.companyWorkYear + } ${getLabel(547526, labelData)}
@@ -340,8 +352,11 @@ export default class DrawerComponents extends React.Component { showJob, } = this.state; let arr = []; + + const { labelData } = this.props; + if (detailType == 'chart') { - arr.push({ label: '导出图片', key: '1' }); + arr.push({ label: `${getLabel(547315, labelData)}`, key: '1' }); //arr.push({ label: '导出PDF', key: '2' }); } else { arr.push({ label: '导出表格', key: '3' }); @@ -351,7 +366,7 @@ export default class DrawerComponents extends React.Component { return ( - 是否显示岗位 + {getLabel(547447, labelData)} )} - + } @@ -393,7 +408,7 @@ export default class DrawerComponents extends React.Component { {data.length > 0 && ( @@ -418,13 +433,11 @@ export default class DrawerComponents extends React.Component { scroll={{ y: 600 }} loading={spinning} pagination={{ - locale: { - // 翻页文本替换 - items_per_page: '条/页', - jump_to: '跳至', - page: '页', - }, - showTotal: (total) => `共 ${dataSource.length} 条`, + showSizeChanger: false, + showTotal: (total) => + `${getLabel(547523, labelData)} ${ + dataSource.length + } ${getLabel(547524, labelData)}`, }} /> diff --git a/src/components/topBar/index.jsx b/src/components/topBar/index.jsx index fa3b8d7..baec137 100644 --- a/src/components/topBar/index.jsx +++ b/src/components/topBar/index.jsx @@ -15,6 +15,7 @@ import { Modal, Input, message, + notification, } from 'antd'; const { Option } = Select; const { TextArea } = Input; @@ -23,6 +24,8 @@ import 'moment/locale/zh-cn'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import { HomeOutlined } from '@ant-design/icons'; moment.locale('zh-cn'); +import { getLabel } from '../../util/i18n.js'; +import { SmileOutlined } from '@ant-design/icons'; export class TopBar extends React.Component { constructor(props) { @@ -63,8 +66,9 @@ export class TopBar extends React.Component { */ handleOk = () => { const { description, requestData } = this.state; + const { labelData } = this.props; if (description.length == 0) { - return message.error('请填写描述信息'); + return message.error(`${getLabel(547512, labelData)}`); } this.setState({ confirmLoading: true }); let api = @@ -80,9 +84,9 @@ export class TopBar extends React.Component { open: false, confirmLoading: false, }); - message.success('版本记录成功,请重新刷新页面', 2, 3); + message.success(`${getLabel(547513, labelData)}`, 2, 3); } else { - message.error('版本记录失败,请联系相关人员处理数据', 2, 3); + message.error(`${getLabel(547514, labelData)}`, 2, 3); } }); }; @@ -175,7 +179,7 @@ export class TopBar extends React.Component { onClick={this.handleExportMenuClick.bind(this)} items={[ { - label: '导出图片', + label: `${getLabel(547315, this.props.labelData)}`, key: '1', }, // { @@ -187,14 +191,14 @@ export class TopBar extends React.Component { ); render() { - const { disabled, type } = this.props; + const { disabled, type, labelData } = this.props; const { rootTreeData, open, confirmLoading, treeExpandedKeys } = this.state; return (
- 维度: + {getLabel(547293, labelData)}: this.handleFormChange({ level: value })} > - - - - + + + + @@ -288,10 +292,10 @@ export class TopBar extends React.Component { }) } > - 显示虚拟组织 + {getLabel(547302, labelData)} @@ -309,7 +313,7 @@ export class TopBar extends React.Component { this.setState({ open: true }); }} > - 版本记录 + {getLabel(547305, labelData)} - + this.setState({ open: false })} > -

- 提示:版本记录耗时较长,请谨慎操作(仅记录当前维度的数据版本) -

-

主题:

+

{getLabel(547316, labelData)}

+

{getLabel(547317, labelData)}: