版本:v1.0.1
狀態:最終版
最後更新日期:2026-11-24
文件目的
說明託運總表的格式、欄位規則用途與應用情境
- 使用地方:
- 司機到場收貨/取件以及批次出貨核對時使用
- 每次請準備一式兩份:一份給司機帶回、一份司機簽名由寄件方自己留存作對帳與備查依據
欄位定義
| 編號 | 欄位名稱 | 欄位名稱 | 說明 |
|---|---|---|---|
| 1 | 發送日期 | esdate | |
| 2 | 客代 | escsno | 請帶入客代+公司名稱 ex:93938482 XX寶-Sog |
| 3 | 列印時間 | 列印託運總扁表時間 | |
| 4 | 序 | 流水號 | |
| 5 | 查貨號碼 | edelno | |
| 6 | 到著站 | erstno | |
| 7 | 收貨人 | ercsig | |
| 8 | 收貨人地址 | eraddr | |
| 9 | 收件電話 | ertel1 | |
| 10 | 件數 | ejamt | 請參考【商品重量-件數】說明 |
| 11 | 傳票區分 | eprdct | 請參考【傳票區分-簡稱】說明 |
| 12 | 代收貨款 | eqmny | |
| 13 | 報值金額 | egamt | |
| 14 | 訂單編號 | epino | |
| 15 | 備註 | emark | |
| 16 | 重量 | eqamt | 請參考【商品重量-重量單位】說明 |
| 17 | 收貨司機簽收 | ||
| 18 | 客戶簽收 | ||
| 19 | 收貨日 |
範例

