add 文件管理

This commit is contained in:
2021-06-23 17:56:29 +08:00
parent 3734dda2db
commit 32856f4757
9 changed files with 636 additions and 157 deletions

View File

@@ -46,7 +46,6 @@ const { getState, subscribe } = store
const stroePath = 'user'
export default class Auth extends Component {
state = getState(stroePath)
constructor(props) {
@@ -62,11 +61,10 @@ export default class Auth extends Component {
}
render() {
const flag = auth.call(this.state, this.props.auth)
if (flag) {
return this.props.children
return this.props.children || <></>
}
return <></>

View File

@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { Form, Button, Table, Tooltip } from 'antd'
import { AntIcon } from 'components'
const propsMap = ['autoLoad', 'loadData', 'pageIndex', 'pageSize']
const propsMap = ['columns', 'autoLoad', 'loadData', 'pageIndex', 'pageSize']
const clearChildren = data => {
data.forEach(p => {
@@ -17,6 +17,17 @@ const clearChildren = data => {
return data
}
const rowNoColumn = {
title: '#',
dataIndex: 'rowNo',
width: 30,
fixed: true,
align: 'center',
ellipsis: true,
className: 'yo-table--row-no',
render: (text, record, index) => index + 1,
}
/**
* 渲染查询栏
* @returns
@@ -64,7 +75,7 @@ export default class QueryTable extends Component {
// 加载状态
loading: false,
// 表格类型
type: '',
type: 'tree',
// 数据
dataSource: [],
}
@@ -105,6 +116,8 @@ export default class QueryTable extends Component {
this.loadData =
typeof this.props.loadData === 'function' ? this.props.loadData : async () => {}
this.rowNumber = typeof this.props.rowNumber === 'boolean' ? this.props.rowNumber : true
if (this.props.pageIndex) {
this.pageIndex = this.props.pageIndex
this.pagination.current = this.pageIndex
@@ -113,6 +126,19 @@ export default class QueryTable extends Component {
this.pageSize = this.props.pageSize
this.pagination.pageSize = this.pageSize
}
// 默认排序
if (this.props.columns) {
for (const column of this.props.columns) {
if (column.defaultSortOrder) {
this.sorter = {
sortField: column.dataIndex,
sortOrder: column.defaultSortOrder,
}
break
}
}
}
}
/**
@@ -247,7 +273,9 @@ export default class QueryTable extends Component {
}
render() {
const { loading, dataSource } = this.state
const { rowNumber } = this
const { loading, dataSource, type } = this.state
const { query, operator, columns } = this.props
@@ -262,11 +290,19 @@ export default class QueryTable extends Component {
loading,
pagination: this.pagination,
dataSource,
columns: (columns || []).filter(p => !p.hidden),
columns: (() => {
const c = []
if (type !== 'tree' && rowNumber) {
c.push(rowNoColumn)
}
c.push(...(columns || []))
return c.filter(p => !p.hidden)
})(),
bordered: true,
size: 'middle',
rowKey: record => record.id || Math.random().toString(16).slice(2),
sticky: true,
scroll: { x: 'max-content' },
...attrs,
}