作者 刘朕
1 个管道 的构建 通过 耗费 1 秒

合并分支 '1iuzhen' 到 'master'

订单导出、销售订单列表筛选问题修复



查看合并请求 !209
... ... @@ -19,11 +19,13 @@ class OrderController extends AdminBaseController
protected $order_model;
protected $option_table;
protected $sort_model;
protected $order_sort_table;
public function _initialize()
{
$this->table = 'Order';
$this->order_model = new OrderModel();
$this->option_table = 'OrderOption';
$this->order_sort_table = 'OrderSort';
// 订单字段类型定义
$this->sort_model[1] = '<div class="text_item form_options" data-validate="{validate}">
... ... @@ -83,6 +85,7 @@ class OrderController extends AdminBaseController
</div>';
}
/**
* 电子订单列表
* @adminMenu(
... ... @@ -134,7 +137,7 @@ class OrderController extends AdminBaseController
$where['create_time'] = ['<= time', $endTime];
}
}
$list = Db::name('order_view')->where($where)->paginate(10);
$list = $this->singleData('order_view',$where,2,[],10);
$list->appends($param);
$this->assign('list',$list->items());
$this->assign('page',$list->render());
... ... @@ -146,7 +149,7 @@ class OrderController extends AdminBaseController
$this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
// 订单类型查询
$sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray();
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
$this->assign('sortList',$sortList);
return $this->fetch();
}
... ... @@ -199,7 +202,7 @@ class OrderController extends AdminBaseController
$where['create_time'] = ['<= time', $endTime];
}
}
$list = Db::name('order_view')->where($where)->paginate(10);
$list = $this->singleData('order_view',$where,2,[],10);
$list->appends($param);
$this->assign('list',$list->items());
$this->assign('page',$list->render());
... ... @@ -211,7 +214,7 @@ class OrderController extends AdminBaseController
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('sort_id',$param['sort_id']);
// 订单类型
$sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray();
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
$this->assign('sortList',$sortList);
return $this->fetch();
}
... ... @@ -270,7 +273,7 @@ class OrderController extends AdminBaseController
$where['create_time'] = ['<= time', $endTime];
}
}
$list = Db::name('order_view')->where($where)->paginate(10);
$list = $this->singleData('order_view',$where,2,[],10);
$list->appends($param);
$this->assign('list',$list->items());
$this->assign('page',$list->render());
... ... @@ -283,7 +286,7 @@ class OrderController extends AdminBaseController
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('user_id',$param['user_id']);
// 订单类型
$sortList = Db::name('OrderSort')->where(['delete_time'=>0])->select()->toArray();
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
$this->assign('sortList',$sortList);
return $this->fetch();
}
... ... @@ -344,14 +347,13 @@ class OrderController extends AdminBaseController
}
}
// 查询数据并导出
$list = Db::name('order_view')->where($where)->select()->toArray();
$list = $this->singleData('order_view',$where,1);
$this->expList($list);
}
// 数据导出
private function expList($array)
{
//导出Excel
$objPHPExcel = new \PHPExcel();
... ... @@ -397,6 +399,7 @@ class OrderController extends AdminBaseController
$objPHPExcel->getActiveSheet()->getColumnDimension('AN')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AO')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AP')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AQ')->setWidth(20);
// 设置水平居中
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// 设置垂直居中
... ... @@ -444,7 +447,8 @@ class OrderController extends AdminBaseController
->setCellValue('AM1', '不适龄备注')
->setCellValue('AN1', '图片')
->setCellValue('AO1', '月龄版升级年份')
->setCellValue('AP1', '备注');
->setCellValue('AP1', '备注')
->setCellValue('AQ1', '客户编号');
$i = 2;
... ... @@ -475,37 +479,39 @@ class OrderController extends AdminBaseController
'id' => $vs['id']
];
$vs['cell'] = Db::name('OrderOption')->where($where)->value('cell');
if($vs['type'] == 3) {
// 纯数字字段转化为字符串格式,防止以科学计数法进行显示
$objPHPExcel->setActiveSheetIndex(0)
->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);
} elseif($vs['type'] == 8) {
// 导出图片格式,高度自适应
$filePath = './upload/'.$vs['user_choose'];
if(!empty($vs['user_choose']) && file_exists($filePath)) {
$image = \think\Image::open('./upload/'.$vs['user_choose']);
// 返回图片的宽度
$width = $image->width();
// 返回图片的高度
$height = $image->height();
$default = $height/($width/100);
//设置默认行高(通过图片缩放比例计算高度)
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);
// 图片生成
$objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();
$objDrawing[$i]->setPath($filePath);
// 设置宽度
$objDrawing[$i]->setWidth(100); //照片宽度
/*设置图片要插入的单元格*/
$objDrawing[$i]->setCoordinates($vs['cell'].$i);
// 图片偏移距离
$objDrawing[$i]->setOffsetX(12);
$objDrawing[$i]->setOffsetY(12);
$objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet());
if(!empty($vs['cell'])) {
if($vs['type'] == 3) {
// 纯数字字段转化为字符串格式,防止以科学计数法进行显示
$objPHPExcel->setActiveSheetIndex(0)
->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);
} elseif($vs['type'] == 8) {
// 导出图片格式,高度自适应
$filePath = './upload/'.$vs['user_choose'];
if(!empty($vs['user_choose']) && file_exists($filePath)) {
$image = \think\Image::open('./upload/'.$vs['user_choose']);
// 返回图片的宽度
$width = $image->width();
// 返回图片的高度
$height = $image->height();
$default = $height/($width/100);
//设置默认行高(通过图片缩放比例计算高度)
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);
// 图片生成
$objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();
$objDrawing[$i]->setPath($filePath);
// 设置宽度
$objDrawing[$i]->setWidth(100); //照片宽度
/*设置图片要插入的单元格*/
$objDrawing[$i]->setCoordinates($vs['cell'].$i);
// 图片偏移距离
$objDrawing[$i]->setOffsetX(12);
$objDrawing[$i]->setOffsetY(12);
$objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet());
}
} else {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($vs['cell'] . $i, $vs['user_choose']);
}
} else {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($vs['cell'] . $i, $vs['user_choose']);
}
}
$i++;
... ...
... ... @@ -147,12 +147,14 @@
html += `<div class="list_style" data-href="${element.detail_url}">
<div class="style_one">
<p class="style_text">
订单类型:<span class="font_weight">${element.name}</span>
订单类型:<span class="font_weight">${element.sort_name}</span>
</p>
${status}
</div>
<p class="order_num">订单编号:${element.order_sn}</p>
<p class="order_data" id="change_time">提交时间:${element.create_time}</p>
<p class="order_data">订单确认码:${element.number}</p>
<p class="order_data">联系电话:${element.mobile}</p>
${change}
</div>`;
});
... ...