admin
2021-03-02 4011b8d0b377af33e2bc435f7726329630d706cb
src/main/webapp/admin/new/fenqu.html
@@ -319,19 +319,15 @@
                            <th>栏目ID</th>
                            <th>栏目名称</th>
                            <th>选择</th>
                            <th>栏目ID</th>
                            <th>栏目名称</th>
                            <th>选择</th>
                            </thead>
                            <tbody>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
                                <td><input type="checkbox"/></td>
                            </tr>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
                                <td><input type="checkbox"/></td>
                            </tr>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
                                <td><input type="checkbox"/></td>
@@ -376,16 +372,6 @@
                            <th>选择</th>
                            </thead>
                            <tbody>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
                                <td><input type="checkbox"/></td>
                            </tr>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
                                <td><input type="checkbox"/></td>
                            </tr>
                            <tr>
                                <td>12</td>
                                <td>热门推荐</td>
@@ -522,13 +508,86 @@
            if (data.code == 0) {
                var item = $("#hometype table tbody tr").eq(0);
                $("#hometype table tbody").empty();
                data.data.forEach(function (hometype) {
                var homeTypeList = data.data;
                var rows = homeTypeList.length % 2 == 0 ? homeTypeList.length / 2 : parseInt(homeTypeList.length / 2) + 1;
                for (var i = 0; i < rows; i++) {
                    $("#hometype table tbody").append("<tr>" + item.html() + "</tr>");
                    var newItem = $("#hometype table tbody tr").eq($("#hometype table tbody tr").length - 1);
                    newItem.find("td").eq(0).html(hometype.id);
                    newItem.find("td").eq(1).html(hometype.name);
                    newItem.find("td").eq(2).find("input[type='checkbox']").eq(0).val(hometype.id);
                });
                    newItem.find("td").eq(0).html(homeTypeList[i * 2].id);
                    newItem.find("td").eq(1).html(homeTypeList[i * 2].name);
                    newItem.find("td").eq(2).find("input[type='checkbox']").eq(0).val(homeTypeList[i * 2].id);
                    if (homeTypeList.length > i * 2 + 1) {
                        newItem.find("td").eq(3).html(homeTypeList[i * 2 + 1].id);
                        newItem.find("td").eq(4).html(homeTypeList[i * 2 + 1].name);
                        newItem.find("td").eq(5).find("input[type='checkbox']").eq(0).val(homeTypeList[i * 2 + 1].id);
                    } else {
                        newItem.find("td").eq(3).empty();
                        newItem.find("td").eq(4).empty();
                        newItem.find("td").eq(5).empty();
                    }
                    newItem.css("cursor", "pointer");
                    //设置颜色
                    if (i % 2 == 0) {
                        newItem.find("td").css("background", "#EEEEEE");
                    }
                    newItem.find("td").click(function () {
                        //查询当前tr的本个/下一个checkbox
                        console.log($(this).find("input[type='checkbox']"));
                        if ($(this).find("input[type='checkbox']").length > 0) {
                            if ($(this).find("input[type='checkbox']").is(":checked")) {
                                //取消选中
                                $(this).find("input[type='checkbox']").prop('checked', false);
                            } else {
                                //选中
                                $(this).find("input[type='checkbox']").prop('checked', true);
                            }
                        } else {
                            //查询下一个
                            var $this = $(this);
                            for (var i = 0; i < 3; i++) {
                                var checkb = $this.next().find("input[type='checkbox']");
                                if (checkb.length > 0) {
                                    if (checkb.is(":checked")) {
                                        //取消选中
                                        checkb.prop('checked', false);
                                    } else {
                                        //选中
                                        checkb.prop('checked', true);
                                    }
                                    break;
                                } else {
                                    $this = $this.next();
                                }
                            }
                        }
                        return false;
                    });
                    newItem.find("input[type='checkbox']").bind("click", function (event) {
                        var $this = $(this);
                        var checked = $this.is(":checked");
                        console.log('checkbox:' + checked)
                        setTimeout(function () {
                            if (checked) {
                                //选中
                                $this.prop('checked', true);
                                console.log("设置选中")
                            } else {
                                //取消选中
                                $this.prop('checked', false);
                                console.log("取消选中")
                            }
                        });
                        return false;
                    });
                }
            }
        }, 'json');
@@ -544,6 +603,7 @@
                    newItem.find("td").eq(0).html(special.id);
                    newItem.find("td").eq(1).html(special.name);
                    newItem.find("td").eq(2).find("input[type='checkbox']").eq(0).val(special.id);
                });
            }
        }, 'json');
@@ -629,23 +689,29 @@
                }
                $(".table .addrecommend a").bind("click", function () {
                    var index = layer.open({
                        type: 1,
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: 0, //不显示关闭按钮
                        anim: 2,
                        area: ['500px', '250px'],
                        shadeClose: true, //开启遮罩关闭
                        content: $("#hometype-sure")
                    });
                    //直接添加到推荐
                    var key = $(this).attr("key");
                    $("#hometype-sure input[type=button]").click(function () {
                        $("#hometype .picture").val($("#hometype-sure .picture").val());
                        $("#hometype .desc").val($("#hometype-sure .desc").val());
                        $("#hometype .videoids").val(key);
                        layer.close(index);
                        $("#hometype").modal("show");
                    });
                    $("#hometype .videoids").val(key);
                    $("#hometype").modal("show");
                    // var index = layer.open({
                    //     type: 1,
                    //     skin: 'layui-layer-demo', //样式类名
                    //     closeBtn: 0, //不显示关闭按钮
                    //     anim: 2,
                    //     area: ['500px', '250px'],
                    //     shadeClose: true, //开启遮罩关闭
                    //     content: $("#hometype-sure")
                    // });
                    // var key = $(this).attr("key");
                    // $("#hometype-sure input[type=button]").click(function () {
                    //     $("#hometype .picture").val($("#hometype-sure .picture").val());
                    //     $("#hometype .desc").val($("#hometype-sure .desc").val());
                    //     $("#hometype .videoids").val(key);
                    //     layer.close(index);
                    //     $("#hometype").modal("show");
                    // });
                });
@@ -718,9 +784,9 @@
        $("#hometype .modal-footer button:last").click(function () {
            var ids = "";
            for (var i = 0; i < $("#hometype .table tr").length; i++) {
                if ($("#hometype .table tr td input[type=checkbox]").eq(i).is(':checked')) {
                    ids += $("#hometype .table tr td input[type=checkbox]").eq(i).val() + ",";
            for (var i = 0; i < $("#hometype .table td").length; i++) {
                if ($("#hometype .table  td input[type=checkbox]").eq(i).is(':checked')) {
                    ids += $("#hometype .table  td input[type=checkbox]").eq(i).val() + ",";
                }
            }
            if (ids.length < 1) {
@@ -730,7 +796,6 @@
            if (ids.length > 0)
                ids = ids.substr(0, ids.length - 1);
            alert(ids);
            $.post('api/home/addhomevideos', {
                'videoids': $("#hometype .videoids").val(),