فهرست منبع

后台内容列表筛选项,支持同时多个条件进行筛选
Exce表格数据导出支持不限量分卷打包导出

齐博 2 سال پیش
والد
کامیت
1e1c26d208

+ 444 - 444
application/admin/controller/Member.php

@@ -1,447 +1,447 @@
-<?php
-namespace app\admin\controller;
-
-use app\common\controller\AdminBase; 
-use app\common\traits\AddEditList;
-use app\common\model\User as UserModel;
-//use app\common\model\Groupcfg AS GroupcfgModel;
-use app\common\fun\Cfgfield;
-use app\common\field\Post AS FieldPost;
-
-/**
- * 用户管理
- */
-class Member extends AdminBase
-{
-	use AddEditList;	
-	protected $validate = '';
-	protected $model;
-	protected $form_items;
-	protected $list_items;
-	protected $tab_ext = [
-				'id'=>false,                //用户数据表非常特殊,没有用id而是用uid
-				'page_title'=>'会员资料管理',
-				];
-	
-	protected function _initialize()
-    {
-		parent::_initialize();
-		$this->model = new UserModel();
-	}
-	
-	/**
-	 * 用户列表
-	 */
-	public function index($type='') {
-	    $order = 'uid desc';
-	    $this->list_items = [
-	        //['uid', '用户UID', 'text'],
-	        ['uid', '用户名', 'username'],
-	        ['icon', '头像', 'image'],
-	        ['groupid', '用户组', 'select',getGroupByid()],
-	        ['grouptype', '角色', 'select',get_role()],
-	        ['regdate', '注册日期', 'datetime'],
-            ['lastvist', '登录日期', 'datetime'],
-	        ['regip', '注册IP', 'text'],
-	        ['money', '积分', 'text'],
-	        ['rmb', '余额', 'text'],
-	        ['yz', '审核', 'switch'],
-	        ['wx_attention', '关注公众号', 'callback',function($v,$rs){
-	            if ($rs['weixin_api']==''&&$rs['wx_attention']==1) {
-	                $rs['wx_attention'] = 0;
-	                edit_user(['uid'=>$rs['uid'],'wx_attention'=>0]);
-	            }
-	            $url = purl('weixin/check/ifgz',[],'index');
-	            if ($rs['weixin_api']&&$rs['wx_attention']) {
-	                $code = '<i class="fa fa-check-circle-o" id="uid-'.$rs['uid'].'" style="color:red;"></i>';
-	            }else{
-	                $code = '<i class="fa fa-ban" id="uid-'.$rs['uid'].'" style="color:#666;"></i>';
-	            }
-	            $code .=<<<EOT
-<script type="text/javascript">
-if("{$rs['weixin_api']}"!=""){
-	$.get("{$url}?type=set&uid={$rs['uid']}",function(res){
-		if(res.code==0){
-			$("#uid-{$rs['uid']}").removeClass("fa-ban");
-            $("#uid-{$rs['uid']}").removeClass("fa-check-circle-o");
-			$("#uid-{$rs['uid']}").addClass("fa-check-circle-o");
-			$("#uid-{$rs['uid']}").css({"color":"red"});
-		}else if(res.code==1){
-            $("#uid-{$rs['uid']}").css({"color":"#666"});
-        }else{
-            //同步失败
-        }
-	});
-}
-</script>
-EOT;
-	            return $code;
-	        }],
-	        ['uid','登录','callback',function($k,$v){
-	            $url = urls('edit',['type'=>'login','id'=>$k]);
-	            return "<a target='_blank' href='$url' class='fa fa-child' onclick='return confirm(\"你确认要登录他的帐号吗?\")' title='你确认要登录他的帐号吗?'>登录</a>";
-	        }],
-	    ];	    
-	    
-	    //支持搜索的字段
-	    $this -> tab_ext['search'] = [
-	        'username'=>'用户名',
-	        'nickname'=>'昵称',
-	        'truename'=>'真实姓名',
-	        'mobphone'=>'手机号',
-	        'regip'=>'注册IP',
+<?php
+namespace app\admin\controller;
+
+use app\common\controller\AdminBase; 
+use app\common\traits\AddEditList;
+use app\common\model\User as UserModel;
+//use app\common\model\Groupcfg AS GroupcfgModel;
+use app\common\fun\Cfgfield;
+use app\common\field\Post AS FieldPost;
+
+/**
+ * 用户管理
+ */
+class Member extends AdminBase
+{
+	use AddEditList;	
+	protected $validate = '';
+	protected $model;
+	protected $form_items;
+	protected $list_items;
+	protected $tab_ext = [
+				'id'=>false,                //用户数据表非常特殊,没有用id而是用uid
+				'page_title'=>'会员资料管理',
+				];
+	
+	protected function _initialize()
+    {
+		parent::_initialize();
+		$this->model = new UserModel();
+	}
+	
+	/**
+	 * 用户列表
+	 */
+	public function index($type='') {
+	    $order = 'uid desc';
+	    $this->list_items = [
+	        //['uid', '用户UID', 'text'],
+	        ['uid', '用户名', 'username'],
+	        ['icon', '头像', 'image'],
+	        ['groupid', '用户组', 'select',getGroupByid()],
+	        ['grouptype', '角色', 'select',get_role()],
+	        ['regdate', '注册日期', 'datetime'],
+            ['lastvist', '登录日期', 'datetime'],
+	        ['regip', '注册IP', 'text'],
+	        ['money', '积分', 'text'],
+	        ['rmb', '余额', 'text'],
+	        ['yz', '审核', 'switch'],
+	        ['wx_attention', '关注公众号', 'callback',function($v,$rs){
+	            if ($rs['weixin_api']==''&&$rs['wx_attention']==1) {
+	                $rs['wx_attention'] = 0;
+	                edit_user(['uid'=>$rs['uid'],'wx_attention'=>0]);
+	            }
+	            $url = purl('weixin/check/ifgz',[],'index');
+	            if ($rs['weixin_api']&&$rs['wx_attention']) {
+	                $code = '<i class="fa fa-check-circle-o" id="uid-'.$rs['uid'].'" style="color:red;"></i>';
+	            }else{
+	                $code = '<i class="fa fa-ban" id="uid-'.$rs['uid'].'" style="color:#666;"></i>';
+	            }
+	            $code .=<<<EOT
+<script type="text/javascript">
+if("{$rs['weixin_api']}"!=""){
+	$.get("{$url}?type=set&uid={$rs['uid']}",function(res){
+		if(res.code==0){
+			$("#uid-{$rs['uid']}").removeClass("fa-ban");
+            $("#uid-{$rs['uid']}").removeClass("fa-check-circle-o");
+			$("#uid-{$rs['uid']}").addClass("fa-check-circle-o");
+			$("#uid-{$rs['uid']}").css({"color":"red"});
+		}else if(res.code==1){
+            $("#uid-{$rs['uid']}").css({"color":"#666"});
+        }else{
+            //同步失败
+        }
+	});
+}
+</script>
+EOT;
+	            return $code;
+	        }],
+	        ['uid','登录','callback',function($k,$v){
+	            $url = urls('edit',['type'=>'login','id'=>$k]);
+	            return "<a target='_blank' href='$url' class='fa fa-child' onclick='return confirm(\"你确认要登录他的帐号吗?\")' title='你确认要登录他的帐号吗?'>登录</a>";
+	        }],
+	    ];	    
+	    
+	    //支持搜索的字段
+	    $this -> tab_ext['search'] = [
+	        'username'=>'用户名',
+	        'nickname'=>'昵称',
+	        'truename'=>'真实姓名',
+	        'mobphone'=>'手机号',
+	        'regip'=>'注册IP',
 	        'weixin_api'=>'微信API',	        
-	    ];
-	    $this -> tab_ext['order'] = 'money,rmb,uid,regdate,lastvist';   //排序选择
-	    $this -> tab_ext['id'] = 'uid';    //用户数据表非常特殊,没有用id而是用uid , 这里需要特别指定id为uid
-	    $this -> tab_ext['help_msg'] = '1、这里的权限很大,建议设置为只有超管才能使用
-<br>2、这里修改财务不会有记录,要有记录的话,请分配财务人员使用插件中心>财务与积分功能><a href="'.purl('marketing/member/index',[],'admin').'" style="color:red;">会员积分财务管理</a> 在那里操作
-<br>3、excel导出注意事项,鉴于负载效率考虑,每次只能导出2000条记录,要导出更多的话,请点击下一页再重复导出。';
-	    
-	    //筛选字段
-	    $this -> tab_ext['filter_search'] = [
-	            'groupid'=>getGroupByid(),
-	            'grouptype'=>get_role(),
-	            'wx_attention'=>['未关注','已关注'],
-	            'yz'=>['未审核','已审核'],
-	    ];
-	    $this -> tab_ext['top_button'] = [
-	        [
-	                'type'=>'add',
+	    ];
+	    $this -> tab_ext['order'] = 'money,rmb,uid,regdate,lastvist';   //排序选择
+	    $this -> tab_ext['id'] = 'uid';    //用户数据表非常特殊,没有用id而是用uid , 这里需要特别指定id为uid
+	    $this -> tab_ext['help_msg'] = '1、这里的权限很大,建议设置为只有超管才能使用
+<br>2、这里修改财务不会有记录,要有记录的话,请分配财务人员使用插件中心>财务与积分功能><a href="'.purl('marketing/member/index',[],'admin').'" style="color:red;">会员积分财务管理</a> 在那里操作
+<br>3、excel导出注意事项,鉴于负载效率考虑,每次只能导出2000条记录,要导出更多的话,请点击下一页再重复导出。';
+	    
+	    //筛选字段
+	    $this -> tab_ext['filter_search'] = [
+	            'groupid'=>getGroupByid(),
+	            'grouptype'=>get_role(),
+	            'wx_attention'=>['未关注','已关注'],
+	            'yz'=>['未审核','已审核'],
+	    ];
+	    $this -> tab_ext['top_button'] = [
+	        [
+	                'type'=>'add',
 	                'title'=>'创建新用户',
-	        ],
-	    ];
-	    if ($this->user['groupid']==3) {   //超管才有批量删除功能
-	        $this -> tab_ext['top_button'][]=[
-	                'type'=>'delete',
+	        ],
+	    ];
+	    if ($this->user['groupid']==3) {   //超管才有批量删除功能
+	        $this -> tab_ext['top_button'][]=[
+	                'type'=>'delete',
 	                'title'=>'批量删除用户',	 
-	        ];
-	    }
-	    $weburl = get_url('location');
-	    $this -> tab_ext['top_button'][]=[
-	            'type'=>'excel',
-	            'title'=>'导出excel表格',
-	            'icon'=>'fa fa-table',
-	            'url'=>$weburl . (strstr($weburl,'?')?"&":'?').'type=excel',
-	    ];
-	    
-	    if ($type=='excel') {
-	        return $this->excel();
-	    }
-	    
-	    return $this -> getAdminTable(self::getListData($this->get_search(), $order ));
-	}
-	
-	/**
-	 * 多条件搜索
-	 * @return string[][]|unknown[]|mixed[]
-	 */
-	protected function get_search()
-	{
-	    $map = [];
-	    $detail = input();
-	    if (isset($detail['search_bindphone']) && $detail['search_bindphone']!=='') {
-	        $map['mob_yz'] = $detail['search_bindphone'];
-	    }
-	    if (isset($detail['search_bindwxmp']) && $detail['search_bindwxmp']!=='') {
-	        $map['wx_attention'] = $detail['search_bindwxmp'];
-	    }
-	    if (isset($detail['search_bindwxlogin']) && $detail['search_bindwxlogin']!=='') {
-	        $map['weixin_api'] = ['<>',''];
-	    }
-	    if (isset($detail['search_bindqqlogin']) && $detail['search_bindqqlogin']!=='') {
-	        $map['qq_api'] = ['<>',''];
-	    }
-	    if (isset($detail['search_sex']) && $detail['search_sex']!=='') {
-	        $map['sex'] = $detail['search_sex'];
-	    }
-	    if (isset($detail['search_bindidcard']) && $detail['search_bindidcard']!=='') {
-	        $map['idcard_yz'] = $detail['search_bindidcard'];
-	    }
-	    if (isset($detail['search_faceyz']) && $detail['search_faceyz']!=='') {
-	        $map['weixin_yz'] = $detail['search_faceyz'];
-	    }
-	    if (isset($detail['search_groupid']) && $detail['search_groupid']!=='') {
-	        $map['groupid'] = $detail['search_groupid'];
-	    }
-	    return $map;
-	}
-	
-	protected function excel(){
-	    $map = $this->get_search();
-	    $order = $this -> getOrder() ? $this -> getOrder() : 'uid desc' ;
-	    set_time_limit(0);
-	    $page = input('page')?:1;
-	    $rows = 2000;
-	    $min = ($page-1)*$rows;
-	    $array = UserModel::where($map)->order($order)->limit($min,$rows)->column(true);
-	    if(!$array){
-	        $this->error('没有数据可导出!');
-	    }
-	    
-	    $outstr="<table width=\"100%\" border=\"1\" align=\"center\" cellpadding=\"5\"><tr>";
-	    
-	    $fieldDB = [
-	            'i'=>'序号',
-	            'uid'=>'用户UID',
-	            'username'=>'用户帐号',
-	            'nickname'=>'用户昵称',
-	            'qq_api'=>'是否绑定QQ',
-	            'weixin_api'=>'是否绑定绑定',
-	            'wxapp_api'=>'是否登录过小程序',
-	            'groupid'=>'所属用户组',
-	            'grouptype'=>'用户角色',
-	            'money'=>'可用积分',
-	            'rmb'=>'可用余额',
-	            'lastvist'=>'最后访问时间',
-	            'lastip'=>'最后访问IP',
-	            'regdate'=>'注册日期',
-	            'regip'=>'注册IP',
-	            'sex'=>'性别',
-	            'introduce'=>'介绍签名',
-	            'address'=>'联系地址',
-	            'mobphone'=>'手机号',
-	            'idcard'=>'证件号码',
-	            'truename'=>'真实姓名',
-	            'email_yz'=>'验证邮箱与否',
-	            'mob_yz'=>'验证手机与否',
-	            'wx_attention'=>'是否关注公众号',
-	            'introducer_1'=>'直接推荐人',
-	            'introducer_2'=>'二级推荐人',
-	            'introducer_3'=>'三级推荐人',
-	    ];
-	    
-	    foreach($fieldDB AS $title){
-	        $outstr.="<th bgcolor=\"#A5A0DE\">$title</th>";
-	    }
-	    $i=$min;
-	    $outstr.="</tr>";
-	    foreach($array  AS $rs){
-	        $i++;
-	        $outstr.="<tr>";
-	        foreach($fieldDB AS $k=>$v){
-	            $value = $rs[$k];
-	            if (in_array($k, ['qq_api','weixin_api','wxapp_api','email_yz','mob_yz','wx_attention'])) {
-	                $value = $value?'是':'否';
-	            }elseif($k=='groupid'){
-	                $value=getGroupByid($value);
-	            }elseif($k=='grouptype'){
-	                $value=get_role($value);
-	            }elseif($k=='sex'){
-	                if($value=='2'){
-	                    $value='女';
-	                }elseif($value=='1'){
-	                    $value='男';
-	                }else{
-	                    $value='未知';
-	                }
-	            }elseif(in_array($k, ['lastvist','regdate'])){
-	                $value=date('Y-m-d H:i',$value);
-	            }elseif(in_array($k, ['introducer_1','introducer_2','introducer_3'])){
-	                if ($value) {
-	                    $user = get_user($value);
-	                    $value = $user['username'].'('.$user['nickname'].'/'.$value.')';
-	                }else{
-	                    $value = '';
-	                }
-	            }elseif(($k=='mobphone'||$k=='idcard')&&$value){
-	                $value = '&nbsp;'.$value.'&nbsp;';//避免数字变成负数
-	            }elseif($k=='introduce'&&$value!=''){
-	                $value = filtrate(del_html($value));
-	            }elseif($k=='i'){
-	                $value = $i;
-	            }
-	            $outstr.="<td align=\"center\">{$value}</td>";
-	        }
-	        $outstr.="</tr>\n";
-	    }
-	    $outstr.="</table>";//die($outstr);
-	    ob_end_clean();
-	    header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
-	    header('Pragma: no-cache');
-	    header('Content-Encoding: none');
-	    header('Content-Disposition: attachment; filename=MicrosoftExce.xls');
-	    header('Content-type: text/csv');
-	    echo "<!doctype html>
-	    <html lang='en'>
-	    <head>
-	    <meta charset='UTF-8'>
-	    <title></title>
-	    </head>
-	    <body>
-	    $outstr
-	    </body>
-	    </html>";
-	    exit;
-	}
-	
-	/**
-	 * 登录他人的帐号
-	 * @param number $id
-	 */
-	public function login($id=0){
-	    $result = UserModel::login($id,$password='',$cookietime=null,$not_pwd=true,$type='uid');
-	    if (is_array($result)) {
-	        return $this->success('登录成功',get_url('member'));
-	    }else{
-	        return $this->error('登录失败');
-	    }
-	}
-	
-	private function get_user($uid=0){
-	    if ($uid) {
-	        $user = get_user($uid);
-	        return "<a href=\"".get_url('user',$uid)."\" target=\"_blank\">帐号:{$user['username']} 昵称:{$user['nickname']}</a>";
-	    }
-	    return '';
-	}
-	
-	/**
-	 * 修改用户资料
-	 * @param number $id 用户UID
-	 */
-	public function edit($id = 0,$type='')
-	{
-	    if(empty($id)) $this->error('缺少参数');
-	    
-	    if ($type=='login') {
-	        $this->login($id);
-	    }
-    	
-	    $info = $this->model->get_info($id,'uid',false);
-	    
-	    $this->form_items = [
-	            ['hidden', 'uid'],
-	            ['text', 'username', '用户名','用户名请不要随意修改'],
-	            ['text', 'password', '密码','留空则代表不修改密码,之前加密后的密码是:'.$info['password']],
-	            ['select', 'groupid', '用户组','',getGroupByid()],
-	        ['radio', 'grouptype', '用户角色','',get_role()],
-	        ['datetime', 'group_endtime', '用户组有效期','留空则长期有效,除普通用户组外其它任何用户组(包括超管及黑名单)都可以设置有效期,过期后统一归为普通用户组'],
-	            ['text', 'nickname', '昵称'],
-	            ['text', 'email', '邮箱'],
-	            ['text', 'weixin_api', '微信接口ID'],
-	            ['text', 'qq_api', 'QQ接口ID'],
-	            ['text', 'wxapp_api', '小程序接口ID'],
-	            ['text', 'unionid', '开放平台接口ID'],
-	            ['text', 'unionid', '开放平台接口ID'],
-	            ['radio', 'sex', '性别','',[0=>'保密',1=>'男',2=>'女']],
-	            ['jcrop', 'icon', '头像'],
-	            ['number', 'money', '积分'],
-	            ['money', 'rmb', '可用余额'],
-	            ['money', 'rmb_freeze', '冻结余额'],
-	            ['text', 'rmb_pwd', '支付密码','这是加密后的效果,要修改的话,只须输入原始密码即可'],
-	           ['text', 'truename', '真实名'],
-	        ['text', 'mobphone', '手机号'],
-	        ['text', 'idcard', '证件号'],
-	        ['image', 'idcardpic', '证件扫描件'],
-	        ['radio', 'email_yz', '邮箱验证与否','',['未验证','已验证']],
-	        ['radio', 'mob_yz', '手机验证与否','',['未验证','已验证']],
-	        ['radio', 'idcard_yz', '证件验证与否','',['未验证','已验证']],
-	        ['radio', 'wx_attention', '是否关注公众号','',['未关注','已关注']],
-	        ['radio', 'yz', '帐号验证','',['未验证','已验证']],
-	        ['number', 'introducer_1', '直接推荐人',$this->get_user($info['introducer_1'])],
-	        ['number', 'introducer_2', '2级推荐人',$this->get_user($info['introducer_2'])],
-	        ['number', 'introducer_3', '3级推荐人',$this->get_user($info['introducer_3'])],
-	    ];
-	    
-	    //某用户组下面的所有参数选项
-	    $array = Cfgfield::get_form_items($info['groupid']);
-	    if ($array) {
-	        $this->form_items = array_merge($this->form_items,$array);
-	    }
-	    
-	    if ($this->request->isPost()) {    //修改入库处理
-	        $data = $this->request->post();
-	        if(SUPER_ADMIN!==true&&$data['groupid']==3&&$this->user['groupid']!=3){
-	            $this->error('你无权修改超管资料!');
-	        }
-	        // 验证
-	        if(!empty($this->validate)){
-	            // 验证
-	            $result = $this->validate($data, $this->validate);
-	            if(true !== $result) $this->error($result);
-	        }
-	        $data = FieldPost::format_php_all_field($data,$this->form_items);
-	        if ($data['rmb_pwd'] && strlen($data['rmb_pwd'])!=32) {
-	            $data['rmb_pwd'] = md5($data['rmb_pwd']);
-	        }
-	        if ( $this->model->edit_user($data) ) {
-	            $this->success('修改成功', 'index');
-	        } else {
-	            $this->error('修改无效');
-	        }
-	    }
-	    
-	    $info['password']='';
-	    if (empty($info['introducer_1'])) {
-	        $info['introducer_1']='';
-	    }
-	    if (empty($info['introducer_2'])) {
-	        $info['introducer_2']='';
-	    }
-	    if (empty($info['introducer_3'])) {
-	        $info['introducer_3']='';
-	    }
-	    return $this->editContent($info);
-	}
-	
-	/**
-	 * 后台快速添加新用户
-	 */
-	public function add()
-	{
-	    if (IS_POST) {	        
-	        $data = get_post('post');
-	        if(SUPER_ADMIN!==true&&$data['groupid']==3&&$this->user['groupid']!=3){
-	            $this->error('你无权创建超管!');
-	        }
-	        // 验证
-	        if(!empty($this->validate)){
-	            // 验证
-	            $result = $this->validate($data, $this->validate);
-	            if(true !== $result) $this->error($result);
-	        }	        
-	        $uid = $this->model->register_user($data);
-	        
-	        if ( is_numeric($uid) ) {
-	            $this->success('添加成功', 'index');
-	        } else {
-	            $this->error('添加失败:'.$uid);
-	        }
-	    }
-	    
-	    $this->form_items = [
-	            ['text', 'username', '用户名','创建后不可修改'],
-	            ['text', 'password', '密码'],
-	            ['select', 'groupid', '用户组','',getGroupByid()],
-	            ['text', 'email', '邮箱'],
-	    ];
-	    return $this->addContent();
-	}
-	
-	/**
-	 * 删除用户 用户的其它资料这里没做删除,需要 借助钩子做删除处理 user_delete_end
-	 * @param unknown $ids
-	 */
-	public function delete($ids = null)
-	{
-	    if(empty($ids)) $this->error('缺少参数');	    
-	    $ids = is_array($ids) ? $ids : [$ids];	    
-	    $num = 0;
-	    foreach($ids AS $uid){
-	        $data = UserModel::get_info($uid);
-	        if($data['groupid']==3&&$this->user['groupid']!=3){
-	            $this->error('你无权删除超管!');
-	        }
-	        if($this->model->delete_user($uid)){
-	            $num++;
-	        }
-	    }
-	    
-	    if( $num ){
-	        $this->success('成功删除 '.$num.' 个用户', 'index');
-	    }else{	        
-	        $this->error('删除失败');
-	    }
-	}
-}
+	        ];
+	    }
+	    $weburl = get_url('location');
+	    $this -> tab_ext['top_button'][]=[
+	            'type'=>'excel',
+	            'title'=>'导出excel表格',
+	            'icon'=>'fa fa-table',
+	            'url'=>$weburl . (strstr($weburl,'?')?"&":'?').'type=excel&page=1',
+	    ];
+	    
+	    if ($type=='excel') {
+	        return $this->excel($order);
+	    }
+	    
+	    return $this -> getAdminTable(self::getListData($this->get_search(), $order ));
+	}
+	
+	/**
+	 * 多条件搜索
+	 * @return string[][]|unknown[]|mixed[]
+	 */
+	protected function get_search()
+	{
+	    $map = [];
+	    $detail = input();
+	    if (isset($detail['search_bindphone']) && $detail['search_bindphone']!=='') {
+	        $map['mob_yz'] = $detail['search_bindphone'];
+	    }
+	    if (isset($detail['search_bindwxmp']) && $detail['search_bindwxmp']!=='') {
+	        $map['wx_attention'] = $detail['search_bindwxmp'];
+	    }
+	    if (isset($detail['search_bindwxlogin']) && $detail['search_bindwxlogin']!=='') {
+	        $map['weixin_api'] = ['<>',''];
+	    }
+	    if (isset($detail['search_bindqqlogin']) && $detail['search_bindqqlogin']!=='') {
+	        $map['qq_api'] = ['<>',''];
+	    }
+	    if (isset($detail['search_sex']) && $detail['search_sex']!=='') {
+	        $map['sex'] = $detail['search_sex'];
+	    }
+	    if (isset($detail['search_bindidcard']) && $detail['search_bindidcard']!=='') {
+	        $map['idcard_yz'] = $detail['search_bindidcard'];
+	    }
+	    if (isset($detail['search_faceyz']) && $detail['search_faceyz']!=='') {
+	        $map['weixin_yz'] = $detail['search_faceyz'];
+	    }
+	    if (isset($detail['search_groupid']) && $detail['search_groupid']!=='') {
+	        $map['groupid'] = $detail['search_groupid'];
+	    }
+	    return $map;
+	}
+	
+	protected function excel($order='',$rows = 500){
+	    $array = self::getListData($this->get_search(), $order ,$rows );
+// 	    $map = $this->get_search();
+// 	    $order = $this->getOrder() ? $this->getOrder() : 'uid ASC' ;
+// 	    $array = UserModel::where($map)->order($order)->paginate($rows);
+	    $field_array = [
+	        'i'=>'序号',
+	        'uid'=>'用户UID',
+	        'username'=>'用户帐号',
+	        'nickname'=>'用户昵称',
+	        'qq_api'=>[
+	            'title'=>'是否绑定QQ',
+	            'callback'=>function($v){
+	               return $v?'未绑定':'已绑定';
+	            },
+	        ],
+	        'groupid'=>[
+	            'title'=>'所属用户组',
+	            'opt'=>getGroupByid(),
+	        ],
+	        'grouptype'=>[
+	            'title'=>'用户角色',
+	            'opt'=>get_role(),
+	        ],
+	        'wx_attention'=>[
+	            'title'=>'是否关注公众号',
+	            'opt'=>['未关注','已关注'],
+	        ],
+	        'weixin_api'=>[
+	            'title'=>'是否绑定公众号登录(不一定关注)',
+	            'callback'=>function($v){
+	                return $v?'未绑定':'已绑定';
+	            },
+	        ],
+	        'wxapp_api'=>[
+	            'title'=>'是否绑定小程序登录',
+	            'callback'=>function($v){
+	               return $v?'未绑定':'已绑定';
+	            },
+	        ],
+	        'wxopen_api'=>[
+	            'title'=>'是否绑定APP微信登录',
+	            'callback'=>function($v){	                
+	                   return $v?'未绑定':'已绑定';
+	               },
+	        ],
+	        'money'=>'可用积分',
+	        'rmb'=>'可用余额',
+	        'lastip'=>'最后访问IP',
+	        'lastvist'=>[
+	            'title'=>'最后访问时间',
+	            'type'=>'time',
+	        ],	        
+	        'regdate'=>[
+	            'title'=>'注册日期',
+	            'type'=>'time',
+	        ],
+	        'group_endtime'=>[
+	            'title'=>'用户组截止日期',
+	            'type'=>'time',
+	        ],
+	        'regip'=>'注册IP',
+	        'sex'=>[
+	            'title'=>'性别',
+	            'opt'=>['未知','先生','女士'],
+	        ],
+	        'introduce'=>'介绍签名',
+	        'address'=>'联系地址',
+	        'mobphone'=>'手机号',
+	        'idcard'=>'证件号码',
+	        'truename'=>'真实姓名',
+	        'emai'=>'邮箱',
+	        'email_yz'=>[
+	            'title'=>'验证邮箱与否',
+	            'opt'=>['未验证','已验证'],
+	        ],
+	        'mob_yz'=>[
+	            'title'=>'验证手机与否',
+	            'opt'=>['未验证','已验证'],
+	        ],
+	        'idcard_yz'=>[
+	            'title'=>'证件验证与否',
+	            'opt'=>['未验证','已验证'],
+	        ],
+	        'subscribe_mp'=>[
+	            'title'=>'订阅公众号消息与否',
+	            'opt'=>['未订阅','已订阅'],
+	        ],
+	        'subscribe_wxapp'=>[
+	            'title'=>'订阅小程序消息与否',
+	            'opt'=>['未验证','已验证'],
+	        ],
+	        'introducer_1'=>[
+	            'title'=>'直接推荐人',
+	            'type'=>'username',
+	        ],
+	        'introducer_2'=>[
+	            'title'=>'二级推荐人',
+	            'type'=>'username',
+	        ],
+	        'introducer_3'=>[
+	            'title'=>'三级推荐人',
+	            'type'=>'username',
+	        ],
+	    ];
+	    return $this->bak_excel($array,$field_array);
+	}
+	
+	/**
+	 * 登录他人的帐号
+	 * @param number $id
+	 */
+	public function login($id=0){
+	    $result = UserModel::login($id,$password='',$cookietime=null,$not_pwd=true,$type='uid');
+	    if (is_array($result)) {
+	        return $this->success('登录成功',get_url('member'));
+	    }else{
+	        return $this->error('登录失败');
+	    }
+	}
+	
+	private function get_user($uid=0){
+	    if ($uid) {
+	        $user = get_user($uid);
+	        return "<a href=\"".get_url('user',$uid)."\" target=\"_blank\">帐号:{$user['username']} 昵称:{$user['nickname']}</a>";
+	    }
+	    return '';
+	}
+	
+	/**
+	 * 修改用户资料
+	 * @param number $id 用户UID
+	 */
+	public function edit($id = 0,$type='')
+	{
+	    if(empty($id)) $this->error('缺少参数');
+	    
+	    if ($type=='login') {
+	        $this->login($id);
+	    }
+    	
+	    $info = $this->model->get_info($id,'uid',false);
+	    
+	    $this->form_items = [
+	            ['hidden', 'uid'],
+	            ['text', 'username', '用户名','用户名请不要随意修改'],
+	            ['text', 'password', '密码','留空则代表不修改密码,之前加密后的密码是:'.$info['password']],
+	            ['select', 'groupid', '用户组','',getGroupByid()],
+	        ['radio', 'grouptype', '用户角色','',get_role()],
+	        ['datetime', 'group_endtime', '用户组有效期','留空则长期有效,除普通用户组外其它任何用户组(包括超管及黑名单)都可以设置有效期,过期后统一归为普通用户组'],
+	            ['text', 'nickname', '昵称'],
+	            ['text', 'email', '邮箱'],
+	            ['text', 'weixin_api', '微信接口ID'],
+	            ['text', 'qq_api', 'QQ接口ID'],
+	            ['text', 'wxapp_api', '小程序接口ID'],
+	            ['text', 'unionid', '开放平台接口ID'],
+	            ['text', 'unionid', '开放平台接口ID'],
+	            ['radio', 'sex', '性别','',[0=>'保密',1=>'男',2=>'女']],
+	            ['jcrop', 'icon', '头像'],
+	            ['number', 'money', '积分'],
+	            ['money', 'rmb', '可用余额'],
+	            ['money', 'rmb_freeze', '冻结余额'],
+	            ['text', 'rmb_pwd', '支付密码','这是加密后的效果,要修改的话,只须输入原始密码即可'],
+	           ['text', 'truename', '真实名'],
+	        ['text', 'mobphone', '手机号'],
+	        ['text', 'idcard', '证件号'],
+	        ['image', 'idcardpic', '证件扫描件'],
+	        ['radio', 'email_yz', '邮箱验证与否','',['未验证','已验证']],
+	        ['radio', 'mob_yz', '手机验证与否','',['未验证','已验证']],
+	        ['radio', 'idcard_yz', '证件验证与否','',['未验证','已验证']],
+	        ['radio', 'wx_attention', '是否关注公众号','',['未关注','已关注']],
+	        ['radio', 'yz', '帐号验证','',['未验证','已验证']],
+	        ['number', 'introducer_1', '直接推荐人',$this->get_user($info['introducer_1'])],
+	        ['number', 'introducer_2', '2级推荐人',$this->get_user($info['introducer_2'])],
+	        ['number', 'introducer_3', '3级推荐人',$this->get_user($info['introducer_3'])],
+	    ];
+	    
+	    //某用户组下面的所有参数选项
+	    $array = Cfgfield::get_form_items($info['groupid']);
+	    if ($array) {
+	        $this->form_items = array_merge($this->form_items,$array);
+	    }
+	    
+	    if ($this->request->isPost()) {    //修改入库处理
+	        $data = $this->request->post();
+	        if(SUPER_ADMIN!==true&&$data['groupid']==3&&$this->user['groupid']!=3){
+	            $this->error('你无权修改超管资料!');
+	        }
+	        // 验证
+	        if(!empty($this->validate)){
+	            // 验证
+	            $result = $this->validate($data, $this->validate);
+	            if(true !== $result) $this->error($result);
+	        }
+	        $data = FieldPost::format_php_all_field($data,$this->form_items);
+	        if ($data['rmb_pwd'] && strlen($data['rmb_pwd'])!=32) {
+	            $data['rmb_pwd'] = md5($data['rmb_pwd']);
+	        }
+	        if ( $this->model->edit_user($data) ) {
+	            $this->success('修改成功', 'index');
+	        } else {
+	            $this->error('修改无效');
+	        }
+	    }
+	    
+	    $info['password']='';
+	    if (empty($info['introducer_1'])) {
+	        $info['introducer_1']='';
+	    }
+	    if (empty($info['introducer_2'])) {
+	        $info['introducer_2']='';
+	    }
+	    if (empty($info['introducer_3'])) {
+	        $info['introducer_3']='';
+	    }
+	    return $this->editContent($info);
+	}
+	
+	/**
+	 * 后台快速添加新用户
+	 */
+	public function add()
+	{
+	    if (IS_POST) {	        
+	        $data = get_post('post');
+	        if(SUPER_ADMIN!==true&&$data['groupid']==3&&$this->user['groupid']!=3){
+	            $this->error('你无权创建超管!');
+	        }
+	        // 验证
+	        if(!empty($this->validate)){
+	            // 验证
+	            $result = $this->validate($data, $this->validate);
+	            if(true !== $result) $this->error($result);
+	        }	        
+	        $uid = $this->model->register_user($data);
+	        
+	        if ( is_numeric($uid) ) {
+	            $this->success('添加成功', 'index');
+	        } else {
+	            $this->error('添加失败:'.$uid);
+	        }
+	    }
+	    
+	    $this->form_items = [
+	            ['text', 'username', '用户名','创建后不可修改'],
+	            ['text', 'password', '密码'],
+	            ['select', 'groupid', '用户组','',getGroupByid()],
+	            ['text', 'email', '邮箱'],
+	    ];
+	    return $this->addContent();
+	}
+	
+	/**
+	 * 删除用户 用户的其它资料这里没做删除,需要 借助钩子做删除处理 user_delete_end
+	 * @param unknown $ids
+	 */
+	public function delete($ids = null)
+	{
+	    if(empty($ids)) $this->error('缺少参数');	    
+	    $ids = is_array($ids) ? $ids : [$ids];	    
+	    $num = 0;
+	    foreach($ids AS $uid){
+	        $data = UserModel::get_info($uid);
+	        if($data['groupid']==3&&$this->user['groupid']!=3){
+	            $this->error('你无权删除超管!');
+	        }
+	        if($this->model->delete_user($uid)){
+	            $num++;
+	        }
+	    }
+	    
+	    if( $num ){
+	        $this->success('成功删除 '.$num.' 个用户', 'index');
+	    }else{	        
+	        $this->error('删除失败');
+	    }
+	}
+}

