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