Parcourir la source

2019/11/1 后台修改 version-N+1

wuzhiqiang il y a 5 ans
Parent
commit
fc4a13ab5d

+ 5 - 11
src/main/java/com/yc/education/controller/admin/CarSedanAdminController.java

@@ -264,12 +264,9 @@ public class CarSedanAdminController extends BaseController {
                 if (hssfRow != null) {
                     CarSedan car = new CarSedan();
                     car.setCountry(getValue(hssfRow.getCell(0)));
-                    car.setMiKey(getValue(hssfRow.getCell(1)));
+                    car.setFactory(getValue(hssfRow.getCell(1)));
                     car.setBrand(getValue(hssfRow.getCell(2)));
                     car.setSeries(getValue(hssfRow.getCell(3)));
-                    car.setSalename(getValue(hssfRow.getCell(4)));
-                    car.setYears(getValue(hssfRow.getCell(5)));
-                    car.setFactory(getValue(hssfRow.getCell(6)));
                     car.setAddtime(new Date());
 
                     if (car.getBrand() != null && !"".equals(car.getBrand())) {
@@ -294,13 +291,10 @@ public class CarSedanAdminController extends BaseController {
                 Row row = sheet.getRow(i);
                 //获取表格数据
                 CarSedan car = new CarSedan();
-                car.setCountry(getValue(row.getCell((short)0)));
-                car.setMiKey(getValue(row.getCell((short)1)));
-                car.setBrand(getValue(row.getCell((short)2)));
-                car.setSeries(getValue(row.getCell((short)3)));
-                car.setSalename(getValue(row.getCell((short)4)));
-                car.setYears(getValue(row.getCell((short)5)));
-                car.setFactory(getValue(row.getCell((short)6)));
+                car.setCountry(getValue(row.getCell(0)));
+                car.setFactory(getValue(row.getCell(1)));
+                car.setBrand(getValue(row.getCell(2)));
+                car.setSeries(getValue(row.getCell(3)));
                 car.setAddtime(new Date());
 
                 if (car.getBrand() != null && !"".equals(car.getBrand())) {

+ 50 - 4
src/main/java/com/yc/education/controller/admin/ServiceCategoryAdminController.java

@@ -228,10 +228,28 @@ public class ServiceCategoryAdminController {
      * @return
      */
     @RequestMapping("serviceCategoryAddSupplier.html")
-    public ModelAndView serviceCategoryAddSupplier() {
+    public ModelAndView serviceCategoryAddSupplier(Integer nowId) {
         ModelAndView result = new ModelAndView();
         List<ServiceCategory> findall  = iServiceCategoryService.listSupplierServiceType();//查询经销商一级服务
 
+        /*根据传来的nowId查询当前数据的父类id*/
+        Integer nowPId  = iServiceCategoryService.listByNowId(nowId);
+        result.addObject("nowPId",nowId);
+        /*如果根据当前nowId查出其有父类,则根据其父类id查询父类是否还是父类*/
+        if (nowPId != null){
+            Integer nowGPId  = iServiceCategoryService.listByNowPId(nowPId);
+            if (nowGPId == 0){
+                result.addObject("nowGPId",nowPId);
+            }else {
+                result.addObject("nowGPId",nowGPId);
+            }
+
+
+            // 查询选中当前级别数据
+            List<ServiceCategory> categoryList = iServiceCategoryService.listServiceCategoryByPid(nowPId);
+            result.addObject("categoryList",categoryList);
+        }
+
 
         result.addObject("findall", findall);
         return result;
@@ -255,6 +273,23 @@ public class ServiceCategoryAdminController {
         return am;
     }
 
+    /**
+     * 经销商修改页面根据二级,三级显示修改内容
+     */
+    @ResponseBody
+    @RequestMapping("twoOrThree.html")
+    public AjaxMessage<Object> twoOrThree(String id){
+        AjaxMessage<Object> am = new AjaxMessage<>();
+        int rows = iServiceCategoryService.listByPId(Integer.valueOf(id));//根据修改界面传来的id,查询有没有父类id是该id的信息,有则说明修改页面选中的是二类
+        if (rows > 0){
+            am.setIs(true);
+        }else {
+            am.setIs(false);
+        }
+
+        return am;
+    }
+
 
 
     /**
@@ -427,9 +462,20 @@ public class ServiceCategoryAdminController {
         ServiceCategory service = iServiceCategoryService.selectByKey(id);
         result.addObject("service", service);
 
+        int rows  =  iServiceCategoryService.listByPId(service.getId()); //判断要修改的是二级还是三级
+        if (rows > 0){
+            List<ServiceCategory> findSecondService = iServiceCategoryService.findSecondService(String.valueOf(service.getpId()));//二级pid---一级id
+            result.addObject("first",findSecondService);
+        }else {   //三级
+            List<ServiceCategory> findSecondService1 = iServiceCategoryService.findSecondService(String.valueOf(service.getpId()));//根据三级pid--二级id
 
-        int rows = iServiceCategoryService.listByPId(service.getpId());
-        /*判断选中的服务是否是三级服务名称 rows>0(三级服务) 修改界面 二级分类需要展示*/
+            result.addObject("two",findSecondService1);//二级名称
+            List<ServiceCategory> findSecondService = iServiceCategoryService.findSecondService(String.valueOf(service.getpId()));//根据三级pid--二级id---二级pid---一级id
+            result.addObject("first",findSecondService);//一级名称
+        }
+
+       /* int rows = iServiceCategoryService.listByPId(service.getpId());
+        *//*判断选中的服务是否是三级服务名称 rows>0(三级服务) 修改界面 二级分类需要展示*//*
         if (rows >0){
             List<ServiceCategory> findSecondService = iServiceCategoryService.findSecondService(String.valueOf(service.getpId()));//根据三级服务名称的父类id查询id是此父类id的信息
             result.addObject("second",findSecondService);
@@ -443,7 +489,7 @@ public class ServiceCategoryAdminController {
             List<ServiceCategory> serviceCategory2 = iServiceCategoryService.findSecondService(serviceCategory.get(0).getpId().toString());
             result.addObject("second",serviceCategory2);
             result.addObject("three",serviceCategory);
-        }
+        }*/
         return result;
     }
 

+ 4 - 0
src/main/java/com/yc/education/mapper/ServiceCategoryMapper.java

@@ -131,4 +131,8 @@ public interface ServiceCategoryMapper extends MyMapper< ServiceCategory > {
     List< String > listAllNameByPid(@Param("pId") Integer pId);
 
     List<String> listByNameArray(@Param("nameArray") String[] nameArray);
+
+    Integer listByNowId(@Param("nowId") Integer nowId);
+
+    Integer listByNowPId(@Param("nowPId") Integer nowPId);
 }

+ 4 - 0
src/main/java/com/yc/education/service/IServiceCategoryService.java

@@ -140,4 +140,8 @@ public interface IServiceCategoryService extends IService<ServiceCategory>{  //
     List< String> listAllNameByPid(Integer pId);
 
     List<String> listByNameArray(String[] nameArray);
+
+    Integer listByNowId(Integer nowId);
+
+    Integer listByNowPId(Integer nowPId);
 }

+ 11 - 0
src/main/java/com/yc/education/service/impl/ServiceCategoryServiceImpl.java

@@ -276,4 +276,15 @@ public class ServiceCategoryServiceImpl extends BaseService<ServiceCategory> imp
         return serviceCategoryMapper.listByNameArray(nameArray);
     }
 
+    @Override
+    public Integer listByNowId(Integer nowId) {
+        return serviceCategoryMapper.listByNowId(nowId);
+    }
+
+    @Override
+    public Integer listByNowPId(Integer nowPId) {
+
+        return serviceCategoryMapper.listByNowPId(nowPId);
+    }
+
 }

+ 8 - 1
src/main/resources/mapper/WServiceCategorymapper.xml

@@ -175,7 +175,14 @@
             #{name}
         </foreach>
         )
-
+    </select>
+    <!--经销商添加 根据nowId查询该信息的父类id-->
+    <select id="listByNowId" resultType="INTEGER">
+        select p_id from service_category where id=#{nowId}
+    </select>
+    <!--经销商添加 根据当前id查出父类id,根据父类id查询父类的父类id-->
+    <select id="listByNowPId" resultType="INTEGER">
+        select p_id from service_category where id = #{nowPId}
     </select>
 
 </mapper>

+ 54 - 23
src/main/webapp/WEB-INF/jsp/admin/serviceCategoryAddSupplier.jsp

@@ -85,21 +85,28 @@
             <select name="pId" id="pId" onchange="choose(this.value)" class="input-text">
                 <option value="">请选择</option>
                 <c:forEach items="${findall}" var="newtype">
-                    <option id="ceshi" value="${newtype.id}" >${newtype.name}</option>
+                <option id="ceshi" value="${newtype.id}"
+                        <c:if test="${newtype.id == nowGPId}"> selected="selected" </c:if> >${newtype.name}
+                </option>
                 </c:forEach>
             </select>
         </div>
     </div>
-        <div id = "isShow" hidden="hidden">
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red"></span>服务二级类别:</label>
             <div class="formControls col-xs-8 col-sm-9">
                 <select name="twoPId" id="two" onchange="chooseTwo(this)" class="input-text">
                     <option value="">请选择</option>
+                    <c:forEach items="${categoryList}" var="categoryList">
+                        <option id="ceshi" value="${categoryList.id}"
+                                <c:if test="${categoryList.id == nowPId}"> selected="selected" </c:if> >${categoryList.name}
+                        </option>
+                    </c:forEach>
 
                 </select>
             </div>
         </div>
+        <%--<div id = "isShow" hidden="hidden">
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red"></span>服务三级类别:</label>
             <div class="formControls col-xs-8 col-sm-9">
@@ -109,7 +116,7 @@
                 </select>
             </div>
         </div>
-        </div>
+        </div>--%>
 
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>服务名称:</label>
@@ -211,10 +218,14 @@
             }
         });
     });
