Bladeren bron

bug修复和功能优化

徐滕 2 weken geleden
bovenliggende
commit
6522214809

+ 26 - 3
forge-admin-ui/src/components/ai-form/AiSearch.vue

@@ -196,6 +196,26 @@ async function handleSearch() {
 }
 
 /**
+ * 收集 schema 中声明了 defaultValue 的字段(含布局节点 children),
+ * 用于重置时恢复初始加载状态(与 AiCrudPage buildDefaultSearchParams 语义一致)
+ */
+function collectSchemaDefaults(nodes = [], result = {}) {
+  ;(Array.isArray(nodes) ? nodes : []).forEach((node) => {
+    if (!node || typeof node !== 'object')
+      return
+    if (node.nodeType && node.nodeType !== 'field') {
+      collectSchemaDefaults(node.children || [], result)
+      return
+    }
+    if (node.field && node.defaultValue !== undefined)
+      result[node.field] = node.defaultValue
+    if (node.children)
+      collectSchemaDefaults(node.children, result)
+  })
+  return result
+}
+
+/**
  * 重置
  */
 async function handleReset() {
@@ -217,13 +237,16 @@ async function handleReset() {
       }
     }
 
-    // 重置表单
+    // 重置表单并恢复初始加载状态:只保留 schema 声明了 defaultValue 的字段。
+    // 不能直接清空为 {},否则带 defaultValue 的字段(如订单页下单时间默认今天)
+    // 会出现输入框被清空、查询却仍按默认范围执行的 UI 与实际查询不一致问题
     formRef.value?.reset()
-    formData.value = {}
+    const defaultParams = collectSchemaDefaults(schema.value)
+    formData.value = { ...defaultParams }
 
     isInternalUpdate = true
     emit('reset')
-    emit('update:modelValue', {})
+    emit('update:modelValue', { ...defaultParams })
 
     // 重置后自动搜索
     await handleSearch()

+ 24 - 3
forge-admin-ui/src/views/hotel/dish.vue

@@ -14,6 +14,7 @@
       :search-schema="searchSchema"
       :columns="tableColumns"
       :edit-schema="editSchema"
+      :before-load-list="beforeLoadList"
       :before-submit="beforeSubmit"
       :before-render-form="beforeRenderForm"
       :before-render-detail="beforeRenderDetail"
@@ -287,7 +288,8 @@ const statusLabelMap = {
 }
 
 // 搜索表单配置
-const searchSchema = [
+// 注意:必须定义为 computed,且分类 options 取 .value,确保分类异步加载完成后下拉选项响应式更新
+const searchSchema = computed(() => [
   {
     field: 'name',
     label: '菜品名称',
@@ -298,7 +300,18 @@ const searchSchema = [
     field: 'categoryId',
     label: '分类',
     type: 'select',
-    props: { placeholder: '请选择分类', options: categoryOptions },
+    props: { placeholder: '请选择分类', options: categoryOptions.value },
+  },
+  {
+    field: 'mealType',
+    label: '适用餐段',
+    type: 'select',
+    props: {
+      placeholder: '请选择适用餐段',
+      options: mealTypeOptions,
+      multiple: true,
+      clearable: true,
+    },
   },
   {
     field: 'status',
@@ -306,7 +319,15 @@ const searchSchema = [
     type: 'select',
     props: { placeholder: '请选择状态', options: dishStatusOptions },
   },
-]
+])
+
+/** 加载列表前钩子:将餐段数组转为逗号分隔字符串,供后端 FIND_IN_SET 查询 */
+function beforeLoadList(params) {
+  if (Array.isArray(params.mealType) && params.mealType.length > 0) {
+    params.mealType = params.mealType.join(',')
+  }
+  return params
+}
 
 // 表格列配置
 const tableColumns = computed(() => [

+ 10 - 7
forge-admin-ui/src/views/hotel/order.vue

@@ -267,7 +267,9 @@ const statusOptions = computed(() => {
   return list.map(item => ({ label: item.label, value: Number(item.value) }))
 })
 
-const payMethodOptions = computed(() => dict.value.hotel_pay_method || [])
+// 支付方式筛选暂时隐藏:支付方案未定(第三方融合支付 or 自建支付宝/微信),
+// 确定后恢复此处及 searchSchema 中的 payMethod 字段(useDict 中 hotel_pay_method 一并保留)
+// const payMethodOptions = computed(() => dict.value.hotel_pay_method || [])
 
 const searchSchema = computed(() => [
   {
@@ -299,12 +301,13 @@ const searchSchema = computed(() => [
     type: 'input',
     props: { placeholder: '请输入联系人姓名' },
   },
-  {
-    field: 'payMethod',
-    label: '支付方式',
-    type: 'select',
-    props: { placeholder: '请选择支付方式', options: payMethodOptions.value },
-  },
+  // 支付方式筛选暂时隐藏:支付方案未定(第三方融合支付 or 自建支付宝/微信),确定后再开放
+  // {
+  //   field: 'payMethod',
+  //   label: '支付方式',
+  //   type: 'select',
+  //   props: { placeholder: '请选择支付方式', options: payMethodOptions.value },
+  // },
 ])
 
 /** 时间戳或字符串 → yyyy-MM-dd */

+ 4 - 3
forge-admin-ui/src/views/hotel/room.vue

@@ -71,7 +71,8 @@ const statusLabelMap = {
 }
 
 // 搜索表单配置
-const searchSchema = [
+// 注意:必须定义为 computed,且 options 取 .value,确保房型异步加载完成后下拉选项响应式更新
+const searchSchema = computed(() => [
   {
     field: 'roomNo',
     label: '房间号',
@@ -88,9 +89,9 @@ const searchSchema = [
     field: 'roomTypeId',
     label: '房型',
     type: 'select',
-    props: { placeholder: '请选择房型', options: roomTypeOptions },
+    props: { placeholder: '请选择房型', options: roomTypeOptions.value },
   },
-]
+])
 
 // 表格列配置
 // 注:编辑/删除由 AiCrudPage 默认操作列自动提供

+ 2 - 1
forge-server/forge-business/forge-hotel/src/main/resources/mapper/business/hotel/HotelDishMapper.xml

@@ -54,7 +54,8 @@
         </if>
         <if test="query.mealType != null and query.mealType != ''">
             <!-- 支持多选:meal_type 存储逗号分隔值如 "breakfast,lunch",NULL 表示全天可用 -->
-            AND (FIND_IN_SET(#{query.mealType}, d.meal_type) > 0 OR d.meal_type IS NULL)
+            <!-- 使用 REGEXP 匹配查询值中的任意一个:将 "breakfast,lunch" 转为正则 (^|,)(breakfast|lunch)(,|$) -->
+            AND (d.meal_type REGEXP CONCAT('(^|,)(', REPLACE(#{query.mealType}, ',', '|'), ')(,|$)') OR d.meal_type IS NULL)
         </if>
         ORDER BY d.sort_order ASC, d.sales DESC
     </select>

+ 1 - 1
forge-server/forge-business/forge-hotel/src/main/resources/mapper/business/hotel/order/HotelOrderMapper.xml

@@ -64,7 +64,7 @@
         WHERE o.tenant_id = #{tenantId}
           AND o.del_flag = 0
         <if test="query.roomNo != null and query.roomNo != ''">
-            AND o.room_no = #{query.roomNo}
+            AND o.room_no LIKE CONCAT('%', #{query.roomNo}, '%')
         </if>
         <!-- 顾客端按在住会话过滤:同一住客会话内多人共享可见订单,换客后新会话看不到旧订单 -->
         <if test="query.stayId != null">