From fcef7f07123f2e1fb7a70cedc4a8c4707be244f8 Mon Sep 17 00:00:00 2001 From: Devil Date: Sun, 8 Aug 2021 22:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=88=97=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A0=BC=E5=AD=90=E6=94=AF=E6=8C=81=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Common.php | 2 ++ .../default/public/module/form_table.html | 27 +++++++++++++++++++ app/index/controller/Common.php | 2 ++ .../default/public/module/form_table.html | 27 +++++++++++++++++++ app/module/FormHandleModule.php | 16 +++++++++++ 5 files changed, 74 insertions(+) diff --git a/app/admin/controller/Common.php b/app/admin/controller/Common.php index eaf8e5922..a04691588 100755 --- a/app/admin/controller/Common.php +++ b/app/admin/controller/Common.php @@ -394,6 +394,8 @@ class Common extends BaseController } } + // 表格列表公共标识 + MyViewAssign('hook_name_form_list', $current.'_list'); // 内容外部顶部 MyViewAssign('hook_name_content_top', $current.'_content_top'); // 内容外部底部 diff --git a/app/admin/view/default/public/module/form_table.html b/app/admin/view/default/public/module/form_table.html index b6ffedfd4..180be5eee 100644 --- a/app/admin/view/default/public/module/form_table.html +++ b/app/admin/view/default/public/module/form_table.html @@ -298,6 +298,33 @@ {{/if}} {{/case}} {{/switch}} + + + {{if !empty($t['unique_key']) and $t['view_type'] neq 'operate'}} + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ {{$hook_name_form_list}}_grid_{{$t.unique_key}} +
+ {{/if}} + {{php}} + $hook_data = MyEventTrigger($hook_name_form_list.'_grid_'.$t['unique_key'], [ + 'hook_name' => $hook_name_form_list.'_grid_'.$t['unique_key'], + 'is_backend' => true, + 'id' => isset($data_list[$i][$form_table['base']['key_field']]) ? $data_list[$i][$form_table['base']['key_field']] : 0, + 'data' => $data_list[$i], + ]); + if(!empty($hook_data) && is_array($hook_data)) + { + foreach($hook_data as $hook) + { + if(is_string($hook) || is_int($hook)) + { + echo htmlspecialchars_decode($hook); + } + } + } + {{/php}} + {{/if}} {{/if}} {{/if}} diff --git a/app/index/controller/Common.php b/app/index/controller/Common.php index 54d1bf7c6..21344f1f9 100755 --- a/app/index/controller/Common.php +++ b/app/index/controller/Common.php @@ -554,6 +554,8 @@ class Common extends BaseController } } + // 表格列表公共标识 + MyViewAssign('hook_name_form_list', $current.'_list'); // 内容外部顶部 MyViewAssign('hook_name_content_top', $current.'_content_top'); // 内容外部底部 diff --git a/app/index/view/default/public/module/form_table.html b/app/index/view/default/public/module/form_table.html index b6ffedfd4..180be5eee 100644 --- a/app/index/view/default/public/module/form_table.html +++ b/app/index/view/default/public/module/form_table.html @@ -298,6 +298,33 @@ {{/if}} {{/case}} {{/switch}} + + + {{if !empty($t['unique_key']) and $t['view_type'] neq 'operate'}} + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ {{$hook_name_form_list}}_grid_{{$t.unique_key}} +
+ {{/if}} + {{php}} + $hook_data = MyEventTrigger($hook_name_form_list.'_grid_'.$t['unique_key'], [ + 'hook_name' => $hook_name_form_list.'_grid_'.$t['unique_key'], + 'is_backend' => true, + 'id' => isset($data_list[$i][$form_table['base']['key_field']]) ? $data_list[$i][$form_table['base']['key_field']] : 0, + 'data' => $data_list[$i], + ]); + if(!empty($hook_data) && is_array($hook_data)) + { + foreach($hook_data as $hook) + { + if(is_string($hook) || is_int($hook)) + { + echo htmlspecialchars_decode($hook); + } + } + } + {{/php}} + {{/if}} {{/if}} {{/if}} diff --git a/app/module/FormHandleModule.php b/app/module/FormHandleModule.php index 04d0c1812..63e555f0b 100644 --- a/app/module/FormHandleModule.php +++ b/app/module/FormHandleModule.php @@ -620,6 +620,22 @@ class FormHandleModule { $this->order_by['field'] = empty($v['sort_field']) ? $form_name : $v['sort_field']; } + + // 唯一key,避免是模块路径、直接取最后一段 + $unique_key = ''; + if(!empty($v['view_key'])) + { + // 多字段情况下 + if(is_array($v['view_key'])) + { + $unique_key = isset($v['view_key'][0]) ? $v['view_key'][0] : ''; + } else { + // 字段名称、模块路径 + $temp = explode('/', $v['view_key']); + $unique_key = empty($temp) ? '' : end($temp); + } + } + $v['unique_key'] = $unique_key; } }