Просмотр исходного кода

feature:
1、页面上可以操作产品是否上生产线
2、页面上可以编辑品相口味

yingjian.wu 3 месяцев назад
Родитель
Сommit
2cf9ecf0d0

+ 12 - 0
src/main/java/com/qlm/controller/jinzai/ItemNewController.java

@@ -66,6 +66,18 @@ public class ItemNewController extends CommonController {
                 return;
             }
 
+            if (WxUtil.isNull(itemDto.getKouwei())) {
+                apiResponse = ApiResponse.error("口味不能为空");
+                renderJson(apiResponse);
+                return;
+            }
+
+            if (WxUtil.isNull(itemDto.getSku())) {
+                apiResponse = ApiResponse.error("SKU不能为空");
+                renderJson(apiResponse);
+                return;
+            }
+
             if (WxUtil.isNull(itemDto.getItemNo())) {
                 apiResponse = ApiResponse.error("品相编号不能为空");
                 renderJson(apiResponse);

+ 13 - 0
src/main/java/com/qlm/dto/ProductDto.java

@@ -27,6 +27,11 @@ public class ProductDto implements Serializable {
     private String  createTime;
     private String operator;
 
+    /**
+     * 是否投入生产
+     */
+    private Integer lineOn;
+
 
     // getter和setter方法
     public Long getId() {
@@ -164,4 +169,12 @@ public class ProductDto implements Serializable {
     public void setOperator(String operator) {
         this.operator = operator;
     }
+
+    public Integer getLineOn() {
+        return lineOn;
+    }
+
+    public void setLineOn(Integer lineOn) {
+        this.lineOn = lineOn;
+    }
 }

+ 3 - 0
src/main/java/com/qlm/service/impl/ItemServiceImpl.java

@@ -57,6 +57,7 @@ public class ItemServiceImpl implements IItemService {
             item.set("status", itemDto.getStatus() != null ? itemDto.getStatus() : 1);
             item.set("code_length", itemDto.getCodeLength());
             item.set("item_no", itemDto.getItemNo());
+            item.set("kouwei",itemDto.getKouwei());
 
             Db.save("t_jz_item", item);
             return ApiResponse.success("保存成功");
@@ -86,6 +87,7 @@ public class ItemServiceImpl implements IItemService {
             item.set("product_id", itemDto.getProductId());
             item.set("sku", itemDto.getSku());
             item.set("bip", itemDto.getBip());
+            item.set("kouwei",itemDto.getKouwei());
             item.set("status", itemDto.getStatus());
             item.set("item_no", itemDto.getItemNo());
             item.set("updated_time", new Date());
@@ -402,6 +404,7 @@ public class ItemServiceImpl implements IItemService {
         itemDto.setStatus(record.getInt("status"));
         itemDto.setCodeLength(record.getInt("code_length"));
         itemDto.setItemNo(record.getStr("item_no"));
+        itemDto.setKouwei(record.getStr("kouwei"));
         return itemDto;
     }
 

+ 3 - 0
src/main/java/com/qlm/service/impl/ProductServiceImpl.java

@@ -128,6 +128,7 @@ public class ProductServiceImpl implements IProductService {
             record.set("unit", productDto.getUnit());
             record.set("standard", productDto.getSpec());
             record.set("operator", loginUser.getUsername());
+            record.set("line_on", productDto.getLineOn() == null ? 0 : productDto.getLineOn());
 
             boolean save = Db.save("t_jz_product", record);
             return save ? ApiResponse.success() : ApiResponse.error("保存产品信息失败");
@@ -158,6 +159,7 @@ public class ProductServiceImpl implements IProductService {
             record.set("unit", productDto.getUnit());
             record.set("standard", productDto.getSpec());
             record.set("operator", loginUser.getUsername());
+            record.set("line_on", productDto.getLineOn() == null ? 0 : productDto.getLineOn());
 
             boolean update = Db.update("t_jz_product", record);
             return update ? ApiResponse.success() : ApiResponse.error("更新产品信息失败");
@@ -282,6 +284,7 @@ public class ProductServiceImpl implements IProductService {
         dto.setDetail(record.getStr("detail"));
         dto.setCreateTime(DateUtil.format(record.getDate("create_time"), "yyyy-MM-dd HH:mm:ss"));
         dto.setOperator(record.getStr("operator"));
+        dto.setLineOn(WxUtil.getInt("line_on", record));
         return dto;
     }
 }

+ 24 - 4
src/main/webapp/page/jinzai/itemNew.jsp

@@ -217,6 +217,15 @@
                                 </div>
                             </div>
                         </div>
+
+                        <div class="row mb-4">
+                            <div class="col-md-6">
+                                <label for="modalKouWei" class="required control-label">口味</label>
+                                <input type="text" class="form-control" id="modalKouWei" name="modalKouWei" placeholder="请输入" required>
+                            </div>
+                            <div class="col-md-6">
+                            </div>
+                        </div>
                     </form>
                 </div>
             </div>
@@ -440,6 +449,7 @@
                     $('#modalItemName').val(item.itemName);
                     $('#modalSku').val(item.sku);
                     $('#modalbip').val(item.bip);
+                    $('#modalKouWei').val(item.kouwei);
 
                     // 设置状态开关
                     if (item.status === 1) {
@@ -473,7 +483,8 @@
             itemName: $('#modalItemName').val(),
             sku: $('#modalSku').val(),
             bip: $('#modalbip').val(),
-            status: $('#modalStatus').is(':checked') ? 1 : 0
+            status: $('#modalStatus').is(':checked') ? 1 : 0,
+            kouwei: $('#modalKouWei').val()
         };
 
         $.ajax({
@@ -540,6 +551,10 @@
                 modalSku: {
                     required: true,
                     maxlength: 50
+                },
+                modalKouWei: {
+                    required: true,
+                    maxlength: 50
                 }
             },
             messages: {
@@ -558,9 +573,9 @@
                     required: '请输入SKU',
                     maxlength: 'SKU最多50个字符'
                 },
-                modalbip: {
-                    required: '请输入BIP编号',
-                    maxlength: 'BIP编号最多50个字符'
+                modalKouWei: {
+                    required: '请输入口味',
+                    maxlength: '口味最多50个字符'
                 }
             }
         });
@@ -631,6 +646,11 @@
                 title: '品相名称',
                 align: 'center',
                 width: "15%"
+            }, {
+                field: 'kouwei',
+                title: '口味',
+                align: 'center',
+                width: "15%"
             }, {
                 field: 'sku',
                 title: 'SKU',

+ 56 - 3
src/main/webapp/page/jinzai/productList.jsp

@@ -248,7 +248,15 @@
                                 </div>
                             </div>
                             <div class="col-md-6">
-                                <!-- 预留一列 -->
+                                <label class="required control-label">是否投入生产</label>
+                                <div class="d-flex align-items-center gap-2">
+                                    <label class="toggle-switch">
+                                        <input type="checkbox" id="modalLineOn" name="modalLineOn" checked>
+                                        <span class="slider"></span>
+                                    </label>
+                                    <span id="lineOnText">否</span>
+                                    <div class="text-muted">是、否,默认否</div>
+                                </div>
                             </div>
                         </div>
 
@@ -315,17 +323,21 @@
                                         <td id="detailPackLevel"></td>
                                     </tr>
                                     <tr>
-                                        <td class="text-right"><strong>每箱数:</strong></td>
+                                        <td class="text-right"><strong>每箱数:</strong></td>
                                         <td id="detailBoxPerPile"></td>
                                     </tr>
                                     <tr>
-                                        <td class="text-right"><strong>每垛数:</strong></td>
+                                        <td class="text-right"><strong>每垛数:</strong></td>
                                         <td id="detailBoxPerBox"></td>
                                     </tr>
                                     <tr>
                                         <td class="text-right"><strong>状态:</strong></td>
                                         <td id="detailStatus"></td>
                                     </tr>
+                                    <tr>
+                                        <td class="text-right"><strong>是否投入生产:</strong></td>
+                                        <td id="detailLineOn"></td>
+                                    </tr>
                                     <tr>
                                         <td class="text-right"><strong>详细信息:</strong></td>
                                         <td id="detailDetails"></td>
@@ -404,6 +416,18 @@
                 statusText.textContent = '禁用';
             }
         });
+
+        // 状态切换按钮
+        const lineOnToggle = document.getElementById('modalLineOn');
+        const LineOnText = document.getElementById('LineOnText');
+
+        lineOnToggle.addEventListener('change', function () {
+            if (this.checked) {
+                LineOnText.textContent = '是';
+            } else {
+                LineOnText.textContent = '否';
+            }
+        });
     });
 
     // 加载类别数据
