作者 董瑞恩
1 个管道 的构建 通过 耗费 0 秒

interface

... ... @@ -183,20 +183,10 @@ class AdminEquipmentController extends AdminBaseController{
}
}
public function ceshi(){
$ids=$this->request->param('ids/a');
$data=$this->batch_export($ids);
if ($data==true){
$this->success('成功');
}else{
$this->error('失败');
}
}
//批量导出
public function batch_export($ids){
$data= Db::name('equipment')->where(['id' => ['in', $ids]])->select();
public function batch_export(){
//$ids=$this->request->param('ids');
$data= Db::name('equipment')->select();
// 导出Exl
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel");
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Drawing");
... ... @@ -215,12 +205,12 @@ class AdminEquipmentController extends AdminBaseController{
$objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objActSheet->setCellValue('A1', '商品货号');
$objActSheet->setCellValue('B1', '商品名称');
$objActSheet->setCellValue('A1', '设备锁编号');
$objActSheet->setCellValue('B1', '设备锁名称');
$objActSheet->setCellValue('C1', '商品图');
$objActSheet->setCellValue('D1', '商品条码');
$objActSheet->setCellValue('E1', '商品属性');
$objActSheet->setCellValue('F1', '报价(港币)');
$objActSheet->setCellValue('D1', '初始医院');
$objActSheet->setCellValue('E1', 'MAC地址');
$objActSheet->setCellValue('F1', '备注');
// 设置个表格宽度
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(16);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(80);
... ... @@ -238,7 +228,7 @@ class AdminEquipmentController extends AdminBaseController{
foreach($data as $k=>$v){
$k +=2;
$objActSheet->setCellValue('A'.$k, $v['mac_address']);
$objActSheet->setCellValue('A'.$k, $v['serial_number']);
$objActSheet->setCellValue('B'.$k, $v['name']);
$img = Db::name('equipment')->where('id',$v['id'])->find();
... ... @@ -257,7 +247,7 @@ class AdminEquipmentController extends AdminBaseController{
// 表格内容
$objActSheet->setCellValue('D'.$k, $v['hospital']);
$objActSheet->setCellValue('E'.$k, $v['key']);
$objActSheet->setCellValue('E'.$k, $v['mac_address']);
$objActSheet->setCellValue('F'.$k, $v['note']);
// 表格高度
... ... @@ -265,7 +255,7 @@ class AdminEquipmentController extends AdminBaseController{
}
$fileName = '报价表';
$fileName = '设备信息表';
$date = date("Y-m-d",time());
$fileName .= "_{$date}.xls";
$fileName = iconv("utf-8", "gb2312", $fileName);
... ...
... ... @@ -34,16 +34,18 @@
</form>
<form class="js-ajax-form" action="" method="post">
<div class="table-actions">
<button class="btn btn-primary btn-sm js-ajax-submit" type="button"
<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
onclick="doAdd()">新增
</button>
<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
onclick="batch_add()">批量新增
</button>
<a class="btn btn-primary btn-sm" href="{:url('AdminEquipment/batch_export')}">批量导出
</a>
<!--js-ajax-submit-->
<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
data-action="{:url('AdminEquipment/ceshi')}" data-subcheck="true">批量导出
</button>
<!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"-->
<!--data-action="{:url('AdminEquipment/ceshi')}" data-subcheck="true">批量导出-->
<!--</button>-->
</div>
<table class="table table-hover table-bordered table-list">
<thead>
... ...