u
This commit is contained in:
@@ -19,17 +19,18 @@ export default class ArticleSearchDialog extends PureComponent {
|
|||||||
this.state = {
|
this.state = {
|
||||||
assigningSku: null,
|
assigningSku: null,
|
||||||
error: null,
|
error: null,
|
||||||
|
showAllArticles: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (!prevProps.open && this.props.open) {
|
if (!prevProps.open && this.props.open) {
|
||||||
this.setState({ assigningSku: null, error: null });
|
this.setState({ assigningSku: null, error: null, showAllArticles: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClose = () => {
|
handleClose = () => {
|
||||||
this.setState({ assigningSku: null, error: null });
|
this.setState({ assigningSku: null, error: null, showAllArticles: false });
|
||||||
this.props.onClose?.();
|
this.props.onClose?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,9 +62,9 @@ export default class ArticleSearchDialog extends PureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { open, onClose, line, kind = 'delivery', supplierArticles: propSupplierArticles } = this.props;
|
const { open, onClose, line, kind = 'delivery', supplierArticles: propSupplierArticles } = this.props;
|
||||||
const { assigningSku, error } = this.state;
|
const { assigningSku, error, showAllArticles } = this.state;
|
||||||
const isDelivery = kind === 'delivery';
|
const isDelivery = kind === 'delivery';
|
||||||
const onlySupplierArticles = isDelivery && !line;
|
const onlySupplierArticles = isDelivery && !line && !showAllArticles;
|
||||||
const rawSku = line?.sku != null ? String(line.sku).trim() : '';
|
const rawSku = line?.sku != null ? String(line.sku).trim() : '';
|
||||||
|
|
||||||
const supplierArticlesList = onlySupplierArticles
|
const supplierArticlesList = onlySupplierArticles
|
||||||
@@ -122,7 +123,7 @@ export default class ArticleSearchDialog extends PureComponent {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography variant="h6" component="div" fontWeight={600}>
|
<Typography variant="h6" component="div" fontWeight={600}>
|
||||||
{line
|
{line
|
||||||
? 'Existierenden Artikel zuordnen'
|
? (isDelivery ? 'Artikel neu zuordnen' : 'Existierenden Artikel zuordnen')
|
||||||
: isDelivery
|
: isDelivery
|
||||||
? 'Lieferanten-Artikel auswählen'
|
? 'Lieferanten-Artikel auswählen'
|
||||||
: 'Artikel auswählen'}
|
: 'Artikel auswählen'}
|
||||||
@@ -134,7 +135,21 @@ export default class ArticleSearchDialog extends PureComponent {
|
|||||||
{line?.name ? ` · ${line.name}` : ''}
|
{line?.name ? ` · ${line.name}` : ''}
|
||||||
</>
|
</>
|
||||||
) : isDelivery ? (
|
) : isDelivery ? (
|
||||||
'Nur mit dem ausgewählten Lieferanten verknüpfte Artikel'
|
<Box component="span" sx={{ display: 'inline-flex', alignItems: 'center', gap: 1 }}>
|
||||||
|
<span>
|
||||||
|
{showAllArticles
|
||||||
|
? 'Alle Artikel im Katalog durchsuchen'
|
||||||
|
: 'Nur mit dem ausgewählten Lieferanten verknüpfte Artikel'}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
onClick={() => this.setState({ showAllArticles: !showAllArticles })}
|
||||||
|
sx={{ fontSize: '0.72rem', py: 0, px: 0.75, textTransform: 'none', minWidth: 'auto', fontWeight: 600 }}
|
||||||
|
>
|
||||||
|
{showAllArticles ? 'Nur Lieferanten-Artikel' : 'Alle Artikel durchsuchen'}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
'Artikel für Beleg auswählen'
|
'Artikel für Beleg auswählen'
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -766,6 +766,30 @@ class ManifestFormLine extends PureComponent {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{this.props.onSearchArticle && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
|
||||||
|
disabled={this.props.saving || this.props.supplierArticleBusy || this.isFullyLedgered()}
|
||||||
|
onClick={this.handleSearchArticle}
|
||||||
|
sx={{
|
||||||
|
fontSize: '0.7rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
minWidth: 'auto',
|
||||||
|
py: 0.25,
|
||||||
|
px: 1,
|
||||||
|
color: 'primary.main',
|
||||||
|
'&:hover': {
|
||||||
|
bgcolor: 'primary.50',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Artikel neu zuordnen
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Brand */}
|
{/* Brand */}
|
||||||
{cachedArticle.brand?.name && (
|
{cachedArticle.brand?.name && (
|
||||||
<BrandLabel
|
<BrandLabel
|
||||||
@@ -1124,6 +1148,30 @@ class ManifestFormLine extends PureComponent {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{this.props.onSearchArticle && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
|
||||||
|
disabled={this.props.saving || this.props.supplierArticleBusy || this.isFullyLedgered()}
|
||||||
|
onClick={this.handleSearchArticle}
|
||||||
|
sx={{
|
||||||
|
fontSize: '0.7rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
minWidth: 'auto',
|
||||||
|
py: 0.25,
|
||||||
|
px: 1,
|
||||||
|
color: 'primary.main',
|
||||||
|
'&:hover': {
|
||||||
|
bgcolor: 'primary.50',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Artikel neu zuordnen
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Brand */}
|
{/* Brand */}
|
||||||
{(fullArticle.brand?.name || article.brand?.name) && (
|
{(fullArticle.brand?.name || article.brand?.name) && (
|
||||||
<BrandLabel
|
<BrandLabel
|
||||||
@@ -1307,6 +1355,34 @@ class ManifestFormLine extends PureComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.onSearchArticle) {
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, py: 0.25 }}>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
startIcon={<SearchIcon sx={{ fontSize: 14 }} />}
|
||||||
|
disabled={this.isFullyLedgered()}
|
||||||
|
onClick={this.handleSearchArticle}
|
||||||
|
sx={{
|
||||||
|
fontSize: '0.7rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
minWidth: 'auto',
|
||||||
|
py: 0.25,
|
||||||
|
px: 1,
|
||||||
|
color: 'primary.main',
|
||||||
|
'&:hover': {
|
||||||
|
bgcolor: 'primary.50',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Artikel suchen
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -576,6 +576,20 @@ class LieferungNeuPage extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// If this line was previously mapped to a different article, unlink the old supplier article
|
||||||
|
const existingSupplierArticle =
|
||||||
|
(line?.key != null ? this.state.supplierArticlesByLineKey?.[line.key] : null) ||
|
||||||
|
(supplierSku ? (this.state.supplierArticlesMap?.[supplierSku.toLowerCase()] || this.state.supplierArticlesMap?.[supplierSku]) : null);
|
||||||
|
const oldInternalSku = existingSupplierArticle?.article?.sku;
|
||||||
|
const oldAssignmentId = existingSupplierArticle?.id;
|
||||||
|
if (oldInternalSku && oldAssignmentId != null && String(oldInternalSku).toLowerCase() !== String(internalSku).toLowerCase()) {
|
||||||
|
try {
|
||||||
|
await this.automat.actions.unlinkSupplierArticle(oldInternalSku, oldAssignmentId, line?.key);
|
||||||
|
} catch (unlinkErr) {
|
||||||
|
console.warn('Vorherige Lieferanten-Zuordnung konnte nicht gelöst werden:', unlinkErr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await articleApi.addSupplier(internalSku, {
|
await articleApi.addSupplier(internalSku, {
|
||||||
entityId: partyId,
|
entityId: partyId,
|
||||||
sku: supplierSku || undefined,
|
sku: supplierSku || undefined,
|
||||||
@@ -587,13 +601,16 @@ class LieferungNeuPage extends PureComponent {
|
|||||||
|
|
||||||
if (supplierSku) {
|
if (supplierSku) {
|
||||||
await this.automat.actions.fetchSupplierArticleForSku(supplierSku, line.key);
|
await this.automat.actions.fetchSupplierArticleForSku(supplierSku, line.key);
|
||||||
|
} else {
|
||||||
|
await this.automat.actions.fetchSupplierArticleForSku(internalSku, line.key);
|
||||||
}
|
}
|
||||||
await this.automat.actions.fetchSupplierArticles(partyId);
|
await this.automat.actions.fetchSupplierArticles(partyId);
|
||||||
|
|
||||||
if (!line.name && article.name) {
|
if (!line.name || (existingSupplierArticle?.article?.name && line.name === existingSupplierArticle.article.name)) {
|
||||||
this.automat.actions.updateLineitem({
|
this.automat.actions.updateLineitem({
|
||||||
...line,
|
...line,
|
||||||
name: article.name,
|
name: article.name || line.name,
|
||||||
|
...(!line.sku ? { sku: internalSku } : {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user