Browse Source

first commit

liuhairui 2 months ago
parent
commit
cdeb831c69

+ 1 - 1
application/.htaccess

@@ -1 +1 @@
-deny from all
+deny from all

File diff suppressed because it is too large
+ 410 - 390
application/admin/controller/Deliver.php


File diff suppressed because it is too large
+ 1038 - 168
application/admin/controller/QcodeAdd.php


+ 1 - 0
application/admin/lang/zh-cn/qcode_bach.php

@@ -12,6 +12,7 @@ return [
     'Large_num'         => '大件数量',
     'Print_date'        => '打印日期',
     'Company_name'      => '公司名称',
+    'Actual_quantity'      => '汇总',
 
     'Code'              => '标签代码',
     'P_nums'            => '打印次数',

+ 157 - 36
application/admin/view/deliver/apply.html

@@ -1,52 +1,173 @@
 <style>
-     /*默认背景颜色 */
+    /* 默认背景颜色 */
     .table tbody tr.selected {
-        background-color: yellow !important;  /* 选中行背景色为黄色 */
+        background-color: yellow !important;
+    }
+    .table-detail tbody tr.selected {
+        background-color: yellow !important;
+    }
+
+    /* 布局样式 */
+    .container-wrapper {
+        display: flex;
+        width: 100%;
+        position: relative;
+    }
+    #date-sidebar {
+        width: 200px;
+        background: #f8f9fa;
+        border-right: 1px solid #dee2e6;
+        height: 64vh;
+        overflow-y: auto;
+        transition: all 0.3s ease;
+    }
+    #date-sidebar.collapsed {
+        width: 0;
+        overflow: hidden;
+        border-right: none;
+    }
+    .content-area {
+        flex: 1;
+        padding: 15px;
+        overflow-y: auto;
+        transition: all 0.3s ease;
+    }
+    .sidebar-toggle {
+        position: absolute;
+        left: 200px;
+        top: 0px;
+        z-index: 1000;
+        background: #f8f9fa;
+        border: 1px solid #dee2e6;
+        border-left: none;
+        border-radius: 0 4px 4px 0;
+        padding: 5px 10px;
+        cursor: pointer;
+        transition: all 0.3s ease;
+    }
+    #date-sidebar.collapsed + .sidebar-toggle {
+        left: 0;
+    }
+
+    /* 树形导航样式 */
+    .nav-sidebar {
+        padding-left: 0;
+        list-style: none;
+    }
+    .nav-sidebar .nav-item {
+        position: relative;
+    }
+    .nav-sidebar .nav-link {
+        display: block;
+        padding: 8px 15px;
+        color: #333;
+        text-decoration: none;
+        transition: all 0.2s;
+    }
+    .nav-sidebar .nav-link:hover {
+        background-color: #e9ecef;
+    }
+    .nav-sidebar .nav-link .fa {
+        margin-right: 5px;
+        width: 15px;
+        text-align: center;
+    }
+    .nav-sidebar .children {
+        padding-left: 20px;
+        display: none;
+    }
+    .nav-sidebar .expanded > .children {
+        display: block;
+    }
+    .nav-sidebar .has-children > .nav-link:after {
+        content: "\f054";
+        font-family: "FontAwesome";
+        position: absolute;
+        right: 15px;
+        top: 10px;
+        font-size: 12px;
+        transition: transform 0.2s;
+    }
+    .nav-sidebar .has-children.expanded > .nav-link:after {
+        transform: rotate(90deg);
+    }
+    .nav-sidebar .active > .nav-link {
+        background-color: #e9ecef;
+        font-weight: bold;
     }
-     .table-detail tbody tr.selected {
-         background-color: yellow !important;  /* 选中行背景色为黄色 */
-     }
 
 </style>
-<div class="row" style="font-size: 12px;">
-    <div class="panel panel-default panel-intro">
-        <div class="panel-body">
-            <div id="myTabContent" class="tab-content">
-                <div class="tab-pane fade active in row" id="one">
-                    <div class="widget-body no-padding">
-                        <div id="toolbar" class="toolbar">
-                            <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> 刷新</a>
+
+<div class="container-wrapper">
+    <!-- 左侧日期侧边栏 -->
+    <div id="date-sidebar">
+        <div class="sidebar-header" style="padding: 10px 15px; background: #e9ecef; font-weight: bold;">
+<!--            <i class="fa fa-calendar"></i> 发货日期-->
+        </div>
+        <ul class="nav nav-sidebar" id="date-nav">
+            <!-- 数据将通过JavaScript动态加载 -->
+            <li class="nav-item">
+                <a href="javascript:;" class="nav-link loading-text">
+                    <i class="fa fa-spinner fa-spin"></i> 加载中...
+                </a>
+            </li>
+        </ul>
+    </div>
+
+    <!-- 展开/收缩按钮 -->
+    <div class="sidebar-toggle" id="sidebarToggle">
+        <i class="fa fa-chevron-left"></i>
+    </div>
+
+    <!-- 右侧内容区域 -->
+    <div class="content-area" id="contentArea">
+        <!-- 内容保持不变 -->
+        <div class="row" style="font-size: 12px;">
+            <div class="panel panel-default panel-intro">
+                <div class="panel-body">
+                    <div id="myTabContent" class="tab-content">
+                        <div class="tab-pane fade active in row" id="one">
+                            <div class="widget-body no-padding">
+                                <table id="table2" class="table table-striped table-bordered table-hover table-nowrap"
+                                       data-operate-edit=""
+                                       data-search="false" data-show-toggle="false"
+                                       data-show-columns="false" data-show-export="false"
+                                       data-common-search="false"
+                                       data-operate-del="{:$auth->check('deliver/apply_del')}"
+                                       style="height: 300px;"
+                                       width="100%">
+                                </table>
+                            </div>
                         </div>
