2 Commits 5537e2a9cc ... 554567e00c

Author SHA1 Message Date
  chenp 554567e00c 下拉优化 2 years ago
  chenp 680850469c bug 2 years ago

+ 13 - 0
canteen/src/main/java/com/youxianxin/project/system/goodsType/domain/JnGoodsType.java

@@ -1,10 +1,13 @@
 package com.youxianxin.project.system.goodsType.domain;
 
+import com.youxianxin.project.system.goods.domain.JnGoods;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.youxianxin.framework.aspectj.lang.annotation.Excel;
 import com.youxianxin.framework.web.domain.BaseEntity;
 
+import java.util.List;
+
 /**
  * 菜品类型管理对象 jn_goods_type
  * 
@@ -30,6 +33,8 @@ public class JnGoodsType extends BaseEntity
     @Excel(name = "预留字段2")
     private String hold2;
 
+    private List<JnGoods> goodsList;
+
     public void setTypeId(Long typeId)
     {
         this.typeId = typeId;
@@ -67,6 +72,14 @@ public class JnGoodsType extends BaseEntity
         return hold2;
     }
 
+    public List<JnGoods> getGoodsList() {
+        return goodsList;
+    }
+
+    public void setGoodsList(List<JnGoods> goodsList) {
+        this.goodsList = goodsList;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 40 - 17
canteen/src/main/java/com/youxianxin/project/system/group/controller/JnGroupController.java

@@ -12,6 +12,8 @@ import com.youxianxin.project.system.accountGroup.domain.JnAccountGroup;
 import com.youxianxin.project.system.accountGroup.service.IJnAccountGroupService;
 import com.youxianxin.project.system.goods.domain.JnGoods;
 import com.youxianxin.project.system.goods.service.IJnGoodsService;
+import com.youxianxin.project.system.goodsType.domain.JnGoodsType;
+import com.youxianxin.project.system.goodsType.service.IJnGoodsTypeService;
 import com.youxianxin.project.system.user.domain.User;
 import com.youxianxin.project.system.utils.ReturnCode;
 import io.swagger.annotations.ApiOperation;
@@ -46,6 +48,8 @@ public class JnGroupController extends BaseController
     @Autowired
     private IJnGoodsService jnGoodsService;
     @Autowired
+    private IJnGoodsTypeService jnGoodsTypeService;
+    @Autowired
     private IJnAccountService jnAccountService;
     @Autowired
     private IJnAccountGroupService jnAccountGroupService;
@@ -103,12 +107,21 @@ public class JnGroupController extends BaseController
         //供应商只能看到自己添加的菜品
         String roleKey = sysUser.getRoles().get(0).getRoleKey();
         JnGoods jnGoods = new JnGoods();
+        JnGoodsType goodsType = new JnGoodsType();
         if ("supplier".equals(roleKey)){
             jnGoods.setUserId(sysUser.getUserId());
+            goodsType.setHold1(sysUser.getUserId() + "");
         }
-        List<JnGoods> goodsList = jnGoodsService.selectJnGoodsList(jnGoods);
 
-        map.put("goodsList",goodsList);
+        List<JnGoodsType> goodsTypeList = jnGoodsTypeService.selectJnGoodsTypeList(goodsType);
+        goodsTypeList.forEach(type -> {
+            jnGoods.setGoodsType(type.getTypeId());
+            List<JnGoods> goodsList = jnGoodsService.selectJnGoodsList(jnGoods);
+            type.setGoodsList(goodsList);
+        });
+
+        map.put("goodsTypeList", goodsTypeList);
+//        map.put("goodsList",goodsList);
         return prefix + "/add";
     }
 
@@ -149,32 +162,42 @@ public class JnGroupController extends BaseController
         //供应商只能看到自己添加的菜品
         String roleKey = sysUser.getRoles().get(0).getRoleKey();
         JnGoods jnGoods = new JnGoods();
+        JnGoodsType goodsType = new JnGoodsType();
         if ("supplier".equals(roleKey)){
             jnGoods.setUserId(sysUser.getUserId());
+            goodsType.setHold1(sysUser.getUserId() + "");
         }
-        List<JnGoods> goodsList = jnGoodsService.selectJnGoodsList(jnGoods);
         JnGroup jnGroup = jnGroupService.selectJnGroupByGroupId(groupId);
-        //根据分组中的菜品ids,标记选中的菜品
-        if (StringUtils.isNotEmpty(jnGroup.getGoodsIds())){
-            if (jnGroup.getGoodsIds().contains(",")){
-                String[] split = jnGroup.getGoodsIds().split(",");
-                for (String s:split){
+        List<JnGoodsType> goodsTypeList = jnGoodsTypeService.selectJnGoodsTypeList(goodsType);
+        goodsTypeList.forEach(type -> {
+            jnGoods.setGoodsType(type.getTypeId());
+            List<JnGoods> goodsList = jnGoodsService.selectJnGoodsList(jnGoods);
+            //根据分组中的菜品ids,标记选中的菜品
+            if (StringUtils.isNotEmpty(jnGroup.getGoodsIds())){
+                if (jnGroup.getGoodsIds().contains(",")){
+                    String[] split = jnGroup.getGoodsIds().split(",");
+                    for (String s:split){
+                        for (JnGoods jg:goodsList){
+                            if (s.equals(jg.getGoodsId().toString())){
+                                jg.setFlag(true);
+                            }
+                        }
+                    }
+                }else {
                     for (JnGoods jg:goodsList){
-                        if (s.equals(jg.getGoodsId().toString())){
+                        if (jnGroup.getGoodsIds().equals(jg.getGoodsId().toString())){
                             jg.setFlag(true);
                         }
                     }
                 }
-            }else {
-                for (JnGoods jg:goodsList){
-                    if (jnGroup.getGoodsIds().equals(jg.getGoodsId().toString())){
-                        jg.setFlag(true);
-                    }
-                }
             }
-        }
+            type.setGoodsList(goodsList);
+        });
+
+
 
-        mmap.put("goodsList", goodsList);
+//        mmap.put("goodsList", goodsList);
+        mmap.put("goodsTypeList", goodsTypeList);
         mmap.put("jnGroup", jnGroup);
         return prefix + "/edit";
     }

+ 12 - 3
canteen/src/main/resources/templates/system/group/add.html

@@ -12,15 +12,21 @@
             <div class="form-group">    
                 <label class="col-sm-3 control-label">分组名称:</label>
                 <div class="col-sm-8">
-                    <input name="groupName" maxlength="20" class="form-control" type="text">
+                    <input name="groupName" maxlength="20" class="form-control" type="text" style="width: 500px">
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-3 control-label">菜品:</label>
                 <div class="col-sm-9" style="display: flex;align-items: center">
                     <div style="width: 50%;padding-left: 0px" class="col-sm-5">
-                        <select name="goodsIds" class="form-control select2-multiple" multiple>
-                            <option th:each="goods:${goodsList}" th:value="${goods.goodsId}" th:text="${goods.goodsName}" ></option>
+<!--                        <select name="goodsIds" class="form-control select2-multiple" multiple>-->
+<!--                            <option th:each="goods:${goodsList}" th:value="${goods.goodsId}" th:text="${goods.goodsName}" ></option>-->
+<!--                        </select>-->
+
+                        <select name="goodsIds" id="devProductIds" class="form-select selectpicker" multiple="multiple" data-actions-box="true" data-select-all-text="选中全部" data-deselect-all-text="取消选中" title="请选择">
+                            <optgroup th:each="type:${goodsTypeList}" th:label="${type.typeName}">
+                                <option th:each="goods:${type.goodsList}" th:value="${goods.goodsId}" th:text="${goods.goodsName}"></option>
+                          </optgroup>
                         </select>
                     </div>
                 </div>
@@ -42,6 +48,9 @@
         $("#form-group-add").validate({
             focusCleanup: true
         });
+        $("#devProductIds").selectpicker({
+            width:500,
+        })
 
         function submitHandler() {
             if ($.validate.form()) {

+ 15 - 7
canteen/src/main/resources/templates/system/group/edit.html

@@ -27,21 +27,26 @@
             <div class="form-group">    
                 <label class="col-sm-3 control-label">分组名称:</label>
                 <div class="col-sm-8">
-                    <input name="groupName" th:field="*{groupName}" maxlength="20" class="form-control" type="text">
+                    <input name="groupName" th:field="*{groupName}" maxlength="20" class="form-control" type="text" style="width: 500px">
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-3 control-label">菜品:</label>
                 <div class="col-sm-9" style="display: flex;align-items: center">
-                    <div style="width: 100%;padding-left: 0px" class="col-sm-5">
+                    <div style="width: 100%;padding-left: 0px" class="col-sm-8">
 <!--                        <select name="goodsIds" id="devProductIds" class="form-control select2-multiple" multiple>-->
 <!--                            <option th:each="goods:${goodsList}" th:value="${goods.goodsId}" th:text="${goods.goodsName}" th:selected="${goods.flag}"></option>-->
 <!--                        </select>-->
-                        <label>
-                            <div class="item" th:each="goods:${goodsList}">
-                                <input name="goodsIds" type="checkbox" th:value="${goods.goodsId}" th:checked="${goods.flag}" th:text="${goods.goodsName}" />
-                            </div>
-                        </label>
+<!--                        <label>-->
+<!--                            <div class="item" th:each="goods:${goodsList}">-->
+<!--                                <input name="goodsIds" type="checkbox" th:value="${goods.goodsId}" th:checked="${goods.flag}" th:text="${goods.goodsName}" />-->
+<!--                            </div>-->
+<!--                        </label>-->
+                        <select name="goodsIds" id="devProductIds" class="form-select selectpicker" multiple="multiple" data-actions-box="true" data-select-all-text="选中全部" data-deselect-all-text="取消选中" title="请选择">
+                            <optgroup th:each="type:${goodsTypeList}" th:label="${type.typeName}">
+                                <option th:each="goods:${type.goodsList}" th:value="${goods.goodsId}" th:text="${goods.goodsName}" th:selected="${goods.flag}"></option>
+                          </optgroup>
+                        </select>
                     </div>
                 </div>
             </div>
@@ -62,6 +67,9 @@
         $("#form-group-edit").validate({
             focusCleanup: true
         });
+        $("#devProductIds").selectpicker({
+            width:500,
+        })
 
         function submitHandler() {
             if ($.validate.form()) {

+ 2 - 2
canteen/src/main/resources/templates/system/user/edit.html

@@ -42,7 +42,8 @@
                         <label class="col-sm-3 control-label">部门:</label>
                         <div class="col-sm-8">
                             <div class="input-group">
-                                <input name="deptId" onclick="selectDeptTree()" id="treeId" type="text" placeholder="请选择归属部门" class="form-control">
+                                <input name="deptId" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" th:field="*{dept.deptName}"/>
+                                <input id="treeId"  type="text" th:field="*{dept.deptId}" hidden="hidden">
                                 <span class="input-group-addon"><i class="fa fa-search"></i></span>
                             </div>
                         </div>
@@ -230,7 +231,6 @@
 
         /* 用户管理-修改-选择部门树 */
         function selectDeptTree() {
-            console.log(111111111)
         	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
             var url = ctx + "system/dept/selectDeptTree/" + deptId;
 		    var options = {