Commit 17af9925 by 杨昕

编辑媒资

parent 3f24562e
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Web;
use App\Model\MediaCategoryModel;
use App\Model\MediaModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
......@@ -10,7 +11,6 @@ class MediaController extends Controller
{
public function index(Request $request){
$medias = MediaModel::mediaList($request);
return view('admin.media.media_list', [
......@@ -23,12 +23,24 @@ class MediaController extends Controller
}
public function edit(Request $request){
/**
* 编辑房间
* @param Request $request
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\ControllerException
*/
public function edit(Request $request,$id){
$media = handler_drive(function () use ($request,$id){
return MediaModel::getMediaDetail($id);
});
$media_types = MediaCategoryModel::catgList($request);
return view('admin.media.media_edit', [
'media' => $media,
'media_types' => $media_types
]);
}
......
......@@ -89,9 +89,26 @@ class MediaModel extends Eloquent
return $id;
}
public static function upload($request){
/**
* 获取媒资详情
* @param $id
* @return mixed
* @throws DatabaseException
*/
public static function getMediaDetail($id){
try{
$media = MediaModel::find($id);
if (empty($media)){
throw new \Exception('媒资不存在');
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $media;
}
......
......@@ -38,7 +38,7 @@
<!--***** FORM GROUP *****-->
<div class="card form" id="form5">
<div class="card-header">
<h3>编辑用户</h3>
<h3>编辑媒资</h3>
</div>
<br>
<form id="newForm">
......@@ -46,16 +46,33 @@
<input type="hidden" name="_token" value="{{csrf_token()}}">
{{ method_field('PUT')}}
<input type="hidden" name="id" value="{{$info['_id']}}">
<input type="hidden" name="id" value="{{$media['_id']}}">
<div class="form-group">
<label for="uesrname">姓名</label>
<label for="media_name">媒资名称</label>
<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="姓名" value="{{$info['name']}}">
<div class="input-group-addon"><i class="icon iconfont icon-title">&#xe62b;</i></div>
<input type="text" class="form-control" name="name" id="media_name"
placeholder="姓名" value="{{$media['media_name']}}">
</div>
</div>
<div class="form-group">
<label for="exampleSelect1">媒资类别</label>
<select class="form-control" id="exampleSelect1">
@foreach($media_types as $media_type)
@if($media_type['name'] == $media['media_type'])
<option value="{{$media['media_type']}}" selected>{{$media_type['name']}}</option>
@else
<option value="{{$media['media_type']}}">{{$media_type['name']}}</option>
@endif
@endforeach
</select>
</div>
{{--<div class="form-group">--}}
{{--<label for="mobile">电话号码</label>--}}
......@@ -66,36 +83,46 @@
{{--</div>--}}
{{--</div>--}}
{{--<div class="form-group">--}}
{{--<label for="mobile">邮箱</label>--}}
{{--<div class="input-group ">--}}
{{--<div class="input-group-addon"><i class="iconfont">&#xe610;</i></div>--}}
{{--<input type="text" class="form-control" name="email" id="emial" value="{{$info['email']}}"--}}
{{--placeholder="邮箱">--}}
{{--</div>--}}
{{--</div>--}}
<div class="form-group">
<label for="role">状态</label>
<label for="mobile">媒资视频链接</label>
<div class="input-group ">
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="status" value="1" @if($info['status'] == 1 ) checked @endif>
<span class="mr5" style="margin-right: 20px;">不可用</span>
</label>
<div class="input-group-addon"><i class="iconfont">&#xe746;</i></div>
<input type="text" class="form-control" name="media_url" id="media_url" value="{{$media['media_url']}}"
placeholder="视频链接">
</div>
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="status" value="0" @if($info['status'] == 0) checked @endif>
<span class="mr5" style="margin-right: 20px;">可用</span>
</label>
</div>
<div class="form-group">
<label class="digest">公钥</label>
<textarea class="form-control" name="access_key" id="digest" rows="5" placeholder="公钥">{{$media['access_key']}}</textarea>
</div>
<div class="form-group">
<label class="digest">私钥</label>
<textarea class="form-control" name="secret_key" id="digest" rows="5" placeholder="私钥">{{$media['secret_key']}}</textarea>
</div>
{{--<div class="form-group">--}}
{{--<label for="role">状态</label>--}}
{{--<div class="input-group ">--}}
{{--<div class="checkbox">--}}
{{--<label class="radio-inline">--}}
{{--<input type="radio" name="status" value="1" @if($media['status'] == 1 ) checked @endif>--}}
{{--<span class="mr5" style="margin-right: 20px;">不可用</span>--}}
{{--</label>--}}
{{--</div>--}}
{{--<div class="checkbox">--}}
{{--<label class="radio-inline">--}}
{{--<input type="radio" name="status" value="0" @if($info['status'] == 0) checked @endif>--}}
{{--<span class="mr5" style="margin-right: 20px;">可用</span>--}}
{{--</label>--}}
{{--</div>--}}
{{--</div>--}}
{{--</div>--}}
<button type="submit" onclick="registerUser();"
......@@ -168,7 +195,7 @@
console.log("formdata",formdata)
fetch_response('POST',"/web/member/{{$info['_id']}}", formdata).then(function (res) {
fetch_response('POST',"/web/media_manager/{{$media['_id']}}", formdata).then(function (res) {
if (res.code == 200) {
$('body').toast({
position: 'fixed',
......@@ -177,7 +204,7 @@
top: '50%'
});
setTimeout(function () {
window.location.href = '/web/member';
window.location.href = '/web/media_manager';
}, 2000)
} else {
......
......@@ -41,9 +41,8 @@
</button>
<form>
<input type="text" name="name" class="form-input" placeholder="用户名称" value="{{$name}}">
<input id="endDate" width="312" class="form-input" />
<input type="text" name="name" class="form-input" placeholder="媒资名称" value="{{$name}}">
{{--<input id="endDate" width="312" class="form-input" />--}}
<button type="submit" class="btn btn-primary">搜索</button>
</form>
{{--<span style="display: inline-block;height: 40px;line-height: 40px; float: right">共{{$users->total()}}条</span>--}}
......@@ -54,6 +53,8 @@
<tr class="bg-info text-white">
<th>序号</th>
<th>媒资编号</th>
<th>媒资名称</th>
<th>视频类别</th>
<th>视频地址</th>
<th>创建时间</th>
<th>操作</th>
......@@ -66,12 +67,14 @@
<tr class="<?php if($key%2==0) echo 'table-success';?>">
<td>{{$key+1}}</td>
<td style="max-width: 150px;">{{$media['_id']}}</td>
<td style="max-width: 300px;">{{$media['media_url']}}</td>
<td style="max-width: 150px;">{{$media['media_name']}}</td>
<td style="max-width: 50px;">{{$media['media_type']}}</td>
<td style="max-width: 200px;">{{$media['media_url']}}</td>
<td style="max-width: 100px;">{{$media['create_time']}}</td>
<td class="td-manage">
<a title="编辑" href="/web/member/{{$media['_id']}}/edit">
<a title="编辑" href="/web/media_manager/{{$media['_id']}}/edit">
<i class="iconfont">&#xe609;</i>
</a>
{{--<a onclick="x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)" title="修改密码"--}}
......@@ -138,7 +141,7 @@
confirm: function () {
fetch_response('DELETE',"/web/member/"+id).then(function (res) {
fetch_response('DELETE',"/web/media_manager/"+id).then(function (res) {
if (res.code==200) {
$('body').toast({
position:'fixed',
......@@ -147,7 +150,7 @@
top:'50%'
});
setTimeout(function () {
window.location.href='/web/member';
window.location.href='/web/media_manager';
},2000)
}else{
$('body').toast({
......@@ -171,106 +174,8 @@
});
}
function member_stop(obj,id){
var status = $(obj).attr('status');
var opts = new FormData();
var title = "停用";
opts.append('_token', "{{csrf_token()}}")
if (status == '1'){
title = "开启";
}
$.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/member/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/member/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('已启用');
$('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%'
});
}
});
}
},
cancel: function () {
$('body').toast({
position: 'fixed',
content: '已取消',
duration: 1000,
top: '50%'
});
}
});
}
// updateConfig(1);
$('#endDate').bind("onclickOnce",function () {
alert('sdfs')
})
......@@ -285,20 +190,6 @@
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});
// var options = {};
//
// options.locale = {
......
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