<html lang="zh-cn">
|
|
<head>
|
<meta charset="utf-8">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<title>分区-热门分类</title>
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/maincontent.css" rel="stylesheet">
|
</head>
|
|
<body>
|
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
</nav>
|
<div id="mainbody">
|
<div id="sidebar">
|
<dl>
|
</dl>
|
</div>
|
<div id="neirong">
|
<div class="erjidh">
|
<table class="table">
|
<tbody>
|
<tr>
|
<td class="xiala">
|
<select name="select" id="appclass" class="form-control">
|
<option key='0'>全部</option>
|
</select>
|
</td>
|
<td>
|
<form class="form-inline" role="form">
|
<div class="form-group" role="search">
|
<input type="text" class="form-control" style="width:200px;" placeholder="搜索">
|
</div>
|
<button type="button" class="btn btn-default search">搜索</button>
|
</form>
|
</td>
|
<td>
|
<div class="tianjia">
|
<a href="#" class="btn btn-primary add" role="button">添加 +</a>
|
</div>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
<div class="zhuti">
|
<div class="zhutisousuo">
|
<table class="table">
|
<thead>
|
<tr>
|
<th width="10%">选择</th>
|
<th width="10%">编号</th>
|
<th width="20%">名称</th>
|
<th width="25%">APP名称</th>
|
<th width="20%">创建时间</th>
|
<th width="15%">删除</th>
|
</tr>
|
</thead>
|
</table>
|
</div>
|
<div class="liebiao">
|
<table class="table">
|
<tbody>
|
<tr style="display: none;">
|
<td width="10%">
|
<div class="xuanze">
|
<label>
|
<input type="checkbox" value="#"/>
|
</label>
|
</div>
|
</td>
|
<td width="10%">
|
<div class="bianhao"></div>
|
</td>
|
<td width="20%" style="text-align:center; line-height:105px;">
|
<div class="bianhaomingcheng">
|
</div>
|
</td>
|
<td width="25%" class="appnametd">
|
<div class="appname" style="display: none;">
|
<div class="checkbox">
|
<label>
|
<input type="checkbox" value="#"><div>
|
</div></label>
|
</div>
|
</div>
|
</td>
|
<td width="20%" style="text-align:center; line-height:105px;" class="createtime"></td>
|
<td width="15%">
|
<div class="anniu" name="del"><img src="image/dustbin.png" data-toggle="modal">
|
</div>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
</div>
|
<div class="bottom">
|
<div class="qx">
|
<div class="checkbox">
|
<label>
|
<input type="checkbox" class="checkAll">
|
全选</label>
|
</div>
|
</div>
|
<button class="btn btn-warning delAll" type="button">批量删除</button>
|
<div class="page">
|
<ul class="pagination">
|
<li class="disabled pre">
|
<a href="#">«</a>
|
</li>
|
<li>
|
<a href="#" class="next">»</a>
|
</li>
|
</ul>
|
<div class="form-group">
|
<div class="tzan">
|
<button type="button" class="btn btn-primary">跳转</button>
|
</div>
|
<div class="tz">
|
<input class="form-control" type="text" id="customPage" placeholder="页数">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div id="videotypes" style="display: none;">
|
<div style="align-content: center;"></div>
|
<div class="row" style="margin-left: 10px;">
|
<span style="float: left;">选择视频分类</span>
|
<select class="col-lg-5 roottype" id="classtype">
|
</select>
|
</div>
|
<!--<div class="row" style="margin-top: 170px;margin-left: 230px;">
|
<button class="btn btn-info sure">确定</button>
|
<button class="btn btn-default cancel">取消</button>
|
</div>-->
|
</div>
|
|
<script src="js/jquery.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
<script src="js/page.js"></script>
|
<script src="js/nav.js"></script>
|
<script src="js/common.js"></script>
|
<script src="layer/layer.js"></script>
|
|
<script>
|
var trHTML;
|
var appHTML;
|
var trCheckHtml;
|
$(function(){
|
|
var $tbody = $(".liebiao > .table > tbody");
|
trHTML = $tbody.html();
|
appHTML = $tbody.find(".appnametd").html();
|
trCheckHtml = $(".trCheck").html();
|
|
getVideoType(0);
|
// $.post("api/class/getnextclass", { 'pid': 0 }, function(data) {
|
// if(data.code == 0) {
|
// var alldata = data.data;
|
// for(var edata in alldata) {
|
// var selectType = $("#classtype");
|
// var selected = false;
|
// if(edata == 0) {
|
// selected = true;
|
// }
|
// if(selected) {
|
// selectType.append("<option value='" + alldata[edata].id + "' selected='selected'>" + alldata[edata].name + "</option>");
|
// } else {
|
// selectType.append("<option value='" + alldata[edata].id + "'>" + alldata[edata].name + "</option>");
|
// }
|
// }
|
// }
|
// }, 'json');
|
|
$(".add").bind("click",function(){
|
layindex = layer.open({
|
type: 1,
|
title: '添加',
|
btn:['确定','取消'],
|
shadeClose: true,
|
yes:function(){
|
sure();
|
},
|
shade: 0.8,
|
area: ['500px', '400px'],
|
content: $("#videotypes")
|
});
|
});
|
|
$("#videotypes .cancel").click(function() {
|
layer.close(layindex);
|
});
|
|
$.post("api/common/detailsystemlist", {}, function(data) {
|
if(data.code == 0) {
|
var appclass = $("#appclass");
|
allSystems = data.data;
|
for(var edata in allSystems) {
|
appclass.append("<option key='" + allSystems[edata].id + "'>" + allSystems[edata].name + "</option>");
|
}
|
}
|
getData(1);
|
}, 'json');
|
|
|
|
$(".checkAll").bind("click",function(){
|
if(this.checked) {
|
$(".xuanze > label >input ").prop('checked', true)
|
} else {
|
$(".xuanze > label >input ").prop('checked', false)
|
}
|
});
|
|
|
$(".search").bind("click",function(){
|
getData(1);
|
});
|
|
$(".delAll").bind("click", function() {
|
var arr= new Array();
|
var selectAll = $(".xuanze label input").each(function(){
|
var cur = $(this);
|
var ck= cur.context.checked;
|
if (ck) {
|
var val = cur.attr("key");
|
arr.push(val);
|
}
|
});
|
if(arr.length==0){
|
layer.msg("请先选择数据!");
|
return;
|
}
|
layer.confirm('是否批量删除?', {
|
btn: ['否','是']
|
}, function(index){
|
layer.close(index);
|
return false;
|
}, function(){
|
delHotVideoType(arr);
|
$(".checkAll").prop("checked",false);
|
});
|
|
});
|
|
});
|
</script>
|
<script>
|
|
// function setSelection(pid,$selectType){
|
// $.post("api/class/getnextclass", { 'pid': pid }, function(data) {
|
// $selectType.nextAll().remove();
|
// if(data.code == 0) {
|
// var alldata = data.data;
|
// for(var edata in alldata) {
|
// var selected = false;
|
// if(edata == 0) {
|
// selected = true;
|
// }
|
// if(selected) {
|
// selectType.append("<option value='" + alldata[edata].id + "' selected='selected'>" + alldata[edata].name + "</option>");
|
// } else {
|
// selectType.append("<option value='" + alldata[edata].id + "'>" + alldata[edata].name + "</option>");
|
// }
|
// }
|
// }
|
// }, 'json');
|
// }
|
|
|
|
function sure(){
|
var value= $("#videotypes select:last-of-type > option:checked").val();
|
$.post("api/videoType/addHotVideoType", {"type.id": value}, function(data) {
|
if(data.code == 0) {
|
layer.alert('添加成功!', {
|
icon: 1,
|
skin: 'layer-ext-seaing'
|
});
|
getData(1);
|
layer.close(layindex);
|
}else{
|
layer.alert('添加失败!', {
|
icon: 2,
|
skin: 'layer-ext-seaing'
|
});
|
}
|
}, 'json');
|
}
|
|
function getVideoType(pid, $parentselectitem) {
|
$.post('../new/api/class/getnextclass', {
|
"pid": pid
|
}, function(data) {
|
if(data.data.length > 0) {
|
if($parentselectitem==undefined) { //第一级
|
$("#videotypes .roottype").empty();
|
for(var i = 0; i < data.data.length; i++) {
|
$("#videotypes .roottype").append("<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>");
|
}
|
$("#videotypes .roottype").bind("change", function() {
|
getVideoType($(this).val(), $(this));
|
});
|
$parentselectitem = $("#classtype");
|
getVideoType(data.data[0].id,$parentselectitem);
|
} else { //下面几级
|
$parentselectitem.nextAll().remove();
|
if(pid > 0) {
|
var html = "<hr/><span style='float: left;'> </span>";
|
html += "<select class='col-lg-5'>";
|
html += "<option value='" + pid + "'>全部</option>";
|
for(var i = 0; i < data.data.length; i++) {
|
html += "<option value='" + data.data[i].id + "'>" + data.data[i].name + "</option>";
|
}
|
html += "</select><hr/>";
|
|
$parentselectitem.parent().append(html);
|
$parentselectitem.parent().find("select:last-of-type").bind("change", function() {
|
getVideoType($(this).val(), $(this));
|
});
|
}
|
}
|
}
|
|
}, 'json');
|
}
|
|
function delHotVideoType(ids){
|
$.ajax({
|
type:"post",
|
url:"api/videoType/deleteHotVideoType",
|
async:true,
|
data:{"ids":ids},
|
dataType:"json",
|
traditional: true, //阻止深度序列化
|
success:function(data){
|
if(data.code == "0") {
|
layer.alert('删除成功!', {
|
icon: 1,
|
skin: 'layer-ext-seaing'
|
});
|
getData(1);
|
}else{
|
layer.alert('删除失败!', {
|
icon: 2,
|
skin: 'layer-ext-seaing'
|
});
|
}
|
},
|
error:function(){
|
layer.msg("请稍后再试!");
|
}
|
});
|
}
|
|
function getData(pageIndex) {
|
var key = $(".form-inline > .form-group >input").val();
|
var detailsystemId= $("select[name='select']").find("option:checked").attr("key");
|
$.post("api/videoType/getHotVideoTypeList", { "page": pageIndex , "key":key ,"detailSystem":detailsystemId}, function(data) {
|
if(data.code == 0) {
|
setData(data,pageIndex);
|
fillPage(data.pageEntity, function(page) {
|
getData(page);
|
});
|
}
|
}, 'json');
|
}
|
|
function setData(data,pageIndex){
|
var $tbody = $(".liebiao > .table > tbody");
|
$(".liebiao tbody").empty();
|
var list = data.list;
|
for(var mm = 0; mm < list.length;mm++) {
|
var id = data.list[mm].hotType.id;
|
var name = data.list[mm].hotType.type.name;
|
var createtime = data.list[mm].hotType.createtime;
|
var detailSystemList = data.list[mm].detailSystemList;
|
$tbody.append(trHTML);
|
$tbody.find("tr").eq(mm).css("display","table-row");
|
var $curCheck = $tbody.find(".xuanze label input").eq(mm);
|
$curCheck.attr("key",id);
|
var $curCode = $tbody.find(".bianhao").eq(mm);
|
$curCode.text(id);
|
var $curName = $tbody.find(".bianhaomingcheng").eq(mm);
|
$curName.text(name);
|
$tbody.find(".createtime").eq(mm).text(getCommonTime(createtime));
|
$tbody.find("tr").eq(mm).find(".anniu").attr("key",id);
|
//app分类处理
|
for (var nn = 0; nn<detailSystemList.length;nn++) {
|
var detailSystem = detailSystemList[nn].detailSystem;
|
var selected = detailSystemList[nn].selected;
|
var $curttr=$tbody.find("tr").eq(mm);
|
var blank=" "+detailSystem.appName;
|
$curttr.find(".appnametd").append(appHTML);
|
$curttr.find(".appnametd > .appname").eq(nn).css("display","table-row");
|
$curttr.find(".appnametd .appname input").eq(nn).attr("key",detailSystem.id);
|
$curttr.find(".appnametd .appname input").eq(nn).attr("value",id);
|
$curttr.find(".appnametd .appname input").eq(nn).attr("checked",selected);
|
$curttr.find(".appnametd .appname label > div").eq(nn).append(blank);
|
}
|
}
|
|
$tbody.find("tr").find(".appnametd .appname input").bind("click",function(){
|
var id = $(this).val();
|
var sysid = $(this).attr("key");
|
var ck = this.checked;
|
var type = ck ? "0" : "1";
|
$.post("api/videoType/setSystemOfHotVideoType",{"type":type,"detailSystem.id":sysid,"hotType.id":id},function(){
|
if(ck){
|
if(data.code=="0")
|
layer.msg("添加成功");
|
else
|
layer.msg("添加失败");
|
}else{
|
if(data.code=="0")
|
layer.msg("删除成功");
|
else
|
layer.msg("删除失败");
|
}
|
},"text")
|
});
|
|
$("div[name='del']").bind("click",function(){
|
var $obj=$(this);
|
layer.confirm('您确定要删除?', {
|
btn: ['否','是'] //按钮
|
}, function(index){
|
layer.close(index);
|
return false;
|
}, function(){
|
var id = $obj.attr("key");
|
var arr = new Array();
|
arr.push(id);
|
delHotVideoType(arr);
|
});
|
});
|
|
}
|
</script>
|
</body>
|
|
</html>
|