+ 128 - 10
application/common/controller/Base.php

@@ -530,16 +530,17 @@ class Base extends Controller
                 $map[$search_field] = ['like', "%$keyword%"];
             }
         }
-        if (is_array($search_fields)) {
+        
+        if (is_array($search_fields)) { //列表筛选
             foreach($search_fields AS $key=>$value){
                 if ($value===''||$value===null) {
                     continue;
                 }
-                if (in_array($key, ['id','uid']) || (is_numeric($value)&&$value<999999)) {
+                //if (in_array($key, ['id','uid']) || (is_numeric($value)&&$value<999999)) {
                     $map[$key] = ['=', $value];
-                }else{
-                    $map[$key] = ['like', "%$value%"];
-                }
+                //}else{
+                //    $map[$key] = ['like', "%$value%"];
+                //}
             }
         }
         
@@ -588,7 +589,7 @@ class Base extends Controller
         //             }
         //         }
         return  array_merge( $map , $this->map);
-        }
+    }
         
         /**
          * 获取字段排序
@@ -597,11 +598,11 @@ class Base extends Controller
          */
         protected function getOrder($extra_order = '')
         {
-            if(ENTRANCE!='admin'){
-                //return '';
-            }
             $order = input('param._order/s', '');
             $by    = input('param._by/s', '');
+            if(ENTRANCE!='admin'&&$order!='id'&&!in_array($by, ['asc','desc'])){
+                return '';
+            }
             if ($order != '' && $by != '') {
                 return $order . ' ' . $by;
             }elseif ($extra_order != '') {
@@ -659,5 +660,122 @@ class Base extends Controller
             return NULL;
         }
         
-    }
+        
+        /**
+         * 导出excel数据
+         * 具体使用教程,请参考示例 \plugins\comment\admin\Content.php 及 \application\common\controller\admin\Order.php 及 \application\admin\controller\Member.php中的方法excel()
+         * @param array|object $data 
+         * @param array $field_array
+         * @param number $rows
+         */
+        protected function bak_excel($data,$field_array,$rows=0){
+            $totalpage = '';
+            if(is_array($data)){
+                $listdb = $data;
+            }else{
+                $array = getArray($data);
+                $listdb = $array['data'];
+                $totalpage = $array['last_page'];
+                $rows = $array['per_page'];
+            }
+            $path = RUNTIME_PATH.'mysql_bak/'.substr(md5($this->user['password'].$this->user['uid']), 0,10).'/';
+            $page = input('page')?:1;
+            if ($page==1) {
+                delete_dir($path);
+            }
+            makepath($path);
+            if(!$listdb){
+                if ($page==1) {
+                    $this->error('没有数据可导出!');
+                }elseif($page==2){
+                    ob_end_clean();
+                    header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
+                    header('Pragma: no-cache');
+                    header('Content-Encoding: none');
+                    header('Content-Disposition: attachment; filename=MicrosoftExce.xls');
+                    header('Content-type: text/csv');
+                    echo file_get_contents($path.'1.xls');
+                    exit;
+                }else{
+                    $this->php_zip = new \app\common\util\Zip;
+                    $tempzip = RUNTIME_PATH."MicrosoftExcel.zip";      //临时文件
+                    
+                    if($this->php_zip->run($tempzip,dirname($path).'/',basename($path))){
+                        //ob_end_clean();
+                        set_time_limit(0);
+                        header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
+                        header('Pragma: no-cache');
+                        header('Content-Encoding: none');
+                        header('Content-Disposition: attachment; filename='.basename($tempzip));
+                        header('Content-type: .zip');
+                        header('Content-Length: '.filesize($tempzip));
+                        readfile($tempzip);
+                        unlink($tempzip);
+                        delete_dir($path);
+                        exit;
+                    }else{
+                        $this->error('打包失败') ;
+                    }
+                }
+            }
+            $outstr="<table width=\"100%\" border=\"1\" align=\"center\" cellpadding=\"5\"><tr>";
+            $field_array = ['i'=>'序号']+$field_array;
+            foreach($field_array AS $rs){
+                $outstr.="<th bgcolor=\"#A5A0DE\">".(is_array($rs)?$rs['title']:$rs)."</th>";
+            }
+            $outstr.="</tr>";
+            
+            $min = ($page-1)*$rows;
+            $i = $min;
+            foreach($listdb AS $rs){
+                $i++;
+                $outstr.="<tr>";
+                foreach($field_array AS $k=>$ar){
+                    $value = $rs[$k];
+                    if (is_array($ar)) {
+                        if($ar['key']){
+                            $value = $rs[$ar['key']];
+                        }
+                        if(is_array($ar['opt'])){
+                            $value = $ar['opt'][$value];
+                        }elseif($ar['callback']){
+                            $value = $ar['callback']($value,$rs);
+                        }elseif($ar['type']=='username'){
+                            $value = get_user_name($value);
+                        }elseif($ar['type']=='time'){
+                            $value = $value?format_time($value,'Y-m-d H:i'):'';
+                        }
+                    }elseif($k=='i'){
+                        $value = $i;
+                    }elseif(strstr($value,'<')||strstr($value,'>')){
+                        $value = filtrate(del_html($value));
+                    }
+                    if( preg_match('/^[\d]{10,}$/', $value) ){
+                        $value = '&nbsp;'.$value.'&nbsp;';
+                    }
+                    $outstr.="<td align=\"center\">{$value}</td>";
+                }
+                $outstr.="</tr>\n";
+            }
+            $outstr.="</table>";
+            if ($totalpage==1) {
+                ob_end_clean();
+                header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()).' GMT');
+                header('Pragma: no-cache');
+                header('Content-Encoding: none');
+                header('Content-Disposition: attachment; filename=MicrosoftExcel.xls');
+                header('Content-type: text/csv');
+                echo $outstr;
+                exit;
+            }
+            $filename = $path.$page.'.xls';
+            file_put_contents($filename, $outstr);
+            $page++;
+            $url = preg_replace("/(\?|&)page=([\d]+)/", '', $this->weburl);
+            $url .= (strstr($url,'?')?'&':'?') . 'page='.$page;
+            echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL={$url}'>正在备份第 {$page} 卷,总共 {$totalpage} 卷";
+            exit;
+        }
+        
+}
     

