动态列表数据格子支持钩子

feat/task1-c-wallet
Devil 2021-08-08 22:02:11 +08:00
parent 40ddae0d41
commit fcef7f0712
5 changed files with 74 additions and 0 deletions

View File

@ -394,6 +394,8 @@ class Common extends BaseController
}
}
// 表格列表公共标识
MyViewAssign('hook_name_form_list', $current.'_list');
// 内容外部顶部
MyViewAssign('hook_name_content_top', $current.'_content_top');
// 内容外部底部

View File

@ -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)}}
<div class="plugins-tag">
<span>{{$hook_name_form_list}}_grid_{{$t.unique_key}}</span>
</div>
{{/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}}
</td>
{{/if}}

View File

@ -554,6 +554,8 @@ class Common extends BaseController
}
}
// 表格列表公共标识
MyViewAssign('hook_name_form_list', $current.'_list');
// 内容外部顶部
MyViewAssign('hook_name_content_top', $current.'_content_top');
// 内容外部底部

View File

@ -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)}}
<div class="plugins-tag">
<span>{{$hook_name_form_list}}_grid_{{$t.unique_key}}</span>
</div>
{{/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}}
</td>
{{/if}}

View File

@ -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;
}
}