-                        <table id="table2" class="table table-striped table-bordered table-hover table-nowrap"
-                               data-operate-edit=""
-                               data-search="false" data-show-toggle="false"
-                               data-show-columns="false" data-show-export="false"
-                               data-common-search="false"
-                               data-operate-del="{:$auth->check('deliver/apply_del')}"
-                               width="100%">
-                        </table>
                     </div>
                 </div>
             </div>
         </div>
-    </div>
-</div>
-<div class="row" style="font-size: 12px;">
-    <div class="panel panel-default panel-intro">
-        <div class="panel-body">
-            <div class="tab-content">
-                <div class="tab-pane fade active in row" id="two">
-                    <div class="widget-body no-padding">
-                        <table id="table-detail"
-                               class="table table-striped table-bordered table-hover"
-                               data-search="false" data-show-toggle="false"
-                               data-show-columns="false" data-show-export="false"
-                               data-common-search="false"
-                               width="100%">
-                        </table>
+
+        <div class="row" style="font-size: 12px;">
+            <div class="panel panel-default panel-intro">
+                <div class="panel-body">
+                    <div class="tab-content">
+                        <div class="tab-pane fade active in row" id="two">
+                            <div class="widget-body no-padding">
+                                <div id="toolbar2" class="toolbar">
+                                    <a href="javascript:;" class="btn btn-primary" id="addPalletBtn" title="新增">
+                                        <i class="fa fa-plus"></i> 新增
+                                    </a>
+                                </div>
+                                <table id="table-detail"
+                                       class="table table-striped table-bordered table-hover"
+                                       data-search="false" data-show-toggle="false"
+                                       data-show-columns="false" data-show-export="false"
+                                       data-common-search="false"
+                                       width="100%">
+                                </table>
+                            </div>
+                        </div>
                     </div>
                 </div>
             </div>
         </div>
     </div>
 </div>
+

+ 234 - 22
application/admin/view/deliver/dispatch.html

@@ -1,32 +1,244 @@
 <style>
     /* 默认背景颜色 */