+ 108 - 5
application/common/controller/admin/Order.php

@@ -11,10 +11,7 @@ class Order extends AdminBase
     protected $model;
     protected $list_items;
     protected $form_items;
-    protected $tab_ext = [
-            'page_title'=>'订单记录',
-            'top_button'=>[ ['type'=>'delete']],
-    ];
+    protected $tab_ext = [];
     
     protected function _initialize()
     {
@@ -102,12 +99,28 @@ class Order extends AdminBase
                 ],
         ];
         
-        $listdb = self::getListData($this->get_search(), $order = []);
+        if(input('excel')){
+            return $this->excel(500);
+        }
+        
+        $listdb = self::getListData($this->get_search());
         $this->tab_ext['id_name'] = '订单ID';
         $this->assign('search_time','create_time');
         if (empty($this->get_template('search_inc'))) {
             $this->tab_ext['search_file'] = $this->get_template('admin@common/order_search');
         }
+        
+        $this->tab_ext = [
+            'page_title'=>'订单记录',
+            'top_button'=>[
+                ['type'=>'delete'],
+                [
+                    'title'=>'导出Exce',
+                    'icon'=>'fa fa-table',
+                    'url'=>$this->weburl.(strstr($this->weburl,'?')?'&':'?').'excel=1&page=1',
+                ],
+            ],
+        ];
         return $this -> getAdminTable($listdb);
     }
     
