diff --git a/application/common/view/list.html b/application/common/view/list.html index 0702c447..6de664b1 100644 --- a/application/common/view/list.html +++ b/application/common/view/list.html @@ -31,7 +31,7 @@

筛选

-
+
{block name="search"}{/block}
@@ -175,9 +175,9 @@ // 提交表单 function submitform(formname) { - $('#'+formname).submit(); - // layer.msg('aa'); + $('#aabbcc').click(); } + {block name="myjs"}{/block} diff --git a/application/system/controller/School.php b/application/system/controller/School.php index 474909b6..cfce7da2 100644 --- a/application/system/controller/School.php +++ b/application/system/controller/School.php @@ -33,9 +33,11 @@ class School extends Base 'limit'=>'10', 'field'=>'update_time', 'order'=>'asc', - 'xingzhi'=>[] + 'xingzhi'=>[], + 'searchval'=>'' ],'POST'); + // 实例化 $sch = new sch; diff --git a/application/system/model/School.php b/application/system/model/School.php index 6766d5ee..5b675c12 100644 --- a/application/system/model/School.php +++ b/application/system/model/School.php @@ -40,6 +40,7 @@ class School extends Base { // 整理变量 $xingzhi = $src['xingzhi']; + $searchval = $src['searchval']; // 查询数据 $data = $this @@ -47,12 +48,9 @@ class School extends Base ->when(count($xingzhi)>0,function($query) use($xingzhi){ $query->where('xingzhi','in',$xingzhi); }) - // ->when(strlen($search)>0,function($query) use($search){ - // $query->where('title|jiancheng','like',$search); - // }) - // ->when(strlen($search)>0,function($query) use($search){ - // $query->where('title|jiancheng','like',$search); - // }) + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title|jiancheng','like','%'.$searchval.'%'); + }) ->with( [ 'dwXingzhi'=>function($query){ diff --git a/application/system/view/school/create.html b/application/system/view/school/create.html index 26daaa12..c309e56f 100644 --- a/application/system/view/school/create.html +++ b/application/system/view/school/create.html @@ -8,7 +8,7 @@
+ autocomplete="off" class="layui-input " value="{$list.data.title|default=''}" placeholder="中文2-25个字符">
@@ -17,7 +17,7 @@
+ autocomplete="off" class="layui-input" value="{$list.data.jiancheng|default=''}" placeholder="中文1-6个字符">
@@ -26,7 +26,7 @@
+ autocomplete="off" class="layui-input" value="{$list.data.biaoshi|default=''}" placeholder="数字">
@@ -94,7 +94,7 @@
+ autocomplete="off" class="layui-input" value="999" placeholder="数字1-999">
diff --git a/application/system/view/school/index.html b/application/system/view/school/index.html index bba47a79..ab4f6c8f 100644 --- a/application/system/view/school/index.html +++ b/application/system/view/school/index.html @@ -18,23 +18,21 @@
+ autocomplete="off" class="layui-input " onchange ="submitform('search')">
-
+
-
+
{php} $category = getCategory(101);{/php} {volist name="category" id="vo"} - + {/volist}
+
-
-
- - -
+ +
{/block} @@ -84,16 +82,16 @@ layui.use(['table','laypage','form'], function(){ var table = layui.table ,form = layui.form; // 实例化表格 - table.render({ + var tableIns = table.render({ elem: '#tabledemo', toolbar: '#toolbarDemo', - height: 520, url:"{:url('ajaxdata')}", method:"POST", //数据接口 page: true, //开启分页 loading:true, autoSort:false, id:'mytable', + defaultToolbar:'', cols: [[ //表头 {type:'checkbox',LAY_CHECKED:false, fixed: 'left'}, {field: 'title', title: '单位名称',sort: true, minWidth:240}, @@ -176,13 +174,17 @@ layui.use(['table','laypage','form'], function(){ }; }); - // 监听筛选 + form.on('submit(*)', function(data){ - table.reload('mytable', { - where: data.field - }); - return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。 - }); + console.log(data.field) //当前容器的全部表单字段,名值对形式:{name: value} + //这里以搜索为例 +tableIns.reload({ + where: data.field +}); + return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。 + }); + + });