u
This commit is contained in:
@@ -24,8 +24,6 @@ import AddIcon from '@mui/icons-material/Add';
|
|||||||
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||||
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
||||||
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||||
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
|
||||||
import Inventory2Icon from '@mui/icons-material/Inventory2';
|
|
||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import AppDialog from '../AppDialog';
|
import AppDialog from '../AppDialog';
|
||||||
import { shipment as shipmentApi, shipping as shippingApi } from '../../api';
|
import { shipment as shipmentApi, shipping as shippingApi } from '../../api';
|
||||||
@@ -174,7 +172,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
this.handleDeletePackage = this.handleDeletePackage.bind(this);
|
this.handleDeletePackage = this.handleDeletePackage.bind(this);
|
||||||
this.handleMarkPackageShipped = this.handleMarkPackageShipped.bind(this);
|
this.handleMarkPackageShipped = this.handleMarkPackageShipped.bind(this);
|
||||||
this.handleStateChange = this.handleStateChange.bind(this);
|
this.handleStateChange = this.handleStateChange.bind(this);
|
||||||
this.handleNavigateFull = this.handleNavigateFull.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -260,7 +257,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
this.setState((prev) => ({
|
this.setState((prev) => ({
|
||||||
shipment: { ...prev.shipment, state: newState },
|
shipment: { ...prev.shipment, state: newState },
|
||||||
}));
|
}));
|
||||||
const label = newState === 'delivered' ? 'Geliefert' : newState === 'returned' ? 'Retoure' : 'Neu';
|
const label = newState === 'delivered' ? 'Versendet' : newState === 'returned' ? 'Retoure' : 'Neu';
|
||||||
enqueueSnackbar(`Lieferstatus geändert: ${label}`, { variant: 'success' });
|
enqueueSnackbar(`Lieferstatus geändert: ${label}`, { variant: 'success' });
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
orderAutomat.actions.reload(),
|
orderAutomat.actions.reload(),
|
||||||
@@ -274,14 +271,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNavigateFull() {
|
|
||||||
const { shipment, onClose, onNavigate } = this.props;
|
|
||||||
onClose?.();
|
|
||||||
if (onNavigate && shipment?.id) {
|
|
||||||
onNavigate(`/auftrag/ausliefern?shipmentId=${shipment.id}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { open, onClose } = this.props;
|
const { open, onClose } = this.props;
|
||||||
const { shipment, loading, error, addPackageDialogOpen, busyAction } = this.state;
|
const { shipment, loading, error, addPackageDialogOpen, busyAction } = this.state;
|
||||||
@@ -290,7 +279,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
|
|
||||||
const shLines = Array.isArray(shipment.lines) ? shipment.lines : [];
|
const shLines = Array.isArray(shipment.lines) ? shipment.lines : [];
|
||||||
const shPackages = Array.isArray(shipment.shippings) ? shipment.shippings : [];
|
const shPackages = Array.isArray(shipment.shippings) ? shipment.shippings : [];
|
||||||
const hasShippedPackages = shPackages.some((p) => p.state === 'shipped');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppDialog open={open} onClose={onClose} maxWidth="md" fullWidth>
|
<AppDialog open={open} onClose={onClose} maxWidth="md" fullWidth>
|
||||||
@@ -298,46 +286,23 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
|
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
|
||||||
<LocalShippingIcon color="primary" sx={{ fontSize: 28 }} />
|
<LocalShippingIcon color="primary" sx={{ fontSize: 28 }} />
|
||||||
<Box>
|
<Box>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
<Typography variant="h6" sx={{ fontWeight: 700, lineHeight: 1.2 }}>
|
||||||
<Typography variant="h6" sx={{ fontWeight: 700, lineHeight: 1.2 }}>
|
{shipment.number || 'Lieferschein'}
|
||||||
{shipment.number || 'Lieferschein'}
|
</Typography>
|
||||||
</Typography>
|
|
||||||
<Chip
|
|
||||||
size="small"
|
|
||||||
color={hasShippedPackages ? 'success' : 'default'}
|
|
||||||
label={hasShippedPackages ? 'Im Versand' : 'Bereitstellung'}
|
|
||||||
sx={{ fontWeight: 600, height: 20, fontSize: '0.7rem' }}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
<Typography variant="caption" color="text.secondary">
|
||||||
{shipment.date ? `Datum: ${formatDate(shipment.date)}` : ''}
|
{shipment.date ? `Datum: ${formatDate(shipment.date)}` : ''}
|
||||||
{shipment.externalNumber ? ` • Ref: ${shipment.externalNumber}` : ''}
|
{shipment.externalNumber ? ` • Ref: ${shipment.externalNumber}` : ''}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
<IconButton
|
||||||
<TextField
|
aria-label="close"
|
||||||
select
|
onClick={onClose}
|
||||||
size="small"
|
size="small"
|
||||||
label="Lieferstatus"
|
sx={{ color: (theme) => theme.palette.grey[500] }}
|
||||||
value={shipment.state || 'new'}
|
>
|
||||||
onChange={(e) => this.handleStateChange(e.target.value)}
|
<CloseIcon />
|
||||||
disabled={busyAction}
|
</IconButton>
|
||||||
sx={{ minWidth: 130 }}
|
|
||||||
>
|
|
||||||
<MenuItem value="new">Neu</MenuItem>
|
|
||||||
<MenuItem value="delivered">Geliefert</MenuItem>
|
|
||||||
<MenuItem value="returned">Retoure</MenuItem>
|
|
||||||
</TextField>
|
|
||||||
<IconButton
|
|
||||||
aria-label="close"
|
|
||||||
onClick={onClose}
|
|
||||||
size="small"
|
|
||||||
sx={{ color: (theme) => theme.palette.grey[500] }}
|
|
||||||
>
|
|
||||||
<CloseIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Box>
|
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
|
|
||||||
<DialogContent dividers sx={{ p: 2.5, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
<DialogContent dividers sx={{ p: 2.5, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
||||||
@@ -349,9 +314,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
|
|
||||||
{/* Shipped Article Positions */}
|
{/* Shipped Article Positions */}
|
||||||
<Box>
|
<Box>
|
||||||
<Typography variant="subtitle2" sx={{ fontWeight: 700, mb: 1 }}>
|
|
||||||
Gelieferte Artikel-Positionen ({shLines.length})
|
|
||||||
</Typography>
|
|
||||||
<TableContainer sx={{ border: '1px solid', borderColor: 'divider', borderRadius: 1.5, bgcolor: WHITE }}>
|
<TableContainer sx={{ border: '1px solid', borderColor: 'divider', borderRadius: 1.5, bgcolor: WHITE }}>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableHead sx={{ bgcolor: SURFACE_RAISED }}>
|
<TableHead sx={{ bgcolor: SURFACE_RAISED }}>
|
||||||
@@ -386,10 +348,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
|
|
||||||
{/* Shipping Packages / Tracking */}
|
{/* Shipping Packages / Tracking */}
|
||||||
<Box>
|
<Box>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 1 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end', mb: shPackages.length > 0 ? 1 : 0 }}>
|
||||||
<Typography variant="subtitle2" sx={{ fontWeight: 700 }}>
|
|
||||||
Pakete & Sendungsverfolgung ({shPackages.length})
|
|
||||||
</Typography>
|
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -402,14 +361,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{shPackages.length === 0 ? (
|
{shPackages.length > 0 ? (
|
||||||
<Box sx={{ p: 2.5, textAlign: 'center', bgcolor: WHITE, borderRadius: 1.5, border: '1px dashed', borderColor: 'divider' }}>
|
|
||||||
<Inventory2Icon sx={{ color: 'text.secondary', fontSize: 28, mb: 0.5 }} />
|
|
||||||
<Typography variant="body2" color="text.secondary">
|
|
||||||
Noch keine Pakete erfasst.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
) : (
|
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
{shPackages.map((pkg) => {
|
{shPackages.map((pkg) => {
|
||||||
const isShipped = pkg.state === 'shipped';
|
const isShipped = pkg.state === 'shipped';
|
||||||
@@ -493,25 +445,41 @@ export default class ShipmentDetailDialog extends PureComponent {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
) : null}
|
||||||
</Box>
|
</Box>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions sx={{ p: 2, justifyContent: 'space-between' }}>
|
<DialogActions sx={{ p: 2, justifyContent: 'flex-end' }}>
|
||||||
<Button variant="outlined" onClick={onClose}>
|
{(!shipment.state || shipment.state === 'new') && (
|
||||||
Schließen
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
{this.props.onNavigate && (
|
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
startIcon={<OpenInNewIcon />}
|
color="primary"
|
||||||
onClick={this.handleNavigateFull}
|
disabled={busyAction}
|
||||||
sx={{ textTransform: 'none', fontWeight: 600 }}
|
onClick={() => this.handleStateChange('delivered')}
|
||||||
|
sx={{ textTransform: 'none', fontWeight: 700 }}
|
||||||
>
|
>
|
||||||
In Auslieferungen öffnen
|
{busyAction ? 'Wird versendet…' : 'Versenden'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{shipment.state === 'delivered' && (
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="warning"
|
||||||
|
disabled={busyAction}
|
||||||
|
onClick={() => this.handleStateChange('returned')}
|
||||||
|
sx={{ textTransform: 'none', fontWeight: 700 }}
|
||||||
|
>
|
||||||
|
{busyAction ? 'Wird gebucht…' : 'Retoure'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{shipment.state === 'returned' && (
|
||||||
|
<Chip
|
||||||
|
label="Retoure"
|
||||||
|
color="error"
|
||||||
|
variant="outlined"
|
||||||
|
sx={{ fontWeight: 700, height: 28, fontSize: '0.8rem' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
|
|
||||||
{addPackageDialogOpen && (
|
{addPackageDialogOpen && (
|
||||||
|
|||||||
Reference in New Issue
Block a user