@@ -132,6 +145,96 @@ class Order extends AdminBase
         return $map;
     }
     
+    /**
+     * 导出excel表格数据
+     * @param number $rows 每卷几条记录
+     * @return unknown
+     */
+    protected function excel($rows = 500){
+        $array = self::getListData($this->get_search(), $order='' ,$rows );
+        $field_array = [
+            'i'=>'序号',
+            'uid'=>'用户UID',
+            'uid'=>[
+                'key'=>'uid',   //处理上面key重复的问题
+                'title'=>'用户帐号',
+                'type'=>'username',
+            ],
+            'linkman'=>'联系人',
+            'telphone'=>'联系电话',
+            'address'=>'联系地址',
+            'totalmoney'=>'优惠前的总金额',
+            'pay_money'=>'实付金额',
+            'order_sn'=>'订单号',
+            'shop'=>[
+                'title'=>'所购买的商品',
+                'callback'=>function($v){
+                    $array = [];
+                    $detail = explode(',',$v);
+                    foreach ($detail AS $ar){
+                        list($shopid,$num,$type1,$type2,$type3) = explode('-',$ar);
+                        $info = $this->model_content->getInfoByid($shopid);
+                        $array[] = $info['title']."({$num}份)";
+                    }                    
+                    return implode(";\r\n", $array);
+                 },
+            ],
+            'create_time'=>[
+                'title'=>'下单日期',
+                'type'=>'time',
+            ],
+            'shipping_time'=>[
+                'title'=>'发货日期',
+                'type'=>'time',
+            ],
+            'receive_time'=>[
+                'title'=>'收货日期',
+                'type'=>'time',
+            ],
+            'pay_time'=>[
+                'title'=>'支付日期',
+                'type'=>'time',
+            ],
+            'pay_status'=>[
+                'title'=>'支付状态',
+                'opt'=>['未付款','已付款'],
+            ],
+            'receive_status'=>[
+                'title'=>'收货状态',
+                'opt'=>['未签收','已签收'],
+            ],
+            'shipping_status'=>[
+                'title'=>'发货状态',
+                'opt'=>['未发货','已发货'],
+            ],
+            'shipping_name'=>'物流名称',
+            'shipping_code'=>'物流单号',
+            'user_note'=>'用户备注',
+            'admin_note'=>'商家备注',
+            'ifolpay'=>[
+                'title'=>'付款渠道',
+                'opt'=>['线下付款','在线支付'],
+            ],
+            'ifolpay'=>[
+                'title'=>'付款渠道',
+                'opt'=>['线下付款','在线支付'],
+            ],
+            'introducer_1'=>[
+                'title'=>'直接推荐人',
+                'type'=>'username',
+            ],
+            'introducer_2'=>[
+                'title'=>'二级推荐人',
+                'type'=>'username',
+            ],
+            'introducer_3'=>[
+                'title'=>'三级推荐人',
+                'type'=>'username',
+            ],
+        ];
+        return $this->bak_excel($array,$field_array);
+    }
+    
     /**
      * 查看详情
      * @param number $id

+ 63 - 0
application/common/fun/Field.php

@@ -221,6 +221,7 @@ class Field{
     
     /**
      * 生成后台筛选URL
+     * 将弃用,这个不能实现多选
      */
     public function make_admin_filter_url($order='',$by='',$search_field='',$keyword=''){
         
@@ -236,6 +237,68 @@ class Field{
         return auto_url(request()->action(),$array);
     }
     
+    
+    /**
+     * 生成筛选URL
+     * @param string $order 排序字段名
+     * @param string $by 排序方式,正序或倒序
+     * @param string $search_field 当前选择的字段名
+     * @param string $keyword 当前选择的字段值
+     * @return unknown
+     */
+    public static function seach_url($search_field='',$keyword='',$order='',$by=''){
+        static $url = null;
+        if($url===null){
+            if(IN_PLUGIN){
+                $url = '?';
+            }else{
+                $url = auto_url(request()->action()).'?';
+            }            
+        }
+        $array = input();
+        if($search_field){
+            if ($keyword!=='') {
+                $array['search_fields'][$search_field] = $keyword;
+            }else{
+                unset($array['search_fields'][$search_field]);
+            }
+        }
+        if($order){
+            $array['_order'] = $order;
+        }
+        if($by){
+            $array['_by'] = $by;
+        }
+        $str = '';
+        foreach($array AS $key=>$value){
+            if(is_array($value)){
+                foreach($value AS $k=>$v){
+                    $str .= $key.'['.$k.']='.urlencode($v).'&';
+                }
+            }elseif($value!==''){
+                $str .= $key.'='.urlencode($value).'&';
+            }
+        }
+        return $url.$str;
+    }
+    
+    /**
+     * 检查是否选中当前字段
+     * @param string $name
+     * @param unknown $value
+     * @return boolean
+     */
+    public static function is_choose($name='',$value=''){
+        $array = input()['search_fields'];
+        if($value===null||$value===''){
+            if(isset($array[$name])){
+                return true;
+            }
+        }elseif(isset($array[$name]) && $value!=='' && $array[$name]==$value){
+            return true;
+        }
+    }
+    
     /**
      * 判断是否加载过某个JS 避免重复加载,一般用在生成表单页
      * @param string $type

+ 2 - 0
application/common/upgrade/log328.txt

@@ -0,0 +1,2 @@
+后台内容列表筛选项,支持同时多个条件进行筛选
+Exce表格数据导出支持不限量分卷打包导出

+ 67 - 1
plugins/comment/admin/Content.php

@@ -25,6 +25,11 @@ class Content extends AdminBase
                 'target-form' => 'ids',
                 'icon'        => 'fa fa-check-circle-o',
                 'href'        => auto_url('batch',['action'=>'yz'])
+            ],
+            [
+                'title'=>'导出Exce',
+                'icon'=>'fa fa-table',
+                'url'=>$this->weburl.(strstr($this->weburl,'?')?'&':'?').'excel=1&page=1',
             ],
         ];
         
@@ -54,10 +59,11 @@ class Content extends AdminBase
             'status'=>['未审核','已审核'],
         ];
         
-        $this->list_items = [
+        $this->list_items = [            
                     ['content','评论内容','callback',function($value){
                         return get_word(del_html($value), 70);
                     }],
+                    ['create_time','评论日期','datetime'],
                     ['status','审核与否','switch'],               
                     ['uid','发布者','username'],
                     ['sysid','所属模块','callback',function($value){
@@ -77,6 +83,66 @@ class Content extends AdminBase
                 ];
     }
     
+    public function index() {
+        
+        if(input('excel')){
+            return $this->excel(500);
+        }
+
+        $listdb = $this->getListData($map = [], $order = '');
+        return $this -> getAdminTable($listdb);
+    }
+    
+    /**
+     * 导出excel表格数据
+     * @param number $rows 每卷几条记录
+     * @return unknown
+     */
+    protected function excel($rows = 500){
+        $array = self::getListData($map = [], $order='' ,$rows );
+        $array_module = [];
+        foreach (modules_config() AS $rs){
+            $array_module[$rs['id']] = $rs['name'];
+        }
+        foreach (plugins_config() AS $rs){
+            $array_module[-$rs['id']] = $rs['name'];
+        }
+        $field_array = [
+            'i'=>'序号',
+            'id'=>'ID',
+            'uid'=>'用户UID',
+            '_uid'=>[
+                'key'=>'uid',   //处理上面key重复的问题
+                'title'=>'用户帐号',
+                'type'=>'username',
+            ],
+            'create_time'=>[
+                'title'=>'评论日期',
+                'type'=>'time',
+            ],
+            'content'=>'评论内容',
+            'agree'=>'支持数',
+            'disagree'=>'反对数',
+            'sysid'=>[
+                'title'=>'所属频道',
+                'opt'=>$array_module,
+            ],
+            'aid'=>[
+                'title'=>'归属主题',
+                'callback'=>function($v,$rs){
+                    $array = $rs['sysid']>0?modules_config($rs['sysid']):plugins_config(abs($rs['sysid']));
+                    $dirname = $array['keywords'];
+                    $model = get_model_class($dirname,'content');
+                    if($model){
+                        $info = $model->getInfoByid($v);
+                        return $info['title'];
+                    }
+                },
+             ],
+        ];
+        return $this->bak_excel($array,$field_array);
+    }
+    
     /**
      * 批量处理
      * @param string $action

+ 36 - 4
template/admin_style/default/admin/common/search_inc.htm

@@ -1,9 +1,38 @@
-		{if $search_time}
+{php}
+if(!$search_time&&input('search_timefield'))$search_time=input('search_timefield');
+if(!$search_time&&$listdb&&isset($listdb[0]['create_time']))$search_time='create_time';
+if(!$search_time&&$listdb&&isset($listdb[0]['posttime']))$search_time='posttime';
+{/php}
+
+{if $search_time}
 		<input type="text" placeholder='开始日期' value="{:input('search_begintime')}" class="search_begintime time" name="search_begintime">
 		<input type="text" placeholder='结束日期' value="{:input('search_endtime')}" class="search_endtime time" name="search_endtime">
-		<script>laydate.render({ elem: '.search_begintime',type: 'datetime'});</script>
-		<script>laydate.render({ elem: '.search_endtime',type: 'datetime'});</script>
-		{/if}
+		<!--<script>laydate.render({ elem: '.search_begintime',type: 'datetime'});</script>
+		<script>laydate.render({ elem: '.search_endtime',type: 'datetime'});</script>-->
+		
+	<script type="text/javascript">
+	function get_search_time(o){
+		o.render({ elem: '.search_begintime',type: 'datetime'});
+		o.render({ elem: '.search_endtime',type: 'datetime'
+			,done: function(value, date, endDate){
+				setTimeout(()=>{
+					$('.search_endtime').val(value.replace('00:00:00','23:59:59'));
+				},300);
+			}
+		});
+	}
+	if(typeof(layui)=='object'){
+		$(function(){
+			layui.use('laydate', function(){
+				var laydate = layui.laydate;
+				get_search_time(laydate);
+			}); 
+		});
+	}else{
+		get_search_time(laydate)
+	}
+	</script>
+{/if}
 
 		{if $sort_array}
 	    <select name="search_fid">
@@ -50,6 +79,9 @@ function search_content(){
 		return ;
 	}
 	var url = location.href.indexOf('?')>0 ? location.href.substr(0,location.href.indexOf('?')) : location.href;
+	if(/#$/.test(url)){
+		url=url.replace('#','');
+	}	
 	url +='?search_field=' + field + '&keyword=' +keyword;
 	if(search_fid!=''){
 		url +='&search_fid=' + search_fid;

+ 7 - 7
template/admin_style/default/admin/common/table.htm

@@ -125,11 +125,11 @@ function show_allsons(type){
 			{php}$_id=$tab_ext['id']?:'id';{/php}
 			{:strtoupper($_id)}
 			{if input('_order')==$_id&&input('_by')=='desc'}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'asc')}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
 			{elseif input('_order')==$_id&&input('_by')=='asc'}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'desc')}"><i style="color:blue;" class="glyphicon glyphicon-triangle-top"></i></a>
 			{else /}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'asc')}"><i class="fa fa-unsorted"></i></a>
 			{/if}			
 	</th>
 	<!-- 自定义字段头部标题 -->
@@ -138,16 +138,16 @@ function show_allsons(type){
 		<!--排序-->
 		{if in_array($vs.name,explode(',',$tab_ext.order))}
 			{if input('_order')==$vs.name&&input('_by')=='desc'}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'asc')}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
 			{elseif input('_order')==$vs.name&&input('_by')=='asc'}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'desc')}"><i style="color:blue;" class="glyphicon glyphicon-triangle-top"></i></a>
 			{else /}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'desc')}"><i class="fa fa-unsorted"></i></a>
 			{/if}			
 		{/if}
 		<!--筛选项-->
 		{if $tab_ext['filter_search'][$vs['name']]}
-			<i {if input('search_field')==$vs.name}style="color:red;"{/if} class="fa fa-filter" onclick="layer.tips('<a href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'))}\' style=\'color:#fff;\'>不限</a><br>{volist name="$tab_ext['filter_search'][$vs['name']]" id="name"}<a style=\'{if (input('keyword')!=''&&input('keyword')==$key)}color:red;{else /}color:#fff;{/if}\' href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'),$vs.name,$key)}\'>{$name}</a><br>{/volist}', $(this), {tips: [3, '#0FA6D8'],tipsMore: false,time:5000 });"></i>
+			<i {if fun('Field@is_choose',$vs.name)}style="color:red;"{/if} class="fa fa-filter" onclick="layer.tips('{if isset(input()['search_fields'][$vs['name']])}<a href=\'{:fun('Field@seach_url',$vs.name)}\' style=\'color:#fff;\'>不限</a><br>{/if}{volist name="$tab_ext['filter_search'][$vs['name']]" id="name"}<a style=\'{if fun('Field@is_choose',$vs.name,$key)}color:red;font-weight: bold;text-shadow: 2px 2px 1px #fff;{else /}color:#fff;{/if}\' href=\'{:fun('Field@seach_url',$vs.name,$key)}\'>{$name}</a><br>{/volist}', $(this), {tips: [3, '#0FA6D8'],tipsMore: false,time:5000 });"></i>
 		{/if}
 	  {$vs.title} 
 	</th>

+ 7 - 7
template/member_style/default/member/common/pc_table02.htm

@@ -35,11 +35,11 @@
 			{php}$_id=$tab_ext['id']?:'id';{/php}
 			{:strtoupper($_id)}
 			{if input('_order')==$_id&&input('_by')=='desc'}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'asc')}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
 			{elseif input('_order')==$_id&&input('_by')=='asc'}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'desc')}"><i style="color:blue;" class="glyphicon glyphicon-triangle-top"></i></a>
 			{else /}
-				<a href="{:fun('Field@make_admin_filter_url',$_id,'asc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
+				<a href="{:fun('Field@seach_url','','',$_id,'asc')}"><i class="fa fa-unsorted"></i></a>
 			{/if}			
 	</th>
 	<!-- 自定义字段头部标题 -->
@@ -48,16 +48,16 @@
 		<!--排序-->
 		{if in_array($vs.name,explode(',',$tab_ext.order))}
 			{if input('_order')==$vs.name&&input('_by')=='desc'}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'asc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'asc')}"><i style="color:red;" class="glyphicon glyphicon-triangle-bottom"></i></a>
 			{elseif input('_order')==$vs.name&&input('_by')=='asc'}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i style="color:red;" class="glyphicon glyphicon-triangle-top"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'desc')}"><i style="color:blue;" class="glyphicon glyphicon-triangle-top"></i></a>
 			{else /}
-				<a href="{:fun('Field@make_admin_filter_url',$vs.name,'desc',input('search_field'),input('keyword'))}"><i class="fa fa-unsorted"></i></a>
+				<a href="{:fun('Field@seach_url','','',$vs.name,'desc')}"><i class="fa fa-unsorted"></i></a>
 			{/if}			
 		{/if}
 		<!--筛选项-->
 		{if $tab_ext['filter_search'][$vs['name']]}
-			<i {if input('search_field')==$vs.name}style="color:red;"{/if} class="fa fa-filter" onclick="layer.tips('<a href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'))}\' style=\'color:#fff;\'>不限</a><br>{volist name="$tab_ext['filter_search'][$vs['name']]" id="name"}<a style=\'{if input('keyword')==$key}color:red;{else /}color:#fff;{/if}\' href=\'{:fun('Field@make_admin_filter_url',input('_order'),input('_by'),$vs.name,$key)}\'>{$name}</a><br>{/volist}', $(this), {tips: [3, '#0FA6D8'],tipsMore: false,time:5000 });"></i>
+			<i {if fun('Field@is_choose',$vs.name)}style="color:red;"{/if} class="fa fa-filter" onclick="layer.tips('{if isset(input()['search_fields'][$vs['name']])}<a href=\'{:fun('Field@seach_url',$vs.name)}\' style=\'color:#fff;\'>不限</a><br>{/if}{volist name="$tab_ext['filter_search'][$vs['name']]" id="name"}<a style=\'{if fun('Field@is_choose',$vs.name,$key)}color:red;font-weight: bold;text-shadow: 2px 2px 1px #fff;{else /}color:#fff;{/if}\' href=\'{:fun('Field@seach_url',$vs.name,$key)}\'>{$name}</a><br>{/volist}', $(this), {tips: [3, '#0FA6D8'],tipsMore: false,time:5000 });"></i>
 		{/if}
 	  {$vs.title} 
 	</th>