优化导出功能,兼容自定义参数、兼容关联查询用法

This commit is contained in:
2022-07-14 09:52:26 +08:00
parent f74349a3c3
commit 065851fcb1
3 changed files with 60 additions and 46 deletions

View File

@@ -12,11 +12,10 @@ use think\console\Output;
class Version extends Command
{
const VERSION = 'v2.0.2';
const VERSION = 'v2.0.3';
const COMMENT = [
'新增查看当前版本命令',
'简单修改了说明文件'
'优化导出功能,兼容自定义参数、兼容关联查询用法',
];
protected function configure()

View File

@@ -23,8 +23,14 @@ class ExcelTools
$runtime_file_list = [];
$model
->where($where)->chunk(100, function ($list) use ($sheet, &$write_line, $fields, $image_fields, &$runtime_file_list, $select_fields, $date_fields) {
$limit = 1000;
$page = 0;
while (true) {
$page++;
$list = $model
->where($where)->page($page, $limit)->select();
foreach ($list as $list_index => $item) {
$write_line++;
$write_col = 1;
@@ -82,7 +88,12 @@ class ExcelTools
$write_col++;
}
}
});
if (count($list) < $limit) {
break;
}
}
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
@@ -92,8 +103,10 @@ class ExcelTools
ob_clean();
foreach ($runtime_file_list as $runtime_file) {
if(file_exists($runtime_file)){
unlink($runtime_file);
}
}
return $content;
}

View File

@@ -1270,6 +1270,8 @@ define(["jquery", "tableSelect", "ckeditor", 'miniTheme', 'tableData', 'citypick
toUrl = admin.url(url);
if (toUrl.indexOf('?') < 0) {
toUrl += '?';
}else{
toUrl += '&'
}
toUrl += query;