fetch(modify):修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 6m6s

This commit is contained in:
sexygoat
2026-01-31 18:12:58 +08:00
parent ecb79dae43
commit 882feaf3ff
8 changed files with 452 additions and 305 deletions

View File

@@ -105,11 +105,31 @@
:label="t('orderManagement.createForm.deviceId')"
prop="device_id"
>
<ElInputNumber
<ElSelect
v-model="createForm.device_id"
filterable
remote
reserve-keyword
:placeholder="t('orderManagement.createForm.deviceIdPlaceholder')"
:remote-method="searchDevices"
:loading="deviceSearchLoading"
style="width: 100%"
/>
clearable
>
<ElOption
v-for="device in deviceOptions"
:key="device.id"
:label="`${device.device_no} (${device.device_name})`"
:value="device.id"
>
<div style="display: flex; justify-content: space-between">
<span>{{ device.device_no }}</span>
<span style="color: var(--el-text-color-secondary); font-size: 12px">
{{ device.device_name }}
</span>
</div>
</ElOption>
</ElSelect>
</ElFormItem>
</ElForm>
<template #footer>
@@ -220,7 +240,7 @@
<script setup lang="ts">
import { h } from 'vue'
import { useI18n } from 'vue-i18n'
import { OrderService, CardService } from '@/api/modules'
import { OrderService, CardService, DeviceService } from '@/api/modules'
import { ElMessage, ElMessageBox, ElTag } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import type {
@@ -232,7 +252,8 @@
BuyerType,
OrderPaymentMethod,
OrderCommissionStatus,
StandaloneIotCard
StandaloneIotCard,
Device
} from '@/types/api'
import type { SearchFormItem } from '@/types'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
@@ -367,6 +388,10 @@
const iotCardOptions = ref<StandaloneIotCard[]>([])
const cardSearchLoading = ref(false)
// 设备搜索相关
const deviceOptions = ref<Device[]>([])
const deviceSearchLoading = ref(false)
// 搜索IoT卡根据ICCID
const searchIotCards = async (query: string) => {
if (!query) {
@@ -392,6 +417,31 @@
}
}
// 搜索设备根据设备号device_no
const searchDevices = async (query: string) => {
if (!query) {
deviceOptions.value = []
return
}
deviceSearchLoading.value = true
try {
const res = await DeviceService.getDevices({
device_no: query,
page: 1,
page_size: 20
})
if (res.code === 0) {
deviceOptions.value = res.data.items || []
}
} catch (error) {
console.error('Search devices failed:', error)
deviceOptions.value = []
} finally {
deviceSearchLoading.value = false
}
}
// 格式化货币 - 将分转换为元
const formatCurrency = (amount: number): string => {
return `¥${(amount / 100).toFixed(2)}`
@@ -606,8 +656,8 @@
// 显示创建订单对话框
const showCreateDialog = async () => {
createDialogVisible.value = true
// 默认加载20条IoT卡数据
await loadDefaultIotCards()
// 默认加载20条IoT卡和设备数据
await Promise.all([loadDefaultIotCards(), loadDefaultDevices()])
}
// 加载默认IoT卡列表
@@ -629,6 +679,25 @@
}
}
// 加载默认设备列表
const loadDefaultDevices = async () => {
deviceSearchLoading.value = true
try {
const res = await DeviceService.getDevices({
page: 1,
page_size: 20
})
if (res.code === 0) {
deviceOptions.value = res.data.items || []
}
} catch (error) {
console.error('Load default devices failed:', error)
deviceOptions.value = []
} finally {
deviceSearchLoading.value = false
}
}
// 对话框关闭后的清理
const handleCreateDialogClosed = () => {
// 重置表单(会同时清除验证状态)
@@ -640,8 +709,9 @@
createForm.iot_card_id = null
createForm.device_id = null
// 清空IoT卡搜索结果
// 清空IoT卡和设备搜索结果
iotCardOptions.value = []
deviceOptions.value = []
}
// 创建订单