From 56105b2448b1725f6f7d587f85d9e06d9544d2d4 Mon Sep 17 00:00:00 2001 From: Water-Zi <928069358@qq.com> Date: Thu, 18 May 2023 16:54:52 +0800 Subject: [PATCH] Added columns to the components list to display the quantity. To improve efficiency during the SMT assembly process, I have added a new column in the component list to display the quantity. Users can enable or disable the display of this column using checkboxes. However, there are the following unresolved issues: Unable to determine if the quantity of PCBs has been modified for automatic updating of the list (related to modifying components associated with reference markers). I lack knowledge in JavaScript and don't know how to retrieve HTML element IDs. It appears that passing parameters is necessary, but implementing this change would require significant modifications to existing code. I hope the author can suggest a better approach for retrieving the parameters. After adding the extra column, the overall width of the original list may be insufficient. Although it's possible to slightly increase the list's width, I have refrained from making modifications to maintain code consistency. --- html/index.html | 14 ++++++++++++-- html/pos_list.js | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/html/index.html b/html/index.html index 79f95f6..27ef213 100644 --- a/html/index.html +++ b/html/index.html @@ -192,7 +192,15 @@

Preload

Components

- + + +   + +  |  + +
+
+ Current: -- / --  |  -- -- -- --  |  Height: -- @@ -205,7 +213,9 @@

Components

Footprint Offset - Value Reference + Value + Quantity
(pre PCB) Quantity
(total) + Reference X Y R diff --git a/html/pos_list.js b/html/pos_list.js index 1dc0ad9..0bf3f47 100644 --- a/html/pos_list.js +++ b/html/pos_list.js @@ -77,9 +77,14 @@ function search_comp_parents(comp, set_color=false, color='') for (let elm of value_list) { if (elm.contains(comp_elm)) { let sub0 = elm.querySelector('td'); + let quantity_list = elm.querySelectorAll('.list_quantity'); parents[1] = sub0.innerText; - if (set_color) + if (set_color) { sub0.style.backgroundColor = color; + for (let quan_elm of quantity_list) { + quan_elm.style.backgroundColor = color; + } + } break; } } @@ -246,9 +251,23 @@ function pos_to_page(pos) { ${readable_float(comp[3])} `; } + let list_quantity_pre_pcb_html = ''; + if (document.getElementById('quantity_pre_pcb').checked) { + list_quantity_pre_pcb_html = ` + ${pos[footprint][value].length} + `; + } + let list_quantity_total_html = ''; + if (document.getElementById('quantity_total').checked) { + list_quantity_total_html = ` + ${csa.fiducial_cam.length * pos[footprint][value].length} + `; + } html_value += ` ${value} + ${list_quantity_pre_pcb_html} + ${list_quantity_total_html} @@ -258,11 +277,14 @@ function pos_to_page(pos) { `; } + let colspan_counter = 5 + colspan_counter += document.getElementById('quantity_pre_pcb').checked ? 1 : 0 + colspan_counter += document.getElementById('quantity_total').checked ? 1 : 0 let html = ` -
${footprint} -- + ${html_value} @@ -443,6 +465,17 @@ window.btn_select_board = async function (idx) { await select_comp(search_current_comp()); }; +async function update_pos(id="", column="") { + if (id != '' && column != '') { + let checkBox = document.getElementById(id); + let elm = document.getElementById(column); + elm.style.display = checkBox.checked ? '' : 'none'; + } + let pos = await db.get('tmp', 'list'); + if (pos) + pos_to_page(pos); +}; +window.update_pos = update_pos; export { search_comp_parents, search_next_comp, search_current_comp, search_first_comp, select_comp, move_to_comp,