mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #914 from SchrodingersGat/recursive-bom
Bugfix: Recursive BOM display
This commit is contained in:
commit
71f3662ebc
@ -280,7 +280,9 @@ function loadBomTable(table, options) {
|
||||
params.sub_part_detail = true;
|
||||
}
|
||||
|
||||
function requestSubItems(part_pk) {
|
||||
// Function to request BOM data for sub-items
|
||||
// This function may be called recursively for multi-level BOMs
|
||||
function requestSubItems(bom_pk, part_pk) {
|
||||
|
||||
inventreeGet(
|
||||
options.bom_url,
|
||||
@ -291,10 +293,17 @@ function loadBomTable(table, options) {
|
||||
{
|
||||
success: function(response) {
|
||||
for (var idx = 0; idx < response.length; idx++) {
|
||||
response[idx].parentId = part_pk;
|
||||
|
||||
response[idx].parentId = bom_pk;
|
||||
|
||||
if (response[idx].sub_part_detail.assembly) {
|
||||
requestSubItems(response[idx].pk, response[idx].sub_part)
|
||||
}
|
||||
}
|
||||
|
||||
table.bootstrapTable('append', response);
|
||||
|
||||
table.treegrid('collapseAll');
|
||||
},
|
||||
error: function() {
|
||||
console.log('Error requesting BOM for part=' + part_pk);
|
||||
@ -303,13 +312,14 @@ function loadBomTable(table, options) {
|
||||
)
|
||||
}
|
||||
|
||||
table.bootstrapTable({
|
||||
table.inventreeTable({
|
||||
treeEnable: true,
|
||||
rootParentId: options.parent_id,
|
||||
idField: 'sub_part',
|
||||
idField: 'pk',
|
||||
uniqueId: 'pk',
|
||||
parentIdField: 'part',
|
||||
parentIdField: 'parentId',
|
||||
treeShowField: 'sub_part',
|
||||
showColumns: true,
|
||||
sortable: true,
|
||||
search: true,
|
||||
rowStyle: function(row, index) {
|
||||
@ -351,7 +361,7 @@ function loadBomTable(table, options) {
|
||||
table.bootstrapTable('updateRow', idx, row, true);
|
||||
|
||||
if (row.sub_part_detail.assembly) {
|
||||
requestSubItems(row.sub_part);
|
||||
requestSubItems(row.pk, row.sub_part);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user