ai-coding
2026-06-19 a852e9437dbd98433639d63b093adee62a87d49b
feat(testPlan): 新增测试计划管理接口是否停车配置的更新

Co-Authored-By: '黄星炤' <huangxz@xiaopeng.com>
2个文件已修改
42 ■■■■■ 已修改文件
src/service/api/testPlanManagement.ts 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/testDemo/testPlanManagement/add.vue 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/service/api/testPlanManagement.ts
@@ -42,6 +42,14 @@
  return request.Post<Service.ResponseResult<any>>(`/operation/api/v1/test-plan-demo/edit/${id}`, data)
}
// 「到下车点是否停车」开关接口:参数以 query 传递,可在任意计划状态下调用。
// 切换后未下发订单按新值执行,已下发订单不受影响。
export function toggleTestPlanStopAtDropoff(planId: number | string, isStopAtDropoff: boolean) {
  return request.Post<Service.ResponseResult<any>>('/operation/api/v1/test-plan-demo/stopAtDropoff', null, {
    params: { planId, isStopAtDropoff },
  })
}
export function fetchTestPlanDetail(id: number | string) {
  return request.Get<Service.ResponseResult<any>>(`/operation/api/v1/test-plan-demo/detail/${id}`)
}
src/views/testDemo/testPlanManagement/add.vue
@@ -18,6 +18,7 @@
  fetchTestPlanOrderPageList,
  generateTestPlanPreviewOrders,
  startTestPlanDispatch,
  toggleTestPlanStopAtDropoff,
} from '@/service/api/testPlanManagement'
import PointSelectModal from './components/PointSelectModal.vue'
import VehicleSelectModal from './components/VehicleSelectModal.vue'
@@ -198,6 +199,33 @@
// ================= Step 2: 订单生成结果预览 =================
const isStopAtDropoff = ref(true)
const stopAtDropoffSubmitting = ref(false)
// 切换「到下车点是否停车」时实时调用开关接口更新计划配置。
// 接口失败则回滚开关,保证与后端状态一致。
async function handleStopAtDropoffChange(value: boolean) {
  if (!currentPlanId.value) {
    message.warning('测试计划ID缺失,无法更新停车配置')
    isStopAtDropoff.value = !value
    return
  }
  stopAtDropoffSubmitting.value = true
  try {
    const res = await toggleTestPlanStopAtDropoff(currentPlanId.value, value)
    if (res.code !== 200 && res.code !== 0) {
      throw new Error(res.msg || '更新停车配置失败')
    }
    message.success('停车配置已更新')
  }
  catch (error: any) {
    isStopAtDropoff.value = !value
    message.error(error?.message || '更新停车配置失败')
  }
  finally {
    stopAtDropoffSubmitting.value = false
  }
}
interface Step2Row {
  id: string
@@ -798,7 +826,11 @@
              <span class="text-14px text-[#333] mr-12px"
                >车辆到达下车点是否停靠</span
              >
              <n-switch v-model:value="isStopAtDropoff" />
              <n-switch
                v-model:value="isStopAtDropoff"
                :loading="stopAtDropoffSubmitting"
                @update:value="handleStopAtDropoffChange"
              />
            </div>
          </div>