From abef6b0f09bb84746fb3b242ec6ac501a6ba5cb3 Mon Sep 17 00:00:00 2001 From: devil Date: Fri, 5 Jun 2020 23:29:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=97=E8=A1=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Common.php | 35 +- application/admin/controller/Goods.php | 6 +- application/admin/form/Goods.php | 64 ++- .../view/default/goods/module/operate.html | 4 +- .../admin/view/default/public/form.html | 76 +++- application/common.php | 50 +-- application/module/FormHandle.php | 148 ------- application/module/FormHandleModule.php | 405 ++++++++++++++++++ ...{ViewInclude.php => ViewIncludeModule.php} | 2 +- application/tags.php | 16 + public/static/common/css/common.css | 8 + public/static/common/js/common.js | 24 +- .../pages/plugins/distribution/user/user.acss | 1 + .../plugins/membershiplevelvip/user/user.acss | 1 + .../pages/plugins/distribution/user/user.css | 1 + .../pages/plugins/distribution/user/user.ttss | 1 + .../plugins/membershiplevelvip/user/user.ttss | 1 + .../pages/plugins/distribution/user/user.wxss | 1 + .../plugins/membershiplevelvip/user/user.wxss | 1 + .../library/think/session/driver/Redis.php | 8 +- 20 files changed, 622 insertions(+), 231 deletions(-) delete mode 100644 application/module/FormHandle.php create mode 100644 application/module/FormHandleModule.php rename application/module/{ViewInclude.php => ViewIncludeModule.php} (97%) diff --git a/application/admin/controller/Common.php b/application/admin/controller/Common.php index 2adc98ea7..d5d499dd0 100755 --- a/application/admin/controller/Common.php +++ b/application/admin/controller/Common.php @@ -14,6 +14,7 @@ use think\facade\Hook; use think\Controller; use app\service\AdminPowerService; use app\service\ConfigService; +use app\module\FormHandleModule; /** * 管理员公共控制器 @@ -247,27 +248,25 @@ class Common extends Controller */ public function FormTableInit() { - // 当前操作名称 - $module = request()->module(); - $controller = request()->controller(); - - // 数据处理 - $res = FormTableLoad($controller, $module, $this->data_request); - if($res['code'] == 0) + // 获取表格模型 + $module = FormModulePath($this->data_request); + if(!empty($module)) { - $this->form_table = $res['data']['table']; - $this->form_where = $res['data']['where']; - $this->form_params = $res['data']['params']; + // 调用表格处理 + $res = (new FormHandleModule())->Run($module, $this->data_request); + if($res['code'] == 0) + { + $this->form_table = $res['data']['table']; + $this->form_where = $res['data']['where']; + $this->form_params = $res['data']['params']; - $this->assign('form_table', $this->form_table); - $this->assign('form_params', $this->form_params); - } else { - $this->form_error = $res['msg']; - $this->assign('form_error', $this->form_error); + $this->assign('form_table', $this->form_table); + $this->assign('form_params', $this->form_params); + } else { + $this->form_error = $res['msg']; + $this->assign('form_error', $this->form_error); + } } - - -//print_r($this->data_request);die; } /** diff --git a/application/admin/controller/Goods.php b/application/admin/controller/Goods.php index 2d0a00ca1..868114222 100755 --- a/application/admin/controller/Goods.php +++ b/application/admin/controller/Goods.php @@ -57,10 +57,10 @@ class Goods extends Common $params = $this->data_request; // 条件 - $where = GoodsService::GetAdminIndexWhere($params); + //$where = GoodsService::GetAdminIndexWhere($params); // 总数 - $total = GoodsService::GoodsTotal($where); + $total = GoodsService::GoodsTotal($this->form_where); // 分页 $page_params = array( @@ -74,7 +74,7 @@ class Goods extends Common // 获取数据列表 $data_params = [ - 'where' => $where, + 'where' => $this->form_where, 'm' => $page->GetPageStarNumber(), 'n' => $this->page_size, 'is_category' => 1, diff --git a/application/admin/form/Goods.php b/application/admin/form/Goods.php index fab0652a3..e8efbc2b6 100644 --- a/application/admin/form/Goods.php +++ b/application/admin/form/Goods.php @@ -25,6 +25,11 @@ use app\service\BrandService; */ class Goods { + // 基础条件 + public $condition_base = [ + ['is_delete_time', '=', 0], + ]; + /** * 入口 * @author Devil @@ -43,14 +48,32 @@ class Goods 'status_field' => 'is_shelves', 'is_search' => 1, 'search_url' => MyUrl('admin/goods/index'), - ], // 表单配置 'form' => [ + [ + 'view_type' => 'checkbox', + 'is_checked' => 0, + 'checked_text' => '反选', + 'not_checked_text' => '全选', + 'align' => 'center', + 'width' => 80, + ], + [ + 'view_type' => 'radio', + 'align' => 'center', + 'width' => 50, + ], [ 'label' => '商品ID', 'view_type' => 'field', 'view_key' => 'id', + 'width' => 80, + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'id', + 'where_type' => '=', + ], ], [ 'label' => '商品信息', @@ -61,7 +84,7 @@ class Goods 'form_type' => 'input', 'form_name' => 'title|simple_desc|seo_title|seo_keywords|seo_keywords', 'where_type' => 'like', - 'placeholder' => '请输入名称/简述/SEO信息' + 'placeholder' => '请输入商品名称/简述/SEO信息' ], ], [ @@ -99,7 +122,6 @@ class Goods 'label' => '上下架', 'view_type' => 'status', 'view_key' => 'is_shelves', - 'key_field' => 'id', 'post_url' => MyUrl('admin/goods/statusshelves'), 'is_form_su' => 1, 'align' => 'center', @@ -117,7 +139,6 @@ class Goods 'label' => '首页推荐', 'view_type' => 'status', 'view_key' => 'is_home_recommended', - 'key_field' => 'id', 'post_url' => MyUrl('admin/goods/statushomerecommended'), 'align' => 'center', 'search_config' => [ @@ -147,8 +168,9 @@ class Goods 'search_config' => [ 'form_type' => 'module', 'template' => 'lib/module/goods_category', - 'form_name' => 'category_id', + 'form_name' => 'id', 'where_type' => 'in', + 'where_custom' => 'WhereValueGoodsCategory', 'data' => GoodsService::GoodsCategoryAll(), ], ], @@ -185,4 +207,36 @@ class Goods ], ]; } + + /** + * 商品分类条件处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-06-03 + * @desc description + * @param [string] $name [字段名称] + * @param [array] $params [输入参数] + */ + public function WhereValueGoodsCategory($value, $params = []) + { + if(!empty($value)) + { + // 是否为数组 + if(!is_array($value)) + { + $value = [$value]; + } + + // 获取分类下的所有分类 id + $category_ids = GoodsService::GoodsCategoryItemsIds($value, 1); + + // 获取商品 id + $goods_ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$category_ids])->column('goods_id'); + + // 避免空条件造成无效的错觉 + return empty($goods_ids) ? [0] : $goods_ids; + } + return $value; + } } \ No newline at end of file diff --git a/application/admin/view/default/goods/module/operate.html b/application/admin/view/default/goods/module/operate.html index 59fdadf98..98d69741e 100644 --- a/application/admin/view/default/goods/module/operate.html +++ b/application/admin/view/default/goods/module/operate.html @@ -1,5 +1,5 @@ - @@ -7,7 +7,7 @@ 编辑 - \ No newline at end of file diff --git a/application/admin/view/default/public/form.html b/application/admin/view/default/public/form.html index 2663b8490..bac13b09f 100644 --- a/application/admin/view/default/public/form.html +++ b/application/admin/view/default/public/form.html @@ -93,7 +93,21 @@ {{if !empty($t['align'])}}am-text-{{$t.align}} {{/if}} {{if !empty($t['fixed'])}}am-grid-fixed-{{$t.fixed}} {{/if}} {{if !empty($t['view_type']) and $t['view_type'] eq 'operate'}}am-operate-grid {{/if}} - ">{{if isset($t['label'])}}{{$t.label}}{{/if}} + " + style=" + {{if !empty($t['width'])}} + min-width: {{$t.width}}px; + {{/if}} + " + > + {{switch $t.view_type}} + {{case checkbox}} + + {{/case}} + {{default /}} + {{if isset($t['label'])}}{{$t.label}}{{/if}} + {{/switch}} + {{/foreach}} @@ -107,16 +121,22 @@ {{if !empty($t['align'])}}am-text-{{$t.align}} {{/if}} {{if !empty($t['fixed'])}}am-grid-fixed-{{$t.fixed}} {{/if}} {{if !empty($t['view_type']) and $t['view_type'] eq 'operate'}}am-operate-grid {{/if}} - "> + " + style=" + {{if !empty($t['width'])}} + min-width: {{$t.width}}px; + {{/if}} + " + > {{if !empty($t['search_config']) and !empty($t['search_config']['form_type']) and !empty($t['search_config']['form_name'])}} {{switch $t.search_config.form_type}} {{case input}} - + {{/case}} {{case select}} - {{if isset($t['search_config']['is_seat_select']) and $t['search_config']['is_seat_select'] eq 1 and (!isset($t['search_config']['is_multiple']) or $t['search_config']['is_multiple'] neq 1)}}