Commit d50f3709 by zhaochengxiang

修改bug

parent 5b0d6263
import React, { useEffect, useState, useContext, useMemo, useRef } from 'react';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select, Cascader, Table, Radio, Divider, Typography, Modal, Row, Col } from 'antd';
import { Form, Spin, Input, Descriptions, Space, Button, Tooltip, Select, Cascader, Radio, Divider, Typography, Modal, Row, Col } from 'antd';
import { DownOutlined, UpOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import MetadataInfo from './MetadataInfo';
......@@ -12,6 +12,7 @@ import AssetTagModal from './AssetTagModal';
import { AnchorId, AnchorDirId, AssetManageReference } from '../../../../util/constant';
import IndexCode from './IndexCode';
import Upload from './Upload';
import Table from '../../ResizeableTable';
import { CancelSvg, EditSvg, SaveSvg, FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import SelectUser from '../../Model/Component/SelectUsers';
......
......@@ -140,7 +140,7 @@ const AssetDirectory = (props) => {
</Menu.Item>
<Menu.Item>
<div className='text-center' onClick={onFilterElementClick}>
资产属性管理
资产浏览管理
</div>
</Menu.Item>
<Menu.Item>
......
......@@ -630,31 +630,27 @@ const AssetTable = (props) => {
const deleteAssets = () => {
if ((checkedKeys||[]).length === 0) return;
if (reference === AssetManageReference) {
setAssetDeleteModalVisible(true);
} else {
modal.confirm({
title: '提示',
content: '您确定要永久删除这些资产吗?',
onOk: () => {
let payload = {
data: checkedKeys
}
dispatch({
type: 'assetmanage.deleteDataAssets',
payload,
callback: () => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
},
error: () => {
}
})
modal.confirm({
title: '提示',
content: '您确定要删除这些资产吗?',
onOk: () => {
let payload = {
data: checkedKeys
}
})
}
dispatch({
type: (reference===AssetManageReference)?'assetmanage.unloadDataAssetsFromAllDirs':'assetmanage.deleteDataAssets',
payload,
callback: () => {
showMessage("success","删除成功");
getDataAssets();
setCheckedKeys([]);
},
error: () => {
}
})
}
})
}
const onImportAssetCancel = () => {
......
......@@ -111,9 +111,8 @@ const FC = (props) => {
setTotal(data.totalElements);
data.content?.forEach(item => {
// item.startTime = item._id?.time
// item.endTime
// item.costTime
item.startTime = item.updateTime;
item.costTime = item.cost;
});
setLogs(data.content||[]);
},
......@@ -314,7 +313,10 @@ const FC = (props) => {
catalogs.map((catalog, index) => <Radio key={index} value={catalog.key}>{catalog.title}</Radio>)
}
</Radio.Group>
<Button onClick={() => { setStep(1); }}>查看日志</Button>
<Button onClick={() => {
setStep(1);
getLogs();
}}>查看日志</Button>
</div>
<div className='flex mt-3' style={{ justifyContent: 'space-between' }}>
<Upload style={{ display: 'inline' }} {...uploadProps }>
......
import { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef, useMemo } from 'react';
import { Table } from 'antd';
import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer'
const scrollbarWidth = getScrollbarWidth()
const ResizeableHeaderCell = props => {
const { onResize, width, onClick, ...restProps } = props;
......@@ -33,44 +36,116 @@ const ResizeableHeaderCell = props => {
};
const ResizeableTable = (props) => {
const { columns, ...restProps } = props;
const [_columns, setColumns] = useState([]);
const { columns, ...restProps } = props
useEffect(() => {
setColumns([...columns, { title: '', dataIndex: 'auto' }]);
}, [columns])
const [tableWidth, setTableWidth] = useState(0)
const handleResize = index => (e, { size }) => {
const nextColumns = [..._columns];
nextColumns[index] = {
...nextColumns[index],
width: size.width,
};
const paddingCol = useRef({
key: 'padding',
width: 0,
render: () => undefined
})
setColumns(nextColumns);
const handleResize = (index) => (e, { size }) => {
setCols((prevCols) => {
const nextColumns = [...(prevCols ?? [])];
nextColumns[index] = {
...nextColumns[index],
width: size.width,
};
return nextColumns;
});
};
return (
<Table
components={{
header: {
cell: ResizeableHeaderCell,
}
}}
columns={
_columns.map((column, index) => {
const [cols, setCols] = useState();
useEffect(() => {
if (!!columns && tableWidth > 0) {
const contentWidth = getWidth(tableWidth)
setDefaultWidth(columns, contentWidth)
paddingCol.current.width = 0
const cols = columns
.map((col, index) => {
const colWidth = col.width ?? 100;
return {
...column,
onHeaderCell: column => ({
...col,
width: colWidth,
ellipsis: true,
onHeaderCell: (column: any) => ({
width: column.width,
onResize: handleResize(index),
}),
};
})
}
{ ...restProps }
/>
setCols(cols)
}
}, [columns, tableWidth])
const cols1 = useMemo(() => !!cols ? [...cols, paddingCol.current] : undefined, [cols])
return (
<ResizeObserver
onResize={({ width }) => {
setTableWidth(width)
}}
>
<Table
components={{
header: {
cell: ResizeableHeaderCell,
}
}}
columns={cols1}
{ ...restProps }
/>
</ResizeObserver>
);
}
export default ResizeableTable;
\ No newline at end of file
export default ResizeableTable;
function getWidth(tableWidth) {
// FIXME 判断没有选择列时,32为0
return tableWidth - scrollbarWidth - 32 // scrollbar width, checkbox column
}
function setDefaultWidth(columns, width) {
let rowWidth = 0, count = 0
for (const col of columns) {
if (typeof col.width === 'number') {
rowWidth += col.width
} else {
count++
}
}
if (count > 0) {
const defaultW = (rowWidth > width ? 0 : width - rowWidth) / count
for (const col of columns) {
if (typeof col.width !== 'number') {
col.width = defaultW
}
}
}
}
export function getScrollbarWidth() {
// Creating invisible container
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.overflow = 'scroll'; // forcing scrollbar to appear
outer.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps
document.body.appendChild(outer);
// Creating inner element and placing it in the container
const inner = document.createElement('div');
outer.appendChild(inner);
// Calculating difference between container's full width and the child width
const scrollbarWidth = (outer.offsetWidth - inner.offsetWidth);
// Removing temporary elements from the DOM
outer.parentNode?.removeChild(outer);
return scrollbarWidth;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment