Forráskód Böngészése

feat: 订单管理查询条件优化

变更内容:
- 前端筛选区:删除批次号、卡号筛选项,新增收货人、手机号筛选项
- 后端查询接口:/query 参数从 batch_no/card_no 改为 receiver_name/receiver_phone(模糊匹配)
- 修复重置按钮:清空表单后自动触发重新查询,解决重置后列表显示为空的问题
C 2 hónapja
szülő
commit
086e8d2465
2 módosított fájl, 15 hozzáadás és 15 törlés
  1. 8 8
      server/routes/orders.js
  2. 7 7
      web/src/views/OrderManagement.vue

+ 8 - 8
server/routes/orders.js

@@ -101,7 +101,7 @@ const STATUS_MAP = {
 // 动态查询订单
 router.post('/query', authMiddleware, async (req, res) => {
   try {
-    const { batch_no, card_no, order_no, start_date, end_date, status } = req.body;
+    const { receiver_name, receiver_phone, order_no, start_date, end_date, status } = req.body;
 
     let sql = `
       SELECT
@@ -145,15 +145,15 @@ router.post('/query', authMiddleware, async (req, res) => {
       paramIndex++;
     }
 
-    if (batch_no) {
-      sql += ` AND c.batch_no = $${paramIndex}`;
-      params.push(batch_no);
+    if (receiver_name) {
+      sql += ` AND o.receiver_name LIKE $${paramIndex}`;
+      params.push(`%${receiver_name}%`);
       paramIndex++;
     }
 
-    if (card_no) {
-      sql += ` AND o.card_no = $${paramIndex}`;
-      params.push(card_no);
+    if (receiver_phone) {
+      sql += ` AND o.receiver_phone LIKE $${paramIndex}`;
+      params.push(`%${receiver_phone}%`);
       paramIndex++;
     }
 
@@ -179,7 +179,7 @@ router.post('/query', authMiddleware, async (req, res) => {
 
     const result = await pool.query(sql, params);
     // 记录查询日志
-    await logOperation(req.user.username, req.user.role, '查询订单', `条件: 状态=${status||'全部'}, 批次=${batch_no||'-'}, 卡号=${card_no||'-'}, 订单号=${order_no||'-'}, 日期=${start_date||'-'}~${end_date||'-'}`, req.ip);
+    await logOperation(req.user.username, req.user.role, '查询订单', `条件: 状态=${status||'全部'}, 收货人=${receiver_name||'-'}, 手机号=${receiver_phone||'-'}, 订单号=${order_no||'-'}, 日期=${start_date||'-'}~${end_date||'-'}`, req.ip);
     res.json({ success: true, data: result.rows, total: result.rows.length });
   } catch (err) {
     console.error('查询订单失败:', err);

+ 7 - 7
web/src/views/OrderManagement.vue

@@ -46,19 +46,19 @@
           <el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始" end-placeholder="结束" value-format="YYYY-MM-DD" style="width: 240px" />
         </div>
         <div class="filter-field">
-          <label>批次号</label>
-          <el-input v-model="form.batch_no" placeholder="输入批次号" clearable />
+          <label>收货人</label>
+          <el-input v-model="form.receiver_name" placeholder="输入收货人" clearable />
         </div>
         <div class="filter-field">
-          <label>卡号</label>
-          <el-input v-model="form.card_no" placeholder="输入卡号" clearable />
+          <label>手机号</label>
+          <el-input v-model="form.receiver_phone" placeholder="输入手机号" clearable />
         </div>
         <div class="filter-field">
           <label>订单号</label>
           <el-input v-model="form.order_no" placeholder="输入订单号" clearable />
         </div>
         <div class="filter-actions">
-          <el-button @click="handleReset">重置</el-button>
+          <el-button @click="handleReset(); $emit('query')">重置</el-button>
           <el-button type="primary" @click="$emit('query')">查询</el-button>
         </div>
       </div>
@@ -128,7 +128,7 @@ const props = defineProps({
 })
 defineEmits(['query', 'exportExcel', 'openImport'])
 
-const form = reactive({ batch_no: '', card_no: '', order_no: '', status: 0 })
+const form = reactive({ receiver_name: '', receiver_phone: '', order_no: '', status: 0 })
 const dateRange = ref(null)
 const currentPage = ref(1)
 const pageSize = ref(20)
@@ -151,7 +151,7 @@ function getParams() {
 }
 
 function handleReset() {
-  form.batch_no = ''; form.card_no = ''; form.order_no = ''; form.status = 0
+  form.receiver_name = ''; form.receiver_phone = ''; form.order_no = ''; form.status = 0
   dateRange.value = null
 }