@@ -564,6 +588,10 @@
         $('#productId').val('');
         $('#modalStatus').prop('checked', true);
         $('#statusText').text('启用');
+
+        $('#modalLineOn').prop('checked', false);
+        $('#LineOnText').text('否');
+
         $('#productModalLabel').text('新增产品');
 
         // 重置表单验证状态
@@ -631,6 +659,14 @@
                         $('#modalStatus').prop('checked', false);
                         $('#statusText').text('禁用');
                     }
+
+                    if (product.lineOn === 1) {
+                        $('#modalLineOn').prop('checked', true);
+                        $('#lineOnText').text('是');
+                    } else {
+                        $('#modalLineOn').prop('checked', false);
+                        $('#lineOnText').text('否');
+                    }
                 } else {
                     layer.msg(data.msg, {icon: 5});
                 }
@@ -659,6 +695,7 @@
             barCode: $('#modalBarcode').val(),
             level: $('#modalPackLevel').val(),
             status: $('#modalStatus').is(':checked') ? 1 : 0,
+            lineOn: $('#modalLineOn').is(':checked') ? 1 : 0,
             tuoNum: $('#modalBoxPerPile').val(),
             xiangNum: $('#modalBoxPerBox').val(),
             detail: $('#modalDetails').val()
@@ -867,6 +904,14 @@
                         return value === 1 ? '<span class="label label-primary">启用</span>' : '<span class="label label-default">禁用</span>';
                     }
                 },
+                {
+                    field: 'lineOn',
+                    title: '是否投入生产',
+                    align: 'center',
+                    formatter: function (value) {
+                        return value === 1 ? '<span class="label label-primary">是</span>' : '<span class="label label-default">否</span>';
+                    }
+                },
                 {
                     field: 'id',
                     title: '操作',
@@ -980,6 +1025,14 @@
                     } else {
                         $('#detailStatus').text('');
                     }
+
+                    if (product.lineOn === 1) {
+                        $('#detailLineOn').html('<span class="label label-success">是</span>');
+                    } else if (product.status === 0) {
+                        $('#detailLineOn').html('<span class="label label-default">否</span>');
+                    } else {
+                        $('#detailLineOn').text('');
+                    }
                     
                     $('#detailDetails').text(product.details || '');
                     $('#detailCreator').text(product.operator || '');