From be056f701f46662efb39f17fd2bafdbea57c8580 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 24 May 2023 10:46:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=9A=E4=BF=A1=E5=AE=89=E5=85=A8=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .umirc.ts | 6 +- src/components/topBar/index.jsx | 251 +++++++++----------------------- src/department/index.js | 5 - src/pages/company.jsx | 23 +-- 4 files changed, 81 insertions(+), 204 deletions(-) delete mode 100644 src/department/index.js diff --git a/.umirc.ts b/.umirc.ts index 0c771fc..02b7fc6 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -2,7 +2,7 @@ * @Author: Chengliang 1546584672@qq.com * @Date: 2022-08-04 10:22:55 * @LastEditors: Chengliang 1546584672@qq.com - * @LastEditTime: 2022-12-15 11:50:19 + * @LastEditTime: 2023-05-23 15:18:17 * @FilePath: /org-chart-frant/.umirc.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -11,7 +11,7 @@ import { defineConfig } from 'umi'; export default defineConfig({ hash: true, history: { type: 'hash' }, - base: '/spa/orgChart/', + base: '/spa/aischart/', // exportStatic: {}, publicPath: './', nodeModulesTransform: { @@ -26,7 +26,7 @@ export default defineConfig({ proxy: { '/api': { // 标识需要进行转换的请求的url - target: 'http://hr.jinyosolar.cn:90/api', // 服务端域名 / http://localhost:8686 + target: 'http://127.0.0.1:8686/api', // 服务端域名 / http://localhost:8686 changeOrigin: true, // 允许域名进行转换 pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉 }, diff --git a/src/components/topBar/index.jsx b/src/components/topBar/index.jsx index 9327ead..f4b0904 100644 --- a/src/components/topBar/index.jsx +++ b/src/components/topBar/index.jsx @@ -4,7 +4,6 @@ import { DatePicker, Select, Button, - Checkbox, Row, Col, Dropdown, @@ -21,21 +20,13 @@ export class TopBar extends React.Component { constructor(props) { super(props); this.state = { - fclasslist: [], - companylist: [], //下拉框跟节点 + deptartmentTreeData: [], //部门异步树 treeExpandedKeys: [], - companyData: [], - departmentData: [], - companyTreeData: [], - deptartmentTreeData: [], + levelOptions: [], //层级数据,hrm中层级字段 requestData: { - date: moment(new Date()).format('YYYY-MM-DD'), - fclass: '0', - root: '0', - level: '3', - fisvitual: '0', - company: undefined, - department: undefined, + date: moment(new Date()).format('YYYY-MM-DD'), //日期 + department: [], + level: '2', //显示层级 }, }; } @@ -44,69 +35,54 @@ export class TopBar extends React.Component { let requestData = { ...this.state.requestData, ...payload }; this.setState({ requestData }); } - //日期可选择未来 - // disabledDate (current) { - // // return current && current >moment().subtract(1, "days"); - // return current && current > moment().endOf("day"); - // } handleExportMenuClick(e) { this.props.onExport(e.key == '1' ? 'png' : 'pdf'); } - handleExportButtonClick() { - this.props.onExport('png'); - } - /** - * 分部 - * @param {*} parentId + * 部门树数据 + * @param {} parentId + * @returns */ - getCompanyTreeNode = (parentId) => { - let api = - '/api/bs/hrmorganization/jclorgchart/getCompanyTree?company=' + parentId; - fetch(api) - .then((res) => res.json()) - .then((data) => { - if (data.code == 200) { - let arr = [...this.state.companyTreeData, ...data.data]; - this.setState({ - companyTreeData: arr, - }); - } - }); + getDepartmentTreeNode = (parentId) => { + // let api = + // '/api/bs/hrmorganization/jclorgchart/getDepartmentTree?department=' + + // parentId; + // fetch(api) + // .then((res) => res.json()) + // .then((data) => { + // if (data.code == 200) { + // let arr = [...this.state.deptartmentTreeData, ...data.data]; + // this.setState({ + // deptartmentTreeData: arr, + // }); + // } + // }); + let treeData = []; + if (parentId === null) { + treeData = [ + { id: 1, pId: 0, value: '1', title: 'Expand to load' }, + { id: 2, pId: 0, value: '2', title: 'Expand to load' }, + { id: 3, pId: 0, value: '3', title: 'Tree Node', isLeaf: true }, + ]; + } else { + treeData = [ + { id: 6, pId: 1, value: '3', title: 'Tree Node', isLeaf: true }, + ]; + } + + let arr = [...this.state.deptartmentTreeData, ...treeData]; + this.setState({ + deptartmentTreeData: arr, + }); }; /** - * 部门 + * 部门树异步加载 * @param {} parentId * @returns */ - getDepartmentTreeNode = (parentId) => { - let api = - '/api/bs/hrmorganization/jclorgchart/getDepartmentTree?department=' + - parentId; - fetch(api) - .then((res) => res.json()) - .then((data) => { - if (data.code == 200) { - let arr = [...this.state.deptartmentTreeData, ...data.data]; - this.setState({ - deptartmentTreeData: arr, - }); - } - }); - }; - - onCompanyLoadData = (treeNode) => - new Promise((resolve) => { - const { id } = treeNode.props; - setTimeout(() => { - this.getCompanyTreeNode(id); - resolve(); - }, 300); - }); - onDepartmentLoadData = (treeNode) => new Promise((resolve) => { const { id } = treeNode.props; @@ -116,55 +92,12 @@ export class TopBar extends React.Component { }, 300); }); - onCompanyChange = (value, label, extra) => { - let company = value.length > 0 ? this.paramsUtil(value) : undefined; - let requestData = { - ...this.state.requestData, - company: company, - department: undefined, - }; - this.setState({ - companyData: value, - requestData, - departmentData: [], - deptartmentTreeData: [], - treeExpandedKeys: [], - }); - this.getDepartmentTreeList(company); - }; - onDepartmentChange = (value) => { let department = value.length > 0 ? this.paramsUtil(value) : undefined; let requestData = { ...this.state.requestData, department: department }; this.setState({ departmentData: value, requestData }); }; - getCompanyTreeList = () => { - let api = '/api/bs/hrmorganization/jclorgchart/getCompanyTree'; - fetch(api) - .then((res) => res.json()) - .then((data) => { - if (data.code == 200) { - this.setState({ - companyTreeData: data.data, - }); - } - }); - }; - - getDepartmentTreeList = (company) => { - let api = `/api/bs/hrmorganization/jclorgchart/getDepartmentTree?company=${company}`; - fetch(api) - .then((res) => res.json()) - .then((data) => { - if (data.code == 200) { - this.setState({ - deptartmentTreeData: data.data, - }); - } - }); - }; - paramsUtil = (param) => { let arr = param.map(function (obj, index) { return obj.value; @@ -179,17 +112,32 @@ export class TopBar extends React.Component { }; componentDidMount() { - fetch(this.props.url) - .then((res) => res.json()) - .then((data) => { - this.setState({ - fclasslist: data.fclasslist, - companylist: data.companylist, - }); - }); - this.getCompanyTreeList(); + // fetch(this.props.url) + // .then((res) => res.json()) + // .then((data) => { + // this.setState({ + // levelOptions: data.levelOptions + // }); + // }); + + const options = [ + { value: '1', label: '一级' }, + { value: '2', label: '二级' }, + { value: '3', label: '三级' }, + ]; + const treeData = [ + { id: 1, pId: 0, value: '1', title: 'Expand to load' }, + { id: 2, pId: 0, value: '2', title: 'Expand to load' }, + { id: 3, pId: 0, value: '3', title: 'Tree Node', isLeaf: true }, + ]; + this.setState({ + levelOptions: options, + }); + this.getDepartmentTreeNode(null); } + /** + * 导出多选 */ menu = (