问题
As i am new to the framework and nodejs, i was wondering if this can be possible to do it. I have a table from database which contains dynamic values in addition with the table(several columns). I have couple of columns which contains comments section which are with prices and also price column.
I have a button Download with price(only checked boxes should download with all the columns as pdf)- "Something like invoice"
I have second button Download without price(only checked boxes should download with all the columns except one or two columns as pdf)- "Something like invoice"
Note: The current problem with the table is even though when the check box is enabled or not all the records are stored in database. I would also like to know if this possible with javascript or nodejs to submit only selected one's.
So far the connection and routing is done only things are to save and download.
<!DOCTYPE html>
<html lang="en">
<head>
<%- include ../partials/head %>
<link href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
</head>
<body>
<% include ../partials/menu %>
<form action="/dist/Add/<%= idpacking %>/<%= AWBNo %>" method="post" name="form1">
<div class="container-fluid bg-3 text-center">
<div class="container">
<h3>Distributor information</h3><br>
<ul class="list-inline">
<li class="list-inline-item">AWB No:<%= AWBNo %></li>
<li class="list-inline-item">Date:<%= AWBNo %></li>
<li class="list-inline-item">Land:<%= AWBNo %></li>
<li class="list-inline-item">Lieferant:<%= AWBNo %></li>
</ul>
<!-- <% if (messages.error) { %>
<p style="color:red"><%- messages.error %></p>
<% } %> -->
<% if (messages.success) { %>
<p class="alert alert-success mt-4"><%- messages.success %></p>
<% } %>
<br>
<div class="btn-group btn-group-justified">
<a href="#" class="btn btn-primary">Save</a>
<a href="#" class="btn btn-primary">Download With Price</a>
<a href="#" class="btn btn-primary">Download Without Price</a>
</div>
<br>
<div class="container1">
<div class="row">
<div class="col-12">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col" style="text-align:center;">Box No.</th>
<th scope="col" style="text-align:center;">Produkt Name</th>
<th scope="col" style="text-align:center;">Gew.</th>
<th scope="col" style="text-align:center;">Stk.</th>
<th scope="col" style="text-align:center;">Kunde</th>
<th scope="col" style="text-align:center;">Preis</th>
<th scope="col" style="text-align:center;">Spedition</th>
<th scope="col" style="text-align:center;">Verteillungs-Tag</th>
<th scope="col" style="text-align:center;">Res</th>
<th scope="col" style="text-align:center;">Bestell-Nr.</th>
<th scope="col" style="text-align:center;">Notiz</th>
<th scope="col" style="text-align:center;">Teilen</th>
<th scope="col" style="text-align:center;">Liefersch</th>
</tr>
</thead>
<tbody>
<% if(data.length){
for(var i = 0; i< data.length; i++) {%>
<input type="hidden" value= "<%= data[i].ProductId%>" name="ProductId">
<tr>
<td>
<input type="checkbox" class="custom-control-input" id="Check_Row" name="Check_Row" checked>
<label class="custom-control-label" for="customCheck1"><%= i+1 %></label>
</td>
<td><%= data[i].P_Name%></td>
<td>
<input type="number" class="custom-number" min="0" max="<%= data[i].Weight%>" id="Weight" name="Weight" style="width: 7em" value="<%= data[i].Weight%>">
</td>
<td>
<input type="number" class="custom-stk1" id="Pcs" name="Pcs" style="width: 7em" value="<%= data[i].Pcs%>" >
</td>
<td class="select">
<select id="Distributor" name="Distributor" >
<option value=""></option>
<option value="1">YinSeaFood</option>
<option value="2">YinSeaFood1</option>
<option value="3">YinSeaFood2</option>
<option value="4">YinSeaFood3</option>
</select>
</td>
<td>
<div class="input-group">
<span class="input-group-addon">€</span>
<input type="number" value="<%= data[i].P_Price %>" min="0" step="0.01" data-number-to-fixed="2" data-number-stepfactor="100"
class="form-control currency" id="Price" name="Price" style="width: 7em"/>
</td>
<td class="select">
<select id="carrier" name="carrier">
<option value=""></option>
<option value="1">DHL</option>
<option value="2">HERMES</option>
<option value="3">UPS</option>
<option value="4">Fedex</option>
</select>
</td>
<td>
<input type="text" name="DOD" style="width: 9.5em" class="date-picker">
</td>
<td>
<input type="date" name="ResDate" style="width: 9.5em">
</td>
<td>
<input type="textbox" name="OrderNo" style="width: 9.5em">
</td>
<td>
<input type="textbox" name="Note" style="width: 9.5em" >
</td>
<td>
<input type="radio" name="Partition" id="Gew" class="responsive">
<label for="yes">Gew.</label>
<input type="radio" name="Partition" id="Stk" class="responsive">
<label for="no">Stk.</label>
</td>
<td>
<textarea name="Comment" id="Comment">
</textarea>
</td>
</tr>
<% }
}else{ %>
<tr>
<td colspan="3">No Product</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div>
<script>
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
date = date.split("/").reverse().join("-");
$(".date-picker").val(date);
</script>
</body>
</html>
来源:https://stackoverflow.com/questions/56872451/download-pdf-file-with-only-selected-checkboxes-from-table