Commit c8d53abb by 杨昕

添加媒资类别列表

parent c04306c2
Pipeline #9846 passed with stages
in 33 seconds
......@@ -98,7 +98,7 @@ class MediaController extends Controller
SrsHookValidate::srsHookCallback($request,[
'media_name' => 'required',
'media_type' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
......
......@@ -16,9 +16,9 @@ class MediaCategoryController extends Controller
$catgList = MediaCategoryModel::catgListPage($request);
return $catgList;
});
$data['name'] = $request->name;
$data['media_categories'] = $result;
return view('admin.media_category.list');
return view('admin.media_category.list',$data);
}
}
......@@ -145,7 +145,7 @@ class MediaModel extends Eloquent
*/
$media_info = explode("&",$request->media_name);
$mediaCatg = MediaCategoryModel::where('_id',$request->media_type)->first();
$mediaCatg = MediaCategoryModel::where('name',$request->media_type)->first();
if (empty($mediaCatg)){
throw new \Exception("媒资类别不存在");
}
......
......@@ -61,9 +61,9 @@
@foreach($media_types as $media_type)
@if($media_type['name'] == $media['media_type'])
<option value="{{$media['media_type_id']}}" selected>{{$media_type['name']}}</option>
<option value="{{$media_type['name']}}" selected>{{$media_type['name']}}</option>
@else
<option value="{{$media['media_type_id']}}">{{$media_type['name']}}</option>
<option value="{{$media_type['name']}}">{{$media_type['name']}}</option>
@endif
@endforeach
......
......@@ -3,6 +3,12 @@
@include('admin.common.commonMedia')
<link rel="stylesheet" href="{{ asset('xadmin/extra/datepicker/css/daterangepicker.css')}}">
<link rel="stylesheet" href="{{ asset('xadmin/extra/datepicker/css/htmleaf-demo.css')}}">
<script src="{{ asset('xadmin/extra/datepicker/js/moment.js')}}"></script>
<script src="{{ asset('xadmin/extra/datepicker/js/daterangepicker.js')}}"></script>
<body>
<!--====================================================
......@@ -22,211 +28,80 @@
<div class="card form">
<div class="card-header">
<h3><i class="fa fa-user-circle"></i> 栏目列表</h3>
<h3>媒资类别列表</h3>
</div>
<br>
<!--***** CONTENT *****-->
<div class="row" style="margin: 0 20px;">
<xblock>
<button class="btn btn-primary" onclick="x_admin_show('/web/news_category/create')">
<div class="row ml20">
<div class="xblock">
<button class="btn btn-primary" onclick="x_admin_show('/web/media_category/create')">
添加
</button>
<span class="x-right">共有数据:{{$count}} 条</span>
</xblock>
<table class="table table-condensed">
<form>
<input type="text" name="name" class="form-input" placeholder="类别名称" value="{{$name}}">
<button type="submit" class="btn btn-primary">搜索</button>
</form>
<span style="display: inline-block;height: 40px;line-height: 40px; float: right">共{{$media_categories->total()}}条</span>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>分类名</th>
<th>排序</th>
<tr class="bg-info text-white">
<th>序号</th>
<th>类别编号</th>
<th>媒资类别名称</th>
<th>状态</th>
{{--<th>链接</th>--}}
{{--<th>方法名称</th>--}}
<th>描述</th>
<th>操作</th>
</tr>
</thead>
<tbody class="x-cate">
@if (count($result)>=1)
@foreach($result as $v)
@if ($v['parent_id'] == 0)
@if(isset($v['son']))
<tr cate-id="{{$v['id']}}" fid="0">
<td>{{$v['id']}}</td>
<td><i class="iconfont x-show" status='true'>&#xe79f;</i>{{$v['title']}}</td>
<td>{{$v['sort']}}</td>
@if($v['st']== 0)
<td>启用</td>
@else
<td>禁用</td>
@endif
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$v['description']}}</td>
<td class="td-manage">
<a title="编辑" href="news_category/{{$v['id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$v['id']}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@foreach($v['son'] as $son)
@if(isset($son['son']))
<tr cate-id="{{$son['id']}}" fid="{{$v['id']}}">
<td>{{$son['id']}}</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="iconfont x-show" status='true'>&#xe79f;</i>{{$son['title']}}</td>
<td>{{$son['sort']}}</td>
@if($son['st']== 0)
<td>启用</td>
@else
<td>禁用</td>
@endif
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$son['description']}}</td>
<td class="td-manage">
<a title="编辑" href="news_category/{{$son['id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$son['id']}}')"
href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@foreach($son['son'] as $last_son)
<tr cate-id="{{$last_son['id']}}" fid="{{$son['id']}}">
<td>{{$last_son['id']}}</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├{{$last_son['title']}}</td>
<td>{{$last_son['sort']}}</td>
@if($last_son['st']== 0)
<td>启用</td>
@else
<td>禁用</td>
@endif
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$last_son['description']}}</td>
<td class="td-manage">
<a title="编辑" href="news_category/{{$last_son['id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$last_son['id']}}')"
href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@endforeach
@else
<tr cate-id="{{$son['id']}}" fid="{{$v['id']}}">
<td>{{$son['id']}}</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i
class="iconfont x-show"
status='true'>&#xe79f;</i>{{$son['title']}}</td>
<td>{{$son['sort']}}</td>
@if($son['st']== 0)
<td>启用</td>
@else
<td>禁用</td>
@endif
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$son['description']}}</td>
<td class="td-manage">
<a title="编辑" href="news_category/{{$son['id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$son['id']}}')"
href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@endif
@endforeach
@else
<tr cate-id="{{$v['id']}}" fid="0">
<td>{{$v['id']}}</td>
<td><i class="iconfont x-show" status='true'>&#xe79f;</i>{{$v['title']}}</td>
<td>{{$v['sort']}}</td>
@if($v['st']== 0)
<td>启用</td>
@else
<td>禁用</td>
@endif
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$v['description']}}</td>
<td class="td-manage">
<a title="编辑" href="news_category/{{$v['id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$v['id']}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@endif
@else
<tr cate-id="{{$v['id']}}" fid="{{$v['parent_id']}}">
<td>{{$v['id']}}</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;├{{$v['title']}}</td>
<td>{{$v['sort']}}</td>
@if($v['st']== 0)
<td>启用</td>
<tbody>
@if(count($media_categories)>0)
@foreach ($media_categories as $key => $media_category)
<tr class="<?php if($key%2==0) echo 'table-success';?>">
<td>{{$key+1}}</td>
<td style="max-width: 150px;">{{$media_category['_id']}}</td>
<td>{{$media_category['name']}}</td>
<td>
@if($media_category['status']==0)
启用
@else
<td>禁用</td>
停用
@endif
{{--<td>{{$v['link']}}</td>--}}
{{--<td>{{$v['slug']}}</td>--}}
<td>{{$v['description']}}</td>
<td class="td-manage">
<a title="编辑"
onclick="x_admin_show('编辑','news_category/{{$v['id']}}/edit',440,500)"
href="javascript:;">
<i class="iconfont">&#xe609;</i>
</a>
<a title="删除" onclick="member_del(this,'{{$v['id']}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@endif
</td>
<td class="td-manage">
<a onclick="member_stop(this,'{{$media_category["_id"]}}')" href="javascript:;" status="{{$media_category['status']}}">
<i class="iconfont">@if( $media_category['status'] == 1 ) &#xe79e;@else&#xe689;@endif</i>
</a>
<a title="编辑" href="/web/member/{{$media_category['_id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
{{--<a onclick="x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)" title="修改密码"--}}
{{--href="javascript:;">--}}
{{--<i class="iconfont">&#xe61a;</i>--}}
{{--</a>--}}
<a title="删除" onclick="member_del(this,'{{$media_category["_id"]}}')" href="javascript:;">
<i class="iconfont">&#xe695;</i>
</a>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="6" style="text-align:center">暂无数据</td>
<td colspan="9" style="text-align:center">暂无数据</td>
</tr>
@endif
</tbody>
</table>
<div class="page">
<div>
{{$media_categories->appends(['name'=>$name])->links()}}
</div>
</div>
</div>
</div>
......@@ -247,14 +122,12 @@
<script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script>
<script type="text/javascript">
function x_admin_show(url) {
window.location.href = url;
// window.open(url);
function x_admin_show(url){
window.location.href = url;
}
/*权限-删除*/
function member_del(row, id) {
function member_del(row,id){
$.confirm({
......@@ -262,70 +135,145 @@
// cancelButtonClass: 'btn-info',
cancelButtonClass: 'btn-info',
confirmButtonClass: 'btn-danger',
confirmButton: '确认',
cancelButton: '取消',
content:'确认要删除吗?',
content:'确认要刪除吗?',
confirmButton:'确认',
cancelButton:'取消',
confirm: function () {
fetch_response('DELETE', "/web/news_category/" + id).then(function (res) {
$('body').toast({
position: 'fixed',
content: res.msg,
duration: 1000,
top: '50%'
});
if (res.code == 200) {
fetch_response('DELETE',"/web/media_category/"+id).then(function (res) {
if (res.code==200) {
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
setTimeout(function () {
window.location.href = '/web/news_category';
}, 2000)
window.location.href='/web/media_category';
},2000)
}else{
$('body').toast({
position:'fixed',
content:res.msg,
duration:1000,
top:'50%'
});
}
}).error(function (err) {
console.log('err')
})
},
cancel: function () {
$.alert('cancel triggered!');
$('body').toast({
position:'fixed',
content:'已取消',
duration:1000,
top:'50%'
});
}
});
}
$("tbody.x-cate tr[fid!='0']").hide();
function member_stop(obj,id){
var cateIds = [];
var status = $(obj).attr('status');
var opts = new FormData();
var title = "停用";
opts.append('_token', "{{csrf_token()}}")
function getCateId(cateId) {
if (status == '1'){
title = "开启";
}
$("tbody tr[fid=" + cateId + "]").each(function (index, el) {
id = $(el).attr('cate-id');
cateIds.push(id);
getCateId(id);
});
}
// 栏目多级显示效果
$('.x-show').click(function () {
if ($(this).attr('status') == 'true') {
$(this).html('&#xe66b;');
$(this).attr('status', 'false');
cateId = $(this).parents('tr').attr('cate-id');
$("tbody tr[fid=" + cateId + "]").show();
} else {
cateIds = [];
$(this).html('&#xe79f;');
$(this).attr('status', 'true');
cateId = $(this).parents('tr').attr('cate-id');
getCateId(cateId);
for (var i in cateIds) {
$("tbody tr[cate-id=" + cateIds[i] + "]").hide().find('.x-show').html('&#xe623;').attr('status', 'true');
$.confirm({
// confirmButtonClass: 'btn-info',
// cancelButtonClass: 'btn-info',
cancelButtonClass: 'btn-info',
confirmButtonClass: 'btn-danger',
content:'确认要'+title+'吗?',
confirmButton:'确认',
cancelButton:'取消',
confirm: function () {
if(title == '停用'){
//发异步把用户状态进行更改
opts.append('id',id);
opts.append('status',0);
fetch_response('POST','/web/media_category/disable',opts).then(function(res){
if(res.code == 200){
$(obj).attr('title','启用')
$(obj).find('i').html('&#xe79e;');
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
$('body').toast({
position: 'fixed',
content: '已停用',
duration: 1000,
top: '50%'
});
setTimeout(function () {
window.location.href = '/web/member';
}, 2000)
}else{
$('body').toast({
position: 'fixed',
content: res.msg,
duration: 1000,
top: '50%'
});
}
});
}else{
opts.append('id',id);
opts.append('status',1);
fetch_response('POST','/web/media_category/disable',opts).then(function(res){
if(res.code == 200){
$(obj).attr('title','停用')
$(obj).find('i').html('&#xe689;');
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
// layer.msg('已启用!',{icon: 6,time:1000},function(){
// window.location.reload();
// });
$('body').toast({
position: 'fixed',
content: '已启用',
duration: 1000,
top: '50%'
});
setTimeout(function () {
window.location.href = '/web/media_category';
}, 2000)
}else{
$('body').toast({
position: 'fixed',
content: res.msg,
duration: 1000,
top: '50%'
});
}
});
}
},
cancel: function () {
$('body').toast({
position: 'fixed',
content: '已取消',
duration: 1000,
top: '50%'
});
}
}
})
});
}
</script>
</body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment