Browse Source

复选框选中推荐

2510966293@qq.com 5 years ago
parent
commit
08cebd985c

+ 1 - 1
src/main/java/com/yc/education/controller/admin/OwnerServiceAdminController.java

@@ -207,7 +207,7 @@ public class OwnerServiceAdminController {
         int rows = 0;
         for (String string : idList){
 
-            OwnerService ownerService = iOwnerService.selectByKey(string);
+            OwnerService ownerService = iOwnerService.selectByKey(Integer.valueOf(string));
 
             if (ownerService.getIsRecommendation() == 1){
                 ownerService.setIsRecommendation(0);

+ 11 - 21
src/main/webapp/WEB-INF/jsp/admin/ownerServiceList.jsp

@@ -109,10 +109,10 @@
                     </td>
                     <td class="text-l">
                         <c:if test="${service.isRecommendation == 1}">
-                            <input type="checkbox" name = "isRecommendation" onclick="check()" value="${service.id }" checked="checked"/> 推荐
+                            <input type="checkbox" name = "isRecommendation" onclick="check(${service.id })" value="${service.id }" checked="checked"/> 推荐
                         </c:if>
                         <c:if test="${service.isRecommendation == 0}">
-                            <input type="checkbox" name = "isRecommendation" onclick="check()" value="${service.id}"/> 推荐
+                            <input type="checkbox" name = "isRecommendation" onclick="check(${service.id })" value="${service.id}"/> 推荐
                         </c:if>
 
                     </td>
@@ -237,28 +237,18 @@
 
     });
     /*        推荐复选框         */
-    function check() {
-
-        var checkVal = "";
-            checkVal += $(this).val();
-        alert(checkVal);
+    function check(obj) {
         $.ajax({
-            type: "POST",
-            url: "recommendationUpdate.html",
-            data: {
-                "id": checkVal,
-                dataType: "json",
-                success: function (ajax) {
-                    if (ajax.is) {
-                        layer.alert(ajax.msg, {skin: 'layui-layer-molv', closeBtn: 0, anim: 4}, function () {
-                            window.location = window.location;
-                        });
-                    } else {
-                        layer.msg(ajax.msg, {icon: 2, time: 1000});
-                    }
+            type:"POST",
+            url:"recommendUpdate.html",
+            data:{"id":obj.toString()},
+            dataType:"json",
+            success:function(ajax){
+                if(!ajax.is){
+                    layer.msg("修改失败",{icon:2,time:1000})
                 }
             }
-        });
+        })
     }
 </script>
 </body>