From fc0ba2379c15192dd61b674980d73934f77aaf8b Mon Sep 17 00:00:00 2001 From: jianglong Date: Sat, 6 Jan 2024 11:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/content/Resource.php | 11 +++++- app/admin/controller/content/ResourceCategory.php | 7 +++- app/admin/logic/content/ResourceCategoryLogic.php | 28 ++++++++++++-- app/admin/logic/content/ResourceLogic.php | 10 +++++ app/admin/view/content/resource/add.html | 41 +++++++++++++++++++- app/admin/view/content/resource/edit.html | 44 +++++++++++++++++++++- app/admin/view/content/resource/lists.html | 1 + app/admin/view/content/resource_category/add.html | 12 ++++++ app/admin/view/content/resource_category/edit.html | 12 ++++++ .../view/content/resource_category/lists.html | 1 + app/api/logic/ResourceLogic.php | 8 ++++ app/common/model/content/Resource.php | 10 +++++ .../temp/11b1f5a2163bcf964e1939530bd00942.php | 43 ++++++++++++++++++++- .../temp/78162e704fbe5f7a6099f3687a5c91f8.php | 3 +- .../temp/e90c6cc0d969fe8d18d6f2260835932b.php | 3 +- .../temp/f147d63d483a25f220830848ba1555dd.php | 14 ++++++- .../cache/9f/d2f37875d1da637002182ec566f162.php | 2 +- .../session/sess_ee5ef07b6cec43c0853f1fa95f09ad66 | 1 - 18 files changed, 234 insertions(+), 17 deletions(-) delete mode 100644 runtime/session/sess_ee5ef07b6cec43c0853f1fa95f09ad66 diff --git a/app/admin/controller/content/Resource.php b/app/admin/controller/content/Resource.php index 06a5494..cad0517 100644 --- a/app/admin/controller/content/Resource.php +++ b/app/admin/controller/content/Resource.php @@ -71,10 +71,17 @@ class Resource extends AdminBase return JsonServer::success('编辑成功'); } + $id = $this->request->get('id'); + $detail = ResourceLogic::detail($id); + $category2 = []; + if($detail['cid']>0){ + $category2 = ResourceCategoryLogic::getCategory($detail['cid']); + } return view('', [ - 'detail' => ResourceLogic::detail($id), - 'category' => ResourceCategoryLogic::getCategory() + 'detail' => $detail, + 'category' => ResourceCategoryLogic::getCategory(), + 'category2' => $category2 ]); } diff --git a/app/admin/controller/content/ResourceCategory.php b/app/admin/controller/content/ResourceCategory.php index 6d3b20a..24da0ce 100644 --- a/app/admin/controller/content/ResourceCategory.php +++ b/app/admin/controller/content/ResourceCategory.php @@ -45,7 +45,9 @@ class ResourceCategory extends AdminBase } - return view(); + return view('', [ + 'category' => ResourceCategoryLogic::getCategory() + ]); } /** @@ -66,7 +68,8 @@ class ResourceCategory extends AdminBase $id = $this->request->get('id'); return view('', [ - 'detail' => ResourceCategoryLogic::detail($id) + 'detail' => ResourceCategoryLogic::detail($id), + 'category' => ResourceCategoryLogic::getCategory() ]); } diff --git a/app/admin/logic/content/ResourceCategoryLogic.php b/app/admin/logic/content/ResourceCategoryLogic.php index b4d1fbe..ffdd129 100644 --- a/app/admin/logic/content/ResourceCategoryLogic.php +++ b/app/admin/logic/content/ResourceCategoryLogic.php @@ -20,8 +20,11 @@ class ResourceCategoryLogic extends Logic { try { $where = [ - ['del', '=', 0] + ['del', '=', 0], ]; + if(isset($get['pid']) && $get['pid']>0){ + $where[] = ['pid', '=', $get['pid']]; + } $model = new ResourceCategory(); $lists = $model->field(true) @@ -36,6 +39,21 @@ class ResourceCategoryLogic extends Logic foreach ($lists['data'] as &$item) { $item['is_show'] = $item['is_show'] ? '启用' : '停用'; + if($item['pid']){ + $where2 = [ + ['del', '=', 0], + ['id', '=', $item['pid']], + ]; + $cates = $model->where($where2)->find(); + if($cates){ + $item['p_name'] = $cates['name']; + }else{ + $item['p_name'] = '无'; + } + }else{ + $item['p_name'] = '无'; + } + } return ['count'=>$lists['total'], 'lists'=>$lists['data']]; @@ -49,12 +67,12 @@ class ResourceCategoryLogic extends Logic * @Author: 张无忌 * @return array */ - public static function getCategory() + public static function getCategory($pid=0) { try { $model = new ResourceCategory(); return $model->field(true) - ->where(['del'=>0, 'is_show'=>1]) + ->where(['del'=>0, 'is_show'=>1,'pid'=>$pid]) ->order('id', 'desc') ->select() ->toArray(); @@ -85,7 +103,8 @@ class ResourceCategoryLogic extends Logic try { ResourceCategory::create([ 'name' => $post['name'], - 'is_show' => $post['is_show'] + 'is_show' => $post['is_show'], + 'pid' => $post['pid'] ]); return true; @@ -106,6 +125,7 @@ class ResourceCategoryLogic extends Logic ResourceCategory::update([ 'name' => $post['name'], + 'pid' => $post['pid'], 'is_show' => $post['is_show'] ], ['id'=>$post['id']]); diff --git a/app/admin/logic/content/ResourceLogic.php b/app/admin/logic/content/ResourceLogic.php index 86fbec5..b2a41b0 100644 --- a/app/admin/logic/content/ResourceLogic.php +++ b/app/admin/logic/content/ResourceLogic.php @@ -44,8 +44,16 @@ class ResourceLogic extends Logic ]) ->toArray(); + foreach ($lists['data'] as &$item) { $item['category'] = $item['category']['name'] ?? '未知'; + if($item['cid2']){ + $cates = ResourceCategoryLogic::detail($item['cid2']); + $item['category2'] = $cates ? $cates['name'] : '无'; + }else{ + $item['category2'] = '无'; + } + $item['is_show'] = $item['is_show'] ? '显示' : '隐藏'; $item['path'] = $item['path']?UrlServer::getFileUrl($item['path']):''; $item['path_name']= $item['path']?substr($item['path'],strrpos($item['path'],"/")+1):''; @@ -90,6 +98,7 @@ class ResourceLogic extends Logic try { Resource::create([ 'cid' => $post['cid'], + 'cid2' => $post['cid2'], 'title' => $post['title'], 'image' => $post['image'] ?? '', 'path' => $post['path'] ?? '', @@ -125,6 +134,7 @@ class ResourceLogic extends Logic try { Resource::update([ 'cid' => $post['cid'], + 'cid2' => $post['cid2'], 'title' => $post['title'], 'image' => $post['image'] ?? '', 'path' => $post['path'] ?? '', diff --git a/app/admin/view/content/resource/add.html b/app/admin/view/content/resource/add.html index 62b3bf5..b0e14c0 100644 --- a/app/admin/view/content/resource/add.html +++ b/app/admin/view/content/resource/add.html @@ -74,7 +74,7 @@
- {volist name="category" id="vo"} @@ -84,6 +84,15 @@
+ +
+ +
+
+ +
@@ -193,6 +202,36 @@ } }); + + form.on('select(cid)', function (data) { + console.log(data); + var cid = data.value; + $.ajax({ + type: 'GET', + dataType: 'json', + url: "{:url('content.ResourceCategory/lists')}", + data: {pid:cid,page:1,limit:100}, + success: function(res) { + console.log(res) + var html = ''; + if(res.code == 1 && res.data.count > 0){ + var list = res.data.lists + for (var i=0;i'+item.name+''; + } + + } + console.log(html) + $("#cid2").html(html) + form.render(); + } + + }) + + }); + + form.verify({ content: function() { likeedit.sync(content) diff --git a/app/admin/view/content/resource/edit.html b/app/admin/view/content/resource/edit.html index 6081919..acd22ea 100644 --- a/app/admin/view/content/resource/edit.html +++ b/app/admin/view/content/resource/edit.html @@ -74,7 +74,7 @@
- {volist name="category" id="vo"} @@ -84,6 +84,19 @@
+ +
+ +
+
+ + +
@@ -213,6 +226,34 @@ } }); + form.on('select(cid)', function (data) { + console.log(data); + var cid = data.value; + $.ajax({ + type: 'GET', + dataType: 'json', + url: "{:url('content.ResourceCategory/lists')}", + data: {pid:cid,page:1,limit:100}, + success: function(res) { + console.log(res) + var html = ''; + if(res.code == 1 && res.data.count > 0){ + var list = res.data.lists + for (var i=0;i'+item.name+''; + } + + } + console.log(html) + $("#cid2").html(html) + form.render(); + } + + }) + + }); + form.verify({ content: function() { likeedit.sync(content) @@ -265,5 +306,6 @@ "{$detail.refund_address.province_id ?? ''}", "{$detail.refund_address.city_id ?? ''}", "{$detail.refund_address.district_id ?? ''}" ); + $("") }) \ No newline at end of file diff --git a/app/admin/view/content/resource/lists.html b/app/admin/view/content/resource/lists.html index cca934a..b98275d 100644 --- a/app/admin/view/content/resource/lists.html +++ b/app/admin/view/content/resource/lists.html @@ -92,6 +92,7 @@ ,{field:"title", width:200, align:"center", title:"资料标题"} ,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"} ,{field:"category", width:150, align:"center", title:"资料分类"} + ,{field:"category2", width:150, align:"center", title:"子分类"} ,{field:"address", width:180, align:"center", title:"资料区域"} ,{field:"type", width:150, align:"center", title:"付费类型", templet:"#table-type"} ,{field:"type", width:100, align:"center", title:"文件", templet:"#table-file"} diff --git a/app/admin/view/content/resource_category/add.html b/app/admin/view/content/resource_category/add.html index ee09c35..0ae64c6 100644 --- a/app/admin/view/content/resource_category/add.html +++ b/app/admin/view/content/resource_category/add.html @@ -2,6 +2,18 @@
+ +
+ +
+
+ +
diff --git a/app/admin/view/content/resource_category/edit.html b/app/admin/view/content/resource_category/edit.html index e41d6a8..e3380a3 100644 --- a/app/admin/view/content/resource_category/edit.html +++ b/app/admin/view/content/resource_category/edit.html @@ -2,6 +2,18 @@
+ +
+ +
+
+ +
diff --git a/app/admin/view/content/resource_category/lists.html b/app/admin/view/content/resource_category/lists.html index d3d0aaf..f4e35a1 100644 --- a/app/admin/view/content/resource_category/lists.html +++ b/app/admin/view/content/resource_category/lists.html @@ -35,6 +35,7 @@ var table = layui.table; like.tableLists("#like-table-lists", "{:url()}", [ {field:"id", width:60, title:"ID"} + ,{field:"p_name", width:160, align:"center", title:"父级分类"} ,{field:"name", width:160, align:"center", title:"资料分类"} ,{field:"is_show", width:100, align:"center", title:"资料状态"} ,{field:"create_time", width:180, align:"center", title:"创建时间"} diff --git a/app/api/logic/ResourceLogic.php b/app/api/logic/ResourceLogic.php index f3300da..0affeee 100644 --- a/app/api/logic/ResourceLogic.php +++ b/app/api/logic/ResourceLogic.php @@ -36,6 +36,10 @@ class ResourceLogic extends Logic } } + if(isset($get['pid']) ){ + $where[] = ['pid','=',$get['pid']]; + } + return $model->field(['id', 'name']) ->where([ ['del', '=', 0], @@ -73,6 +77,10 @@ class ResourceLogic extends Logic $where[] = ['cid', '=', $get['cid']]; } + if(isset($get['cid2']) && !empty($get['cid2']) && $get['cid2']>0 && !strstr($get['cid2'],"city_") ) { + $where[] = ['cid2', '=', $get['cid2']]; + } + if(isset($get['cid']) && !empty($get['cid']) && strstr($get['cid'],"city_") ) { $where[] = ['a.city_id', '=', str_replace("city_","",$get['cid'])]; } diff --git a/app/common/model/content/Resource.php b/app/common/model/content/Resource.php index c18f950..1dc0f3a 100644 --- a/app/common/model/content/Resource.php +++ b/app/common/model/content/Resource.php @@ -17,4 +17,14 @@ class Resource extends Models { return $this->hasOne('ResourceCategory', 'id', 'cid'); } + + /** + * @Notes: 关联资源分类模型 + * @Author: + */ + public function category2() + { + return $this->hasOne('ResourceCategory', 'id', 'cid2'); + } + } \ No newline at end of file diff --git a/runtime/admin/temp/11b1f5a2163bcf964e1939530bd00942.php b/runtime/admin/temp/11b1f5a2163bcf964e1939530bd00942.php index 12b78c4..866928c 100644 --- a/runtime/admin/temp/11b1f5a2163bcf964e1939530bd00942.php +++ b/runtime/admin/temp/11b1f5a2163bcf964e1939530bd00942.php @@ -1,4 +1,4 @@ - + @@ -93,7 +93,7 @@
- $vo): $mod = ($i % 2 );++$i;?> @@ -103,6 +103,15 @@
+ +
+ +
+
+ +
@@ -212,6 +221,36 @@ } }); + + form.on('select(cid)', function (data) { + console.log(data); + var cid = data.value; + $.ajax({ + type: 'GET', + dataType: 'json', + url: "", + data: {pid:cid,page:1,limit:100}, + success: function(res) { + console.log(res) + var html = ''; + if(res.code == 1 && res.data.count > 0){ + var list = res.data.lists + for (var i=0;i'+item.name+''; + } + + } + console.log(html) + $("#cid2").html(html) + form.render(); + } + + }) + + }); + + form.verify({ content: function() { likeedit.sync(content) diff --git a/runtime/admin/temp/78162e704fbe5f7a6099f3687a5c91f8.php b/runtime/admin/temp/78162e704fbe5f7a6099f3687a5c91f8.php index 5d4b435..469a5bc 100644 --- a/runtime/admin/temp/78162e704fbe5f7a6099f3687a5c91f8.php +++ b/runtime/admin/temp/78162e704fbe5f7a6099f3687a5c91f8.php @@ -1,4 +1,4 @@ - + @@ -56,6 +56,7 @@ var table = layui.table; like.tableLists("#like-table-lists", "", [ {field:"id", width:60, title:"ID"} + ,{field:"p_name", width:160, align:"center", title:"父级分类"} ,{field:"name", width:160, align:"center", title:"资料分类"} ,{field:"is_show", width:100, align:"center", title:"资料状态"} ,{field:"create_time", width:180, align:"center", title:"创建时间"} diff --git a/runtime/admin/temp/e90c6cc0d969fe8d18d6f2260835932b.php b/runtime/admin/temp/e90c6cc0d969fe8d18d6f2260835932b.php index 42e5fa6..740dd8c 100644 --- a/runtime/admin/temp/e90c6cc0d969fe8d18d6f2260835932b.php +++ b/runtime/admin/temp/e90c6cc0d969fe8d18d6f2260835932b.php @@ -1,4 +1,4 @@ - + @@ -113,6 +113,7 @@ ,{field:"title", width:200, align:"center", title:"资料标题"} ,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"} ,{field:"category", width:150, align:"center", title:"资料分类"} + ,{field:"category2", width:150, align:"center", title:"子分类"} ,{field:"address", width:180, align:"center", title:"资料区域"} ,{field:"type", width:150, align:"center", title:"付费类型", templet:"#table-type"} ,{field:"type", width:100, align:"center", title:"文件", templet:"#table-file"} diff --git a/runtime/admin/temp/f147d63d483a25f220830848ba1555dd.php b/runtime/admin/temp/f147d63d483a25f220830848ba1555dd.php index 513a143..ea0bf87 100644 --- a/runtime/admin/temp/f147d63d483a25f220830848ba1555dd.php +++ b/runtime/admin/temp/f147d63d483a25f220830848ba1555dd.php @@ -1,4 +1,4 @@ - + @@ -21,6 +21,18 @@
+ +
+ +
+
+ +
diff --git a/runtime/cache/9f/d2f37875d1da637002182ec566f162.php b/runtime/cache/9f/d2f37875d1da637002182ec566f162.php index 7bd99d0..d03504c 100644 --- a/runtime/cache/9f/d2f37875d1da637002182ec566f162.php +++ b/runtime/cache/9f/d2f37875d1da637002182ec566f162.php @@ -1,4 +1,4 @@ -a:6:{i:0;s:75:"E:\waibao\ahbcqz\server\runtime\cache\ad\710db81cabed7a4fc183cdbe36b098.php";i:1;s:75:"E:\waibao\ahbcqz\server\runtime\cache\b0\2f627ee37a64f2b7a2192d33ffb6ce.php";i:2;s:75:"E:\waibao\ahbcqz\server\runtime\cache\a5\132d23a4f708efcceee81162e0d944.php";i:3;s:75:"E:\waibao\ahbcqz\server\runtime\cache\51\5060a84cc9236c33edb430c07bcd5d.php";i:4;s:75:"E:\waibao\ahbcqz\server\runtime\cache\15\7f97380bf9d6dd15b8de122c49579f.php";i:5;s:75:"E:\waibao\ahbcqz\server\runtime\cache\85\4e59911e21c259fcd17dbf96f12fd2.php";} \ No newline at end of file +a:7:{i:0;s:75:"E:\waibao\ahbcqz\server\runtime\cache\ad\710db81cabed7a4fc183cdbe36b098.php";i:1;s:75:"E:\waibao\ahbcqz\server\runtime\cache\b0\2f627ee37a64f2b7a2192d33ffb6ce.php";i:2;s:75:"E:\waibao\ahbcqz\server\runtime\cache\a5\132d23a4f708efcceee81162e0d944.php";i:3;s:75:"E:\waibao\ahbcqz\server\runtime\cache\51\5060a84cc9236c33edb430c07bcd5d.php";i:4;s:75:"E:\waibao\ahbcqz\server\runtime\cache\15\7f97380bf9d6dd15b8de122c49579f.php";i:5;s:75:"E:\waibao\ahbcqz\server\runtime\cache\85\4e59911e21c259fcd17dbf96f12fd2.php";i:6;s:75:"E:\waibao\ahbcqz\server\runtime\cache\03\8ff1cb9d73a91f65140a6b0f3fa1a9.php";} \ No newline at end of file diff --git a/runtime/session/sess_ee5ef07b6cec43c0853f1fa95f09ad66 b/runtime/session/sess_ee5ef07b6cec43c0853f1fa95f09ad66 deleted file mode 100644 index 2151f3a..0000000 --- a/runtime/session/sess_ee5ef07b6cec43c0853f1fa95f09ad66 +++ /dev/null @@ -1 +0,0 @@ -a:1:{s:10:"admin_info";a:4:{s:2:"id";i:1;s:7:"account";s:5:"admin";s:4:"name";s:5:"admin";s:7:"role_id";i:0;}} \ No newline at end of file