Commit 42bcfda6 by 李洋

完成搜索

parent 8da67cd9
......@@ -322,8 +322,51 @@ class MessageController extends Controller
private function allHistoryList(Request $request, $id, $viewid)
{
Csrf($request);
$db = DB::connection('message')->table('lie_msg_log');
$info = $db->paginate(20);
//搜索条件
$search_id = $request->input('search_id');
$search_user = $request->input('search_user');
$search_sendtime = $request->input('search_sendtime');
$search_channel = $request->input('search_channel');
$search_status = $request->input('search_status');
$db = DB::connection('message');
if($search_id==null && $search_user==null && $search_sendtime==null && $search_channel==null && $search_status==null)
{
$info = $db->table('lie_msg_log')->paginate(20);
$search_id = '';
$search_user = '';
$search_sendtime = '';
$search_channel = 0;
$search_status = 0;
}else
{
//select option是否为0,为0则不查
if($search_channel==0 && $search_status!=0)
{
$info = $db->table('lie_msg_log')
->where('log_id','like',"%$search_id%")->where('obj_user','like',"%$search_user%")
->where('expect_send_time',$search_sendtime)
->where('status',$search_status)->paginate(20);
}elseif($search_channel!=0 && $search_status==0)
{
$info = $db->table('lie_msg_log')
->where('log_id','like',"%$search_id%")->where('obj_user','like',"%$search_user%")
->where('expect_send_time',$search_sendtime)->where('channel_type',$search_channel)
->paginate(20);
}elseif($search_channel==0 && $search_status==0)
{
$info = $db->table('lie_msg_log')
->where('log_id','like',"%$search_id%")->where('obj_user','like',"%$search_user%")
->where('expect_send_time',$search_sendtime)->paginate(20);
}else
{
$info = $db->table('lie_msg_log')
->where('log_id','like',"%$search_id%")->where('obj_user','like',"%$search_user%")
->where('expect_send_time',$search_sendtime)->where('channel_type',$search_channel)
->where('status',$search_status)->paginate(20);
}
}
$msg_channels = [
'全部',
'站内信',
......@@ -331,11 +374,17 @@ class MessageController extends Controller
'邮件',
'微信通知'
];
$data=[
'title'=>'asd',
'id'=>$id,
'info'=>$info,
'msg_channels'=>$msg_channels
'msg_channels'=>$msg_channels,
'search_id'=>$search_id,
'search_user'=>$search_user,
'search_sendtime'=>$search_sendtime,
'search_channel'=>$search_channel,
'search_status'=>$search_status,
];
return view($viewid, $data);
......
......@@ -8,4 +8,14 @@ layui.use('laydate', function(){
type:'datetime',
format:'yyyy-MM-dd HH:mm'
});
});
\ No newline at end of file
});
//指定条件搜索
$('#search-btn').click(function () {
var search_id = $('#search-msg-id').val();
var search_user = $('#search-msg-userobj').val();
var search_sendtime = $('#Choice_start').val();
var search_channel = $('#search-msg-channel option:selected').val();
var search_status = $('#search-msg-status option:selected').val();
window.location.href="/message/allhistoryList?search_id="+search_id+"&search_user="+search_user+"&search_sendtime="+search_sendtime+"&search_channel="+search_channel+"&search_status="+search_status;
})
\ No newline at end of file
......@@ -24,33 +24,33 @@
<form method="get" action="/message/templateList">
<div style="text-align: center">
<label>消息编号:</label>
<input class="form-control" type="text" id="search-msg-id" placeholder="请输入消息编号"/>
<input class="form-control" type="text" id="search-msg-id" placeholder="请输入消息编号" value="{{ $search_id }}"/>
<label>用户:</label>
<input class="form-control" type="text" id="search-msg-userobj" placeholder="请输入用户">
<input class="form-control" type="text" id="search-msg-userobj" placeholder="请输入用户" value="{{ $search_user }}">
<label>发送时间:</label>
<input type="text" class="form-control" id="Choice_start" name="create_time_start/condition" value=""/>
<input type="text" class="form-control" id="Choice_start" name="create_time_start/condition" value="{{ $search_sendtime }}"/>
</div>
<div class="div-b" style="text-align: center">
<label>消息渠道:</label>
<select class="form-control" id="search-msg-channel">
@for($i=0;$i<count($msg_channels);$i++)
<option value="{{ $i }}">{{ $msg_channels[$i] }}</option>
<option value="{{ $i }}" @if($i==$search_channel) selected @endif>{{ $msg_channels[$i] }}</option>
@endfor
</select>
<label>消息状态:</label>
<select class="form-control" id="search-msg-status">
<option value="0">全部</option>
<option value="-3">已取消</option>
<option value="-2">待发送</option>
<option value="-1">发送失败</option>
<option value="1">发送成功</option>
<option value="0" @if(0==$search_status) selected @endif>全部</option>
<option value="-3" @if(-3==$search_status) selected @endif>已取消</option>
<option value="-2" @if(-2==$search_status) selected @endif>待发送</option>
<option value="-1" @if(-1==$search_status) selected @endif>发送失败</option>
<option value="1" @if(1==$search_status) selected @endif>发送成功</option>
</select>
<input class="btn btn-primary btn-sm" type="submit" value="搜索"/>
<input class="btn btn-primary btn-sm" id="search-btn" value="搜索"/>
</div>
</form>
......
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 sign in to comment