u
This commit is contained in:
@@ -5,10 +5,11 @@ import { http } from './http.js';
|
||||
* Shape: LabelTemplate = { id, company_id, name, width, height, dpi, type, content, thumb }
|
||||
*/
|
||||
export const labeltemplate = {
|
||||
/** GET /api/labeltemplate → { labeltemplates: LabelTemplate[] } */
|
||||
/** GET /api/labeltemplate(?sku=...) → { labeltemplates: LabelTemplate[] } */
|
||||
// #region GET /api/labeltemplate — list
|
||||
list() {
|
||||
return http('/api/labeltemplate');
|
||||
list(params) {
|
||||
const search = params?.sku ? `?sku=${encodeURIComponent(params.sku)}` : '';
|
||||
return http(`/api/labeltemplate${search}`);
|
||||
},
|
||||
// #endregion
|
||||
|
||||
|
||||
@@ -82,15 +82,27 @@ export default class ArticleLabelTab extends PureComponent {
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (
|
||||
prevProps.article?.sku !== this.props.article?.sku ||
|
||||
prevProps.article?.name !== this.props.article?.name ||
|
||||
prevProps.article?.prices !== this.props.article?.prices ||
|
||||
prevProps.article?.eans !== this.props.article?.eans
|
||||
) {
|
||||
this.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unsub?.();
|
||||
}
|
||||
|
||||
async loadData() {
|
||||
this.setState({ loading: true, error: null });
|
||||
const sku = this.props.article?.sku;
|
||||
try {
|
||||
const [resTemplates] = await Promise.all([
|
||||
labeltemplate.list(),
|
||||
labeltemplate.list(sku ? { sku } : undefined),
|
||||
companyAutomat.actions.loadAgentPrinters().catch(() => companyAutomat.state.agentprinters),
|
||||
]);
|
||||
|
||||
@@ -139,6 +151,7 @@ export default class ArticleLabelTab extends PureComponent {
|
||||
try {
|
||||
await article.printLabel(articleData.sku, {
|
||||
templateId: selectedTemplateId,
|
||||
agentprinterId: selectedPrinterId,
|
||||
printerId: selectedPrinterId,
|
||||
quantity,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user