mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
refactor: gantt block (#4059)
* refactor: gantt block * style: style improve * fix: bug * fix: bug
This commit is contained in:
parent
6a0777397a
commit
d25670f29f
@ -77,12 +77,13 @@ const InternalGanttBlockProvider = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const GanttBlockProvider = (props) => {
|
export const GanttBlockProvider = (props) => {
|
||||||
const params = { filter: props.params.filter, paginate: false, sort: props.fieldNames.start };
|
const params = { filter: props.params.filter, paginate: false, sort: ['id'] };
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection_deprecated();
|
||||||
|
|
||||||
if (collection?.tree) {
|
if (collection?.tree) {
|
||||||
params['tree'] = true;
|
params['tree'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div aria-label="block-item-gantt" role="button">
|
<div aria-label="block-item-gantt" role="button">
|
||||||
<BlockProvider name="gantt" {...props} params={params}>
|
<BlockProvider name="gantt" {...props} params={params}>
|
||||||
@ -143,7 +144,6 @@ export const useGanttBlockProps = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [ctx?.service?.loading]);
|
}, [ctx?.service?.loading]);
|
||||||
console.log(tasks);
|
|
||||||
return {
|
return {
|
||||||
fieldNames: ctx.fieldNames,
|
fieldNames: ctx.fieldNames,
|
||||||
timeRange: ctx.timeRange,
|
timeRange: ctx.timeRange,
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
useTableBlockContext,
|
useTableBlockContext,
|
||||||
useToken,
|
useToken,
|
||||||
withDynamicSchemaProps,
|
withDynamicSchemaProps,
|
||||||
|
useDesignable,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
@ -99,12 +100,9 @@ export const Gantt: any = withDynamicSchemaProps((props: any) => {
|
|||||||
const { styles } = useStyles();
|
const { styles } = useStyles();
|
||||||
const { token } = useToken();
|
const { token } = useToken();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const currentTheme = api.auth.getOption('theme');
|
const currentTheme = JSON.parse(api.auth.getOption('theme'))?.uid;
|
||||||
const tableRowHeight = currentTheme === 'compact' ? 45 : 55.56;
|
|
||||||
const {
|
const {
|
||||||
headerHeight = document.querySelector('.ant-table-thead')?.clientHeight || 0, // 与 antd 表格头部高度一致
|
|
||||||
listCellWidth = '155px',
|
listCellWidth = '155px',
|
||||||
rowHeight = tableRowHeight,
|
|
||||||
ganttHeight = 0,
|
ganttHeight = 0,
|
||||||
preStepsCount = 1,
|
preStepsCount = 1,
|
||||||
barFill = 60,
|
barFill = 60,
|
||||||
@ -137,6 +135,9 @@ export const Gantt: any = withDynamicSchemaProps((props: any) => {
|
|||||||
expandAndCollapseAll,
|
expandAndCollapseAll,
|
||||||
fieldNames,
|
fieldNames,
|
||||||
} = useProps(props); // 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
} = useProps(props); // 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
||||||
|
const { designable } = useDesignable();
|
||||||
|
const headerHeight = currentTheme.includes('compact') ? 45 : designable ? 65 : 55;
|
||||||
|
const rowHeight = currentTheme.includes('compact') ? 45 : 65;
|
||||||
const ctx = useGanttBlockContext();
|
const ctx = useGanttBlockContext();
|
||||||
const appInfo = useCurrentAppInfo();
|
const appInfo = useCurrentAppInfo();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -520,7 +521,10 @@ export const Gantt: any = withDynamicSchemaProps((props: any) => {
|
|||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
.ant-table-row {
|
.ant-table-row {
|
||||||
height: ${tableRowHeight}px;
|
height: ${rowHeight}px;
|
||||||
|
}
|
||||||
|
.ant-table-thead {
|
||||||
|
height: ${headerHeight}px;
|
||||||
}
|
}
|
||||||
`)}
|
`)}
|
||||||
>
|
>
|
||||||
|
@ -221,7 +221,10 @@ export const TaskGanttContent: React.FC<TaskGanttContentProps> = ({
|
|||||||
} else if (action === 'dblclick') {
|
} else if (action === 'dblclick') {
|
||||||
!!onDoubleClick && onDoubleClick(task);
|
!!onDoubleClick && onDoubleClick(task);
|
||||||
} else if (action === 'click') {
|
} else if (action === 'click') {
|
||||||
!!onClick && onClick(task);
|
const targetElement = event.target as HTMLElement; // 将 event.target 转换为 HTMLElement 类型
|
||||||
|
if (targetElement.tagName === 'rect') {
|
||||||
|
!!onClick && onClick(task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Change task event start
|
// Change task event start
|
||||||
else if (action === 'move') {
|
else if (action === 'move') {
|
||||||
|
@ -5,7 +5,7 @@ const useStyles = createStyles(({ token, css }) => {
|
|||||||
scrollWrapper: css`
|
scrollWrapper: css`
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -4px;
|
bottom: -8px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
scrollbarWidth: thin;
|
scrollbarWidth: thin;
|
||||||
height: 1.2rem;
|
height: 1.2rem;
|
||||||
|
@ -100,7 +100,7 @@ export const TaskItem: React.FC<TaskItemProps> = (props) => {
|
|||||||
{taskItem}
|
{taskItem}
|
||||||
<text
|
<text
|
||||||
x={isProjectBar ? task.x1 : getX()}
|
x={isProjectBar ? task.x1 : getX()}
|
||||||
y={isProjectBar ? task.y - 8 : isTextInside ? task.y + taskHeight * 0.5 : task.y + taskHeight * 0.65}
|
y={isProjectBar ? task.y - 8 : isTextInside ? task.y + taskHeight * 0.65 : task.y + taskHeight * 0.65}
|
||||||
className={isProjectBar ? cx('projectLabel') : isTextInside ? cx('barLabel') : cx('barLabelOutside')}
|
className={isProjectBar ? cx('projectLabel') : isTextInside ? cx('barLabel') : cx('barLabelOutside')}
|
||||||
ref={textRef}
|
ref={textRef}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user