新增
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m7s

This commit is contained in:
sexygoat
2026-03-19 18:32:02 +08:00
parent 407287f538
commit f06d8c9133
22 changed files with 2260 additions and 117 deletions

View File

@@ -452,7 +452,7 @@
label-width="120px"
>
<ElFormItem label="设备号">
<span style="font-weight: bold; color: #409eff">{{ currentOperatingDevice }}</span>
<span style="font-weight: bold; color: #409eff">{{ currentOperatingImei }}</span>
</ElFormItem>
<ElFormItem label="下行速率" prop="download_speed">
<ElInputNumber
@@ -484,27 +484,70 @@
</ElDialog>
<!-- 切换SIM卡对话框 -->
<ElDialog v-model="switchCardDialogVisible" title="切换SIM卡" width="500px">
<ElForm
ref="switchCardFormRef"
:model="switchCardForm"
:rules="switchCardRules"
label-width="120px"
>
<ElFormItem label="设备号">
<span style="font-weight: bold; color: #409eff">{{ currentOperatingDevice }}</span>
</ElFormItem>
<ElFormItem label="目标ICCID" prop="target_iccid">
<ElInput
v-model="switchCardForm.target_iccid"
placeholder="请输入要切换到的目标ICCID"
clearable
/>
</ElFormItem>
</ElForm>
<ElDialog v-model="switchCardDialogVisible" title="切换SIM卡" width="600px">
<div v-if="loadingDeviceCards" style="text-align: center; padding: 40px">
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
<div style="margin-top: 16px">加载设备绑定的卡列表中...</div>
</div>
<template v-else>
<ElAlert
v-if="deviceBindingCards.length === 0"
title="该设备暂无绑定的SIM卡"
type="warning"
:closable="false"
style="margin-bottom: 20px"
>
<template #default>
<div>当前设备没有绑定任何SIM卡,无法进行切换操作</div>
<div>请先为设备绑定SIM卡后再进行切换</div>
</template>
</ElAlert>
<ElForm
v-if="deviceBindingCards.length > 0"
ref="switchCardFormRef"
:model="switchCardForm"
:rules="switchCardRules"
label-width="120px"
>
<ElFormItem label="设备号">
<span style="font-weight: bold; color: #409eff">{{ currentOperatingImei }}</span>
</ElFormItem>
<ElFormItem label="目标ICCID" prop="target_iccid">
<ElSelect
v-model="switchCardForm.target_iccid"
placeholder="请选择要切换到的目标ICCID"
style="width: 100%"
clearable
>
<ElOption
v-for="card in deviceBindingCards"
:key="card.iccid"
:label="`${card.iccid} - 插槽${card.slot_position} - ${card.carrier_name}`"
:value="card.iccid"
>
<div style="display: flex; justify-content: space-between; align-items: center">
<span>{{ card.iccid }}</span>
<ElTag size="small" style="margin-left: 10px">插槽{{ card.slot_position }}</ElTag>
</div>
</ElOption>
</ElSelect>
<div style="margin-top: 8px; font-size: 12px; color: #909399">
当前设备共绑定 {{ deviceBindingCards.length }} 张SIM卡
</div>
</ElFormItem>
</ElForm>
</template>
<template #footer>
<ElButton @click="switchCardDialogVisible = false">取消</ElButton>
<ElButton type="primary" @click="handleConfirmSwitchCard" :loading="switchCardLoading">
<ElButton
v-if="deviceBindingCards.length > 0"
type="primary"
@click="handleConfirmSwitchCard"
:loading="switchCardLoading"
>
确认切换
</ElButton>
</template>
@@ -519,7 +562,7 @@
label-width="120px"
>
<ElFormItem label="设备号">
<span style="font-weight: bold; color: #409eff">{{ currentOperatingDevice }}</span>
<span style="font-weight: bold; color: #409eff">{{ currentOperatingImei }}</span>
</ElFormItem>
<ElFormItem label="WiFi状态" prop="enabled">
<ElRadioGroup v-model="setWiFiForm.enabled">
@@ -683,11 +726,12 @@
{ type: 'number', min: 1, message: '速率不能小于1KB/s', trigger: 'blur' }
]
})
const currentOperatingDevice = ref<string>('')
// 设备操作右键菜单
const deviceOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
const currentOperatingDeviceNo = ref<string>('')
const currentOperatingDevice = ref<Device | null>(null)
const currentOperatingImei = ref<string>('') // 用于存储当前操作设备的IMEI
const switchCardDialogVisible = ref(false)
const switchCardLoading = ref(false)
@@ -696,8 +740,10 @@
target_iccid: ''
})
const switchCardRules = reactive<FormRules>({
target_iccid: [{ required: true, message: '请输入目标ICCID', trigger: 'blur' }]
target_iccid: [{ required: true, message: '请选择目标ICCID', trigger: 'change' }]
})
const deviceBindingCards = ref<any[]>([]) // 设备绑定的卡列表
const loadingDeviceCards = ref(false) // 加载设备绑定卡列表的状态
const setWiFiDialogVisible = ref(false)
const setWiFiLoading = ref(false)
@@ -1454,6 +1500,9 @@
case 'set-wifi':
showSetWiFiDialog(deviceNo)
break
case 'manual-deactivate':
handleManualDeactivateDevice()
break
case 'delete':
handleDeleteDeviceByNo(deviceNo)
break
@@ -1470,6 +1519,39 @@
}
}
// 手动停用设备(资产层面的停用)
const handleManualDeactivateDevice = () => {
const device = currentOperatingDevice.value
if (!device) {
ElMessage.error('未找到设备信息')
return
}
ElMessageBox.confirm(
`确定要手动停用设备 ${device.virtual_no} 吗?此操作将在资产管理层面停用该设备。`,
'确认手动停用',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
.then(async () => {
try {
const res = await DeviceService.deactivateDevice(device.id)
if (res.code === 0) {
ElMessage.success('手动停用成功')
loadDeviceList()
}
} catch (error: any) {
console.error('手动停用失败:', error)
}
})
.catch(() => {
// 用户取消
})
}
// 通过设备号删除设备
const handleDeleteDeviceByNo = async (deviceNo: string) => {
// 先根据设备号找到设备对象
@@ -1537,7 +1619,7 @@
// 显示设置限速对话框
const showSpeedLimitDialog = (imei: string) => {
currentOperatingDevice.value = imei
currentOperatingImei.value = imei
speedLimitForm.download_speed = 1024
speedLimitForm.upload_speed = 512
speedLimitDialogVisible.value = true
@@ -1551,7 +1633,7 @@
if (valid) {
speedLimitLoading.value = true
try {
const res = await DeviceService.setSpeedLimit(currentOperatingDevice.value, {
const res = await DeviceService.setSpeedLimit(currentOperatingImei.value, {
download_speed: speedLimitForm.download_speed,
upload_speed: speedLimitForm.upload_speed
})
@@ -1572,10 +1654,35 @@
}
// 显示切换SIM卡对话框
const showSwitchCardDialog = (imei: string) => {
currentOperatingDevice.value = imei
const showSwitchCardDialog = async (deviceNo: string) => {
currentOperatingImei.value = deviceNo
switchCardForm.target_iccid = ''
deviceBindingCards.value = []
switchCardDialogVisible.value = true
// 使用当前操作的设备
const device = currentOperatingDevice.value
if (!device) {
ElMessage.error('未找到设备信息')
return
}
// 加载设备绑定的卡列表
loadingDeviceCards.value = true
try {
const res = await DeviceService.getDeviceCards(device.id)
if (res.code === 0 && res.data) {
deviceBindingCards.value = res.data.bindings || []
if (deviceBindingCards.value.length === 0) {
ElMessage.warning('该设备暂无绑定的SIM卡')
}
}
} catch (error) {
console.error('加载设备绑定卡列表失败:', error)
ElMessage.error('加载卡列表失败')
} finally {
loadingDeviceCards.value = false
}
}
// 确认切换SIM卡
@@ -1586,7 +1693,7 @@
if (valid) {
switchCardLoading.value = true
try {
const res = await DeviceService.switchCard(currentOperatingDevice.value, {
const res = await DeviceService.switchCard(currentOperatingImei.value, {
target_iccid: switchCardForm.target_iccid
})
if (res.code === 0) {
@@ -1607,7 +1714,7 @@
// 显示设置WiFi对话框
const showSetWiFiDialog = (imei: string) => {
currentOperatingDevice.value = imei
currentOperatingImei.value = imei
setWiFiForm.enabled = 1
setWiFiForm.ssid = ''
setWiFiForm.password = ''
@@ -1622,7 +1729,7 @@
if (valid) {
setWiFiLoading.value = true
try {
const res = await DeviceService.setWiFi(currentOperatingDevice.value, {
const res = await DeviceService.setWiFi(currentOperatingImei.value, {
enabled: setWiFiForm.enabled,
ssid: setWiFiForm.ssid,
password: setWiFiForm.password
@@ -1690,6 +1797,13 @@
})
}
if (hasAuth('device:manual_deactivate')) {
items.push({
key: 'manual-deactivate',
label: '手动停用'
})
}
if (hasAuth('device:delete')) {
items.push({
key: 'delete',
@@ -1701,10 +1815,11 @@
})
// 显示设备操作菜单
const showDeviceOperationMenu = (e: MouseEvent, deviceNo: string) => {
const showDeviceOperationMenu = (e: MouseEvent, deviceNo: string, device?: Device) => {
e.preventDefault()
e.stopPropagation()
currentOperatingDeviceNo.value = deviceNo
currentOperatingDevice.value = device || null
deviceOperationMenuRef.value?.show(e)
}
@@ -1718,7 +1833,7 @@
// 处理表格行右键菜单
const handleRowContextMenu = (row: Device, column: any, event: MouseEvent) => {
showDeviceOperationMenu(event, row.virtual_no)
showDeviceOperationMenu(event, row.virtual_no, row)
}
</script>