diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/OrderController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/OrderController.php
index 8711725..c933d36 100644
--- a/Laravel/app/Http/Controllers/API/Admin/YeWu/OrderController.php
+++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/OrderController.php
@@ -9,6 +9,12 @@ use App\Services\OrderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Str;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
class OrderController extends Controller
{
public function GetList()
@@ -26,6 +32,20 @@ class OrderController extends Controller
if (isset($searchInfo['order_number'])) {
$list = $list->where('order_number', $searchInfo['order_number']);
}
+ if (isset($searchInfo['order_title'])) {
+ $list = $list->where('title', 'like', '%' . $searchInfo['order_title'] . '%');
+ }
+ if (isset($searchInfo['create_date'])) {
+ $searchInfo['create_date'][0]=$searchInfo['create_date'][0].' 00:00:00';
+ $searchInfo['create_date'][1]=$searchInfo['create_date'][1].' 23:59:59';
+ $list = $list->whereBetween('created_at', $searchInfo['create_date']);
+ }
+ if (isset($searchInfo['appointment_date'])) {
+ $list = $list->whereBetween('appointment_date', $searchInfo['appointment_date']);
+ }
+ if (isset($searchInfo['youxiaoqi_date'])) {
+ $list = $list->whereBetween('youxiaoqi_end', $searchInfo['youxiaoqi_date']);
+ }
$count = $list->count();
$list = $list->orderBy('id', 'desc')
->skip(($page - 1) * $pageSize) // 跳过前9999条记录
@@ -182,4 +202,125 @@ class OrderController extends Controller
}
}
+ public function ExportExcel()
+ {
+ $searchInfo = request('searchInfo');
+ $list = DB::table('orders')
+ ->select('*',
+ DB::raw("
+ CASE
+ WHEN type = 1 THEN '个检'
+ WHEN type = 2 THEN '团检'
+ ELSE '未知'
+ END AS type_text
+ "),
+ DB::raw("
+ CASE
+ WHEN status = 1 THEN '待支付'
+ WHEN status = 2 THEN '已支付'
+ WHEN status = 3 THEN '交易关闭'
+ WHEN status = 4 THEN '已完成'
+ WHEN status = 5 THEN '已退款'
+ WHEN status = 6 THEN '已转赠'
+ ELSE '未知'
+ END AS status_text
+ "),
+ DB::raw("
+ CASE
+ WHEN check_status = 1 THEN '待检'
+ WHEN check_status = 2 THEN '已到检'
+ ELSE '未知'
+ END AS check_status_text
+ "),
+ );
+
+ if (isset($searchInfo['name'])) {
+ $list = $list->where('name', 'like', '%' . $searchInfo['name'] . '%');
+ }
+ if (isset($searchInfo['id_number'])) {
+ $list = $list->where('id_number', $searchInfo['id_number']);
+ }
+ if (isset($searchInfo['order_number'])) {
+ $list = $list->where('order_number', $searchInfo['order_number']);
+ }
+ if (isset($searchInfo['order_title'])) {
+ $list = $list->where('title', 'like', '%' . $searchInfo['order_title'] . '%');
+ }
+ if (isset($searchInfo['create_date'])) {
+ $searchInfo['create_date'][0]=$searchInfo['create_date'][0].' 00:00:00';
+ $searchInfo['create_date'][1]=$searchInfo['create_date'][1].' 23:59:59';
+ $list = $list->whereBetween('created_at', $searchInfo['create_date']);
+ }
+ if (isset($searchInfo['appointment_date'])) {
+ $list = $list->whereBetween('appointment_date', $searchInfo['appointment_date']);
+ }
+ if (isset($searchInfo['youxiaoqi_date'])) {
+ $list = $list->whereBetween('youxiaoqi_end', $searchInfo['youxiaoqi_date']);
+ }
+ $count = $list->count();
+ $list = $list->orderBy('id', 'desc')->get();
+
+
+
+ ini_set('memory_limit', '512M');
+ $template_path = Storage::path('public/excel/kong.xlsx');
+ $spreadsheet = IOFactory::load($template_path);
+ $worksheet = $spreadsheet->getActiveSheet();
+ $styleArray = [
+ 'borders' => [
+ 'allBorders' => [
+ 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ ],
+ ];
+
+ $worksheet->setCellValueExplicit('A1' , '姓名', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('B1' , '证件号', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('C1' , '电话', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('D1' , '订单号', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('E1' , '标题', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('F1' , '类型', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('G1' , '价格', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('H1' , '使用积分', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('I1' , '使用预存款', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('G1' , '状态', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('K1' , '有效期', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('L1' , '到检状态', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+ $worksheet->setCellValueExplicit('M1' , '创建时间', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
+
+ $row = 2;
+ $col = [
+ 'A' => 'name',
+ 'B' => 'id_number',
+ 'C' => 'phone',
+ 'D' => 'order_number', // 新增列
+ 'E' => 'title', // 原 phone 列往后移动
+ 'F' => 'type_text',
+ 'G' => 'price',
+ 'H' => 'jifen',
+ 'I' => 'yucunkuan',
+ 'J' => 'status_text',
+ 'K' => 'youxiaoqi_end',
+ 'L' => 'check_status_text',
+ 'M' => 'created_at',
+ ];
+
+ foreach ($list as $table_item) {
+ foreach ($col as $index => $key) {
+ $worksheet->setCellValueExplicit($index . $row, $table_item->$key, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);}
+ $row++;
+ }
+ $worksheet->getStyle('A3:T' . ($row - 1))->applyFromArray($styleArray);
+ $file_name = Str::orderedUuid();
+ $dir_path = "public/excel/" . date('Ym') . '/' . $file_name;
+ Storage::makeDirectory($dir_path);
+
+ $excel_path = $dir_path . "/订单列表.xlsx";
+ $writer = new Xlsx($spreadsheet);
+ $writer->save(Storage::path($excel_path));
+ $url = Storage::url($excel_path);
+ return \Yz::Return(true,'完成',['url'=> env('APP_URL').$url]);
+
+ }
}
diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php
index 079e525..b006f4a 100644
--- a/Laravel/routes/api.php
+++ b/Laravel/routes/api.php
@@ -142,6 +142,7 @@ Route::group(['middleware' => ['checktoken', 'log'], 'prefix' => 'v1'], function
Route::post('admin/QuestionExport', 'App\Http\Controllers\API\Admin\YeWu\QuestionLogController@Export');//导出回答
Route::post('admin/GetWorkUnitEnableList', 'App\Http\Controllers\API\Admin\YeWu\WorkUnitController@GetEnableList');//获取单位列表
Route::post('admin/CancelZhuanZengCode', 'App\Http\Controllers\API\Admin\YeWu\TransferCodeController@CancelZhuanZeng');//取消转赠
+ Route::post('admin/OrderExportExcel', 'App\Http\Controllers\API\Admin\YeWu\OrderController@ExportExcel');
diff --git a/admin/src/api/api.js b/admin/src/api/api.js
index ee582b2..1edf3de 100644
--- a/admin/src/api/api.js
+++ b/admin/src/api/api.js
@@ -463,4 +463,7 @@ export const GetWorkUnitEnableList = (data = {}) => {
//取消转赠码
export const CancelZhuanZengCode = (data = {}) => {
return axios({ url: import.meta.env.VITE_APP_API + `v1/admin/CancelZhuanZengCode`, data: data })
+}
+export const OrderExportExcel = (data = {}) => {
+ return axios({ url: import.meta.env.VITE_APP_API + `v1/admin/OrderExportExcel`, data: data })
}
\ No newline at end of file
diff --git a/admin/src/views/OrderMngr/Order.vue b/admin/src/views/OrderMngr/Order.vue
index 5aae630..55a37d3 100644
--- a/admin/src/views/OrderMngr/Order.vue
+++ b/admin/src/views/OrderMngr/Order.vue
@@ -11,12 +11,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
搜索
-
+
+ 导出当前结果
+
-
@@ -31,6 +50,8 @@
+
+
待支付
@@ -41,6 +62,7 @@
已转赠
+
{{scope.row.appointment_date}} {{scope.row.appointment_time}}
@@ -160,7 +182,8 @@ import {ElMessage, ElMessageBox} from 'element-plus'
OrderGetList,
OrderGetDetail,
OrderSave,OrderRefund,
- CancelZhuanZengCode
+ CancelZhuanZengCode,
+ OrderExportExcel
} from '@/api/api.js'
import {
Edit
@@ -282,6 +305,34 @@ import {ElMessage, ElMessageBox} from 'element-plus'
})
}).catch(() => {
})
+ }
+ const OrderExportExcelFunc=()=>{
+ ElMessageBox.confirm(
+ '确定导出吗?',
+ '提示',
+ {
+ confirmButtonText: '确认',
+ cancelButtonText: '取消',
+ type: 'warning',
+ }
+ ).then(() => {
+ loading.value = true
+ OrderExportExcel({
+ searchInfo: searchInfo.value
+ }).then(res => {
+ loading.value = false
+ if (res.status) {
+ const a = document.createElement('a');
+ a.style.display = 'none';
+ a.href = res.data.url;
+ document.body.appendChild(a);
+ a.click();
+ } else {
+ ElMessage.error(res.msg)
+ }
+ })
+ })
+
}
onMounted(() => {
GetList()