From 38873a5206877666f7d7a5f8cd763f8700bf695c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Wed, 3 Apr 2019 16:55:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E4=BD=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/view/create.html | 46 ++- application/common/view/list.html | 15 +- application/http/middleware/YanZheng.php | 2 +- application/system/controller/Category.php | 86 ++--- application/system/controller/School.php | 4 +- application/system/controller/SystemBase.php | 5 +- application/system/model/Category.php | 54 ++- application/system/model/School.php | 8 +- application/system/view/category/create.html | 169 +++++---- .../view/category/{edit.html => edit1.html} | 0 application/system/view/category/index.html | 263 ++++++++------ application/system/view/category/index1.html | 122 +++++++ application/system/view/school/create.html | 62 +--- application/system/view/school/edit.html | 108 ------ application/system/view/school/index.html | 324 ++++++++++-------- .../system/view/system_base/index.html | 75 ++-- config/template.php | 2 +- database/seeds/Rule.php | 4 +- 18 files changed, 748 insertions(+), 601 deletions(-) rename application/system/view/category/{edit.html => edit1.html} (100%) create mode 100644 application/system/view/category/index1.html delete mode 100644 application/system/view/school/edit.html diff --git a/application/common/view/create.html b/application/common/view/create.html index ea3e8fe3..a914ae9b 100644 --- a/application/common/view/create.html +++ b/application/common/view/create.html @@ -24,8 +24,48 @@ {block name="form"}{/block} {block name="myjs"}{/block} - + \ No newline at end of file diff --git a/application/common/view/list.html b/application/common/view/list.html index b0500660..0702c447 100644 --- a/application/common/view/list.html +++ b/application/common/view/list.html @@ -29,7 +29,7 @@
-

查询条件

+

筛选

