From 5855a97255ea8c63e890b2b9943e7172710e7891 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:23:27 +0800 Subject: [PATCH] Improve category selection in goods management - Simplify HTML structure and recommend a concise coding method for category selection in both add and edit pages of the mall goods module. - Modify the corresponding JS file to support the new category display format. - Refactor controller code to assign categories using a more efficient method. - Ensure consistent category data processing across all related views. Note: This change updates the way categories are presented to the admin user, enhancing usability and maintainability of the goods management system. --- app/admin/controller/mall/Goods.php | 2 ++ app/admin/view/mall/goods/add.html | 15 +++++++++++++++ app/admin/view/mall/goods/edit.html | 14 ++++++++++++++ app/admin/view/mall/goods/index.html | 5 ++++- app/admin/view/system/uploadfile/index.html | 3 +-- public/static/admin/js/mall/goods.js | 2 +- 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/mall/Goods.php b/app/admin/controller/mall/Goods.php index 3ba19f6..14beecd 100644 --- a/app/admin/controller/mall/Goods.php +++ b/app/admin/controller/mall/Goods.php @@ -2,6 +2,7 @@ namespace app\admin\controller\mall; +use app\admin\model\MallCate; use app\admin\model\MallGoods; use app\common\controller\AdminController; use app\admin\service\annotation\ControllerAnnotation; @@ -25,6 +26,7 @@ class Goods extends AdminController { parent::__construct($app); $this->model = new MallGoods(); + $this->assign('cate', (new MallCate())->column('title', 'id')); } /** diff --git a/app/admin/view/mall/goods/add.html b/app/admin/view/mall/goods/add.html index 44b169a..f150645 100644 --- a/app/admin/view/mall/goods/add.html +++ b/app/admin/view/mall/goods/add.html @@ -1,5 +1,7 @@
+ +
@@ -8,6 +10,19 @@
+ + + + + + + + + + + + +
diff --git a/app/admin/view/mall/goods/edit.html b/app/admin/view/mall/goods/edit.html index d24a3b1..af6f9cd 100644 --- a/app/admin/view/mall/goods/edit.html +++ b/app/admin/view/mall/goods/edit.html @@ -1,6 +1,7 @@
+
@@ -9,6 +10,19 @@
+ + + + + + + + + + + + +
diff --git a/app/admin/view/mall/goods/index.html b/app/admin/view/mall/goods/index.html index a6198e7..5016922 100644 --- a/app/admin/view/mall/goods/index.html +++ b/app/admin/view/mall/goods/index.html @@ -8,4 +8,7 @@ lay-filter="currentTable">
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/app/admin/view/system/uploadfile/index.html b/app/admin/view/system/uploadfile/index.html index ddeeddc..7e4d221 100644 --- a/app/admin/view/system/uploadfile/index.html +++ b/app/admin/view/system/uploadfile/index.html @@ -9,6 +9,5 @@
\ No newline at end of file diff --git a/public/static/admin/js/mall/goods.js b/public/static/admin/js/mall/goods.js index 17dce39..faed6b2 100644 --- a/public/static/admin/js/mall/goods.js +++ b/public/static/admin/js/mall/goods.js @@ -31,7 +31,7 @@ define(["jquery", "easy-admin"], function ($, ea) { {type: "checkbox"}, {field: 'id', width: 80, title: 'ID', searchOp: '='}, {field: 'sort', width: 80, title: '排序', edit: 'text'}, - {field: 'cate.title', minWidth: 80, title: '商品分类'}, + {field: 'cate_id', minWidth: 80, title: '商品分类', search: 'select', selectList: cateSelects}, {field: 'title', minWidth: 80, title: '商品名称'}, {field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image}, {field: 'market_price', width: 100, title: '市场价', templet: ea.table.price},