-    .table tbody tr.selected {
-        background-color: yellow !important;  /* 选中行背景色为黄色 */
+    .table tbody tr.selected,
+    .table-detail tbody tr.selected {
+        background-color: yellow !important;
+    }
+
+    /* 主容器布局 */
+    .container-wrapper {
+        display: flex;
+        width: 100%;
+        height: 100%;
+        position: relative;
+        overflow: hidden;
+    }
+
+    /* 侧边栏样式 */
+    #date-sidebar {
+        width: 240px;
+        min-width: 240px;
+        background: #f8f9fa;
+        border-right: 1px solid #e0e0e0;
+        height: 100%;
+        overflow-y: auto;
+        transition: all 0.3s ease;
+        display: flex;
+        flex-direction: column;
+    }
+
+    #date-sidebar.collapsed {
+        transform: translateX(-100%);
+        width: 0;
+        min-width: 0;
+        border-right: none;
+    }
+
+    /* 侧边栏头部 */
+    .sidebar-header {
+        padding: 12px 16px;
+        background: #f0f2f5;
+        border-bottom: 1px solid #e0e0e0;
+        font-weight: 600;
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        flex-shrink: 0;
+    }
+
+    .sidebar-header i {
+        margin-right: 8px;
+        color: #555;
+    }
+
+    /* 侧边栏内容 */
+    .sidebar-content {
+        flex: 1;
+        overflow-y: auto;
+        padding: 8px 0;
+    }
+
+    /* 树形导航样式 */
+    .nav-sidebar {
+        padding-left: 0;
+        margin-bottom: 0;
+        list-style: none;
+    }
+
+    .nav-sidebar .nav-item {
+        position: relative;
+    }
+
+    .nav-sidebar .nav-link {
+        display: flex;
+        align-items: center;
+        padding: 8px 16px 8px 24px;
+        color: #333;
+        text-decoration: none;
+        transition: all 0.2s;
+        font-size: 13px;
+    }
+
+    .nav-sidebar .nav-link:hover {
+        background-color: #e6f7ff;
+    }
+
+    .nav-sidebar .nav-link .fa {
+        margin-right: 8px;
+        width: 16px;
+        text-align: center;
+        font-size: 14px;
+    }
+
+    .nav-sidebar .children {
+        padding-left: 24px;
+        display: none;
+    }
+
+    .nav-sidebar .expanded > .children {
+        display: block;
+    }
+
+    .nav-sidebar .has-children > .nav-link:after {
+        content: "\f078";
+        font-family: "FontAwesome";
+        position: absolute;
+        right: 16px;
+        top: 10px;
+        font-size: 10px;
+        transition: transform 0.2s;
+        color: #666;
+    }
+
+    .nav-sidebar .has-children.expanded > .nav-link:after {
+        transform: rotate(180deg);
+    }
+
+    .nav-sidebar .active > .nav-link {
+        background-color: #e6f7ff;
+        color: #1890ff;
+        font-weight: 500;
+    }
+
+    .nav-sidebar .nav-header {
+        padding: 8px 16px;
+        font-size: 12px;
+        color: #666;
+        font-weight: 600;
+        text-transform: uppercase;
+        letter-spacing: 0.5px;
+    }
+
+    /* 内容区域 */
+    .content-area {
+        flex: 1;
+        height: 100%;
+        overflow: auto;
+        padding: 16px;
+        background: #fff;
+        transition: all 0.3s ease;
+    }
+
+    /* 侧边栏切换按钮 */
+    .sidebar-toggle {
+        position: absolute;
+        left: 240px;
+        top: 16px;
+        z-index: 100;
+        background: #fff;
+        border: 1px solid #e0e0e0;
+        border-left: none;
+        border-radius: 0 4px 4px 0;
+        padding: 6px 8px;
+        cursor: pointer;
+        transition: all 0.3s ease;
+        box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
+    }
+
+    .sidebar-toggle:hover {
+        background: #f5f5f5;
+    }
+
+    #date-sidebar.collapsed + .sidebar-toggle {
+        left: 0;
+    }
+
+    #date-sidebar.collapsed + .sidebar-toggle i {
+        transform: rotate(180deg);
+    }
+
+    /* 加载状态 */
+    .loading-text {
+        color: #999;
+        justify-content: center;
+    }
+
+    .loading-text .fa {
+        margin-right: 8px;
+    }
+
+    /* 响应式调整 */
+    @media (max-width: 768px) {
+        #date-sidebar:not(.collapsed) {
+            position: absolute;
+            z-index: 1000;
+            height: 100%;
+            box-shadow: 2px 0 8px rgba(0,0,0,0.15);
+        }
+
+        .sidebar-toggle {
+            display: none;
+        }
     }
 </style>
