fix: bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 7m11s

This commit is contained in:
sexygoat
2026-04-24 18:39:39 +08:00
parent 2d6b5d7903
commit 17c299e4ce
27 changed files with 500 additions and 481 deletions

View File

@@ -351,7 +351,7 @@
</ElSelect>
</ElFormItem>
</ElCol>
<ElCol :span="8">
<ElCol :span="9">
<ElFormItem label="ICCID" prop="iot_card_id">
<ElSelect
v-model="bindCardForm.iot_card_id"
@@ -401,6 +401,7 @@
</ElCol>
<ElCol :span="3">
<ElButton
v-permission="'device:bind_card'"
type="primary"
@click="handleConfirmBindCard"
:loading="bindCardLoading"
@@ -419,11 +420,9 @@
</div>
<div v-else>
<ElTable :data="deviceCards" border style="width: 100%">
<ElTableColumn prop="slot_position" label="插槽位置" width="120" align="center">
<ElTableColumn prop="slot_position" label="插槽位置" width="120">
<template #default="{ row }">
<div
style="display: flex; gap: 10px; align-items: center; justify-content: center"
>
<div style="display: flex; gap: 10px; align-items: center">
<span>SIM-{{ row.slot_position }}</span>
<ElTag v-if="row.is_current" type="success" size="small">当前</ElTag>
</div>
@@ -431,7 +430,7 @@
</ElTableColumn>
<ElTableColumn prop="iccid" label="ICCID" min-width="120" />
<ElTableColumn prop="msisdn" label="接入号" width="160" />
<ElTableColumn prop="network_status" label="网络状态" width="100" align="center">
<ElTableColumn prop="network_status" label="网络状态" width="100">
<template #default="{ row }">
<ElTag :type="getNetworkStatusTagType(row.network_status)">
{{ getNetworkStatusText(row.network_status) }}
@@ -445,7 +444,13 @@
</ElTableColumn>
<ElTableColumn label="操作" width="100" fixed="right" align="center">
<template #default="{ row }">
<ElButton type="danger" size="small" link @click="handleUnbindCard(row)">
<ElButton
v-permission="'device:unbind_card'"
type="danger"
size="small"
link
@click="handleUnbindCard(row)"
>
解绑
</ElButton>
</template>
@@ -470,93 +475,13 @@
@confirm="handleConfirmSwitchCard"
/>
<!-- 设置WiFi对话框 -->
<ElDialog v-model="setWiFiDialogVisible" title="设置WiFi" width="500px">
<ElForm
ref="setWiFiFormRef"
:model="setWiFiForm"
:rules="setWiFiRules"
label-width="120px"
>
<ElFormItem label="设备号">
<span style="font-weight: bold; color: #409eff">{{ currentOperatingImei }}</span>
</ElFormItem>
<ElFormItem label="WiFi状态" prop="enabled">
<ElRadioGroup v-model="setWiFiForm.enabled">
<ElRadio :value="1">启用</ElRadio>
<ElRadio :value="0">禁用</ElRadio>
</ElRadioGroup>
</ElFormItem>
<ElFormItem label="WiFi名称" prop="ssid">
<ElInput
v-model="setWiFiForm.ssid"
placeholder="请输入WiFi名称1-32个字符"
maxlength="32"
show-word-limit
clearable
autocomplete="off"
/>
</ElFormItem>
<ElFormItem label="WiFi密码" prop="password">
<ElInput
v-model="setWiFiForm.password"
type="password"
placeholder="请输入WiFi密码8-63个字符"
maxlength="63"
show-word-limit
show-password
clearable
autocomplete="off"
/>
</ElFormItem>
</ElForm>
<template #footer>
<ElButton @click="setWiFiDialogVisible = false">取消</ElButton>
<ElButton type="primary" @click="handleConfirmSetWiFi" :loading="setWiFiLoading">
确认设置
</ElButton>
</template>
</ElDialog>
<!-- 设置切卡模式对话框 -->
<ElDialog v-model="switchModeDialogVisible" title="设置切卡模式" width="500px">
<ElForm
ref="switchModeFormRef"
:model="switchModeForm"
:rules="switchModeRules"
label-width="120px"
>
<ElFormItem label="设备标识">
<span style="font-weight: bold; color: #409eff">{{
currentOperatingDeviceIdentifier
}}</span>
</ElFormItem>
<ElFormItem label="当前模式">
<ElTag :type="currentDeviceSwitchMode === 0 ? 'success' : 'warning'">
{{ currentDeviceSwitchMode === 0 ? '自动切卡' : '手动切卡' }}
</ElTag>
</ElFormItem>
<ElFormItem label="切卡模式" prop="switch_mode">
<ElRadioGroup v-model="switchModeForm.switch_mode">
<ElRadio :value="0">自动切卡</ElRadio>
<ElRadio :value="1">手动切卡</ElRadio>
</ElRadioGroup>
</ElFormItem>
<ElFormItem>
<div style="font-size: 12px; color: #909399; line-height: 1.6">
<p>说明</p>
<p> <strong>自动切卡</strong>设备根据信号强度自动切换到最优的SIM卡</p>
<p> <strong>手动切卡</strong>需要手动触发切换SIM卡操作</p>
</div>
</ElFormItem>
</ElForm>
<template #footer>
<ElButton @click="switchModeDialogVisible = false">取消</ElButton>
<ElButton type="primary" @click="handleConfirmSwitchMode" :loading="switchModeLoading">
确认设置
</ElButton>
</template>
</ElDialog>
<SwitchModeDialog
v-model="switchModeDialogVisible"
:device-identifier="currentOperatingDeviceIdentifier"
:current-mode="currentDeviceSwitchMode"
@confirm="handleConfirmSwitchMode"
/>
<!-- 实名认证策略对话框 -->
<RealnamePolicyDialog
@@ -586,6 +511,7 @@
import { Loading } from '@element-plus/icons-vue'
import type { FormInstance, FormRules } from 'element-plus'
import SwitchCardDialog from '@/components/device/SwitchCardDialog.vue'
import SwitchModeDialog from '@/views/asset-management/asset-information/components/dialogs/SwitchModeDialog.vue'
import type {
Device,
DeviceStatus,
@@ -663,6 +589,7 @@
// 搜索表单店铺/系列选项
const shopOptions = ref<any[]>([])
const searchSeriesOptions = ref<any[]>([])
const searchBatchNoOptions = ref<any[]>([])
// 设备详情弹窗相关
const deviceDetailDialogVisible = ref(false)
@@ -699,37 +626,11 @@
const deviceBindingCards = ref<any[]>([]) // 设备绑定的卡列表
const loadingDeviceCards = ref(false) // 加载设备绑定卡列表的状态
const setWiFiDialogVisible = ref(false)
const setWiFiLoading = ref(false)
const setWiFiFormRef = ref<FormInstance>()
const setWiFiForm = reactive({
enabled: 1,
ssid: '',
password: ''
})
const setWiFiRules = reactive<FormRules>({
ssid: [
{ required: true, message: '请输入WiFi名称', trigger: 'blur' },
{ min: 1, max: 32, message: 'WiFi名称长度为1-32个字符', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入WiFi密码', trigger: 'blur' },
{ min: 8, max: 63, message: 'WiFi密码长度为8-63个字符', trigger: 'blur' }
]
})
// 切换模式相关
const switchModeDialogVisible = ref(false)
const switchModeLoading = ref(false)
const switchModeFormRef = ref<FormInstance>()
const currentOperatingDeviceIdentifier = ref<string>('')
const currentDeviceSwitchMode = ref<number>(0)
const switchModeForm = reactive({
switch_mode: 0
})
const switchModeRules = reactive<FormRules>({
switch_mode: [{ required: true, message: '请选择切卡模式', trigger: 'change' }]
})
// 实名认证策略相关
const realnamePolicyDialogVisible = ref(false)
@@ -754,6 +655,34 @@
// 搜索表单
const searchForm = reactive({ ...initialSearchState })
// 搜索批次号(用于搜索表单)
const loadSearchBatchNoOptions = async (batchNo?: string) => {
try {
const params: any = {
page: 1,
page_size: 20
}
if (batchNo) {
params.batch_no = batchNo
}
const res = await CardService.getIotCardImportTasks(params)
if (res.code === 0) {
searchBatchNoOptions.value = res.data.items || []
}
} catch (error) {
console.error('加载批次号选项失败:', error)
}
}
// 搜索批次号
const handleSearchBatchNo = (query: string) => {
if (query) {
loadSearchBatchNoOptions(query)
} else {
loadSearchBatchNoOptions()
}
}
// 搜索表单配置
const searchFormItems: SearchFormItem[] = [
{
@@ -792,11 +721,20 @@
{
label: '批次号',
prop: 'batch_no',
type: 'input',
type: 'select',
config: {
clearable: true,
placeholder: '请输入批次号'
}
filterable: true,
remote: true,
remoteMethod: handleSearchBatchNo,
loading: false,
placeholder: '请选择或搜索批次号'
},
options: () =>
searchBatchNoOptions.value.map((b) => ({
label: b.batch_no,
value: b.batch_no
}))
},
{
label: '设备类型',
@@ -941,6 +879,7 @@
bindCardForm.search_type = 'iccid'
bindCardForm.iot_card_id = undefined
bindCardForm.slot_position = 1
bindCardFormRef.value?.resetFields()
// 加载未绑定设备的卡列表
await Promise.all([loadDeviceCards(device.virtual_no), loadDefaultIotCards()])
}
@@ -1338,8 +1277,6 @@
let isFirstActivation = true
onMounted(() => {
getTableData()
searchShops('')
searchSeries('')
})
// 当页面被 keep-alive 激活时自动刷新数据
@@ -1492,6 +1429,7 @@
allocateForm.target_shop_id = undefined
allocateForm.remark = ''
allocateResult.value = null
shopCascadeOptions.value = []
allocateDialogVisible.value = true
}
@@ -1505,7 +1443,7 @@
try {
const data = {
device_ids: selectedDevices.value.map((d) => d.id),
target_shop_id: allocateForm.target_shop_id![0],
target_shop_id: allocateForm.target_shop_id![allocateForm.target_shop_id.length - 1],
remark: allocateForm.remark
}
const res = await DeviceService.allocateDevices(data)
@@ -1720,15 +1658,6 @@
await showSwitchCardDialog(imei)
break
}
case 'set-wifi': {
const imei = device?.imei || (await getDeviceImei(deviceNo))
if (!imei) {
ElMessage.error('无法获取设备IMEI,无法执行WiFi设置操作')
return
}
showSetWiFiDialog(imei)
break
}
case 'manual-deactivate':
handleManualDeactivateDevice()
break
@@ -1926,77 +1855,33 @@
}
}
// 显示设置WiFi对话框
const showSetWiFiDialog = (imei: string) => {
currentOperatingImei.value = imei
setWiFiForm.enabled = 1
setWiFiForm.ssid = ''
setWiFiForm.password = ''
setWiFiDialogVisible.value = true
}
// 确认设置WiFi
const handleConfirmSetWiFi = async () => {
if (!setWiFiFormRef.value) return
await setWiFiFormRef.value.validate(async (valid) => {
if (valid) {
setWiFiLoading.value = true
try {
const res = await DeviceService.setWiFi(currentOperatingImei.value, {
enabled: setWiFiForm.enabled,
ssid: setWiFiForm.ssid,
password: setWiFiForm.password
})
if (res.code === 0) {
ElMessage.success('WiFi设置成功')
setWiFiDialogVisible.value = false
} else {
ElMessage.error(res.msg || '设置失败')
}
} catch (error: any) {
console.error('设置WiFi失败:', error)
} finally {
setWiFiLoading.value = false
}
}
})
}
// 显示切换模式对话框
const showSwitchModeDialog = (deviceIdentifier: string, currentMode?: number) => {
currentOperatingDeviceIdentifier.value = deviceIdentifier
currentDeviceSwitchMode.value = currentMode ?? 0
switchModeForm.switch_mode = currentMode ?? 0
switchModeDialogVisible.value = true
}
// 确认切换模式
const handleConfirmSwitchMode = async () => {
if (!switchModeFormRef.value) return
await switchModeFormRef.value.validate(async (valid) => {
if (valid) {
switchModeLoading.value = true
try {
const res = await DeviceService.setSwitchMode(
currentOperatingDeviceIdentifier.value,
switchModeForm.switch_mode
)
if (res.code === 0) {
ElMessage.success('设置切卡模式成功')
switchModeDialogVisible.value = false
await getTableData()
} else {
ElMessage.error(res.msg || '设置切卡模式失败')
}
} catch (error: any) {
console.error('设置切卡模式失败:', error)
} finally {
switchModeLoading.value = false
}
const handleConfirmSwitchMode = async (data: { switch_mode: number }) => {
switchModeLoading.value = true
try {
const res = await DeviceService.setSwitchMode(
currentOperatingDeviceIdentifier.value,
data.switch_mode
)
if (res.code === 0) {
ElMessage.success('设置切卡模式成功')
switchModeDialogVisible.value = false
await getTableData()
} else {
ElMessage.error(res.msg || '设置切卡模式失败')
}
})
} catch (error: any) {
console.error('设置切卡模式失败:', error)
} finally {
switchModeLoading.value = false
}
}
// 设备操作菜单项配置
@@ -2048,14 +1933,6 @@
})
}
if (hasAuth('device:set_wifi')) {
moreActions.push({
label: '设置WiFi',
handler: () => handleDeviceOperation('set-wifi', row.virtual_no, row),
type: 'primary'
})
}
if (hasAuth('device:clear_series')) {
moreActions.push({
label: '清除关联',