优化聚合结算导出

master
chenzhi 5 years ago
parent cf9480eb89
commit ce4c938080

@ -262,23 +262,25 @@ class AggregateFinanceStatementController extends ThinkController
$this->display();
}
//导出
public function export(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = explode(",",$_REQUEST['ids']);
foreach ($ids as $k => $v) {
$this->doexport($v);
}
}
private function doexport($id)
// public function export(){
// if(!isset($_REQUEST['ids'])) $this->error("参数错误");
// $ids = explode(",",$_REQUEST['ids']);
// foreach ($ids as $k => $v) {
// $this->doexport($v);
// }
// }
public function export()
{
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$data = M("aggregate_statement","tab_")->where("id = '{$id}'")->find();
$data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方
$data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方
$data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录
//收款方
$big_pay_money = convertAmountToCn($data['pay_money']);//大写
$big_pay_money = convertAmountToCn($data['ratio_money']);//大写
$data['receive_company'] = $data['pay_type'] ? $data['first_party_info'] : $data['second_party_info'];
$data['pay_company'] = $data['pay_type'] ? $data['second_party_info'] : $data['first_party_info'];
$this->excelDownStreamTemplate($data,$big_pay_money);
@ -353,16 +355,12 @@ class AggregateFinanceStatementController extends ThinkController
}else{
$fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$statement_begin_time}-{$statement_end_time}";
}
// dd($fileName);
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}

@ -251,6 +251,7 @@
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
return $(elem).val();
}).get();
if(text.length > 2){
layer.msg("<font style='color:white'>" + '暂不支持超过20条的批量导出' + "</font>");
return;
@ -259,9 +260,12 @@
layer.msg("<font style='color:white'>" + '请先选择要导出的结算单' + "</font>");
return;
}
text = text.join(",");
window.location.href = "{:U('export')}"+"&ids="+text;
for (var index = 0; index < text.length; index++) {
var id = text[index];
var url ="{:U('export')}"+"&id="+id;
var iframeExcel = "<iframe src='"+url+"' width='0px' height='0px' style='z-index:-1;position: absolute;top: -999999px;'></iframe>"//添加下载的地址到iframe这里是公司信息我用**表示了。
$("body").append(iframeExcel)
}
})
$("#shenhe").click(function () {

Loading…
Cancel
Save