| | |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | ColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | | useRecordContext, |
| | | useTranslate, |
| | | useNotify, |
| | | useListContext, |
| | | FunctionField, |
| | | TextField, |
| | | NumberField, |
| | | DateField, |
| | | BooleanField, |
| | | ReferenceField, |
| | | TextInput, |
| | | DateTimeInput, |
| | | DateInput, |
| | | SelectInput, |
| | | NumberInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | DataTable |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | import MyField from "../components/MyField"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | import StickyDataTable from "@/page/components/StickyDataTable"; |
| | | import useTableLayout from '@/utils/useTableLayout'; |
| | | import ChipArrayField from '@/page/components/ChipArrayField'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | | height: '.9em' |
| | | }, |
| | | '& .RaDatagrid-row': { |
| | | cursor: 'auto' |
| | | }, |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | }, |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | |
| | | />, |
| | | ] |
| | | |
| | | const getColumns = (translate) => [ |
| | | <NumberField source="id" />, |
| | | <TextField source="templateCode" label="table.field.taskPathTemplateMerge.templateCode" />, |
| | | <TextField source="templateName" label="table.field.taskPathTemplateMerge.templateName" />, |
| | | <TextField source="sourceType" label="table.field.taskPathTemplateMerge.sourceType" />, |
| | | <TextField source="targetType" label="table.field.taskPathTemplateMerge.targetType" />, |
| | | <ChipArrayField |
| | | source="conditionExpression" |
| | | label="table.field.taskPathTemplateMerge.conditionExpression" |
| | | apiEndpoint="/taskPathTemplate/many/{ids}" |
| | | labelField="templateName" |
| | | dialogTitle={translate('table.field.taskPathTemplateMerge.conditionExpression')} |
| | | initialDisplayCount={1} |
| | | placeholderText="{count} 个模板" |
| | | />, |
| | | <TextField source="conditionDesc" label="table.field.taskPathTemplateMerge.conditionDesc" />, |
| | | <NumberField source="version" label="table.field.taskPathTemplateMerge.version" />, |
| | | <NumberField source="isCurrent" label="table.field.taskPathTemplateMerge.isCurrent" />, |
| | | <DateField source="effectiveTime" label="table.field.taskPathTemplateMerge.effectiveTime" showTime />, |
| | | <DateField source="expireTime" label="table.field.taskPathTemplateMerge.expireTime" showTime />, |
| | | <NumberField source="priority" label="table.field.taskPathTemplateMerge.priority" />, |
| | | <NumberField source="timeoutMinutes" label="table.field.taskPathTemplateMerge.timeoutMinutes" />, |
| | | <NumberField source="maxRetryTimes" label="table.field.taskPathTemplateMerge.maxRetryTimes" />, |
| | | <NumberField source="retryIntervalSeconds" label="table.field.taskPathTemplateMerge.retryIntervalSeconds" />, |
| | | <TextField source="remark" label="table.field.taskPathTemplateMerge.remark" />, |
| | | <NumberField source="stepSize" label="table.field.taskPathTemplateMerge.stepSize" />, |
| | | |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField>, |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime />, |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField>, |
| | | <DateField source="createTime" label="common.field.createTime" showTime />, |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} />, |
| | | <TextField source="memo" label="common.field.memo" sortable={false} />, |
| | | <WrapperField source="opt" cellClassName="opt" label="common.field.opt"> |
| | | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> |
| | | </WrapperField> |
| | | ]; |
| | | |
| | | const TaskPathTemplateMergeList = () => { |
| | | const translate = useTranslate(); |
| | | |
| | |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> |
| | | <SelectColumnsButton preferenceKey='taskPathTemplateMerge' /> |
| | | <ColumnsButton storeKey='taskPathTemplateMerge' /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='taskPathTemplateMerge' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <TaskPathTemplateMergePanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'createBy', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="templateCode" label="table.field.taskPathTemplateMerge.templateCode" /> |
| | | <TextField source="templateName" label="table.field.taskPathTemplateMerge.templateName" /> |
| | | <TextField source="sourceType" label="table.field.taskPathTemplateMerge.sourceType" /> |
| | | <TextField source="targetType" label="table.field.taskPathTemplateMerge.targetType" /> |
| | | <TextField source="conditionExpression" label="table.field.taskPathTemplateMerge.conditionExpression" /> |
| | | <TextField source="conditionDesc" label="table.field.taskPathTemplateMerge.conditionDesc" /> |
| | | <NumberField source="version" label="table.field.taskPathTemplateMerge.version" /> |
| | | <NumberField source="isCurrent" label="table.field.taskPathTemplateMerge.isCurrent" /> |
| | | <DateField source="effectiveTime" label="table.field.taskPathTemplateMerge.effectiveTime" showTime /> |
| | | <DateField source="expireTime" label="table.field.taskPathTemplateMerge.expireTime" showTime /> |
| | | <NumberField source="priority" label="table.field.taskPathTemplateMerge.priority" /> |
| | | <NumberField source="timeoutMinutes" label="table.field.taskPathTemplateMerge.timeoutMinutes" /> |
| | | <NumberField source="maxRetryTimes" label="table.field.taskPathTemplateMerge.maxRetryTimes" /> |
| | | <NumberField source="retryIntervalSeconds" label="table.field.taskPathTemplateMerge.retryIntervalSeconds" /> |
| | | <TextField source="remark" label="table.field.taskPathTemplateMerge.remark" /> |
| | | <NumberField source="stepSize" label="table.field.taskPathTemplateMerge.stepSize" /> |
| | | |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="createTime" label="common.field.createTime" showTime /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt"> |
| | | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | <TableItems drawerVal={drawerVal} /> |
| | | </List> |
| | | <TaskPathTemplateMergeCreate |
| | | open={createDialog} |
| | |
| | | ) |
| | | } |
| | | |
| | | const TableItems = ({ drawerVal }) => { |
| | | const { isLoading } = useListContext(); |
| | | const translate = useTranslate(); |
| | | const { boxMaxWidth, boxMaxHeight } = useTableLayout(drawerVal); |
| | | const columns = getColumns(translate); |
| | | |
| | | return ( |
| | | <Box sx={{ |
| | | position: 'relative', |
| | | maxHeight: boxMaxHeight, |
| | | maxWidth: boxMaxWidth, |
| | | overflowX: 'auto', |
| | | overflowY: 'auto', |
| | | '& .MuiTableCell-root': { |
| | | whiteSpace: 'nowrap', |
| | | } |
| | | }}> |
| | | {columns.length > 0 && |
| | | <StickyDataTable |
| | | stickyRight={['opt']} |
| | | storeKey='taskPathTemplateMerge' |
| | | bulkActionButtons={false} |
| | | rowClick={false} |
| | | hiddenColumns={['id', 'createTime', 'createBy', 'memo', 'statusBool']} |
| | | > |
| | | {columns |
| | | .map((column) => ( |
| | | <DataTable.Col |
| | | key={column.key || column.props.source} |
| | | source={column.props.source} |
| | | label={column.props.label} |
| | | sx={column.props.sx} |
| | | > |
| | | {column} |
| | | </DataTable.Col> |
| | | )) |
| | | } |
| | | </StickyDataTable>} |
| | | </Box> |
| | | ) |
| | | } |
| | | |
| | | export default TaskPathTemplateMergeList; |