|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
|
|
namespace app\admin\model\water;
|
|
namespace app\admin\model\water;
|
|
|
|
|
|
|
|
|
|
+use crmeb\services\PHPExcelService;
|
|
|
use crmeb\traits\ModelTrait;
|
|
use crmeb\traits\ModelTrait;
|
|
|
use crmeb\basic\BaseModel;
|
|
use crmeb\basic\BaseModel;
|
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\concern\SoftDelete;
|
|
@@ -41,6 +42,12 @@ class WaterQuery extends BaseModel
|
|
|
|
|
|
|
|
if ($where['name'])$model->where('u.uid|u.nickname' , 'like', '%'.$where['name'].'%');
|
|
if ($where['name'])$model->where('u.uid|u.nickname' , 'like', '%'.$where['name'].'%');
|
|
|
if ($where['uid'])$model->where('u.uid' , $where['uid']);
|
|
if ($where['uid'])$model->where('u.uid' , $where['uid']);
|
|
|
|
|
+
|
|
|
|
|
+ if (isset($where['excel']) && $where['excel'] == 1) {
|
|
|
|
|
+ $list = $model->select()->toArray();
|
|
|
|
|
+ self::SaveExcel($list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$data['count'] = $model->count();
|
|
$data['count'] = $model->count();
|
|
|
if ($where['page'] && $where['limit']){
|
|
if ($where['page'] && $where['limit']){
|
|
|
$model->page($where['page'], $where['limit']);
|
|
$model->page($where['page'], $where['limit']);
|
|
@@ -53,5 +60,41 @@ class WaterQuery extends BaseModel
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * excel
|
|
|
|
|
+ * @param $list
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function SaveExcel($list)
|
|
|
|
|
+ {
|
|
|
|
|
+ $export = [];
|
|
|
|
|
+ foreach ($list as $index => $item) {
|
|
|
|
|
+
|
|
|
|
|
+ $export[] = [
|
|
|
|
|
+ $item['uid'],
|
|
|
|
|
+ $item['nickname'],
|
|
|
|
|
+ $item['long'],
|
|
|
|
|
+ $item['wide'],
|
|
|
|
|
+ $item['high'],
|
|
|
|
|
+ $item['is_warm'] ? '保温' : '不保温',
|
|
|
|
|
+ $item['is_channel'] ? '需要' : '不需要',
|
|
|
|
|
+ $item['is_ladder'] ? '需要' : '不需要',
|
|
|
|
|
+ $item['is_gc'] ? '大公差' : '正常公差',
|
|
|
|
|
+ $item['price'],
|
|
|
|
|
+ $item['weight'],
|
|
|
|
|
+ $item['create_time'],
|
|
|
|
|
+
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ PHPExcelService::setExcelHeader(['UID', '昵称', '长','宽', '高', '是否保温', '槽钢','人梯', '公差',
|
|
|
|
|
+ '总价','重量','计算时间'])
|
|
|
|
|
+ ->setExcelTile('计算导出' . date('YmdHis', time()), '计算信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
|
|
|
|
|
+ ->setExcelContent($export)
|
|
|
|
|
+ ->ExcelSave();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|