範例程式碼
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<title>新竹物流託運總表</title>
<style>
@page {
size: A4 landscape;
margin: 8mm;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-family: "Microsoft JhengHei", Arial, sans-serif;
color: #000;
}
.page {
width: 277mm;
min-height: 190mm;
border: 1px solid #000;
padding: 5mm;
margin: auto;
}
.header {
text-align: center;
font-size: 18pt;
font-weight: bold;
margin-bottom: 4mm;
}
.info {
display: flex;
justify-content: space-between;
font-size: 10pt;
line-height: 18px;
}
.table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
font-size: 8.5pt;
margin-top: 5mm;
}
.table th {
border: 1px solid #000;
text-align: center;
vertical-align: middle;
padding: 3px;
height: 25px;
white-space: nowrap;
}
.table td {
border: 1px solid #000;
padding: 3px;
height: 45px;
vertical-align: top;
word-break: break-all;
}
/* 欄位寬度 */
.table th:nth-child(1),
.table td:nth-child(1) {
width: 3%;
}
.table th:nth-child(2),
.table td:nth-child(2) {
width: 8%;
}
.table th:nth-child(3),
.table td:nth-child(3) {
width: 5%;
}
.table th:nth-child(4),
.table td:nth-child(4) {
width: 7%;
}
.table th:nth-child(5),
.table td:nth-child(5) {
width: 18%;
}
.table th:nth-child(6),
.table td:nth-child(6) {
width: 8%;
}
.table th:nth-child(7),
.table td:nth-child(7) {
width: 4%;
}
.table th:nth-child(8),
.table td:nth-child(8) {
width: 5%;
}
.table th:nth-child(9),
.table td:nth-child(9) {
width: 6%;
}
.table th:nth-child(10),
.table td:nth-child(10) {
width: 7%;
}
.table th:nth-child(11),
.table td:nth-child(11) {
width: 7%;
}
.table th:nth-child(12),
.table td:nth-child(12) {
width: 13%;
}
.table th:nth-child(13),
.table td:nth-child(13) {
width: 9%;
}
.center {
text-align: center;
vertical-align: middle !important;
}
.number {
text-align: right;
}
.no-data {
text-align: center;
vertical-align: middle !important;
height: 60px !important;
font-size: 11pt;
}
.footer {
margin-top: 8mm;
display: flex;
justify-content: flex-end;
gap: 50mm;
font-size: 11pt;
}
.sign-area {
margin-top: 15mm;
display: flex;
justify-content: space-between;
font-size: 11pt;
white-space: nowrap;
}
.sign-box {
width: auto;
}
.line {
display: inline-block;
width: 120px;
border-bottom: 1px solid #000;
margin-left: 5px;
height: 18px;
}
/* 列印 */
@media print {
body {
margin: 0;
padding: 0;
}
.page {
width: 100%;
min-height: auto;
border: none;
margin: 0;
}
/* 避免一筆資料被切成兩頁 */
.table tr {
page-break-inside: avoid;
break-inside: avoid;
}
/* 多頁列印時重複表頭 */
.table thead {
display: table-header-group;
}
.footer,
.sign-area {
page-break-inside: avoid;
break-inside: avoid;
}
}
</style>
</head>
<body>
<div class="page">
<!-- 標題 -->
<div class="header">新竹物流託運總表</div>
<!-- 基本資料 -->
<div class="info">
<div>發送日期:
<span id="sendDate"></span>
</div>
<div>印表日期:
<span id="printDate"></span>
</div>
</div>
<div class="info">
<div>客代:
<span id="customerCode"></span>
</div>
</div>
<!-- 明細 -->
<table class="table">
<thead>
<tr>
<th>序</th>
<th>查貨號碼</th>
<th>到著站</th>
<th>收貨人名稱</th>
<th>收貨人地址</th>
<th>收貨人電話</th>
<th>件數</th>
<th>重量</th>
<th>傳票區分</th>
<th>代收貨款</th>
<th>報值金額</th>
<th>訂單編號</th>
<th>備註</th>
</tr>
</thead>
<tbody id="detailBody"></tbody>
</table>
<!-- 合計 -->
<div class="footer">
<div>合計:
<span id="totalRows">0</span>筆
</div>
<div>總計:
<span id="totalQty">0</span>
件
</div>
</div>
<!-- 簽收 -->
<div class="sign-area">
<div class="sign-box">收貨司機簽收:
<span class="line"></span>
</div>
<div class="sign-box">客戶簽收:
<span class="line"></span>
</div>
<div class="sign-box">收貨日:
<span class="line"></span>
</div>
</div>
</div>
<script>
// 基本資料
const printInfo = {
sendDate: "2025/05/21",
printDate: "2025/05/21 16:35",
customerCode: "93938482 XX寶-Sog"
};
// 託運資料
const data = [
{
trackingNo: "0000000001",
station: "1247",
name: "王小明",
address: "臺北市士林區中山北路六段193號",
phone: "0900000000",
qty: 1,
weight: "1才",
type: "代收",
codAmount: 222,
declaredAmount: 1000,
orderNo: "01234567890123456789",
remark: "我是備註(OK)"
}
];
function escapeHtml(value) {
if (value === null || value === undefined) {
return "";
}
return String(value)
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
// 金額格式
function formatNumber(value) {
if (
value === null ||
value === undefined ||
value === ""
) {
return "";
}
const number = Number(value);
if (isNaN(number)) {
return escapeHtml(value);
}
return number.toLocaleString("zh-TW");
}
// 顯示基本資料
function renderInfo() {
document.getElementById("sendDate").textContent =
printInfo.sendDate;
document.getElementById("printDate").textContent =
printInfo.printDate;
document.getElementById("customerCode").textContent =
printInfo.customerCode;
}
// 顯示多筆明細
function renderTable() {
const tbody =
document.getElementById("detailBody");
let html = "";
let totalQty = 0;
// 沒有資料
if (data.length === 0) {
document.getElementById("totalRows").textContent = 0;
document.getElementById("totalQty").textContent = 0;
return;
}
// 多筆資料
data.forEach(function(item, index) {
const qty =
Number(item.qty) || 0;
totalQty += qty;
html += `
<tr>
<td class="center">
${index + 1}
</td>
<td class="center">
${escapeHtml(item.trackingNo)}
</td>
<td class="center">
${escapeHtml(item.station)}
</td>
<td>
${escapeHtml(item.name)}
</td>
<td>
${escapeHtml(item.address)}
</td>
<td class="center">
${escapeHtml(item.phone)}
</td>
<td class="center">
${qty}
</td>
<td class="center">
${escapeHtml(item.weight)}
</td>
<td class="center">
${escapeHtml(item.type)}
</td>
<td class="number">
${formatNumber(item.codAmount)}
</td>
<td class="number">
${formatNumber(item.declaredAmount)}
</td>
<td>
${escapeHtml(item.orderNo)}
</td>
<td>
${escapeHtml(item.remark)}
</td>
</tr>
`;
});
// 將資料放進 tbody
tbody.innerHTML = html;
// 合計筆數
document.getElementById("totalRows").textContent =
data.length;
// 總件數
document.getElementById("totalQty").textContent =
totalQty;
}
// 初始化
renderInfo();
renderTable();
</script>
</body>
</html>
