Commit 38f5bec7 by 杨昕

添加媒资类别模块

parent 2d0f40b4
Pipeline #9840 passed with stages
in 33 seconds
...@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Web; ...@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Web;
use App\Model\MediaCategoryModel; use App\Model\MediaCategoryModel;
use App\Model\MediaModel; use App\Model\MediaModel;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
...@@ -57,4 +58,47 @@ class MediaController extends Controller ...@@ -57,4 +58,47 @@ class MediaController extends Controller
return success($res); return success($res);
} }
/**
* 显示
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\ControllerException
*/
public function create(Request $request){
$reslut = handler_drive(function () use($request){
$media_types = MediaCategoryModel::catgList($request);
return $media_types;
});
$data['media_types'] = $reslut;
$data['media_id'] = 'mda-'.generateRandomNum(16);
return view('admin.media.media_add',$data);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function store(Request $request){
$id = handler_drive(function () use($request){
SrsHookValidate::srsHookCallback($request,[
'media_name' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
'media_url' => 'required',
]);
return MediaModel::hookRestoreMedia($request);
});
return success($id);
}
} }
...@@ -40,7 +40,7 @@ class MediaModel extends Eloquent ...@@ -40,7 +40,7 @@ class MediaModel extends Eloquent
$tmp[$catg['_id']] = $catg['name']; $tmp[$catg['_id']] = $catg['name'];
} }
$medias = MediaModel::where($where)->paginate(10); $medias = MediaModel::where($where)->orderBy("create_time","desc")->paginate(10);
foreach ($medias as $media){ foreach ($medias as $media){
$media['media_type'] = $tmp[$media['media_type_id']]; $media['media_type'] = $tmp[$media['media_type_id']];
...@@ -276,6 +276,9 @@ class MediaModel extends Eloquent ...@@ -276,6 +276,9 @@ class MediaModel extends Eloquent
public static function getMediaList($request){ public static function getMediaList($request){
try{ try{
/**
*[{"bookNum":["hb15011","2"],"mediaCatg":"一题一码"}]
*/
$params = json_decode($request->params,true); $params = json_decode($request->params,true);
if (empty($params)){ if (empty($params)){
...@@ -309,7 +312,10 @@ class MediaModel extends Eloquent ...@@ -309,7 +312,10 @@ class MediaModel extends Eloquent
$res[] = $item->groupBy("book_num"); $res[] = $item->groupBy("book_num");
} }
if (isset($res[0]) || empty($res[0])){ /**
* 排除res为空
*/
if (!isset($res[0]) || empty($res[0])){
return []; return [];
} }
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
"id": 11, "id": 11,
"pid": 0, "pid": 0,
"name": "媒资管理", "name": "媒资管理",
"icon": "", "icon": "",
"link": "/manager", "link": "/manager",
"slug": "manager", "slug": "manager",
"description": "", "description": "",
...@@ -198,4 +198,82 @@ ...@@ -198,4 +198,82 @@
"sort": 25, "sort": 25,
"key_name": "media_create" "key_name": "media_create"
}] }]
},{
"id": 3,
"pid": 0,
"name": "媒资类别管理",
"icon": "",
"link": "/media_category",
"slug": "media_category",
"description": "",
"show": 1,
"sort": 2,
"key_name": "media_category",
"son": [{
"id": 31,
"pid": 3,
"name": "媒资类别列表",
"icon": "",
"link": "/media_category",
"slug": "media_category.index",
"description": "",
"show": 1,
"sort": 25,
"key_name": "media_list"
},{
"id": 31,
"pid": 3,
"name": "媒资类别删除",
"icon": "",
"link": "",
"slug": "media_category.destroy",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_destroy"
}, {
"id": 33,
"pid": 3,
"name": "媒资类别添加保存",
"icon": "",
"link": "",
"slug": "media_category.store",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_store"
}, {
"id": 34,
"pid": 3,
"name": "媒资类别修改保存",
"icon": "",
"link": "",
"slug": "media_category.update",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_update"
}, {
"id": 35,
"pid": 3,
"name": "媒资类别编辑",
"icon": "",
"link": "",
"slug": "media_category.edit",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_edit"
}, {
"id": 36,
"pid": 3,
"name": "媒资类别添加",
"icon": "",
"link": "/media_category/create",
"slug": "media_category.create",
"description": "",
"show": 0,
"sort": 25,
"key_name": "media_create"
}]
}] }]
\ No newline at end of file
...@@ -36,95 +36,58 @@ ...@@ -36,95 +36,58 @@
<div class="col-md-12"> <div class="col-md-12">
<!--***** FORM GROUP *****--> <!--***** FORM GROUP *****-->
<div class="card form"> <div class="card form" id="form5">
<div class="card-header"> <div class="card-header">
<h3><i class="fa fa-user-circle"></i>管理员注册</h3> <h3>编辑媒资</h3>
</div> </div>
<br> <br>
<form id="newForm"> <form id="newForm">
<input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="form-group"> <input type="hidden" name="media_id" value="{{$media_id}}">
<label for="uesrname">姓名</label> {{ method_field('POST')}}
<div class="input-group ">
<div class="input-group-addon"><i class="fa fa-user-o"></i></div>
<input type="text" class="form-control" name="name" id="uesrname"
placeholder="姓名">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="nickname"></label> <label for="media_name">媒资名</label>
<div class="input-group "> <div class="input-group ">
<div class="input-group-addon"><i class="fa fa-user-o"></i></div> <div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div>
<input type="text" class="form-control" name="nickname" id="nickname" <input type="text" class="form-control" name="media_name" id="media_name"
placeholder="昵称"> placeholder="媒资名称" value="">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="formGroupExampleInput2">密码<span class="red">*</span></label> <label for="exampleSelect1">媒资类别</label>
<div class="input-group "> <select class="form-control" id="exampleSelect1" name="media_type">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" class="form-control" value="123123" id="inlineFormInputGroup">
<small class="form-text text-muted">6到16个字符</small>
</div>
</div>
<div class="form-group"> @foreach($media_types as $media_type)
<label for="formGroupExampleInput2">确认密码</label> <option value="{{$media_type["name"]}}" >{{$media_type['name']}}</option>
<div class="input-group "> @endforeach
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" name="password" class="form-control" value="123123" </select>
id="inlineFormInputGroup">
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mobile">电话号码</label> <label for="mobile">媒资视频链接</label>
<div class="input-group "> <div class="input-group ">
<div class="input-group-addon"><i class="fa fa-phone"></i></div> <div class="input-group-addon"><i class="iconfont">&#xe746;</i></div>
<input type="text" class="form-control" name="mobile" id="mobile" <input type="text" class="form-control" name="media_url" id="media_url" value=""
placeholder="电话号码"> placeholder="视频链接">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="mobile">邮箱</label> <label class="access-key">公钥</label>
<div class="input-group "> <textarea class="form-control" name="access_key" id="access-key" rows="5" placeholder="公钥"></textarea>
<div class="input-group-addon"><i class="iconfont">&#xe610;</i></div>
<input type="text" class="form-control" name="email" id="emial"
placeholder="邮箱">
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="role">角色</label> <label class="secret-key">私钥</label>
<div class="input-group "> <textarea class="form-control" name="secret_key" id="secret-key" rows="5" placeholder="私钥"></textarea>
<div class="input-group-addon"><i class="fa fa-phone"></i></div> -->
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<span class="mr5" style="margin-right: 20px;">1</span>
</label>
</div>
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<span class="mr5" style="margin-right: 20px;">1</span>
</label>
</div>
</div>
</div> </div>
<button type="submit" onclick="registerUser();" class="btn btn-general btn-blue mr-2">确认</button>
<button type="submit" onclick="registerUser();" <button type="reset" onclick="cancle()" class="btn btn-general btn-white">取消</button>
class="btn btn-general btn-blue mr-2">确认
</button>
<button type="reset" class="btn btn-general btn-white">重置 </button>
</form> </form>
</div> </div>
...@@ -134,14 +97,12 @@ ...@@ -134,14 +97,12 @@
</div> </div>
<!--Global Javascript --> <!--Global Javascript -->
@include('admin.common_bak.foot') @include('admin.common.foot')
<script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script> <script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script>
<script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script> <script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script>
{{--<link rel="stylesheet" href="{{ asset('xadmin/extra/toast/css/toast.css')}}">--}}
<!--Core Javascript --> <!--Core Javascript -->
<script type="text/javascript"> <script type="text/javascript">
...@@ -151,51 +112,48 @@ ...@@ -151,51 +112,48 @@
$("#newForm").validate({ $("#newForm").validate({
rules: { rules: {
nickname: "required",
name: { name: {
required: true, required: true,
minlength: 2 minlength: 2
}, },
password: { // password: {
required: true, // required: true,
minlength: 5 // minlength: 5
}, // },
confirm_password: { // confirm_password: {
required: true, // required: true,
minlength: 5, // minlength: 5,
equalTo: "#password" // equalTo: "#password"
}, // },
email: { // email: {
required: true, // required: true,
email: true // email: true
}, // },
}, },
messages: { messages: {
nickname: {
required:''
},
name: { name: {
required: "昵称不能为空", required: "媒资名称不能为空",
minlength: "昵称至少2个字符" minlength: "Your username must consist of at least 2 characters"
},
password: {
required: "请输入密码",
minlength: "密码长度不能小于5"
},
confirm_password: {
required: "请输入确认密码",
minlength: "密码长度不能小于5",
equalTo: "两次密码输入不一致"
}, },
email: "请输入有效邮箱", // password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long"
// },
// confirm_password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long",
// equalTo: "Please enter the same password as above"
// },
//email: "Please enter a valid email address",
}, },
submitHandler: function (form) { submitHandler: function (form) {
var form = document.querySelector("#newForm"); var form = document.querySelector("#newForm");
var formdata = new FormData(form); var formdata = new FormData(form);
fetch_response('POST', '/web/member', formdata).then(function (res) { console.log("formdata",formdata)
fetch_response('POST',"/web/media_manager", formdata).then(function (res) {
if (res.code == 200) { if (res.code == 200) {
//console.log('dsfsfsd')
$('body').toast({ $('body').toast({
position: 'fixed', position: 'fixed',
content: res.msg, content: res.msg,
...@@ -203,7 +161,7 @@ ...@@ -203,7 +161,7 @@
top: '50%' top: '50%'
}); });
setTimeout(function () { setTimeout(function () {
window.location.href = '/web/member'; window.location.href = '/web/media_manager';
}, 2000) }, 2000)
} else { } else {
...@@ -220,6 +178,18 @@ ...@@ -220,6 +178,18 @@
} }
function cancle() {
$('body').toast({
position: 'fixed',
content: '已取消',
duration: 1000,
top: '50%'
});
setTimeout(function () {
window.history.back();
}, 2000)
}
</script> </script>
</body> </body>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<div class="input-group "> <div class="input-group ">
<div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div> <div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div>
<input type="text" class="form-control" name="media_name" id="media_name" <input type="text" class="form-control" name="media_name" id="media_name"
placeholder="姓名" value="{{$media['media_name']}}"> placeholder="媒资名称" value="{{$media['media_name']}}">
</div> </div>
</div> </div>
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
@foreach($media_types as $media_type) @foreach($media_types as $media_type)
@if($media_type['name'] == $media['media_type']) @if($media_type['name'] == $media['media_type'])
<option value="{{$media['media_type']}}" selected>{{$media_type['name']}}</option> <option value="{{$media['media_type_id']}}" selected>{{$media_type['name']}}</option>
@else @else
<option value="{{$media['media_type']}}">{{$media_type['name']}}</option> <option value="{{$media['media_type_id']}}">{{$media_type['name']}}</option>
@endif @endif
@endforeach @endforeach
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<div class="row ml20"> <div class="row ml20">
<div class="xblock"> <div class="xblock">
<button class="btn btn-primary" onclick="x_admin_show('/web/member/create')"> <button class="btn btn-primary" onclick="x_admin_show('/web/media_manager/create')">
添加 添加
</button> </button>
......
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