Commit f8ba0c1f by zhaochengxiang

字段排序不能滚动问题

parent 04d1dfff
...@@ -104,3 +104,11 @@ div[id^='__qiankun_microapp_wrapper_'] { ...@@ -104,3 +104,11 @@ div[id^='__qiankun_microapp_wrapper_'] {
.yy-typography, .yy-typography p { .yy-typography, .yy-typography p {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
tr.drop-over-downward td {
border-bottom: 2px dashed #1890ff;
}
tr.drop-over-upward td {
border-top: 2px dashed #1890ff;
}
\ No newline at end of file
...@@ -253,8 +253,7 @@ const ImportAction = (props) => { ...@@ -253,8 +253,7 @@ const ImportAction = (props) => {
return newEasyDataModelerIndices.filter(item => (item.indexedEasyDataModelAttributes||[]).length > 0); return newEasyDataModelerIndices.filter(item => (item.indexedEasyDataModelAttributes||[]).length > 0);
} }
return ( const container = (<>
<Spin spinning={loading}>
{ {
<div className='d-flex mb-5' style={{ alignItems: 'center' }}> <div className='d-flex mb-5' style={{ alignItems: 'center' }}>
<span style={{ marginLeft: 'auto' }}>规范:</span> <span style={{ marginLeft: 'auto' }}>规范:</span>
...@@ -298,7 +297,17 @@ const ImportAction = (props) => { ...@@ -298,7 +297,17 @@ const ImportAction = (props) => {
editable={action!=='detail'} editable={action!=='detail'}
terms={terms} terms={terms}
/> />
</Spin> </>);
return (
<>
{
//container包裹在Spin中,会有谷歌浏览器字段排序拖动不能滚动鼠标的问题,所以加载完成后,直接展示container
loading ? <Spin spinning={loading}>
{ container }
</Spin> : container
}
</>
); );
}; };
......
...@@ -603,36 +603,18 @@ const ImportActionIndex = (props) => { ...@@ -603,36 +603,18 @@ const ImportActionIndex = (props) => {
return hasValidateReports ? includeValidateColumn : columns; return hasValidateReports ? includeValidateColumn : columns;
} }
let pendingUpdateFn = undefined;
let requestedFrame = undefined;
const drawFrame = () => {
const newData = update(data, pendingUpdateFn);
onChange && onChange(newData);
pendingUpdateFn = undefined;
requestedFrame = undefined;
};
const scheduleUpdate = (updateFn) => {
pendingUpdateFn = updateFn;
if (!requestedFrame) {
requestedFrame = requestAnimationFrame(drawFrame);
}
}
const moveRow = useCallback( const moveRow = useCallback(
(dragIndex, hoverIndex) => { (dragIndex, hoverIndex) => {
const dragRow = data[dragIndex]; const dragRow = data[dragIndex];
scheduleUpdate({ const newData = update(data, {
$splice: [ $splice: [
[dragIndex, 1], [dragIndex, 1],
[hoverIndex, 0, dragRow], [hoverIndex, 0, dragRow],
], ],
}); });
onChange && onChange(newData);
}, },
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
[data], [data],
...@@ -671,6 +653,7 @@ const ImportActionIndex = (props) => { ...@@ -671,6 +653,7 @@ const ImportActionIndex = (props) => {
editable && <Button className='ml-3' type="primary" onClick={onAddClick} disabled={ editingKey!==null || keyword!=='' } >新增索引</Button> editable && <Button className='ml-3' type="primary" onClick={onAddClick} disabled={ editingKey!==null || keyword!=='' } >新增索引</Button>
} }
</div> </div>
<div className='content'>
<DndProvider backend={HTML5Backend} > <DndProvider backend={HTML5Backend} >
<Form form={form} component={false} onValuesChange={onValuesChange}> <Form form={form} component={false} onValuesChange={onValuesChange}>
<Table <Table
...@@ -700,6 +683,7 @@ const ImportActionIndex = (props) => { ...@@ -700,6 +683,7 @@ const ImportActionIndex = (props) => {
</Form> </Form>
</DndProvider> </DndProvider>
</div> </div>
</div>
); );
}; };
......
.model-import-action-index { .model-import-action-index {
.content {
.yy-table {
max-height: 200px !important; max-height: 200px !important;
overflow: auto !important; overflow: auto !important;
} }
......
...@@ -691,39 +691,18 @@ const ImportActionTable = (props) => { ...@@ -691,39 +691,18 @@ const ImportActionTable = (props) => {
return hasValidateReports ? includeValidateColumn : columns; return hasValidateReports ? includeValidateColumn : columns;
} }
//增加拖拽自动滚动功能
//https://codesandbox.io/s/react-dnd-example-12-s3nnf?file=/src/Container.jsx:393-425
let pendingUpdateFn = undefined;
let requestedFrame = undefined;
const drawFrame = () => {
const newData = update(data, pendingUpdateFn);
onChangeRef.current && onChangeRef.current(newData);
pendingUpdateFn = undefined;
requestedFrame = undefined;
};
const scheduleUpdate = (updateFn) => {
pendingUpdateFn = updateFn;
if (!requestedFrame) {
requestedFrame = requestAnimationFrame(drawFrame);
}
}
const moveRow = useCallback( const moveRow = useCallback(
(dragIndex, hoverIndex) => { (dragIndex, hoverIndex) => {
const dragRow = data[dragIndex]; const dragRow = data[dragIndex];
scheduleUpdate({ const newData = update(data, {
$splice: [ $splice: [
[dragIndex, 1], [dragIndex, 1],
[hoverIndex, 0, dragRow], [hoverIndex, 0, dragRow],
], ],
}); });
// onChangeRef.current && onChangeRef.current(newData); onChangeRef.current && onChangeRef.current(newData);
}, },
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
[data], [data],
...@@ -762,6 +741,7 @@ const ImportActionTable = (props) => { ...@@ -762,6 +741,7 @@ const ImportActionTable = (props) => {
editable && <Button className='ml-3' type="primary" onClick={onAddClick} disabled={ editingKey!=='' || keyword!=='' } >新增字段</Button> editable && <Button className='ml-3' type="primary" onClick={onAddClick} disabled={ editingKey!=='' || keyword!=='' } >新增字段</Button>
} }
</div> </div>
<div className='content'>
<DndProvider backend={HTML5Backend} > <DndProvider backend={HTML5Backend} >
<Form form={form} component={false} onValuesChange={onValuesChange}> <Form form={form} component={false} onValuesChange={onValuesChange}>
<Table <Table
...@@ -845,6 +825,7 @@ const ImportActionTable = (props) => { ...@@ -845,6 +825,7 @@ const ImportActionTable = (props) => {
</Form> </Form>
</DndProvider> </DndProvider>
</div> </div>
</div>
); );
}; };
......
.model-import-action-table { .model-import-action-table {
.yy-table { .content {
max-height: 400px !important; max-height: 400px !important;
overflow: auto !important; overflow: auto !important;
} }
......
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