列表详情支持底部操作(数据打印、导出PDF/excel、导出excel支持多维详情列表)
parent
6d5fd72441
commit
b063bfb179
|
|
@ -21,7 +21,7 @@
|
|||
{{/php}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-padding-sm">
|
||||
<div class="am-padding-sm {{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}form-navigation-present-operate{{/if}}">
|
||||
<!-- content inside top hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
@ -96,6 +96,10 @@
|
|||
</div>
|
||||
<!-- content end -->
|
||||
|
||||
<!-- detail nav operate start -->
|
||||
{{include file="public/module/detail_nav_operate" /}}
|
||||
<!-- detail nav operate end -->
|
||||
|
||||
<!-- content bottom hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
{{/php}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-padding-sm">
|
||||
<div class="am-padding-sm {{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}form-navigation-present-operate{{/if}}">
|
||||
<!-- content inside top hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
@ -99,6 +99,10 @@
|
|||
</div>
|
||||
<!-- content end -->
|
||||
|
||||
<!-- detail nav operate start -->
|
||||
{{include file="public/module/detail_nav_operate" /}}
|
||||
<!-- detail nav operate end -->
|
||||
|
||||
<!-- content bottom hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
{{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}
|
||||
<div class="form-detail-nav-operate am-cf">
|
||||
<!-- 是否开启数据打印操作 -->
|
||||
{{if isset($form_table['base']['is_data_print']) and $form_table['base']['is_data_print'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-icon-print form-table-operate-top-data-print-submit" data-am-popover="{content: '打印当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 数据打印</button>
|
||||
{{/if}}
|
||||
|
||||
<!-- 是否开启数据导出pdf操作 -->
|
||||
{{if isset($form_table['base']['is_data_export_pdf']) and $form_table['base']['is_data_export_pdf'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-icon-file-pdf-o form-table-operate-top-data-print-submit" data-is-pdf="1" data-am-popover="{content: '导出当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 导出PDF</button>
|
||||
{{/if}}
|
||||
|
||||
<!-- 是否开启数据导出excel操作 -->
|
||||
{{if isset($form_table['base']['is_data_export_excel']) and $form_table['base']['is_data_export_excel'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-file-excel-o form-table-operate-top-export-excel-submit" data-am-popover="{content: '导出当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 导出Excel</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
<!-- 是否开启数据打印操作 -->
|
||||
{{if isset($form_table['base']['is_data_print']) and $form_table['base']['is_data_print'] eq 1}}
|
||||
<script type="text/javascript">
|
||||
// 定义打印配置
|
||||
var print_is_list_choice = 0;
|
||||
// 模板打印数据
|
||||
var print_data = {{if empty($form_table_data_detail)}}''{{else /}}{{:json_encode($form_table_data_detail, JSON_UNESCAPED_UNICODE)}}{{/if}};
|
||||
// 打印模板
|
||||
var print_template = {{if empty($form_table['base']['data_print_template'])}}{}{{else /}}{{if is_array($form_table['base']['data_print_template'])}}{{:json_encode($form_table['base']['data_print_template'], JSON_UNESCAPED_UNICODE)}}{{else /}}{{$form_table.base.data_print_template|raw}}{{/if}}{{/if}};
|
||||
</script>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
{{/php}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-padding-sm">
|
||||
<div class="am-padding-sm {{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}form-navigation-present-operate{{/if}}">
|
||||
<!-- content inside top hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
@ -96,6 +96,10 @@
|
|||
</div>
|
||||
<!-- content end -->
|
||||
|
||||
<!-- detail nav operate start -->
|
||||
{{include file="public/module/detail_nav_operate" /}}
|
||||
<!-- detail nav operate end -->
|
||||
|
||||
<!-- content bottom hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
{{/php}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-padding-sm">
|
||||
<div class="am-padding-sm {{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}form-navigation-present-operate{{/if}}">
|
||||
<!-- content inside top hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
@ -99,6 +99,10 @@
|
|||
</div>
|
||||
<!-- content end -->
|
||||
|
||||
<!-- detail nav operate start -->
|
||||
{{include file="public/module/detail_nav_operate" /}}
|
||||
<!-- detail nav operate end -->
|
||||
|
||||
<!-- content bottom hook -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
{{if isset($form_table['base']['is_detail_nav_operate']) and $form_table['base']['is_detail_nav_operate'] eq 1}}
|
||||
<div class="form-detail-nav-operate am-cf">
|
||||
<!-- 是否开启数据打印操作 -->
|
||||
{{if isset($form_table['base']['is_data_print']) and $form_table['base']['is_data_print'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-icon-print form-table-operate-top-data-print-submit" data-am-popover="{content: '打印当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 数据打印</button>
|
||||
{{/if}}
|
||||
|
||||
<!-- 是否开启数据导出pdf操作 -->
|
||||
{{if isset($form_table['base']['is_data_export_pdf']) and $form_table['base']['is_data_export_pdf'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-icon-file-pdf-o form-table-operate-top-data-print-submit" data-is-pdf="1" data-am-popover="{content: '导出当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 导出PDF</button>
|
||||
{{/if}}
|
||||
|
||||
<!-- 是否开启数据导出excel操作 -->
|
||||
{{if isset($form_table['base']['is_data_export_excel']) and $form_table['base']['is_data_export_excel'] eq 1}}
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-file-excel-o form-table-operate-top-export-excel-submit" data-am-popover="{content: '导出当前数据', trigger: 'hover focus', theme: 'warning sm'}"> 导出Excel</button>
|
||||
{{/if}}
|
||||
</div>
|
||||
<!-- 是否开启数据打印操作 -->
|
||||
{{if isset($form_table['base']['is_data_print']) and $form_table['base']['is_data_print'] eq 1}}
|
||||
<script type="text/javascript">
|
||||
// 定义打印配置
|
||||
var print_is_list_choice = 0;
|
||||
// 模板打印数据
|
||||
var print_data = {{if empty($form_table_data_detail)}}''{{else /}}{{:json_encode($form_table_data_detail, JSON_UNESCAPED_UNICODE)}}{{/if}};
|
||||
// 打印模板
|
||||
var print_template = {{if empty($form_table['base']['data_print_template'])}}{}{{else /}}{{if is_array($form_table['base']['data_print_template'])}}{{:json_encode($form_table['base']['data_print_template'], JSON_UNESCAPED_UNICODE)}}{{else /}}{{$form_table.base.data_print_template|raw}}{{/if}}{{/if}};
|
||||
</script>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
@ -543,7 +543,7 @@ class FormHandleModule
|
|||
}
|
||||
|
||||
// 是否存在数据
|
||||
if(empty($error_msg) && empty($this->data_list))
|
||||
if(empty($error_msg) && empty($this->data_list) && empty($this->data_detail))
|
||||
{
|
||||
$error_msg = '没有相关数据、请重新输入搜索条件再试!';
|
||||
}
|
||||
|
|
@ -595,8 +595,56 @@ class FormHandleModule
|
|||
</html>');
|
||||
}
|
||||
|
||||
// 列表或详情数据
|
||||
$list = empty($this->data_list) ? [$this->data_detail] : $this->data_list;
|
||||
|
||||
// 是否存在详情列表数据定义
|
||||
$data = [];
|
||||
if(!empty($this->form_data['detail_form_list']))
|
||||
{
|
||||
foreach($list as $v)
|
||||
{
|
||||
foreach($this->form_data['detail_form_list'] as $dv)
|
||||
{
|
||||
if(!empty($dv) && !empty($dv['label']) && !empty($dv['field']) && !empty($dv['data']) && !empty($v[$dv['field']]) && is_array($v[$dv['field']]))
|
||||
{
|
||||
$is_first = true;
|
||||
$is_title = true;
|
||||
foreach($v[$dv['field']] as $vs)
|
||||
{
|
||||
$temp = $is_first ? $v : [];
|
||||
foreach($dv['data'] as $dvk=>$dvv)
|
||||
{
|
||||
// 追加数据导列表
|
||||
$field = $dv['field'].'_'.$dvk;
|
||||
$temp[$field] = isset($vs[$dvk]) ? $vs[$dvk] : '';
|
||||
|
||||
// 追加表头
|
||||
if($is_title)
|
||||
{
|
||||
$title[$field] = [
|
||||
'name' => $dv['label'].' - '.$dvv,
|
||||
'type' => 'string',
|
||||
];
|
||||
}
|
||||
$is_first = false;
|
||||
}
|
||||
unset($temp[$dv['field']]);
|
||||
$data[] = $temp;
|
||||
$is_title = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($data) && !empty($list))
|
||||
{
|
||||
$data = $list;
|
||||
unset($list);
|
||||
}
|
||||
|
||||
// Excel驱动导出数据
|
||||
$excel = new \base\Excel(['title'=>$title, 'data'=>$this->data_list]);
|
||||
$excel = new \base\Excel(['title'=>$title, 'data'=>$data]);
|
||||
$excel->Export();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,10 +130,7 @@ class Excel
|
|||
$index = 0;
|
||||
foreach($this->title as $tk=>$tv)
|
||||
{
|
||||
if(array_key_exists($tk, $v))
|
||||
{
|
||||
$temp .= ($index == 0 ? '' : ',').str_replace([',', "\n"], [ ',', ''], $v[$tk])."\t";
|
||||
}
|
||||
$temp .= ($index == 0 ? '' : ',').(array_key_exists($tk, $v) ? str_replace([',', "\n"], [ ',', ''], $v[$tk]) : '')."\t";
|
||||
$index++;
|
||||
}
|
||||
$csv_content .= (($excel_charset == 0) ? $temp : iconv('utf-8', $charset, $temp))."\n";
|
||||
|
|
@ -248,7 +245,7 @@ class Excel
|
|||
$drawing->setOffsetY(15);
|
||||
$drawing->setWorksheet($spreadsheet->getActiveSheet());
|
||||
} else {
|
||||
$value = ($excel_charset == 0) ? $v[$tk] : iconv('utf-8', $charset, $v[$tk]);
|
||||
$value = array_key_exists($tk, $v) ? (($excel_charset == 0) ? $v[$tk] : iconv('utf-8', $charset, $v[$tk])) : '';
|
||||
$sheet->setCellValueByColumnAndRow($temp_cum+1, $temp_row, $value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1116,7 +1116,7 @@ button.colorpicker-submit img {
|
|||
}
|
||||
|
||||
/**
|
||||
* 表格-相关样式
|
||||
* 表格-顶部操作相关样式
|
||||
*/
|
||||
.form-table-operate-top > .am-btn:not(:last-child) {
|
||||
margin-right: 10px;
|
||||
|
|
@ -1125,6 +1125,28 @@ button.colorpicker-submit img {
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格-详情底部操作
|
||||
*/
|
||||
.form-navigation-present-operate {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
.form-detail-nav-operate {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
.form-detail-nav-operate > .am-btn {
|
||||
-webkit-box-shadow: 0 0 8px rgb(154 154 154 / 40%);
|
||||
box-shadow: 0 0 8px rgb(154 154 154 / 40%);
|
||||
}
|
||||
.form-detail-nav-operate > .am-btn:not(:last-child) {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格-搜索条件
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2852,22 +2852,22 @@ $(function()
|
|||
var request_value = $form.attr('request-value') || null;
|
||||
if(request_value == null)
|
||||
{
|
||||
Prompt(window['lang_form_config_value_params_tips'] || '表单[类型值]参数配置有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 拼接参数
|
||||
var params = GetFormVal(form_name, true);
|
||||
var pv = 'form_table_is_export_excel=1&';
|
||||
for(var i in params)
|
||||
{
|
||||
if(params[i] != undefined && params[i] != '')
|
||||
// 不存在表单则直接使用当前地址
|
||||
request_value = window.open(UrlFieldReplace('form_table_is_export_excel', 1));
|
||||
} else {
|
||||
// 拼接参数
|
||||
var params = GetFormVal(form_name, true);
|
||||
var pv = 'form_table_is_export_excel=1&';
|
||||
for(var i in params)
|
||||
{
|
||||
pv += i+'='+encodeURIComponent(params[i])+'&';
|
||||
if(params[i] != undefined && params[i] != '')
|
||||
{
|
||||
pv += i+'='+encodeURIComponent(params[i])+'&';
|
||||
}
|
||||
}
|
||||
var join = (request_value.indexOf('?') >= 0) ? '&' : '?';
|
||||
request_value += join+pv.substr(0, pv.length-1);
|
||||
}
|
||||
var join = (request_value.indexOf('?') >= 0) ? '&' : '?';
|
||||
request_value += join+pv.substr(0, pv.length-1);
|
||||
window.open(request_value);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue