绑定卡列表操作卡
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 8m1s

This commit is contained in:
sexygoat
2026-04-02 15:17:55 +08:00
parent 8df7024a45
commit ea14ae92ca

View File

@@ -249,6 +249,40 @@
</ElTag>
</template>
</ElTableColumn>
<ElTableColumn label="操作" width="280" align="center">
<template #default="scope">
<!-- 根据网络状态显示启用或停用按钮 -->
<ElButton
v-if="scope.row.network_status === 0"
type="success"
size="small"
link
@click="handleEnableBindingCard(scope.row)"
v-permission="'iot_card:start'"
>
启用此卡
</ElButton>
<ElButton
v-if="scope.row.network_status === 1"
type="warning"
size="small"
link
@click="handleDisableBindingCard(scope.row)"
v-permission="'iot_card:stop'"
>
停用此卡
</ElButton>
<ElButton
type="info"
size="small"
link
@click="handleDeactivateBindingCard(scope.row)"
v-permission="'iot_card:manual_deactivate'"
>
手动停用
</ElButton>
</template>
</ElTableColumn>
</ElTable>
<ElEmpty v-else description="暂无绑定卡" :image-size="80" style="margin-top: 16px" />
@@ -2368,6 +2402,74 @@
}
}
// ========== 绑定卡列表操作 ==========
// 启用绑定卡列表中的某张卡
const handleEnableBindingCard = async (card: any) => {
try {
await ElMessageBox.confirm(`确认要启用卡片 ${card.iccid} 吗?`, '提示', {
type: 'warning'
})
const res = await CardService.enableIotCard(card.iccid)
if (res.code === 0) {
ElMessage.success('启用成功')
await handleRefreshAsset()
}
} catch (error: any) {
if (error !== 'cancel') {
console.error('启用失败:', error)
ElMessage.error(error?.message || '启用失败')
}
}
}
// 停用绑定卡列表中的某张卡
const handleDisableBindingCard = async (card: any) => {
try {
await ElMessageBox.confirm(`确认要停用卡片 ${card.iccid} 吗?`, '提示', {
type: 'warning'
})
const res = await CardService.disableIotCard(card.iccid)
if (res.code === 0) {
ElMessage.success('停用成功')
await handleRefreshAsset()
}
} catch (error: any) {
if (error !== 'cancel') {
console.error('停用失败:', error)
ElMessage.error(error?.message || '停用失败')
}
}
}
// 手动停用绑定卡列表中的某张卡
const handleDeactivateBindingCard = async (card: any) => {
try {
await ElMessageBox.confirm(
`手动停用后卡片 ${card.iccid} 将永久停用,无法再次使用。此操作不可逆,请谨慎操作。确认要手动停用吗?`,
'警告',
{
type: 'error',
confirmButtonText: '确认停用',
cancelButtonText: '取消'
}
)
const res = await CardService.deactivateIotCard(card.id)
if (res.code === 0) {
ElMessage.success('手动停用成功')
await handleRefreshAsset()
}
} catch (error: any) {
if (error !== 'cancel') {
console.error('手动停用失败:', error)
ElMessage.error(error?.message || '手动停用失败')
}
}
}
// ========== 设备操作 ==========
// 重启设备