{block name="search"}{/block} @@ -37,7 +37,6 @@
- {block name="table"}{/block}
{block name="myjs"}{/block} diff --git a/application/http/middleware/YanZheng.php b/application/http/middleware/YanZheng.php index 1185a0d4..d62b5887 100644 --- a/application/http/middleware/YanZheng.php +++ b/application/http/middleware/YanZheng.php @@ -25,7 +25,7 @@ class YanZheng extends Controller if( strlen($username)<1 ) { // $this->redirect('/login',302); - echo ""; + echo ""; } // 检验用户名或密码是否正确 diff --git a/application/system/controller/Category.php b/application/system/controller/Category.php index 213e1c2d..7ef55f62 100644 --- a/application/system/controller/Category.php +++ b/application/system/controller/Category.php @@ -15,11 +15,8 @@ class Category extends Base // 类别列表 public function index() { - $count = CG::count(); - // 设置要给模板赋值的信息 - $list['title'] = '类别列表'; - $list['count'] = $count; + $list['webtitle'] = '类别列表'; // 模板赋值 $this->assign('list',$list); @@ -29,74 +26,37 @@ class Category extends Base } - // 获取类别列表数据 + // 获取单位列表数据 public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'id', + 'order'=>'asc', + 'xingzhi'=>'' + ],'POST'); - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['name']; - if($order_field=='') - { - $order_field = $getdt['columns'][$order_column]['data']; - } - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - //得到搜索的关键词 - $search = $getdt['search']['value']; + // 实例化 + $cg = new CG; + // 获取记录总数 + $cnt = $cg->count(); - // 获取记录集总数 - $cnt = CG::count(); - //查询数据 - $data =CG::field('id,title,pid,status,paixu') - ->order([$order_field=>$order]) - ->with( - [ - 'glPid'=>function($query){ - $query->field('id,title'); - }, - ] - ) - ->limit($limit_start,$limit_length) - ->all(); - - - // 如果需要查询 - if($search){ - $data =CG::field('id,title,pid,status,paixu') - ->whereOr('title','like','%'.$search.'%') - ->whereOr('pid','in',function($query) use ($search){ - $query->name('category')->where('title','like','%'.$search.'%')->field('id'); - }) - ->with( - [ - 'glPid'=>function($query){ - $query->field('id,title'); - }, - ] - ) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->select(); - } - - $datacnt = $data->count(); - - + // 查询要显示的数据 + $data = $cg->search($src); + + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } diff --git a/application/system/controller/School.php b/application/system/controller/School.php index e2f5a891..474909b6 100644 --- a/application/system/controller/School.php +++ b/application/system/controller/School.php @@ -33,7 +33,7 @@ class School extends Base 'limit'=>'10', 'field'=>'update_time', 'order'=>'asc', - 'xingzhi'=>'' + 'xingzhi'=>[] ],'POST'); // 实例化 @@ -133,7 +133,6 @@ class School extends Base // 模板赋值 $this->assign('list',$list); - // 渲染 return $this->fetch('create'); @@ -148,7 +147,6 @@ class School extends Base $list = request() ->only(['title','jiancheng','biaoshi','xingzhi','jibie','xueduan','paixu'],'put'); - // 验证表单数据 $result = $validate->check($list); $msg = $validate->getError(); diff --git a/application/system/controller/SystemBase.php b/application/system/controller/SystemBase.php index 7b1950dd..277b99bd 100644 --- a/application/system/controller/SystemBase.php +++ b/application/system/controller/SystemBase.php @@ -13,9 +13,8 @@ class SystemBase extends Base // 系统设置 public function index() { - // 获取用户信息 - $list = sysbasemod::field('id,webtitle,keywords,description,thinks,danwei') + $list['data'] = sysbasemod::field('id,webtitle,keywords,description,thinks,danwei') ->order(['id'=>'desc']) ->find(); @@ -23,8 +22,10 @@ class SystemBase extends Base 'webtitle'=>'设置系统信息', 'butname'=>'设置', 'formpost'=>'PUT', + 'url'=>'/sysbase/'.$list['data']['id'], ); + // 模板赋值 $this->assign('list',$list); diff --git a/application/system/model/Category.php b/application/system/model/Category.php index 6c3ce2b5..10609a77 100644 --- a/application/system/model/Category.php +++ b/application/system/model/Category.php @@ -9,15 +9,55 @@ class Category extends Base // 关闭全局自动时间戳 protected $autoWriteTimestamp = false; - // // 父级类别获取器 - // public function getPidAttr($value) - // { - // return $this->where('id',$value)->value('title'); - // } - - // 本模型关联 + // 父级类型关联 public function glPid() { return $this->belongsTo('Category','pid','id'); } + + + // 子类型关联 + public function glCid() + { + return $this->hasMany('Category','pid','id'); + } + + + // 查询所有类别 + public function search($src) + { + // 整理变量 + // $xingzhi = $src['xingzhi']; + + // 查询数据 + $data = $this + ->order([$src['field'] =>$src['order']]) + // ->when(strlen($src['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); + // }) + // ->with( + // [ + // 'dwXingzhi'=>function($query){ + // $query->field('id,title'); + // }, + // 'dwJibie'=>function($query){ + // $query->field('id,title'); + // }, + // 'dwXueduan'=>function($query){ + // $query->field('id,title'); + // }, + // ] + // ) + ->page($src['page'],$src['limit']) + ->select(); + + + return $data; + } } diff --git a/application/system/model/School.php b/application/system/model/School.php index 60d5c9fe..6766d5ee 100644 --- a/application/system/model/School.php +++ b/application/system/model/School.php @@ -39,14 +39,14 @@ class School extends Base public function search($src) { // 整理变量 - // $xingzhi = $src['xingzhi']; + $xingzhi = $src['xingzhi']; // 查询数据 $data = $this ->order([$src['field'] =>$src['order']]) - // ->when(strlen($src['xingzhi'])>0,function($query) use($xingzhi){ - // $query->where('xingzhi','in',$xingzhi); - // }) + ->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); // }) diff --git a/application/system/view/category/create.html b/application/system/view/category/create.html index 26ece488..26daaa12 100644 --- a/application/system/view/category/create.html +++ b/application/system/view/category/create.html @@ -1,68 +1,111 @@ {extend name="common@create" /} -{block name="formaa"} -
-
- -
- -
-
-
- -
- - {php} $ctp = getCategory();{/php} - - -
-
-
- -
- -
-
-
-
- -
-
-
+{block name="form"} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {php} $category = getCategory(101);{/php} + +
+
+
+ +
+ {php} $category = getCategory(102);{/php} + +
+
+
+ +
+ {php} $category = getCategory(103);{/php} + +
+
+
+ +
+ +
+
+
+ +
+
{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/system/view/category/edit.html b/application/system/view/category/edit1.html similarity index 100% rename from application/system/view/category/edit.html rename to application/system/view/category/edit1.html diff --git a/application/system/view/category/index.html b/application/system/view/category/index.html index f2c1ab80..c777f2aa 100644 --- a/application/system/view/category/index.html +++ b/application/system/view/category/index.html @@ -1,122 +1,161 @@ + {extend name="common@list" /} -{block name="topnav"} - -{/block} -{block name="bouttons"} -
- - - - - 批量删除 - - - - - 添加类别 - - - - 共有数据:{$list.count} 条 - -
-{/block} -{block name="tables"} - - - - - - - - - - - - - -
名称父级类别排序状态操作
- +{block name="jsset"} +{/block} +{block name="nav"} + + 系统管理 + 类别管理 + 类别列表 + +{/block} +{block name="search"} +
+ + + + +
+{/block} +{block name="table"} +
{/block} {block name="myjs"} - + + + + + + + + //头工具栏事件 + table.on('toolbar(mytable)', function(obj){ + switch(obj.event){ + case 'dels': + var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值 + delAll(checkStatus,'/school','mytable'); + break; + case 'add': + add('添加单位','/school/create','650','500',true); + break; + }; + }); + + //监听行工具条 + table.on('tool(mytable)', function(obj){ //注:tool是工具条事件名,mytable是table原始容器的属性 lay-filter="对应的值" + var data = obj.data; //获得当前行数据 + var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值) + var tr = obj.tr; //获得当前行 tr 的DOM对象 + + switch(layEvent){ + case 'detail':// 查看 + layer.msg('查看' + data.id); + break; + case 'del':// 删除 + del(obj,"/school"); + break; + case 'edit':// 编辑 + add('编辑单位','/school/'+obj.data.id+'/edit','650','500',true); + break; + case 'status':// 状态 + status(obj,"{:url('setstatus')}"); + break; + }; + }); + + }); + {/block} \ No newline at end of file diff --git a/application/system/view/category/index1.html b/application/system/view/category/index1.html new file mode 100644 index 00000000..f2c1ab80 --- /dev/null +++ b/application/system/view/category/index1.html @@ -0,0 +1,122 @@ +{extend name="common@list" /} +{block name="topnav"} + +{/block} +{block name="bouttons"} +
+ + + + + 批量删除 + + + + + 添加类别 + + + + 共有数据:{$list.count} 条 + +
+{/block} +{block name="tables"} + + + + + + + + + + + + + +
名称父级类别排序状态操作
+ + +{/block} +{block name="myjs"} + +{/block} \ No newline at end of file diff --git a/application/system/view/school/create.html b/application/system/view/school/create.html index 6691068d..26daaa12 100644 --- a/application/system/view/school/create.html +++ b/application/system/view/school/create.html @@ -37,7 +37,7 @@ {volist name="category" id="vo"}
-
+
@@ -106,62 +106,6 @@ {/block} {block name="myjs"} - + {/block} diff --git a/application/system/view/school/edit.html b/application/system/view/school/edit.html deleted file mode 100644 index 62d11be5..00000000 --- a/application/system/view/school/edit.html +++ /dev/null @@ -1,108 +0,0 @@ -{extend name="common@create" /} -{block name="formaa"} - -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - {php} $category = getCategory(101);{/php} - - -
-
-
- -
- - {php} $category = getCategory(102);{/php} - - -
-
-
- -
- - {php} $catetory = getCategory(103);{/php} - - -
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/system/view/school/index.html b/application/system/view/school/index.html index 218da080..bba47a79 100644 --- a/application/system/view/school/index.html +++ b/application/system/view/school/index.html @@ -5,157 +5,195 @@ {/block} {block name="nav"} - 系统管理 - 单位管理 - 单位列表 + 系统管理 + 单位管理 + 单位列表 {/block} {block name="search"} -
- - - - + +
+ +
+ +
+
+
+ +
+ {php} $category = getCategory(101);{/php} + {volist name="category" id="vo"} + + {/volist} +
+
+
+
+ + +
+
{/block} {block name="table"} -
+
{/block} {block name="myjs"} - - - - - - - + + + + + + //执行一个laydate实例 + laydate.render({ + elem: '#end' //指定元素 + }); + + }); + + + {/block} \ No newline at end of file diff --git a/application/system/view/system_base/index.html b/application/system/view/system_base/index.html index fc1753d7..744aa21f 100644 --- a/application/system/view/system_base/index.html +++ b/application/system/view/system_base/index.html @@ -1,14 +1,34 @@ -{extend name="common@create" /} - -{block name="form"} -
+ + + + + + {$list.set.webtitle} + + + + {load href="__STATIC__/xadmin/css/font.css" /} + {load href="__STATIC__/xadmin/css/xadmin.css" /} + {load href="__STATIC__/xadmin/js/jquery.min.js" /} + {load href="__STATIC__/xadmin/lib/layui/layui.js" /} + {load href="__STATIC__/xadmin/js/xadmin.js" /} + {load href="__STATIC__/xadmin/js/cookie.js" /} + + + + +
+
+ autocomplete="off" class="layui-input " value="{$list.data.webtitle|default=''}">
@@ -17,7 +37,7 @@
+ autocomplete="off" class="layui-input" value="{$list.data.keywords|default=''}">
@@ -26,7 +46,7 @@
+ autocomplete="off" class="layui-input" value="{$list.data.description|default=''}">
@@ -35,7 +55,7 @@
+ autocomplete="off" class="layui-input" value="{$list.data.thinks|default=''}">
@@ -44,41 +64,48 @@
+ autocomplete="off" class="layui-input" value="{$list.data.danwei|default=''}">
-
-{/block} - -{block name="myjs"} +
-{/block} + + + + \ No newline at end of file diff --git a/config/template.php b/config/template.php index 5d0ba322..91be2d84 100644 --- a/config/template.php +++ b/config/template.php @@ -35,6 +35,6 @@ return [ // 全局替换 'tpl_replace_string' => [ '__UPLOAD__'=>'/uploads', - '__STATIC__'=>'../static', + '__STATIC__'=>'/static', ] ]; diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 0c96a55f..30b03cd1 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -54,7 +54,7 @@ class Rule extends Seeder // 系统设置 ['id'=>701,'title'=>'类别管理','name'=>'system/Category/index','paixu'=>1,'ismenu' =>true,'pid' =>7,'url'=>'/category',], ['id'=>702,'title'=>'单位管理','name'=>'system/School/index','paixu'=>2,'ismenu' =>true,'pid' =>7,'url'=>'/school',], - ['id'=>703,'title'=>'系统设置','name'=>'system/SystemBase/index','paixu'=>3,'ismenu' =>true,'pid' =>7,'url'=>'/sysbase',], + ['id'=>703,'title'=>'系统设置','name'=>'system/SystemBase/edit','paixu'=>3,'ismenu' =>true,'pid' =>7,'url'=>'/sysbase/1/edit',], // 荣誉管理 @@ -172,8 +172,6 @@ class Rule extends Seeder ['title'=>'编辑','name'=>'system/School/edit','paixu'=>3,'pid'=>702,], ['title'=>'查看','name'=>'system/School/read','paixu'=>4,'pid'=>702,], ['title'=>'状态','name'=>'system/School/setStatus','paixu'=>5,'pid'=>702], - // 系统设置权限 - ['title'=>'编辑','name'=>'system/SystemBase/edit','paixu'=>1,'pid'=>703,], // 荣誉管理 // 单位荣誉管理