u
This commit is contained in:
@@ -13,6 +13,7 @@ import ManifestHeader from './ManifestHeader';
|
||||
import ManifestLines from './ManifestLines';
|
||||
import ManifestPdfDialog from './ManifestPdfDialog';
|
||||
import ArticleSearchDialog from './ArticleSearchDialog';
|
||||
import artikelAutomat, { getArticle } from '../../automats/artikelAutomat';
|
||||
import {
|
||||
buildManifestBody,
|
||||
restoreAttachmentsFromApi,
|
||||
@@ -55,6 +56,7 @@ class ManifestForm extends PureComponent {
|
||||
this.handleExternalNumberChange =
|
||||
this.handleExternalNumberChange.bind(this);
|
||||
this.handleLineChange = this.handleLineChange.bind(this);
|
||||
this.handleSkuBlur = this.handleSkuBlur.bind(this);
|
||||
this.handleAddLine = this.handleAddLine.bind(this);
|
||||
this.handleAddArticleLine = this.handleAddArticleLine.bind(this);
|
||||
this.handleOpenArticleSearchForLine = this.handleOpenArticleSearchForLine.bind(this);
|
||||
@@ -208,6 +210,47 @@ class ManifestForm extends PureComponent {
|
||||
}));
|
||||
}
|
||||
|
||||
async handleSkuBlur(key, sku) {
|
||||
const trimmed = String(sku ?? '').trim();
|
||||
if (!trimmed) return;
|
||||
try {
|
||||
const art = getArticle(trimmed) || (await artikelAutomat.actions.loadArticle(trimmed));
|
||||
if (art && !this._cancelled) {
|
||||
this.setState((prev) => ({
|
||||
lines: prev.lines.map((l) => {
|
||||
if (l.key !== key) return l;
|
||||
const netVal =
|
||||
art.price != null
|
||||
? String(art.price)
|
||||
: art.vknetto != null
|
||||
? String(art.vknetto)
|
||||
: art.net != null
|
||||
? String(art.net)
|
||||
: '';
|
||||
const taxVal =
|
||||
art.taxrate != null
|
||||
? String(art.taxrate)
|
||||
: art.tax != null
|
||||
? String(art.tax)
|
||||
: '';
|
||||
return {
|
||||
...l,
|
||||
sku: art.sku || l.sku,
|
||||
name: art.name || l.name || '',
|
||||
tax: l.tax || taxVal,
|
||||
taxrate: l.taxrate || taxVal,
|
||||
net: l.net || netVal,
|
||||
netprice: l.netprice || netVal,
|
||||
unit: art.unit || l.unit || 'Stück',
|
||||
};
|
||||
}),
|
||||
}));
|
||||
}
|
||||
} catch {
|
||||
// not in catalog or load error; preserve user entry
|
||||
}
|
||||
}
|
||||
|
||||
handleAddLine() {
|
||||
this.setState((prev) => ({ lines: [...prev.lines, emptyLine()] }));
|
||||
}
|
||||
@@ -266,7 +309,15 @@ class ManifestForm extends PureComponent {
|
||||
}
|
||||
|
||||
handleAssignArticleForLine(article, targetLine) {
|
||||
if (!article || !targetLine) return;
|
||||
if (!article) return;
|
||||
if (!targetLine) {
|
||||
this.handleAddArticleLine(article);
|
||||
this.setState({
|
||||
articleSearchDialogOpen: false,
|
||||
articleSearchLine: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const netVal =
|
||||
article.price != null
|
||||
? String(article.price)
|
||||
@@ -513,12 +564,14 @@ class ManifestForm extends PureComponent {
|
||||
|
||||
return (
|
||||
<ManifestLines
|
||||
kind={cfg.kind}
|
||||
columns={cfg.columns}
|
||||
lines={lines}
|
||||
saving={saving}
|
||||
wide={4}
|
||||
linesColor={cfg.linesColor}
|
||||
onLineChange={this.handleLineChange}
|
||||
onSkuBlur={this.handleSkuBlur}
|
||||
onAddLine={this.handleAddLine}
|
||||
onAddArticleLine={this.handleAddArticleLine}
|
||||
onSearchArticle={this.handleOpenArticleSearchForLine}
|
||||
@@ -597,6 +650,7 @@ class ManifestForm extends PureComponent {
|
||||
<ArticleSearchDialog
|
||||
open={this.state.articleSearchDialogOpen}
|
||||
line={this.state.articleSearchLine}
|
||||
kind={kind}
|
||||
onClose={this.handleCloseArticleSearch}
|
||||
onAssign={this.handleAssignArticleForLine}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user