2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Print part labels

This commit is contained in:
Oliver
2021-07-08 22:54:41 +10:00
parent c39f705ef7
commit 15cb1e0005
4 changed files with 61 additions and 2 deletions

View File

@ -105,6 +105,61 @@ function printStockLocationLabels(locations, options={}) {
}
function printPartLabels(parts, options={}) {
/**
* Print labels for the provided parts
*/
if (parts.length == 0) {
showAlertDialog(
'{% trans "Select Parts" %}',
'{% trans "Part(s) must be selected before printing labels" %}',
);
return;
}
// Request available labels from the server
inventreeGet(
'{% url "api-part-label-list" %}',
{
enabled: true,
parts: parts,
},
{
success: function(response) {
if (response.length == 0) {
showAlertDialog(
'{% trans "No Labels Found" %}',
'{% trans "No labels found which match the selected part(s)" %}',
);
return;
}
// Select label to print
selectLabel(
response,
parts,
{
success: function(pk) {
var url = `/api/label/part/${pk}/print/?`;
parts.forEach(function(part) {
url += `parts[]=${part}&`;
});
window.location.href = url;
}
}
);
}
}
);
}
function selectLabel(labels, items, options={}) {
/**
* Present the user with the available labels,