From d3385102f2793ac607db394166dfbd7e04410ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?= <188633308@qq.com> Date: Thu, 17 Jun 2021 18:07:33 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=A4=A7=E9=87=8F=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/assets/style/lib/authority-view.less | 7 +- .../src/assets/style/lib/text-color.less | 3 + .../src/components/authority-view/index.jsx | 196 ++++++++--------- .../src/components/icon-selector/index.jsx | 6 +- web-react/src/components/image/index.jsx | 10 +- web-react/src/components/modal-form/index.jsx | 102 ++++----- web-react/src/components/query-list/index.jsx | 82 +++---- .../components/query-table-actions/index.jsx | 34 +-- .../src/components/query-table/index.jsx | 96 ++++----- .../components/query-tree-layout/index.jsx | 200 +++++++++--------- web-react/src/pages/system/app/index.jsx | 66 +++--- .../src/views/main/_layout/content/index.jsx | 15 +- 12 files changed, 424 insertions(+), 393 deletions(-) diff --git a/web-react/src/assets/style/lib/authority-view.less b/web-react/src/assets/style/lib/authority-view.less index fac0029..7fd6b37 100644 --- a/web-react/src/assets/style/lib/authority-view.less +++ b/web-react/src/assets/style/lib/authority-view.less @@ -1,5 +1,10 @@ @import (reference) '../extend.less'; .yo-authority-view { + &--container { + >.ant-descriptions-view { + border: 0; + } + } .ant-descriptions-item-label { width: 150px; } @@ -11,7 +16,7 @@ } .ant-descriptions-item-content { padding: @padding-sm @padding-md; - >.yo-authority-view--checkbox { + .yo-authority-view--checkbox { display: inline-block; width: 150px; diff --git a/web-react/src/assets/style/lib/text-color.less b/web-react/src/assets/style/lib/text-color.less index f1b835b..f1cd8ae 100644 --- a/web-react/src/assets/style/lib/text-color.less +++ b/web-react/src/assets/style/lib/text-color.less @@ -21,6 +21,9 @@ .text-warning { color: @warning-color; } +.text-gray { + color: gray; +} .text-normal { color: @normal-color; } diff --git a/web-react/src/components/authority-view/index.jsx b/web-react/src/components/authority-view/index.jsx index 2fcddd7..adabbe9 100644 --- a/web-react/src/components/authority-view/index.jsx +++ b/web-react/src/components/authority-view/index.jsx @@ -3,6 +3,94 @@ import { Checkbox, Descriptions, Empty, Spin, Tooltip } from 'antd' import { AntIcon } from 'components' import { EMPTY_ID } from 'util/global' +function generateList(data) { + data.forEach(item => { + if (item.children && item.children.length) { + generateList.call(this, item.children) + } + this.list.push(item) + }) +} + +function getVisible() { + const checked = this.list.filter(item => item.checked) + const caseChildren = checked.filter(item => item.visibleParent || item.type != 2) + const visibleParents = [] + // 递归寻找父级 + const findVisibleParents = (children) => { + const parents = [] + children.forEach(item => { + if (item.parentId) { + const parent = this.list.find(item => item.id === item.parentId) + if (parent) { + parents.push(parent) + visibleParents.push(parent) + } + } + }) + if (parents.length) { + findVisibleParents(parents) + } + } + + findVisibleParents(caseChildren) + + const checkedIds = checked.map(item => item.id) + const visibleParentsIds = visibleParents.map(item => item.id) + + const result = checkedIds + visibleParentsIds.forEach(item => { + if (!result.includes(item)) { + result.push(item) + } + }) + + return result +} + +function renderDescriptions(data) { + return data.map(item => { + return item.children && item.children.length ? renderItem.call(this, item) : renderCheckbox.call(this, item) + }) +} + +function renderItem(data) { + return ( + + this.onChange(e, data)} + >{data.title} + } + > + {renderDescriptions.call(this, data.children)} + + + ) +} + +function renderCheckbox(data) { + return ( +
+ this.onChange(e, data)} + >{data.title} + { + data.visibleParent && data.type == 2 && + + + + } +
+ ) +} + export default class AuthorityView extends Component { state = { @@ -28,13 +116,13 @@ export default class AuthorityView extends Component { } } - async onLoadData() { + onLoadData = async () => { this.setState({ loading: true }) const res = await this.loadData() this.list = [] - this.generateList(res) + generateList.call(this, res) if (this.props.defaultSelectedKeys) { this.list.map(item => { @@ -50,14 +138,14 @@ export default class AuthorityView extends Component { }) } - onReloadData() { + onReloadData = () => { this.onLoadData() } - onChange(e, item) { + onChange = (e, item) => { this.onSelect(e.target.checked, item) - const visible = this.getVisible() + const visible = getVisible.call(this) if (this.props.onSelect) { this.props.onSelect( @@ -71,7 +159,7 @@ export default class AuthorityView extends Component { } } - onSelect(check, item) { + onSelect = (check, item) => { item.checked = check item.indeterminate = false if (item.children && item.children.length) { @@ -86,7 +174,7 @@ export default class AuthorityView extends Component { }) } - onChangeParent(checked, parentId) { + onChangeParent = (checked, parentId) => { const parent = this.list.find(p => p.id === parentId) if (parent) { const checkedCount = parent.children.filter(p => p.checked).length @@ -108,7 +196,7 @@ export default class AuthorityView extends Component { } } - onChangeChildren(checked, children) { + onChangeChildren = (checked, children) => { children.forEach(p => { p.checked = checked p.indeterminate = false @@ -118,101 +206,13 @@ export default class AuthorityView extends Component { }) } - generateList(data) { - data.forEach(item => { - if (item.children && item.children.length) { - this.generateList(item.children) - } - this.list.push(item) - }) - } - - getVisible() { - const checked = this.list.filter(item => item.checked) - const caseChildren = checked.filter(item => item.visibleParent || item.type != 2) - const visibleParents = [] - // 递归寻找父级 - const findVisibleParents = (children) => { - const parents = [] - children.forEach(item => { - if (item.parentId) { - const parent = this.list.find(item => item.id === item.parentId) - if (parent) { - parents.push(parent) - visibleParents.push(parent) - } - } - }) - if (parents.length) { - findVisibleParents(parents) - } - } - - findVisibleParents(caseChildren) - - const checkedIds = checked.map(item => item.id) - const visibleParentsIds = visibleParents.map(item => item.id) - - const result = checkedIds - visibleParentsIds.forEach(item => { - if (!result.includes(item)) { - result.push(item) - } - }) - - return result - } - - renderDescriptions(data) { - return data.map(item => { - return item.children && item.children.length ? this.renderItem(item) : this.renderCheckbox(item) - }) - } - - renderItem(data) { - return ( - - this.onChange(e, data)} - >{data.title} - } - > - {this.renderDescriptions(data.children)} - - - ) - } - - renderCheckbox(data) { - return ( -
- { - data.visibleParent && data.type == 2 && - - - - } - this.onChange(e, data)} - >{data.title} -
- ) - } - render() { return (
}> { !this.state.loading ? - + { this.state.dataSource.map(item => { return ( @@ -226,7 +226,7 @@ export default class AuthorityView extends Component { >{item.title} } > - {this.renderDescriptions(item.children)} + {renderDescriptions.call(this, item.children)} ) }) diff --git a/web-react/src/components/icon-selector/index.jsx b/web-react/src/components/icon-selector/index.jsx index 49dda08..12b981b 100644 --- a/web-react/src/components/icon-selector/index.jsx +++ b/web-react/src/components/icon-selector/index.jsx @@ -11,7 +11,7 @@ export default class IconSelector extends Component { selected: '' } - open(icon) { + open = (icon) => { if (icon) { const activeKey = (icons.find(p => p.icons.includes(icon)) || icons[0]).key this.setState({ @@ -24,11 +24,11 @@ export default class IconSelector extends Component { } } - close() { + close = () => { this.setState({ visible: false }) } - onSelectIcon(icon) { + onSelectIcon = (icon) => { if (this.props.onSelect) { this.props.onSelect(icon) } diff --git a/web-react/src/components/image/index.jsx b/web-react/src/components/image/index.jsx index 3d519bf..2b2c6c5 100644 --- a/web-react/src/components/image/index.jsx +++ b/web-react/src/components/image/index.jsx @@ -11,14 +11,14 @@ const getSrc = async (id) => { return '' } -let id = '' - export default class Image extends Component { state = { src: '' } + id = '' + constructor(props) { super(props) @@ -31,15 +31,15 @@ export default class Image extends Component { } componentDidUpdate() { - if (id !== this.props.id && this.props.id) { + if (this.id !== this.props.id && this.props.id) { this.setSrc() } } setSrc = async () => { if (this.props.id) { - id = this.props.id - const src = await getSrc(id) + this.id = this.props.id + const src = await getSrc(this.id) this.setState({ src }) } } diff --git a/web-react/src/components/modal-form/index.jsx b/web-react/src/components/modal-form/index.jsx index 33e11f5..5b47046 100644 --- a/web-react/src/components/modal-form/index.jsx +++ b/web-react/src/components/modal-form/index.jsx @@ -2,6 +2,50 @@ import React, { Component } from 'react' import { Button, Drawer, message as Message, Modal } from 'antd' import { cloneDeep, isEqual } from 'lodash' +/** + * 渲染对话框 + * @param {*} props + * @param {*} on + * @param {*} childWithProps + * @returns + */ +function renderModal(props, on, childWithProps) { + + on = { + ...on, + onCancel: () => this.onClose() + } + + return + {childWithProps} + + +} + +/** + * 渲染抽屉 + * @param {*} props + * @param {*} on + * @param {*} childWithProps + * @returns + */ +function renderDrawer(props, on, childWithProps) { + on = { + ...on, + onClose: () => this.onClose() + } + + return +
+ {childWithProps} +
+
+ + +
+
+} + export default class ModalForm extends Component { state = { @@ -51,7 +95,7 @@ export default class ModalForm extends Component { * 打开弹窗 * @param {*} data */ - open(data = {}) { + open = (data = {}) => { this.data = data this.setState({ visible: true }) } @@ -59,7 +103,7 @@ export default class ModalForm extends Component { /** * 关闭弹窗 */ - close() { + close = () => { this.setState({ visible: false }) } @@ -68,7 +112,7 @@ export default class ModalForm extends Component { * 对子元素数据进行填充,(如需关闭时对比)之后再获取结构调整后的数据快照 * @returns */ - async onCreated() { + onCreated = async () => { const body = this.childNode.current if (!body || !body.fillData) return @@ -84,7 +128,7 @@ export default class ModalForm extends Component { * (如需关闭时对比)获取当前数据结构与快照对比 * @returns */ - async onClose() { + onClose = async () => { const body = this.childNode.current if (!body) { this.close() @@ -113,7 +157,7 @@ export default class ModalForm extends Component { * 校验并获取结构调整后的数据,调用this.action进行操作 * @returns */ - async onOk() { + onOk = async () => { const body = this.childNode.current if (!body || !this.action || !body.getData) return @@ -137,50 +181,6 @@ export default class ModalForm extends Component { } } - /** - * 渲染对话框 - * @param {*} props - * @param {*} on - * @param {*} childWithProps - * @returns - */ - renderModal(props, on, childWithProps) { - - on = { - ...on, - onCancel: () => this.onClose() - } - - return - {childWithProps} - - - } - - /** - * 渲染抽屉 - * @param {*} props - * @param {*} on - * @param {*} childWithProps - * @returns - */ - renderDrawer(props, on, childWithProps) { - on = { - ...on, - onClose: () => this.onClose() - } - - return -
- {childWithProps} -
-
- - -
-
- } - render() { const props = { @@ -206,8 +206,8 @@ export default class ModalForm extends Component { ) return this.type === 'modal' ? - this.renderModal(props, on, childWithProps) + renderModal.call(this, props, on, childWithProps) : - this.renderDrawer(props, on, childWithProps) + renderDrawer.call(this, props, on, childWithProps) } } diff --git a/web-react/src/components/query-list/index.jsx b/web-react/src/components/query-list/index.jsx index 28a2d7e..1fd5200 100644 --- a/web-react/src/components/query-list/index.jsx +++ b/web-react/src/components/query-list/index.jsx @@ -2,6 +2,39 @@ import React, { Component } from 'react' import { Button, Form, List, Pagination, Spin, Tooltip } from 'antd' import { AntIcon } from 'components' +/** + * 渲染查询栏 + * @returns + */ +function renderQueryBar() { + + const { query, moreQuery } = this.props + + return ( +
+
this.onQuery(value)} + initialValues={this.props.queryInitialValues} + > + {query} + + + + + + } + +
+
+ ) +} + export default class QueryList extends Component { state = { @@ -60,7 +93,7 @@ export default class QueryList extends Component { * 加载数据 * 调用外部传入的loadData函数,可在loadData中自行改变参数 */ - async onLoadData() { + onLoadData = async () => { this.onLoading() const res = await this.props.loadData({ @@ -80,14 +113,14 @@ export default class QueryList extends Component { /** * 数据开始加载 */ - onLoading() { + onLoading = () => { this.setState({ loading: true }) } /** * 数据加载完成 */ - onLoaded() { + onLoaded = () => { this.setState({ loading: false }) } @@ -96,7 +129,7 @@ export default class QueryList extends Component { * 返回表单字段值,加载数据,并且返回到第一页 * @param {*} values */ - onQuery(values) { + onQuery = (values) => { this.query = values this.onReloadData(true) } @@ -105,7 +138,7 @@ export default class QueryList extends Component { * 重置查询 * 初始化表单字段值,加载数据,并返回到第一页 */ - onResetQuery() { + onResetQuery = () => { this.form.current.resetFields() this.query = {} this.onReloadData(true) @@ -115,7 +148,7 @@ export default class QueryList extends Component { * 重新加载表格数据 * @param {Boolean} resetPage 是否重置页码 */ - onReloadData(resetPage = false) { + onReloadData = (resetPage = false) => { if (resetPage) { this.pagination = { ...this.pagination, @@ -125,7 +158,7 @@ export default class QueryList extends Component { this.onLoadData() } - onListChange(current, pageSize) { + onListChange = (current, pageSize) => { this.pagination = { ...this.pagination, current, @@ -134,39 +167,6 @@ export default class QueryList extends Component { this.onLoadData() } - /** - * 渲染查询栏 - * @returns - */ - renderQueryBar() { - - const { query, moreQuery } = this.props - - return ( -
-
this.onQuery(value)} - initialValues={this.props.queryInitialValues} - > - {query} - - - - - - } - -
-
- ) - } - render() { const props = { @@ -177,7 +177,7 @@ export default class QueryList extends Component { return (
- {this.props.query && this.renderQueryBar()} + {this.props.query && renderQueryBar.call(this)}
{this.props.operator} diff --git a/web-react/src/components/query-table-actions/index.jsx b/web-react/src/components/query-table-actions/index.jsx index a539d77..7298fe5 100644 --- a/web-react/src/components/query-table-actions/index.jsx +++ b/web-react/src/components/query-table-actions/index.jsx @@ -1,29 +1,29 @@ import React, { Component } from 'react' import { Divider } from 'antd' +function renderActions() { + const { children } = this.props + const actions = [] + + Array.isArray(children) ? children + .filter(action => action) + .forEach((action, i) => { + actions.push(action) + if (i < this.props.children.length - 1) { + actions.push() + } + }) : (actions.push(children)) + + return actions +} + export default class QueryTableActions extends Component { - renderActions() { - const { children } = this.props - const actions = [] - - Array.isArray(children) ? children - .filter(action => action) - .forEach((action, i) => { - actions.push(action) - if (i < this.props.children.length - 1) { - actions.push() - } - }) : (actions.push(children)) - - return actions - } - render() { return (
- {this.renderActions()} + {renderActions.call(this)}
) diff --git a/web-react/src/components/query-table/index.jsx b/web-react/src/components/query-table/index.jsx index 4db7e68..ac4f06b 100644 --- a/web-react/src/components/query-table/index.jsx +++ b/web-react/src/components/query-table/index.jsx @@ -15,6 +15,43 @@ const clearChildren = (data) => { return data } +/** + * 渲染查询栏 + * @returns + */ +function renderQueryBar() { + + const { query, moreQuery } = this.props + + return ( +
+
this.onQuery(value)} + initialValues={this.props.queryInitialValues} + > + {query} + + + + + + } + +
+
+ ) +} + +function renderTable(props, on) { + return +} + export default class QueryTable extends Component { state = { @@ -84,7 +121,7 @@ export default class QueryTable extends Component { * 加载数据 * 调用外部传入的loadData函数,可在loadData中自行改变参数 */ - async onLoadData() { + onLoadData = async () => { this.onLoading() const res = await this.loadData({ @@ -114,7 +151,7 @@ export default class QueryTable extends Component { /** * 数据开始加载 */ - onLoading() { + onLoading = () => { this.setState({ loading: { indicator: @@ -125,7 +162,7 @@ export default class QueryTable extends Component { /** * 数据加载完成 */ - onLoaded() { + onLoaded = () => { this.setState({ loading: false }) } @@ -134,7 +171,7 @@ export default class QueryTable extends Component { * 返回表单字段值,加载数据,并且返回到第一页 * @param {*} values */ - onQuery(values) { + onQuery = (values) => { this.query = values this.onReloadData(true) } @@ -143,7 +180,7 @@ export default class QueryTable extends Component { * 重置查询 * 初始化表单字段值,加载数据,并返回到第一页 */ - onResetQuery() { + onResetQuery = () => { this.form.current.resetFields() this.query = { ...this.props.queryInitialValues @@ -155,7 +192,7 @@ export default class QueryTable extends Component { * 重新加载表格数据 * @param {Boolean} resetPage 是否重置页码 */ - onReloadData(resetPage = false) { + onReloadData = (resetPage = false) => { if (resetPage) { this.pagination = { ...this.pagination, @@ -171,7 +208,7 @@ export default class QueryTable extends Component { * @param {*} filters * @param {*} sorter */ - onTableChange(pagination, filters, sorter) { + onTableChange = (pagination, filters, sorter) => { this.pagination = { ...pagination, showTotal: (total) => `总共${total}条数据` @@ -183,7 +220,7 @@ export default class QueryTable extends Component { this.onLoadData() } - onAddRow(record = {}) { + onAddRow = (record = {}) => { let { dataSource } = this.state if (!dataSource.find(item => !item.id)) { dataSource = [...dataSource, record] @@ -195,43 +232,6 @@ export default class QueryTable extends Component { return false } - /** - * 渲染查询栏 - * @returns - */ - renderQueryBar() { - - const { query, moreQuery } = this.props - - return ( -
-
this.onQuery(value)} - initialValues={this.props.queryInitialValues} - > - {query} - - - - - - } - - -
- ) - } - - renderTable(props, on) { - return
- } - render() { const { loading, dataSource } = this.state @@ -256,7 +256,7 @@ export default class QueryTable extends Component { return (
- {query && this.renderQueryBar()} + {query && renderQueryBar.call(this)}
{operator} @@ -272,10 +272,10 @@ export default class QueryTable extends Component { { this.props.editable ?
- {this.renderTable(props, on)} + {renderTable.call(this, props, on)} : - this.renderTable(props, on) + renderTable.call(this, props, on) }
) diff --git a/web-react/src/components/query-tree-layout/index.jsx b/web-react/src/components/query-tree-layout/index.jsx index 0390301..d7c4466 100644 --- a/web-react/src/components/query-tree-layout/index.jsx +++ b/web-react/src/components/query-tree-layout/index.jsx @@ -2,6 +2,94 @@ import React, { Component } from 'react' import { Breadcrumb, Empty, Input, Layout, Spin, Tooltip, Tree } from 'antd' import { AntIcon, Container } from 'components' +function generateKey(data, level) { + const n = level || [0] + n.push(0) + data.forEach((p, i) => { + n[n.length - 1] = i + p.key = n.join('-') + p.scopedSlots = { title: 'title' } + if (p[this.replaceFields.children]) { + generateKey.call(this, p[this.replaceFields.children], Object.assign([], n)) + } + }) + return data +} + +function generateList(data) { + // 这里获取不到Key + for (let i = 0; i < data.length; i++) { + const { key } = data[i] + this.list.push({ + key, + [this.replaceFields.value]: data[i][this.replaceFields.value], + [this.replaceFields.title]: data[i][this.replaceFields.title] + }) + if (data[i][this.replaceFields.children]) { + generateList.call(this, data[i][this.replaceFields.children]) + } + } +} + +function getParentKey(key, tree) { + let parentKey; + for (let i = 0; i < tree.length; i++) { + const node = tree[i] + if (node[this.replaceFields.children]) { + if (node[this.replaceFields.children].some(item => item.key === key)) { + parentKey = node.key + } else if (getParentKey.call(this, key, node[this.replaceFields.children])) { + parentKey = getParentKey.call(this, key, node[this.replaceFields.children]) + } + } + } + return parentKey; +} + +function renderTitle(nodeData) { + const title = nodeData[this.replaceFields.title] + if (this.state.searchValue && title.indexOf(this.state.searchValue) > -1) { + return <> + {title.substr(0, title.indexOf(this.state.searchValue))} + {this.state.searchValue} + {title.substr(title.indexOf(this.state.searchValue) + this.state.searchValue.length)} + + } + return <>{title} +} + +function renderBreadcrumbItem() { + + const path = ['顶级'] + + const findPath = (data, level) => { + level = level || 1 + for (let i = 0; i < data.length; i++) { + const item = data[i] + + path[level] = item[this.replaceFields.title] + + if (item[this.replaceFields.value] === this.state.selectedKey) { + path.length = level + 1 + return true + } + + if (item[this.replaceFields.children] && item[this.replaceFields.children].length) { + const found = findPath(item[this.replaceFields.children], level + 1) + if (found) { + return true + } + } + } + } + + if (this.state.selectedKey) { + findPath(this.state.dataSource) + } + + return path.map((p, i) => {p}) +} + export default class QueryTreeLayout extends Component { state = { @@ -49,13 +137,13 @@ export default class QueryTreeLayout extends Component { * 加载数据 * 调用外部传入的loadData函数,可在loadData中自行改变参数 */ - async onLoadData() { + onLoadData = async () => { this.onLoading() const res = await this.props.loadData() - const data = this.generateKey(res) + const data = generateKey.call(this, res) this.list = [] - this.generateList(data) + generateList.call(this, data) let expandedKeys = [] if (this.defaultExpanded) { @@ -71,7 +159,7 @@ export default class QueryTreeLayout extends Component { /** * 数据开始加载 */ - onLoading() { + onLoading = () => { this.setState({ loading: { indicator: @@ -82,22 +170,22 @@ export default class QueryTreeLayout extends Component { /** * 数据加载完成 */ - onLoaded() { + onLoaded = () => { this.setState({ loading: false }) } - onReloadData() { + onReloadData = () => { this.onLoadData() } - onExpand(expandedKeys) { + onExpand = (expandedKeys) => { this.setState({ expandedKeys, autoExpandParent: false }) } - onSelect(selectedKeys) { + onSelect = (selectedKeys) => { const selectedIds = [] selectedKeys.forEach(p => { const data = this.list.find(m => m.key === p) @@ -111,11 +199,11 @@ export default class QueryTreeLayout extends Component { } } - onSearch(value) { + onSearch = (value) => { const expandedKeys = this.list .map(p => { if (p[this.replaceFields.title].indexOf(value) > -1) { - return this.getParentKey(p.key, this.state.dataSource) + return getParentKey.call(this, p.key, this.state.dataSource) } return null }) @@ -128,94 +216,6 @@ export default class QueryTreeLayout extends Component { }) } - generateKey(data, level) { - const n = level || [0] - n.push(0) - data.forEach((p, i) => { - n[n.length - 1] = i - p.key = n.join('-') - p.scopedSlots = { title: 'title' } - if (p[this.replaceFields.children]) { - this.generateKey(p[this.replaceFields.children], Object.assign([], n)) - } - }) - return data - } - - generateList(data) { - // 这里获取不到Key - for (let i = 0; i < data.length; i++) { - const { key } = data[i] - this.list.push({ - key, - [this.replaceFields.value]: data[i][this.replaceFields.value], - [this.replaceFields.title]: data[i][this.replaceFields.title] - }) - if (data[i][this.replaceFields.children]) { - this.generateList(data[i][this.replaceFields.children]) - } - } - } - - getParentKey(key, tree) { - let parentKey; - for (let i = 0; i < tree.length; i++) { - const node = tree[i] - if (node[this.replaceFields.children]) { - if (node[this.replaceFields.children].some(item => item.key === key)) { - parentKey = node.key - } else if (this.getParentKey(key, node[this.replaceFields.children])) { - parentKey = this.getParentKey(key, node[this.replaceFields.children]) - } - } - } - return parentKey; - } - - titleRender(nodeData) { - const title = nodeData[this.replaceFields.title] - if (this.state.searchValue && title.indexOf(this.state.searchValue) > -1) { - return <> - {title.substr(0, title.indexOf(this.state.searchValue))} - {this.state.searchValue} - {title.substr(title.indexOf(this.state.searchValue) + this.state.searchValue.length)} - - } - return <>{title} - } - - renderBreadcrumbItem() { - - const path = ['顶级'] - - const findPath = (data, level) => { - level = level || 1 - for (let i = 0; i < data.length; i++) { - const item = data[i] - - path[level] = item[this.replaceFields.title] - - if (item[this.replaceFields.value] === this.state.selectedKey) { - path.length = level + 1 - return true - } - - if (item[this.replaceFields.children] && item[this.replaceFields.children].length) { - const found = findPath(item[this.replaceFields.children], level + 1) - if (found) { - return true - } - } - } - } - - if (this.state.selectedKey) { - findPath(this.state.dataSource) - } - - return path.map((p, i) => {p}) - } - render() { const { dataSource, expandedKeys, autoExpandParent } = this.state @@ -268,7 +268,7 @@ export default class QueryTreeLayout extends Component { this.titleRender(nodeData)} + titleRender={(nodeData) => renderTitle.call(this, nodeData)} /> } @@ -277,7 +277,7 @@ export default class QueryTreeLayout extends Component { - {this.renderBreadcrumbItem()} + {renderBreadcrumbItem.call(this)} {this.props.children} diff --git a/web-react/src/pages/system/app/index.jsx b/web-react/src/pages/system/app/index.jsx index 3652715..8fdfcd0 100644 --- a/web-react/src/pages/system/app/index.jsx +++ b/web-react/src/pages/system/app/index.jsx @@ -133,12 +133,13 @@ export default class index extends Component { * 如果必须要加载字典数据,可直接对表格设置autoLoad=true */ componentDidMount() { - this.table.current.onLoading() + const { onLoading, onLoadData } = this.table.current + onLoading() getDictData('common_status').then(res => { this.setState({ codes: res }, () => { - this.table.current.onLoadData() + onLoadData() }) }) } @@ -194,13 +195,18 @@ export default class index extends Component { * @param {*} successMessage */ async onAction(action, successMessage) { - this.table.current.onLoading() + const { onLoading, onLoaded, onReloadData } = this.table.current + onLoading() try { - await action - Message.success(successMessage) - this.table.current.onReloadData() + if (action) { + await action + } + if (successMessage) { + Message.success(successMessage) + } + onReloadData() } catch { - this.table.current.onLoaded() + onLoaded() } } @@ -245,31 +251,37 @@ export default class index extends Component { } operator={ - + + + } /> - this.table.current.onReloadData()} - > - - + + this.table.current.onReloadData()} + > + + + - this.table.current.onReloadData()} - > - - + + this.table.current.onReloadData()} + > + + + ) } diff --git a/web-react/src/views/main/_layout/content/index.jsx b/web-react/src/views/main/_layout/content/index.jsx index b230380..ef52e9e 100644 --- a/web-react/src/views/main/_layout/content/index.jsx +++ b/web-react/src/views/main/_layout/content/index.jsx @@ -1,8 +1,9 @@ import React, { Component } from 'react' -import { Layout, Tabs, Menu, Dropdown } from 'antd' +import { Divider, Layout, Tabs, Menu, Dropdown } from 'antd' import NProgress from 'nprogress' import 'nprogress/nprogress.css' import AntIcon from 'components/ant-icon' +import { Container } from 'components' NProgress.configure({ parent: '.ant-layout-content > .yo-tab-external-mount > .yo-tab-external-mount-content' }); @@ -52,7 +53,17 @@ class ComponentDynamic extends Component { render() { if (this.state.component) { - return + return + + 技术支持: 宽易科技 + + + } + /> } return <> }