-     /*根据一级分类查询二级分类*/
-     function choose(pId){
+    var dd = $("#pId").find("option:selected").text();
 
+    /*if (dd.trim() == '汽车配件') {
+        $("#isShow").show();
+    }*/
 
+     /*根据一级分类查询二级分类*/
+     function choose(pId){
          var dd = $("#pId").find("option:selected").text();
 
          if (dd.trim() == '用品改装' || dd.trim() == '汽车配件' || dd.trim() == '汽保设备与工具' || dd.trim() == '商用车' || dd.trim() == '道路救援'){
@@ -222,25 +233,45 @@
          }else {
              $("#isShow").hide();
          }
+         if(dd.trim() == '汽车配件'){
+             $.ajax({
+                 type:"POST",
+                 url:"searchType.html",
+                 data:{"id":"208"},
+                 dataType:"json",
+                 success:function(ajax){
+                     console.log(JSON.stringify(ajax));
+                     if (ajax.is) {
+                         $("#two").html('<option value="">请选择</option>');
+                         var str = '';
+                         for(var i = 0;i<ajax.data.length;i++){
+                             str += '<option value="'  +ajax.data[i].id+  '">'   +ajax.data[i].name+        '</option>';
+                         };
+                         $("#two").append(str);
+                     }
+                 }
+             });
+         }else {
+             $.ajax({
+                 type:"POST",
+                 url:"searchType.html",
+                 data:{"id":pId.toString()},
+                 dataType:"json",
+                 success:function(ajax){
+                     if (ajax.is) {
+                         $("#two").html('<option value="">请选择</option>');
+                         var str = '';
+                         for(var i = 0;i<ajax.data.length;i++){
+                             str += '<option value="'+ajax.data[i].id+'">'+ajax.data[i].name+'</option>';
+                         };
+                         $("#two").append(str);
+
+                     }
+                 }
+
+             });
 
-        $.ajax({
-            type:"POST",
-            url:"searchType.html",
-            data:{"id":pId.toString()},
-            dataType:"json",
-            success:function(ajax){
-            if (ajax.is) {
-                $("#two").html('<option value="">请选择</option>');
-                var str = '';
-                for(var i = 0;i<ajax.data.length;i++){
-                    str += '<option value="'+ajax.data[i].id+'">'+ajax.data[i].name+'</option>';
-                };
-                $("#two").append(str);
-
-            }
-            }
-
-        });
+         }
     }
     function chooseTwo(obj){
         var objS = document.getElementById("two");

+ 1 - 1
src/main/webapp/WEB-INF/jsp/admin/serviceCategoryPidList.jsp

@@ -43,7 +43,7 @@
     <div class="cl pd-5 bg-1 bk-gray mt-20">
 			<span class="l">
                 <a class="btn btn-danger radius"  href="javascript:;"  id="delete"    ><i class="Hui-iconfont">&#xe6e2;</i>批量删除</a>
-				<a class="btn btn-primary radius" href="serviceCategoryAddSupplier.html"><i
+				<a class="btn btn-primary radius" href="serviceCategoryAddSupplier.html?nowId=${pid}"><i
                         class="Hui-iconfont">&#xe600;</i> 添加服务</a>
 			</span>
         <span class="r">共有数据:<strong>${pageInfo.total }</strong> 条</span>

+ 26 - 8
src/main/webapp/WEB-INF/jsp/admin/serviceCategoryUpdateSupplier.jsp

@@ -84,26 +84,26 @@
             <div class="formControls col-xs-8 col-sm-9">
                 <select name="pId" id="pId" onchange="choose(this.value)" class="input-text">
                     <c:forEach items="${findall}" var="newtype">
-                        <c:forEach items="${second}" var="second">
-                        <option value="${newtype.id}" <c:if test="${newtype.id == second.pId}">selected</c:if> >${newtype.name}</option>
+                        <c:forEach items="${first}" var="first">
+                        <option value="${newtype.id}" <c:if test="${newtype.id == first.id}">selected</c:if> >${newtype.name}</option>
                         </c:forEach>
                     </c:forEach>
                 </select>
             </div>
         </div>
-        <div id="isShow" hidden="hidden">
-        <div class="row cl">
+
+        <div class="row cl"  id="showOrNot">
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red"></span>服务二级类别:</label>
             <div class="formControls col-xs-8 col-sm-9">
                 <select name="twoPId" id="two" onchange="chooseTwo(this)" class="input-text">
-                    <c:forEach items="${second}" var="second">
-                        <option value="${second.id}"
-                                <c:if test="${second.id == second.pId}">selected</c:if> >${second.name}</option>
+                    <c:forEach items="${two}" var="two">
+                        <option value="${two.id}">${two.name}</option>
                     </c:forEach>
 
                 </select>
             </div>
         </div>
+      <%--  <div id="isShow" hidden="hidden">
         <div class="row cl" >
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red"></span>服务三级类别:</label>
             <div class="formControls col-xs-8 col-sm-9">
@@ -116,7 +116,7 @@
                 </select>
             </div>
         </div>
-        </div>
+        </div>--%>
         <div class="row cl">
             <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>服务名称:</label>
             <div class="formControls col-xs-8 col-sm-9">
@@ -194,6 +194,7 @@
 
 <script type="text/javascript">
 
+
     /* 回显图片*/
     $(function () {
         $("#caseimage").change(function () {
@@ -227,6 +228,23 @@
         });
     });
 
+    /*判断要修改的是二级还是三级*/
+
+    var getId = $("input[name = 'id']").val();
+    $(function(){
+        $.ajax({
+            type:"POST",
+            url:"twoOrThree.html",
+            data:{"id":getId.toString()},
+            dataType:"json",
+            success:function(ajax){
+                if (ajax.is){
+                   $("#showOrNot").hide();
+                }
+            }
+        })
+    });
+
     /*根据一级分类查询二级分类*/
     function choose(pId){
         var dd = $("#pId").find("option:selected").text();

BIN
src/main/webapp/ajaxexcel/excel/轿车表格导入规范.xlsx