企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# addSearchItem 零云商业版(OpenCMF)、零云商城(lyshop)才有此功能,其他版本不支持 注意如果设置了此方法,那么setSearch的文本框搜索会自动隐藏,setSearch的url作为搜索提交地址属性仍然有效。 多条件搜索,在列表顶部显示多个类型条件用于数据的高效筛选,可选的类型有text、radio、select、date、 datetime、dateranger等 ## 方法原型 function addSearchItem ($template){} ## 参数 | 参数 | 类型 | 是否必须 | 说明 | | ------------ | ------------ | ------------ | ------------ | | $name | string | 是 | 字段名称 | | $type | string | 是 | 表单类型(可以取值的类型text、radio、select、date、 datetime、dateranger) | | $title | string | 是 | 表单标题 | | $options | array | 否 | 表单options(radio、select等类型的选项类似array('username' => '用户名', 'email' => '邮箱', 'mobile' => '手机号')) | ## 用法示例 // 使用Builder快速建立列表页面。 $builder = new \Common\Builder\ListBuilder(); $builder->setMetaTitle('用户列表') ->setTableDataPage($page->show()) ->addSearchItem('status', 'select', '状态' ,'状态', array('1' => '正常', '0' => '已禁用', '-1' => '已删除')) ->addSearchItem('reg_type', 'select', '注册来源' ,'注册时间', array('username' => '用户名', 'email' => '邮箱', 'mobile' => '手机号')) ->addSearchItem('create_time', 'dateranger', '注册时间' '注册时间') ->addSearchItem('keyword', 'text', '关键字','用户名/邮箱/手机号等') ->display(); // 与多条件筛选匹配的控制器代码参考如下: // 多条件筛选 if (isset($_GET['status'])) { $map['status'] = $_GET['status']; } else { $_GET['status'] = '1'; $map['status'] = $_GET['status']; } if ($_GET['reg_type']) { $map['reg_type'] = $_GET['reg_type']; } if ($_GET['create_time']) { $create_time = explode('~', $_GET['create_time']); $map['create_time'] = array(array('gt', strtotime($create_time[0])),array('lt', strtotime($create_time[1]) + 86400)); } $keyword = I('keyword', '', 'string'); $condition = array('like','%'.$keyword.'%'); $map['id|username|nickname|email|mobile'] = array( $condition, $condition, $condition, $condition, $condition, '_multi'=>true );