feat: 新增更新资产实名认证策略
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m5s

This commit is contained in:
sexygoat
2026-04-20 15:10:23 +08:00
parent d721c4b8a9
commit 3acb626a34
10 changed files with 352 additions and 21 deletions

View File

@@ -545,6 +545,14 @@
:menu-width="180"
@select="handleMoreMenuSelect"
/>
<!-- 实名认证策略对话框 -->
<RealnamePolicyDialog
v-model="realnamePolicyDialogVisible"
:asset-identifier="currentRealnamePolicyIccid"
:current-policy="currentRealnamePolicy"
@confirm="handleConfirmRealnamePolicy"
/>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -557,6 +565,7 @@
import { CardService, ShopService, PackageSeriesService, AssetService } from '@/api/modules'
import { ElMessage, ElTag, ElIcon, ElMessageBox } from 'element-plus'
import { Loading } from '@element-plus/icons-vue'
import RealnamePolicyDialog from '@/components/device/RealnamePolicyDialog.vue'
import type { FormInstance, FormRules } from 'element-plus'
import type { SearchFormItem } from '@/types'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
@@ -636,6 +645,54 @@
const cardStatusLoading = ref(false)
const cardStatusData = ref<any>(null)
// 实名认证策略对话框
const realnamePolicyDialogVisible = ref(false)
const currentRealnamePolicyIccid = ref('')
const currentRealnamePolicy = ref('none')
// 显示实名认证策略对话框
const handleShowRealnamePolicy = async (iccid: string, currentPolicy?: string) => {
currentRealnamePolicyIccid.value = iccid
if (currentPolicy !== undefined && currentPolicy !== null) {
currentRealnamePolicy.value = String(currentPolicy)
} else {
try {
const res = await AssetService.resolveAsset(iccid)
if (res.code === 0 && res.data) {
currentRealnamePolicy.value = res.data.realname_policy ?? 'none'
} else {
currentRealnamePolicy.value = 'none'
}
} catch {
currentRealnamePolicy.value = 'none'
}
}
realnamePolicyDialogVisible.value = true
}
// 确认设置实名认证策略
const handleConfirmRealnamePolicy = async (data: { realname_policy: string }) => {
if (!currentRealnamePolicyIccid.value) {
ElMessage.warning('未指定卡片')
return
}
try {
const res = await AssetService.updateRealnamePolicy(
currentRealnamePolicyIccid.value,
data.realname_policy
)
if (res.code === 0) {
ElMessage.success('设置实名认证策略成功')
realnamePolicyDialogVisible.value = false
await getTableData()
} else {
ElMessage.error(res.msg || '设置失败')
}
} catch (error) {
console.error('设置实名认证策略失败:', error)
}
}
// 更多操作右键菜单
const moreMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
@@ -1153,6 +1210,29 @@
})
}
if (hasAuth('asset:realname_policy')) {
actions.push({
label: '实名认证策略',
handler: () => handleCardOperation('realname-policy', row.iccid, row),
type: 'primary'
})
}
// 更多操作放到"更多"下拉菜单中
const moreActions: any[] = []
if (hasAuth('iot_card:clear_series')) {
moreActions.push({
label: '清除关联',
handler: () => handleCardOperation('clear-series', row.iccid),
type: 'primary'
})
}
if (moreActions.length > 0) {
actions.push(...moreActions)
}
// if (hasAuth('iot_card:manual_deactivate')) {
// actions.push({
// label: '手动停用',
@@ -1524,13 +1604,6 @@
})
}
if (hasAuth('iot_card:clear_series')) {
items.push({
key: 'clearSeries',
label: '清除关联'
})
}
return items
})
@@ -1632,7 +1705,7 @@
}
// IoT卡操作处理函数
const handleCardOperation = (command: string, iccid: string) => {
const handleCardOperation = (command: string, iccid: string, row?: any) => {
switch (command) {
case 'realname-status':
showRealnameStatusDialog(iccid)
@@ -1646,12 +1719,48 @@
case 'stop-card':
handleStopCard(iccid)
break
case 'realname-policy':
handleShowRealnamePolicy(iccid, row?.realname_policy)
break
case 'manual-deactivate':
handleManualDeactivate(iccid)
break
case 'clear-series':
handleClearSingleCardSeries(iccid)
break
}
}
// 清除单卡套餐系列绑定
const handleClearSingleCardSeries = (iccid: string) => {
ElMessageBox.confirm(`确定要清除该卡(${iccid})的套餐系列关联吗?`, '确认清除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
try {
const res = await CardService.batchSetCardSeriesBinding({
iccids: [iccid],
series_id: 0
})
if (res.code === 0) {
if (res.data.fail_count === 0) {
ElMessage.success('清除关联成功')
} else {
ElMessage.warning(`失败:${res.data.failed_items?.[0]?.reason || '未知原因'}`)
}
await getTableData()
}
} catch (error) {
console.error('清除关联失败:', error)
}
})
.catch(() => {
// 用户取消
})
}
// 查询流量使用
const showFlowUsageDialog = async (iccid: string) => {
flowUsageDialogVisible.value = true