Commit d50f3709 by zhaochengxiang

修改bug

parent 5b0d6263
import React, { useEffect, useState, useContext, useMemo, useRef } from 'react'; 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 { DownOutlined, UpOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import MetadataInfo from './MetadataInfo'; import MetadataInfo from './MetadataInfo';
...@@ -12,6 +12,7 @@ import AssetTagModal from './AssetTagModal'; ...@@ -12,6 +12,7 @@ import AssetTagModal from './AssetTagModal';
import { AnchorId, AnchorDirId, AssetManageReference } from '../../../../util/constant'; import { AnchorId, AnchorDirId, AssetManageReference } from '../../../../util/constant';
import IndexCode from './IndexCode'; import IndexCode from './IndexCode';
import Upload from './Upload'; import Upload from './Upload';
import Table from '../../ResizeableTable';
import { CancelSvg, EditSvg, SaveSvg, FullScreenSvg, CancelFullScreenSvg } from './AssetSvg'; import { CancelSvg, EditSvg, SaveSvg, FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
import SelectUser from '../../Model/Component/SelectUsers'; import SelectUser from '../../Model/Component/SelectUsers';
......
...@@ -140,7 +140,7 @@ const AssetDirectory = (props) => { ...@@ -140,7 +140,7 @@ const AssetDirectory = (props) => {
</Menu.Item> </Menu.Item>
<Menu.Item> <Menu.Item>
<div className='text-center' onClick={onFilterElementClick}> <div className='text-center' onClick={onFilterElementClick}>
资产属性管理 资产浏览管理
</div> </div>
</Menu.Item> </Menu.Item>
<Menu.Item> <Menu.Item>
......
...@@ -630,19 +630,16 @@ const AssetTable = (props) => { ...@@ -630,19 +630,16 @@ const AssetTable = (props) => {
const deleteAssets = () => { const deleteAssets = () => {
if ((checkedKeys||[]).length === 0) return; if ((checkedKeys||[]).length === 0) return;
if (reference === AssetManageReference) {
setAssetDeleteModalVisible(true);
} else {
modal.confirm({ modal.confirm({
title: '提示', title: '提示',
content: '您确定要永久删除这些资产吗?', content: '您确定要删除这些资产吗?',
onOk: () => { onOk: () => {
let payload = { let payload = {
data: checkedKeys data: checkedKeys
} }
dispatch({ dispatch({
type: 'assetmanage.deleteDataAssets', type: (reference===AssetManageReference)?'assetmanage.unloadDataAssetsFromAllDirs':'assetmanage.deleteDataAssets',
payload, payload,
callback: () => { callback: () => {
showMessage("success","删除成功"); showMessage("success","删除成功");
...@@ -655,7 +652,6 @@ const AssetTable = (props) => { ...@@ -655,7 +652,6 @@ const AssetTable = (props) => {
} }
}) })
} }
}
const onImportAssetCancel = () => { const onImportAssetCancel = () => {
setImportAssetVisible(false); setImportAssetVisible(false);
......
...@@ -111,9 +111,8 @@ const FC = (props) => { ...@@ -111,9 +111,8 @@ const FC = (props) => {
setTotal(data.totalElements); setTotal(data.totalElements);
data.content?.forEach(item => { data.content?.forEach(item => {
// item.startTime = item._id?.time item.startTime = item.updateTime;
// item.endTime item.costTime = item.cost;
// item.costTime
}); });
setLogs(data.content||[]); setLogs(data.content||[]);
}, },
...@@ -314,7 +313,10 @@ const FC = (props) => { ...@@ -314,7 +313,10 @@ const FC = (props) => {
catalogs.map((catalog, index) => <Radio key={index} value={catalog.key}>{catalog.title}</Radio>) catalogs.map((catalog, index) => <Radio key={index} value={catalog.key}>{catalog.title}</Radio>)
} }
</Radio.Group> </Radio.Group>
<Button onClick={() => { setStep(1); }}>查看日志</Button> <Button onClick={() => {
setStep(1);
getLogs();
}}>查看日志</Button>
</div> </div>
<div className='flex mt-3' style={{ justifyContent: 'space-between' }}> <div className='flex mt-3' style={{ justifyContent: 'space-between' }}>
<Upload style={{ display: 'inline' }} {...uploadProps }> <Upload style={{ display: 'inline' }} {...uploadProps }>
......
import { useEffect, useState } from 'react'; import React, { useEffect, useState, useRef, useMemo } from 'react';
import { Table } from 'antd'; import { Table } from 'antd';
import { Resizable } from 'react-resizable'; import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer'
const scrollbarWidth = getScrollbarWidth()
const ResizeableHeaderCell = props => { const ResizeableHeaderCell = props => {
const { onResize, width, onClick, ...restProps } = props; const { onResize, width, onClick, ...restProps } = props;
...@@ -33,44 +36,116 @@ const ResizeableHeaderCell = props => { ...@@ -33,44 +36,116 @@ const ResizeableHeaderCell = props => {
}; };
const ResizeableTable = (props) => { const ResizeableTable = (props) => {
const { columns, ...restProps } = props; const { columns, ...restProps } = props
const [_columns, setColumns] = useState([]);
useEffect(() => { const [tableWidth, setTableWidth] = useState(0)
setColumns([...columns, { title: '', dataIndex: 'auto' }]);
}, [columns])
const handleResize = index => (e, { size }) => { const paddingCol = useRef({
const nextColumns = [..._columns]; key: 'padding',
width: 0,
render: () => undefined
})
const handleResize = (index) => (e, { size }) => {
setCols((prevCols) => {
const nextColumns = [...(prevCols ?? [])];
nextColumns[index] = { nextColumns[index] = {
...nextColumns[index], ...nextColumns[index],
width: size.width, width: size.width,
}; };
return nextColumns;
});
};
setColumns(nextColumns); 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 {
...col,
width: colWidth,
ellipsis: true,
onHeaderCell: (column: any) => ({
width: column.width,
onResize: handleResize(index),
}),
}; };
})
setCols(cols)
}
}, [columns, tableWidth])
const cols1 = useMemo(() => !!cols ? [...cols, paddingCol.current] : undefined, [cols])
return ( return (
<ResizeObserver
onResize={({ width }) => {
setTableWidth(width)
}}
>
<Table <Table
components={{ components={{
header: { header: {
cell: ResizeableHeaderCell, cell: ResizeableHeaderCell,
} }
}} }}
columns={ columns={cols1}
_columns.map((column, index) => {
return {
...column,
onHeaderCell: column => ({
width: column.width,
onResize: handleResize(index),
}),
};
})
}
{ ...restProps } { ...restProps }
/> />
</ResizeObserver>
); );
} }
export default ResizeableTable; 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