作者 开飞机的舒克

后台功能修改

... ... @@ -193,4 +193,40 @@ class Study extends Backend
$this->success();
}
/**
* 批量下载
*/
public function download($ids)
{
$list = $this->model->where('id ', 'in', $ids)->select();
$zip = new \ZipArchive;
$filename = 'tmp/' . date('Ymd',time()) . '_u' . $this->auth->id . '_reports.zip';
if ($zip->open($filename,\ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE){
foreach ($list as $publish) {
$filepath = 'uploads' . 'l' . $publish->file;
if (!file_exists($filepath)) {
$this->error($publish->code . '文件未找到');
}else {
$zip->addFile($filepath, basename($filepath));
}
}
}
//打包zip
$zip->close();
if (!file_exists($filename)) {
$this->error('创建下载文件失败!');
}
Header("Cache-Control : public");
Header("Content-type: application/octet-stream");
// Header("Content-type: application/zip");
header("Content-Transfer-Encoding : binary");
Header("Accept-Length: " . filesize($filename));
Header( "Cache-Control : public");
Header( "Content-type: application/octet-stream");//Header( "Content-type: application/zip");
header( "Content-Transfer-Encoding: binary");
Header( "Accept-Length: " . filesize($filename));
Header("Content-Disposition: attachment; filename=" . basename($filename));//输出文件内容
readfile($filename);flush();
// return json(0);
}
}
... ...
... ... @@ -21,5 +21,6 @@ return [
'Updatetime' => '更新时间',
'Grade.name' => '班级名称',
'School.title' => '校区名称',
'Team.title' => '战队昵称'
'Team.title' => '战队昵称',
'Download' => '批量下载'
];
... ...
... ... @@ -10,6 +10,7 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('study/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('你的权限规则')?'':'hide'}" title="导入" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> 导入</a>
<a href="javascript:;" class="btn btn-success btn-export {:$auth->check('study/export')?'':'hide'}" title="{:__('Export')}" id="btn-export-file"><i class="fa fa-download"></i> {:__('Export')}</a>
<a href="javascript:;" class="btn btn-success btn-download {:$auth->check('study/download')?'':'hide'}" title="{:__('Download')}" id="btn-download-file"><i class="fa fa-download"></i> {:__('Download')}</a>
<div class="dropdown btn-group {:$auth->check('study/multi')?'':'hide'}">
<ul class="dropdown-menu text-left" role="menu">
... ...
... ... @@ -29,7 +29,7 @@ class Screen extends Api
public function index(){
$time = time();
$list = [];
$data = db('data_screen')->find();
$data = db('screen')->find();
$list['images'] = cdnurl($data['images'],true);
if ($data['starttime']<=$time || $data['endtime']>=$time){
$times = $data['endtime'] - $time;
... ...
... ... @@ -32,7 +32,7 @@
"ext-bcmath": "*",
"txthinking/mailer": "^2.0",
"phpoffice/phpexcel": "^1.8",
"tinymeng/code": "^2.0"
"tinymeng/code": "^2.0",
},
"config": {
"preferred-install": "dist",
... ...
... ... @@ -4935,7 +4935,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-03-11 09:49:30 <a href="./" target="_blank">校园活动</a>
Generated on 2023-03-11 13:32:27 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...
... ... @@ -16,7 +16,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
});
var table = $("#table");
//导出功能
$(document).on("click", ".btn-export", function () {
var ids = Table.api.selectedids(table);
... ... @@ -104,10 +103,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
formatter: Table.api.formatter.operate}
]
]
});
}),
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
... ...