controller:
public function show_question(Request $request){
$userinfo = helper('Auth')->user();
$user_group_id = $userinfo['user_group_id'];
$user_id = $userinfo['id'];
app('think\\Route')->setConfig(['default_ajax_return' => 'html']);
$page = $request->param('page');
$question = $request->param('question');
$where = [];
$lawyerid= $request->param('lawyerid');
if($lawyerid){
$where[] = ['B.userid','=',$lawyerid];
}
if($question){
$where[] = ['B.question','LIKE','%'.trim($question).'%'];
}
if($user_group_id == 3 || $user_id = '410784'){
$Rownum = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname')
->where($where)
->group('B.id')
->order('B.id', 'desc')
->count();
}else{
$where[] = ['C.user_id','=',$user_id];
$Rownum = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname')
->where($where)
->group('B.id')
->order('B.id', 'desc')
->count();
}
$listRows = 30;
$total = ceil($Rownum/$listRows);
if($page<0){
$page = 1;
}
if($page > $total){
$page = 1;
}
if($user_group_id == 3 || $user_id = '410784'){
$user = Db::connect($this->_db_config)->table('fa_ai_question')->alias('A')
->field('userid')
->group('userid')
->order('userid', 'ASC')
->select();
foreach ($user as $k => $v){
$arr[]['userid'] = $v['userid'];
}
$userid = array_column($arr,'userid','id');
}else{
$userid = $user_id;
}
$wheres[] = ['userid','in', $userid];
$cusarr = Db::connect($this->_db_config)->table('fa_ai_question B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('*')
->where($wheres)
->group('B.userid')
->select();
$total = array();
foreach ($cusarr as $key => $value){
$total[ $value['userid']]['nickname'] = $value['nickname'];
$sum = Db::connect($this->_db_config)->table('fa_ai_question')
->field('userid')
->where('userid','in', $value['userid'])
->count();
$print_count = Db::connect($this->_db_config)->table('fa_ai_question')
->field('userid')
->where(['userid'=> $value['userid'],'tag_status'=>1])
->count();
$total[ $value['userid']]['print_count'] = $print_count;
$total[ $value['userid']]['count'] = $sum;
}
$this->assign("question", $question);
$this->assign('Rownum',intval($Rownum));
$this->assign("page", $page);
$this->assign("total", $total);
$this->assign("lawyerid", $lawyerid);
$this->assign("aid", $aid);
$this->assign("user_group_id", $user_group_id);
$this->assign->addCss('lawyer/lists.css?t='.time());
$this->assign->addJs('lawyer/report.js?t='.time(), true);
$this->assign->addCss('ai/question.css?t='.time());
// $this->fetch = true;
return $this->fetch = "show_question";
}
.
view:
{extends file="…/manage_base.html"}
{block name=“head”}
< div id=“header” style=“float: left;width: 100%;”>
< div class=“wrap clearfix” id=“usernav”>
< div id=“Menu”>
< ul class=“list”>
< li >< a class=“javascript” rel=“login_box” href="">登录< /a>
< li>< a href="{url(‘lawyer/User/logout’)}">退出< /a>
< /ul>
< /div>
< /div>
< /div>
{/block}
{block name=“content”}
< body style=“width: 100%;height:1500px;background: white;overflow: auto”>
< div style=“float: left;overflow-y: auto;overflow-x: auto;height: 91%;”>
< div class=“aaa” style=“height: 140px;width:100%;float:left;background-color: white”>
< div style=“width: 80%;height: 100px;float: left”>
{foreach $total as
i
n
f
o
i
d
=
>
info_id=>
infoid=>infoList}
< ul style=“width: 80px;height:70px;float: left”>
<div style="width: 10%;height: 100px;float: left">
<li style="float: right; width: 60px;padding: 30px 20px;"><a class="javascript" id="searchBtn" href="javascript://;" style="font-size: 20px; line-height: 20px;">搜索</a></li>
</div>
</div>
<ul class="user-list-area user-list-nav-bg" style="text-align: center;">
<ul class="user-list-content h90">
<li class="col21">ID</li>
<li class="col31">问题</li>
<li class="col21">分配人</li>
<li class="col21">状态</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
<li class="col21">时间</li>
</li>
</ul>
{/block}
public function show_get_question(Request $request){
app('think\\Route')->setConfig(['default_ajax_return' => 'html']);
$userinfo = helper('Auth')->user();
$user_group_id = $userinfo['user_group_id'];
$user_id = $userinfo['id'];
$page = $request->param('page');
$where = [];
$lawyerid= $request->param('lawyerid');
if($lawyerid){
$where[] = ['B.userid','=',$lawyerid];
}
if($user_group_id == 3 || $user_id = '410784'){
$Rownum = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname')
->where($where)
->group('B.id')
->order('B.id', 'desc')
->count();
}else{
$where[] = ['C.user_id','=',$user_id];
$Rownum = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname')
->where($where)
->group('B.id')
->order('B.id', 'desc')
->count();
}
$listRows = 30;
$total = ceil($Rownum/$listRows);
if($page<0){
$page = 1;
}
if($page > $total){
$page = 1;
}
if($user_group_id == 3 || $user_id = '410784'){
$user = Db::connect($this->_db_config)->table('fa_ai_question')->alias('A')
->field('userid')
->group('userid')
->order('userid', 'ASC')
->select();
foreach ($user as $k => $v){
$arr[]['userid'] = $v['userid'];
}
$userid = array_column($arr,'userid','id');
}else{
$userid = $user_id;
}
$wheres[] = ['userid','in', $userid];
$cusarr = Db::connect($this->_db_config)->table('fa_ai_question B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('*')
->where($wheres)
->group('B.userid')
->select();
$total = array();
foreach ($cusarr as $key => $value){
$total[ $value['userid']]['nickname'] = $value['nickname'];
$sum = Db::connect($this->_db_config)->table('fa_ai_question')
->field('userid')
->where('userid','in', $value['userid'])
->count();
$print_count = Db::connect($this->_db_config)->table('fa_ai_question')
->field('userid')
->where(['userid'=> $value['userid'],'tag_status'=>1])
->count();
$total[ $value['userid']]['print_count'] = $print_count;
$total[ $value['userid']]['count'] = $sum;
}
if($page>=1){
$question = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname,B.tag_status,B.tag_status,B.sex,B.marriage,B.custody,B.assets,B.house_property,B.debt,B.id AS id')
->where($where)
->limit(($page - 1) * $listRows, $listRows)
->group('B.id')
->order('B.id', 'desc')
->select();
foreach ($question as $key => $value){
$res_max_id= Db::connect($this->_db_config)->table('fa_ai_tag')->alias('a')
->field('MAX(a.id) AS id ')
->leftJoin('fa_ai_question b','a.qid = b.id ' )
->where('a.qid','=',$value['id'])
->select();
//获取最新的标签的时间
$marktime= Db::connect($this->_db_config)->table('fa_ai_tag a')
->field('*')
-> where('a.id','=',$res_max_id[0]['id'])
->order('a.id', 'desc')
->select();
$question[$key]['createtime'] = $marktime[0]['createtime'];
$id = $value['id'];
$aid_res = Db::connect($this->_db_config)->table('fa_ai_tag')->field('aid')->where(['qid'=>$id])->group('aid')->select();
foreach ($aid_res as $k => $v){
if($v['aid'] == 2){
$aid[$id]['sex'] = '1';
}
if($v['aid'] == 1){
$aid[$id]['marriage'] = '1';
}
if($v['aid'] == 3){
$aid[$id]['custody'] = '1';
}
if($v['aid'] == 4){
$aid[$id]['assets'] = '1';
}
if($v['aid'] ==5){
$aid[$id]['house_property'] = '1';
}
if($v['aid'] == 6){
$aid[$id]['debt'] = '1';
}
if($v['aid'] == 7){
$aid[$id]['jurisdiction'] = '1';
}
if($v['aid'] == 8){
$aid[$id]['maintenance_Fee'] = '1';
}
if($v['aid'] == 9){
$aid[$id]['betrothal_gifts'] = '1';
}
}
}
}else{
if($page<=0){
$page = 1;
}
$question = Db::connect($this->_db_config)->table('fa_ai_question')->alias('B')
->leftJoin('test.zf_member C','B.userid = C.user_id')
->field('B.id,B.userid,B.question,C.nickname,B.tag_status,B.tag_status,B.sex,B.marriage,B.custody,B.assets,B.house_property,B.debt,B.id AS id')
->where($where)
->limit(($page - 1) * $listRows, $listRows)
->group('B.id')
->order('B.id', 'desc')
->select();
//获取最新标签的id,通过id查最新的时间
foreach ($question as $key => $value){
$res_max_id= Db::connect($this->_db_config)->table('fa_ai_tag')->alias('a')
->field('MAX(a.id) AS id ')
->leftJoin('fa_ai_question b','a.qid = b.id ' )
->where('a.qid','=',$value['id'])
->select();
//获取最新的标签的时间
$marktime= Db::connect($this->_db_config)->table('fa_ai_tag a')
->field('*')
-> where('a.id','=',$res_max_id[0]['id'])
->order('a.id', 'desc')
->select();
$question[$key]['createtime'] = $marktime[0]['createtime'];
$id = $value['id'];
$aid_res = Db::connect($this->_db_config)->table('fa_ai_tag')->field('aid')->where(['qid'=>$id])->group('aid')->select();
foreach ($aid_res as $k => $v){
if($v['aid'] == 2){
$aid[$id]['sex'] = '1';
}
if($v['aid'] == 1){
$aid[$id]['marriage'] = '1';
}
if($v['aid'] == 3){
$aid[$id]['custody'] = '1';
}
if($v['aid'] == 4){
$aid[$id]['assets'] = '1';
}
if($v['aid'] ==5){
$aid[$id]['house_property'] = '1';
}
if($v['aid'] == 6){
$aid[$id]['debt'] = '1';
}
if($v['aid'] == 7){
$aid[$id]['jurisdiction'] = '1';
}
if($v['aid'] == 8){
$aid[$id]['maintenance_Fee'] = '1';
}
if($v['aid'] == 9){
$aid[$id]['betrothal_gifts'] = '1';
}
}
}
}
$this->assign("question", $question);
$this->assign("question", $question);
$this->assign('Rownum',intval($Rownum));
$this->assign("page", $page);
$this->assign("total", $total);
$this->assign("lawyerid", $lawyerid);
$this->assign("aid", $aid);
$this->assign("user_group_id", $user_group_id);
$this->assign->addCss('lawyer/lists.css?t='.time());
$this->assign->addJs('lawyer/report.js?t='.time(), true);
$this->assign->addCss('ai/question.css?t='.time());
return $this->fetch = true;
}