Commit 8da67cd9 by 李洋

完成除了所有消息列表的搜索功能

parent a97ffbb4
......@@ -176,10 +176,28 @@ class MessageController extends Controller
private function templateList(Request $request, $id, $viewid)
{
Csrf($request);
$cnt = DB::connection('message');
$search_desc = $request->input('search_desc');
$search_channel = $request->input('search_channel');
//取出自动发送模板数据
$info = $cnt->table('lie_msg_tpl')->where('source_type','1')->paginate(20);
$cnt = DB::connection('message');
//自动发送模板数据
//1.首次进页面无搜索条件
if($search_desc==null && $search_channel==null)
{
$info = $cnt->table('lie_msg_tpl')->where('source_type','1')->paginate(20);
$search_channel = 0;
$search_desc = '';
}else//2.有搜索条件
{
//渠道里没有0,所以如果没选,将此条件剔除掉
if(0==$search_channel)
{
$info = $cnt->table('lie_msg_tpl')->where('source_type','1')->where('description','like',"%$search_desc%")->paginate(20);
}else
{
$info = $cnt->table('lie_msg_tpl')->where('source_type','1')->where('channels','like',"%$search_channel%")->where('description','like',"%$search_desc%")->paginate(20);
}
}
//构建model
foreach ($info as $tpl)
......@@ -213,6 +231,8 @@ class MessageController extends Controller
'id'=>$id,
'info'=>$info,
'msg_channels'=>$msg_channels,
'search_desc'=>$search_desc,
'search_channel'=>$search_channel,
];
return view($viewid, $data);
......@@ -222,8 +242,39 @@ class MessageController extends Controller
private function manualHistoryList(Request $request, $id, $viewid)
{
Csrf($request);
//搜索条件
$search_desc = $request->input('search_desc');
$search_channel = $request->input('search_channel');
$search_sendtime = $request->input('search_sendtime');
$db = DB::connection('message');
$info = $db->table('lie_msg_log')->groupBy('tpl_id')->having('source_type','=',2)->get();
//1.首次进页面无搜索条件
if(null==$search_desc && null==$search_channel && null==$search_sendtime)
{
$info = $db->table('lie_msg_log')->groupBy('tpl_id')->having('source_type','=',2)->get();
$search_channel = 0;
$search_desc = '';
$search_sendtime = '';
}else//2.有搜索条件
{
//渠道里没有0,所以如果没选,将此条件剔除掉
if(0==$search_channel)
{
$info = $db->table('lie_msg_log')->groupBy('lie_msg_log.tpl_id')->having('lie_msg_log.source_type','=',2)
->where('lie_msg_log.expect_send_time',$search_sendtime)
->join('lie_msg_tpl','lie_msg_log.tpl_id','=','lie_msg_tpl.tpl_id')
->where('lie_msg_tpl.description','like',"%$search_desc%")->get();
}else
{
$info = $db->table('lie_msg_log')->groupBy('lie_msg_log.tpl_id')->having('lie_msg_log.source_type','=',2)
->join('lie_msg_tpl','lie_msg_log.tpl_id','=','lie_msg_tpl.tpl_id')
->where('lie_msg_log.expect_send_time',$search_sendtime)
->where('lie_msg_tpl.channels','like',"%$search_channel%")
->where('lie_msg_tpl.description','like',"%$search_desc%")->get();
}
}
//构建model
foreach ($info as $log)
{
//将消息渠道从 数字字符串转化为汉字字符串 用于用户展示
......@@ -259,6 +310,9 @@ class MessageController extends Controller
'id'=>$id,
'info'=>$info,
'msg_channels'=>$msg_channels,
'search_desc'=>$search_desc,
'search_channel'=>$search_channel,
'search_sendtime'=>$search_sendtime,
];
return view($viewid, $data);
......
......@@ -8,4 +8,12 @@ layui.use('laydate', function(){
type:'datetime',
format:'yyyy-MM-dd HH:mm'
});
});
\ No newline at end of file
});
//指定条件搜索
$('#search-btn').click(function () {
var search_desc = $('#search-desc').val();
var search_channel = $('#choose-tpl option:selected').val();
var search_sendtime = $('#Choice_start').val();
window.location.href="/message/manualhistoryList?search_desc="+search_desc+"&search_channel="+search_channel+"&search_sendtime="+search_sendtime;
})
\ No newline at end of file
//指定条件搜索
$('#search-btn').click(function () {
var search_desc = $('#search-desc').val();
var search_channel = $('#choose-tpl option:selected').val();
window.location.href="/message/templatelist?search_desc="+search_desc+"&search_channel="+search_channel;
})
\ No newline at end of file
......@@ -23,17 +23,17 @@
<form method="get" action="/message/templateList">
<div style="text-align: center" class="div-b">
<a class="btn btn-primary btn-sm" href="/message/sendManualMessage" style="float: left;margin-left: 30px">发送消息</a>
<label>消息标题</label>
<input type="text" class="form-control" id="serach-title" placeholder="请输入消息标题">
<label>消息描述</label>
<input type="text" class="form-control" id="search-desc" placeholder="请输入消息描述" value="{{ $search_desc }}">
<label>消息渠道:</label>
<select class="form-control" name="inner-choose-type" id="choose-tpl">
@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>
<input type="text" class="form-control" id="Choice_start" name="create_time_start/condition" value=""/>
<a class="btn btn-primary btn-sm" href="" style="float: right; margin-right: 50px">搜索</a>
<input type="text" class="form-control" id="Choice_start" name="create_time_start/condition" value="{{ $search_sendtime }}"/>
<input class="btn btn-primary btn-sm" id="search-btn" style="float: right; margin-right: 60px" value="搜索"/>
</div>
</form>
</div>
......
......@@ -21,16 +21,16 @@
<div class="form-inline p-l">
<form method="get" action="/message/templateList">
<div style="text-align: center" class="div-b">
<a class="btn btn-primary btn-sm" href="/message/addHistory" style="float: left; margin-left: 30px">新增消息</a>
<label>消息标题</label>
<input type="text" class="form-control" id="serach-title" placeholder="请输入消息标题">
<a class="btn btn-primary btn-sm" href="/message/addTemplate" style="float: left; margin-left: 30px">新增消息模板</a>
<label>消息描述</label>
<input type="text" class="form-control" id="search-desc" placeholder="请输入消息描述" value="{{ $search_desc }}">
<label>消息渠道:</label>
<select class="form-control" name="inner-choose-type" id="choose-tpl">
@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>
<a class="btn btn-primary btn-sm" href="" style="float: right; margin-right: 60px">搜索</a>
<input class="btn btn-primary btn-sm" id="search-btn" style="float: right; margin-right: 60px" value="搜索"/>
</div>
</form>
</div>
......
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