-<div class="panel panel-default panel-intro">
-    <div class="panel-body">
-        <div id="myTabContent" class="tab-content">
-            <div class="tab-pane fade active in" id="one">
-                <div class="widget-body no-padding">
-                    <div id="toolbar" class="toolbar">
-                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-<!--                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('samplecompany/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
-<!--                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('samplecompany/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
-                    </div>
-                    <table id="table3" class="table table-striped table-bordered table-hover table-nowrap"
-                           data-operate-edit=""
-                           data-operate-del="{:$auth->check('deliver/dispatch_del')}"
-                           width="100%">
-                    </table>
-                </div>
-            </div>
 
+<div class="container-wrapper">
+    <!-- 左侧日期侧边栏 -->
+    <div id="date-sidebar">
+        <div class="sidebar-header">
+            <span><i class="fa fa-calendar"></i> 发货日期</span>
+        </div>
+        <div class="sidebar-content">
+            <ul class="nav nav-sidebar" id="date-nav">
+                <li class="nav-item">
+                    <a href="javascript:;" class="nav-link loading-text">
+                        <i class="fa fa-spinner fa-spin"></i> 加载中...
+                    </a>
+                </li>
+            </ul>
         </div>
     </div>
-</div>
-<div class="table" style="margin:0px 30px;">
-    <div id="printcode">
 
+    <!-- 展开/收缩按钮 -->
+    <div class="sidebar-toggle" id="sidebarToggle">
+        <i class="fa fa-chevron-left"></i>
+    </div>
+
+    <!-- 右侧内容区域 -->
+    <div class="content-area" id="contentArea">
+        <div class="panel panel-default panel-intro">
+            <div class="panel-body">
+                <div id="myTabContent" class="tab-content">
+                    <div class="tab-pane fade active in" id="one">
+                        <div class="widget-body no-padding">
+                            <div id="toolbar" class="toolbar">
+                                <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}">
+                                    <i class="fa fa-refresh"></i> 刷新
+                                </a>
+                            </div>
+                            <table id="table3"
+                                   class="table table-striped table-bordered table-hover table-nowrap"
+                                   data-operate-edit=""
+                                   data-operate-del="{:$auth->check('deliver/dispatch_del')}"
+                                   width="100%">
+                            </table>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="table" style="margin:0px 30px;">
+            <div id="printcode"></div>
+        </div>
     </div>
 </div>

+ 4 - 2
application/admin/view/deliver/index.html

@@ -6,8 +6,10 @@
     .table tbody tr.selected {
         background-color: yellow !important;  /* 选中行背景色为黄色 */
     }
-    .content{
-        padding: 0px;
+    /* 强制解除高度限制 */
+    .panel-body, .widget-body.no-padding, #table-detail {
+        height: auto !important;
+        overflow: visible !important;
     }
 </style>
 <div class="panel-heading">

+ 283 - 142
application/admin/view/qcode_add/index.html

@@ -1,7 +1,7 @@
 <style>
     table tr th, table tr td {
         border: thin #ddd dashed;
-        padding: 5px
+        padding: 5px;
     }
 
     .select2-container {
@@ -152,10 +152,43 @@
         font-weight: bold;
         background-color: #f5f5f5;
     }
+
+    .tray-count-select {
+        width: 80px;
+        padding: 5px;
+        border: 1px solid #ccc;
+        border-radius: 4px;
+    }
+
+    .layer-height-select {
+        width: 80px;
+        padding: 5px;
+        border: 1px solid #ccc;
+        border-radius: 4px;
+    }
+
+    .quantity-input.invalid {
+        border-color: red;
+        background-color: #ffeeee;
+    }
+
+    .items-per-box {
+        width: 80px;
+        padding: 5px;
+        border: 1px solid #ccc;
+        border-radius: 4px;
+    }
+
+    .unit-select {
+        width: 80px;
+        padding: 5px;
+        border: 1px solid #ccc;
+        border-radius: 4px;
+    }
 </style>
 
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
-    <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border:solid thin #c0c0c0">
+    <fieldset style="width: 1280px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border:solid thin #c0c0c0">
         <legend style="padding: 0px;margin: 0px">生成厂商信息</legend>
         <div class="form-group">
             <label class="control-label col-xs-2 col-sm-1">生产厂商:</label>
@@ -183,19 +216,18 @@
         </div>
     </fieldset>
 
-    <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border: solid thin #c0c0c0">
-        <legend style="padding: 0px;margin: 0px">打托选择列表</legend>
-        <div style="margin-bottom: 10px;">
-            <input type="text" id="searchInput" placeholder="请输入关键字搜索..." style="width: 300px;height: 35px; "/>
-            <button type="text" id="searchBtn" className="btn btn-primary" style="height: 34px">查询</button>
-            &nbsp;
+    <fieldset style="width:1280px;margin:10px 10px 0;padding:10px;border:solid thin #c0c0c0">
+        <legend style="padding:0;margin:0">打托选择列表</legend>
+        <div style="margin-bottom:10px">
+            <input type="text" id="searchInput" placeholder="请输入关键字搜索..." style="width:300px;height:35px">
+            <button type="button" id="searchBtn" className="btn btn-primary" style="height:34px">查询</button>
             <button id="sadBtn" class="btn btn-success">
                 <i class="fas fa-plus"></i> 新增产品
             </button>
         </div>
 
         <div id="table-container">
-            <table id="table" style="width: 100%;border-collapse: collapse;">
+            <table id="table" style="width:100%;border-collapse:collapse">
                 <thead>
                 <tr>
                     <th>销售订单号</th>
@@ -207,8 +239,7 @@
                     <th>剩余数</th>
                 </tr>
                 </thead>
-                <tbody id="tableBody">
-                </tbody>
+                <tbody id="tableBody"></tbody>
             </table>
         </div>
         <div id="pagination-wrapper">
@@ -219,25 +250,30 @@
         </div>
     </fieldset>
 
-    <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border: solid thin #c0c0c0">
-        <legend style="padding: 0px;margin: 0px">打托选品列表</legend>
+    <fieldset style="width:1280px;margin:10px 10px 0;padding:10px;border:solid thin #c0c0c0">
+        <legend style="padding:0;margin:0">打托选品列表</legend>
         <div id="table-container1">
-            <table id="table1" style="width: 100%;border-collapse: collapse;">
+            <table id="table1" style="width:100%;border-collapse:collapse">
                 <thead>
                 <tr>
-                    <th>序号</th>
-                    <th>产品名称</th>
-                    <th>应发货数量</th>
-                    <th>实际发货数量</th>
-                    <th>备注</th>
-                    <th>操作</th>
+                    <th style="width: 3%">序号</th>
+                    <th style="width: 15%">产品名称</th>
+                    <th style="width: 7%">可发数量</th>
+                    <th style="width: 4%">每箱个数</th>
+                    <th style="width: 4%">单位</th>
+                    <th style="width: 4%">打托数</th>
+                    <th style="width: 4%">层高</th>
+                    <th style="width: 9%">实际发货数量</th>
+                    <th style="width: 15%">备注</th>
+                    <th style="width: 4%">操作</th>
                 </tr>
                 </thead>
-                <tbody id="tableBody1">
-                </tbody>
-                <tfoot id="tableFooter1" style="display: none;">
+                <tbody id="tableBody1"></tbody>
+                <tfoot id="tableFooter1" style="display:none">
                 <tr className="total-row">
-                    <td colSpan="2">合计</td>
+                    <td colSpan="3">合计</td>
+                    <td></td>
+                    <td></td>
                     <td id="totalQuantity">0</td>
                     <td colSpan="2"></td>
                 </tr>
@@ -271,8 +307,7 @@
     };
 
     function addToShipment(row) {
-        console.log($(row).data('remaining_quantity'))
-        if($(row).data('remaining_quantity') == 0){
+        if ($(row).data('remaining_quantity') == 0) {
             layer.msg('库存数量为空!', {icon: 2});
             return;
         }
@@ -283,6 +318,10 @@
             cpbm: $(row).data('cpbm'),
             cpmc: $(row).data('cpmc'),
             remaining_quantity: $(row).data('remaining_quantity'),
+            tray_count: 18,
+            layer_height: '1.35',
+            items_per_box: '20',  // 默认每箱个数
+            unit: '套',          // 默认单位
             remark: ''
         };
 
@@ -302,7 +341,30 @@
     }
 
     function calculateTotalQuantity() {
-        return selectedProducts.reduce((sum, product) => sum + (parseFloat(product.remaining_quantity) || 0), 0);
+        return selectedProducts.reduce((sum, product) => {
+            const quantity = parseFloat(product.actual_quantity);
+            return sum + (isNaN(quantity) ? 0 : quantity);
+        }, 0);
+    }
+
+    function validateQuantityInput(input, maxValue) {
+        const value = input.val().trim();
+        const numericValue = parseFloat(value);
+
+        if (value !== '' && isNaN(numericValue)) {
+            input.addClass('invalid');
+            layer.tips('请输入有效数字', input, {tips: [1, '#FF5722']});
+            return false;
+        }
+
+        if (numericValue > maxValue) {
+            input.addClass('invalid');
+            layer.tips(`不能超过${maxValue}`, input, {tips: [1, '#FF5722']});
+            return false;
+        }
+
+        input.removeClass('invalid');
+        return true;
     }
 
     function renderShipmentTable() {
@@ -310,35 +372,114 @@
         tbody.empty();
 
         if (selectedProducts.length === 0) {
-            tbody.append('<tr><td colspan="5" style="text-align:center;">暂无配货数据</td></tr>');
+            tbody.append('<tr><td colspan="10" style="text-align:center;">暂无配货数据</td></tr>');
             $('#tableFooter1').hide();
             return;
         }
 
         selectedProducts.forEach((product, index) => {
+            // 初始化时确保 actual_quantity 有值
+            if (product.actual_quantity === undefined || product.actual_quantity === '') {
+                product.actual_quantity = product.remaining_quantity;
+            }
+
             const tr = $(`
-                <tr>
-                    <td>${index + 1}</td>
-                    <td>${product.cpmc}</td>
-                    <td>${product.remaining_quantity}</td>
-                    <td><input type="text" class="quantity-input" data-index="${index}" value="${product.actual_quantity || product.remaining_quantity || ''}" placeholder="" style="width:100%;"></td>
-                    <td><input type="text" class="remark-input" data-index="${index}" value="${product.remark || ''}" placeholder="请输入备注" style="width:100%;"></td>
-                    <td><span class="remove-btn" onclick="removeFromShipment(${index})">移除</span></td>
-                </tr>
-            `);
+            <tr>
+                <td>${index + 1}</td>
+                <td>${product.cpmc}</td>
+                <td>${product.remaining_quantity}</td>
+                <td>
+                    <input type="text"
+                           class="items-per-box"
+                           data-index="${index}"
+                           value="${product.items_per_box || '20'}"
+                           list="items-per-box-list"
+                           style="width:80px">
+                    <datalist id="items-per-box-list">
+                        <option value="20">
+                        <option value="24">
+                        <option value="32">
+                        <option value="40">
+                        <option value="42">
+                        <option value="48">
+                        <option value="60">
+                        <option value="72">
+                        <option value="70">
+                        <option value="80">
+                        <option value="96">
+                        <option value="108">
+                        <option value="240">
+                    </datalist>
+                </td>
+                <td>
+                    <select class="unit-select" data-index="${index}">
+                        <option value="套" ${product.unit === '套' ? 'selected' : ''}>套</option>
+                        <option value="张" ${product.unit === '张' ? 'selected' : ''}>张</option>
+                        <option value="个" ${product.unit === '个' ? 'selected' : ''}>个</option>
+                    </select>
+                </td>
+                <td>
+                    <select class="tray-count-select" data-index="${index}">
+                        <option value="18" ${product.tray_count == 18 ? 'selected' : ''}>18</option>
+                        <option value="24" ${product.tray_count == 24 ? 'selected' : ''}>24</option>
+                    </select>
+                </td>
+                <td>
+                    <select class="layer-height-select" data-index="${index}">
+                        <option value="1.35" ${product.layer_height == '1.35' ? 'selected' : ''}>1.35</option>
+                        <option value="1.05" ${product.layer_height == '1.05' ? 'selected' : ''}>1.05</option>
+                    </select>
+                </td>
+                <td>
+                    <input type="text" class="quantity-input" data-index="${index}"
+                           value="${product.actual_quantity || ''}"
+                           placeholder="" style="width:100%"
+                           max="${product.remaining_quantity}">
+                </td>
+                <td><input type="text" class="remark-input" data-index="${index}" value="${product.remark || ''}" placeholder="请输入备注" style="width:100%"></td>
+                <td><span class="remove-btn" onclick="removeFromShipment(${index})">移除</span></td>
+            </tr>
+        `);
             tbody.append(tr);
         });
 
         $('#tableFooter1').show();
         $('#totalQuantity').text(calculateTotalQuantity());
 
-        // 绑定备注输入事件 - 修正后的实现
+        $('.tray-count-select').off('change').on('change', function () {
+            const index = $(this).data('index');
+            selectedProducts[index].tray_count = $(this).val();
+        });
+
+        $('.layer-height-select').off('change').on('change', function () {
+            const index = $(this).data('index');
+            selectedProducts[index].layer_height = $(this).val();
+        });
+
+        $('.items-per-box').off('input').on('input', function () {
+            const index = $(this).data('index');
+            selectedProducts[index].items_per_box = $(this).val();
+        });
+
+        $('.unit-select').off('change').on('change', function () {
+            const index = $(this).data('index');
+            selectedProducts[index].unit = $(this).val();
+        });
+
         $('.remark-input').off('input').on('input', function () {
             const index = $(this).data('index');
-            const remark = $(this).val();
-            if (selectedProducts[index]) {
-                selectedProducts[index].remark = remark;
-            }
+            selectedProducts[index].remark = $(this).val();
+        });
+
+        $('.quantity-input').off('input').on('input', function () {
+            const index = $(this).data('index');
+            const input = $(this);
+            const maxValue = parseFloat(selectedProducts[index].remaining_quantity);
+
+            if (!validateQuantityInput(input, maxValue)) return;
+
+            selectedProducts[index].actual_quantity = input.val().trim() === '' ? '' : parseFloat(input.val());
+            $('#totalQuantity').text(calculateTotalQuantity());
         });
     }
 
@@ -419,18 +560,14 @@
     $(function () {
         loadData();
 
-
-
         $('#searchBtn').on('click', function (e) {
             e.preventDefault();
-            const keyword = $('#searchInput').val().trim();
-            loadData(1, keyword);
+            loadData(1, $('#searchInput').val().trim());
         });
 
         $('#searchInput').on('keypress', function (e) {
             if (e.which === 13) {
-                const keyword = $(this).val().trim();
-                loadData(1, keyword);
+                loadData(1, $(this).val().trim());
             }
         });
 
@@ -438,24 +575,21 @@
             addToShipment(this);
         });
 
-        // 修改sadBtn的点击事件处理
         $('#sadBtn').on('click', function (e) {
             e.preventDefault();
-
-            // 生成一行表格的HTML
             const generateRowHtml = (index) => `
-        <tr data-row="${index}">
-            <td><input type="text" name="order_ddbh" class="form-control" required /></td>
-            <td><input type="text" name="gdbh" class="form-control" required /></td>
-            <td><input type="text" name="cpbm" class="form-control" required /></td>
-            <td><input type="text" name="cpmc" class="form-control" required /></td>
-            <td><input type="number" name="sl" class="form-control" min="1" required /></td>
-            <td>
-                <button type="button" class="btn btn-success btn-xs add-row"><i class="fa fa-plus"></i></button>
-                <button type="button" class="btn btn-danger btn-xs remove-row"><i class="fa fa-minus"></i></button>
-            </td>
-        </tr>
-    `;
+                <tr data-row="${index}">
+                    <td><input type="text" name="order_ddbh" class="form-control" required /></td>
+                    <td><input type="text" name="gdbh" class="form-control" required /></td>
+                    <td><input type="text" name="cpbm" class="form-control" required /></td>
+                    <td><input type="text" name="cpmc" class="form-control" required /></td>
+                    <td><input type="number" name="sl" class="form-control" min="1" required /></td>
+                    <td>
+                        <button type="button" class="btn btn-success btn-xs add-row"><i class="fa fa-plus"></i></button>
+                        <button type="button" class="btn btn-danger btn-xs remove-row"><i class="fa fa-minus"></i></button>
+                    </td>
+                </tr>
+            `;
 
             layer.open({
                 type: 1,
@@ -466,85 +600,72 @@
                 maxmin: true,
                 btn: ['加入选品列表', '取消'],
                 content: `
-            <div style="padding: 20px 30px;">
-                <table class="table table-bordered" id="productTable">
-                    <thead>
-                        <tr>
-                            <th>销售订单号</th>
-                            <th>工单编号</th>
-                            <th>成品编码</th>
-                            <th>成品名称</th>
-                            <th>入库数</th>
-                            <th>操作</th>
-                        </tr>
-                    </thead>
-                    <tbody>
-                        ${generateRowHtml(0)}
-                    </tbody>
-                </table>
-            </div>
-        `,
-                success: function(layero, index) {
-                    // 添加行事件
-                    $(layero).on('click', '.add-row', function() {
-                        const tbody = $('#productTable tbody');
-                        const newRowIndex = tbody.find('tr').length;
-                        tbody.append(generateRowHtml(newRowIndex));
+                    <div style="padding:20px 30px">
+                        <table class="table table-bordered" id="productTable">
+                            <thead>
+                                <tr>
+                                    <th>销售订单号</th>
+                                    <th>工单编号</th>
+                                    <th>成品编码</th>
+                                    <th>成品名称</th>
+                                    <th>入库数</th>
+                                    <th>操作</th>
+                                </tr>
+                            </thead>
+                            <tbody>${generateRowHtml(0)}</tbody>
+                        </table>
+                    </div>
+                `,
+                success: function (layero, index) {
+                    $(layero).on('click', '.add-row', function () {
+                        $('#productTable tbody').append(generateRowHtml($('#productTable tbody tr').length));
                     });
 
-                    // 删除行事件
-                    $(layero).on('click', '.remove-row', function() {
-                        const row = $(this).closest('tr');
+                    $(layero).on('click', '.remove-row', function () {
                         if ($('#productTable tbody tr').length > 1) {
-                            row.remove();
+                            $(this).closest('tr').remove();
                         } else {
                             layer.msg('至少保留一行', {icon: 2});
                         }
                     });
                 },
-                yes: function(index) {
+                yes: function (index) {
                     const newProducts = [];
                     let isValid = true;
 
-                    $('#productTable tbody tr').each(function() {
+                    $('#productTable tbody tr').each(function () {
                         const rowData = {};
                         let rowValid = true;
 
-                        $(this).find('[required]').each(function() {
-                            const $input = $(this);
-                            const val = $input.val().trim();
-
+                        $(this).find('[required]').each(function () {
+                            const val = $(this).val().trim();
                             if (!val) {
-                                layer.tips('此项为必填项', $input, {tips: [1, '#FF5722']});
-                                isValid = false;
-                                rowValid = false;
-                                return false; // 退出当前each循环
+                                layer.tips('此项为必填项', $(this), {tips: [1, '#FF5722']});
+                                isValid = rowValid = false;
+                                return false;
                             }
-
-                            rowData[$input.attr('name')] = val;
+                            rowData[$(this).attr('name')] = val;
                         });
 
                         if (rowValid) {
-                            // 设置剩余数量等于入库数量(因为是新增产品)
                             rowData.remaining_quantity = rowData.sl;
-                            rowData.total_chu_quantity = 0; // 发货数量初始为0
-                            rowData.isNew = true; // 标记为新增产品
+                            rowData.total_chu_quantity = 0;
+                            rowData.tray_count = 18;
+                            rowData.layer_height = '1.35';
+                            rowData.items_per_box = '20';
+                            rowData.unit = '个';
+                            rowData.isNew = true;
                             newProducts.push(rowData);
                         }
                     });
 
                     if (!isValid || newProducts.length === 0) {
-                        if (newProducts.length === 0) {
-                            layer.msg('请至少填写一行有效数据', {icon: 2});
-                        }
+                        if (newProducts.length === 0) layer.msg('请至少填写一行有效数据', {icon: 2});
                         return;
                     }
 
-                    // 将新产品添加到选品列表
                     newProducts.forEach(product => {
-                        // 检查是否已存在相同工单编号的产品
-                        const exists = selectedProducts.some(item => item.gdbh === product.gdbh);
-                        if (!exists) {
+                        if (!selectedProducts.some(item => item.gdbh === product.gdbh)) {
                             selectedProducts.push({
                                 gdbh: product.gdbh,
                                 order_ddbh: product.order_ddbh,
@@ -552,7 +673,11 @@
                                 cpmc: product.cpmc,
                                 remaining_quantity: product.remaining_quantity,
                                 total_chu_quantity: product.total_chu_quantity,
-                                isNew: true, // 标记为新增产品
+                                tray_count: product.tray_count,
+                                layer_height: product.layer_height,
+                                items_per_box: product.items_per_box,
+                                unit: product.unit,
+                                isNew: true,
                                 remark: ''
                             });
                         }
@@ -565,7 +690,6 @@
             });
         });
 
-// 修改提交处理逻辑
         $('#submit').off('click').on('click', function (e) {
             e.preventDefault();
 
@@ -574,23 +698,40 @@
                 return false;
             }
 
-            // 确保所有输入数据已更新
-            $('.quantity-input').each(function() {
+            let allValid = true;
+            $('.quantity-input').each(function () {
                 const index = $(this).data('index');
-                const value = $(this).val() || $(this).attr('value') || '';
-                selectedProducts[index].actual_quantity = value;
+                if (!validateQuantityInput($(this), parseFloat(selectedProducts[index].remaining_quantity))) {
+                    allValid = false;
+                }
             });
 
-            $('.remark-input').each(function() {
+            if (!allValid) {
+                layer.msg('请检查实际发货数量输入是否正确', {icon: 2});
+                return false;
+            }
+
+            $('.quantity-input').each(function () {
                 const index = $(this).data('index');
-                const value = $(this).val() || '';
-                selectedProducts[index].remark = value;
+                selectedProducts[index].actual_quantity = $(this).val().trim() === '' ? '' : parseFloat($(this).val());
             });
 
-            // 分离新增产品和已有产品
-            const newProducts = selectedProducts.filter(p => p.isNew);
-            const existingProducts = selectedProducts.filter(p => !p.isNew);
+            $('.remark-input').each(function () {
+                const index = $(this).data('index');
+                selectedProducts[index].remark = $(this).val() || '';
+            });
 
+            $('.items-per-box').each(function () {
+                const index = $(this).data('index');
+                selectedProducts[index].items_per_box = $(this).val() || '20';
+            });
+
+            $('.unit-select').each(function () {
+                const index = $(this).data('index');
+                selectedProducts[index].unit = $(this).val() || '个';
+            });
+
+            const newProducts = selectedProducts.filter(p => p.isNew);
             const postData = {
                 company_name: $('#c-company_name').val(),
                 postcode: $('#c-postcode').val(),
@@ -600,7 +741,11 @@
                 products: selectedProducts.map(p => ({
                     ...p,
                     remark: p.remark || '',
-                    actual_quantity: p.actual_quantity || p.remaining_quantity
+                    actual_quantity: p.actual_quantity || p.remaining_quantity,
+                    tray_count: p.tray_count || 18,
+                    layer_height: p.layer_height || '1.35',
+                    items_per_box: p.items_per_box || '20',
+                    unit: p.unit || '套'
                 })),
                 newProducts: newProducts.map(p => ({
                     order_ddbh: p.order_ddbh,
@@ -609,42 +754,40 @@
                     cpmc: p.cpmc,
                     sl: p.remaining_quantity,
                     remark: p.remark || '',
-                    actual_quantity: p.actual_quantity || p.remaining_quantity
+                    actual_quantity: p.actual_quantity || p.remaining_quantity,
+                    tray_count: p.tray_count || 18,
+                    layer_height: p.layer_height || '1.35',
+                    items_per_box: p.items_per_box || '20',
+                    unit: p.unit || '个'
                 }))
             };
 
-            // 显示加载中
             const loadingIndex = layer.msg('处理中...', {icon: 16, shade: 0.3, time: 0});
 
-            // 先处理新增产品入库
             if (newProducts.length > 0) {
                 $.ajax({
                     method: "POST",
                     url: "Finishedproduct/finished",
                     contentType: "application/json",
-                    data: JSON.stringify({ data: postData.newProducts }),
-                    success: function(res) {
+                    data: JSON.stringify({data: postData.newProducts}),
+                    success: function (res) {
                         if (res && res.code === 1) {
-                            // 新增产品入库成功后,提交主表单
                             submitMainForm(postData, loadingIndex);
                         } else {
                             layer.close(loadingIndex);
                             layer.msg(res?.msg || '新增产品入库失败', {icon: 2});
                         }
                     },
-                    error: function(xhr) {
+                    error: function (xhr) {
                         layer.close(loadingIndex);
-                        const errorMsg = xhr.responseJSON?.message || xhr.statusText || '请求失败';
-                        layer.msg('新增产品入库失败: ' + errorMsg, {icon: 2});
+                        layer.msg('新增产品入库失败: ' + (xhr.responseJSON?.message || xhr.statusText || '请求失败'), {icon: 2});
                     }
                 });
             } else {
-                // 没有新增产品,直接提交主表单
                 submitMainForm(postData, loadingIndex);
             }
         });
 
-        // 提交主表单的函数
         function submitMainForm(postData, loadingIndex) {
             Fast.api.ajax({
                 url: 'qcode_add/add_bach',
@@ -653,10 +796,10 @@
             }, function (data, res) {
                 layer.close(loadingIndex);
                 if (res.code == 1) {
-                    layer.msg('保存成功', {icon: 1});
                     window.location.reload();
-                    // 或者跳转到其他页面
-                    // Backend.api.addtabs('deliver/apply');
+                    Backend.api.addtabs('/deliver/index');
+                    // layer.msg('保存成功', {icon: 1});
+                    // window.location.reload();
                 } else {
                     layer.msg(res.msg || '保存失败', {icon: 2});
                 }
@@ -666,6 +809,4 @@
             });
         }
     });
-
-
 </script>

Some files were not shown because too many files changed in this diff