This commit is contained in:
@@ -471,12 +471,15 @@
|
||||
</div>
|
||||
|
||||
<ElDescriptions v-else-if="flowUsageData" :column="1" border>
|
||||
<ElDescriptionsItem label="已用流量">{{
|
||||
flowUsageData.usedFlow || 0
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="流量单位">{{
|
||||
flowUsageData.unit || 'MB'
|
||||
}}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="套餐总流量"
|
||||
>{{ flowUsageData.totalFlow || 0 }} MB</ElDescriptionsItem
|
||||
>
|
||||
<ElDescriptionsItem label="已用流量"
|
||||
>{{ flowUsageData.usedFlow || 0 }} MB</ElDescriptionsItem
|
||||
>
|
||||
<ElDescriptionsItem label="剩余流量"
|
||||
>{{ flowUsageData.remainFlow || 0 }} MB</ElDescriptionsItem
|
||||
>
|
||||
<ElDescriptionsItem v-if="flowUsageData.extend" label="扩展信息">{{
|
||||
flowUsageData.extend
|
||||
}}</ElDescriptionsItem>
|
||||
@@ -538,40 +541,6 @@
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<!-- 实名认证链接对话框 -->
|
||||
<ElDialog v-model="realnameLinkDialogVisible" title="实名认证链接" width="500px">
|
||||
<div v-if="realnameLinkLoading" style="text-align: center; padding: 40px">
|
||||
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
|
||||
<div style="margin-top: 16px">获取中...</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="realnameLinkData && realnameLinkData.link" style="text-align: center">
|
||||
<div style="margin-bottom: 16px">
|
||||
<img v-if="qrcodeDataURL" :src="qrcodeDataURL" alt="实名认证二维码" />
|
||||
</div>
|
||||
<ElDescriptions :column="1" border>
|
||||
<ElDescriptionsItem label="实名链接">
|
||||
<a
|
||||
:href="realnameLinkData.link"
|
||||
target="_blank"
|
||||
style="color: var(--el-color-primary)"
|
||||
>
|
||||
{{ realnameLinkData.link }}
|
||||
</a>
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem v-if="realnameLinkData.extend" label="扩展信息">{{
|
||||
realnameLinkData.extend
|
||||
}}</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton type="primary" @click="realnameLinkDialogVisible = false">关闭</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<!-- 更多操作右键菜单 -->
|
||||
<ArtMenuRight
|
||||
ref="moreMenuRef"
|
||||
@@ -595,11 +564,10 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { CardService, ShopService, PackageSeriesService } from '@/api/modules'
|
||||
import { CardService, ShopService, PackageSeriesService, AssetService } from '@/api/modules'
|
||||
import { ElMessage, ElTag, ElIcon, ElMessageBox } from 'element-plus'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import QRCode from 'qrcode'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
@@ -690,11 +658,6 @@
|
||||
const cardStatusLoading = ref(false)
|
||||
const cardStatusData = ref<any>(null)
|
||||
|
||||
const realnameLinkDialogVisible = ref(false)
|
||||
const realnameLinkLoading = ref(false)
|
||||
const realnameLinkData = ref<any>(null)
|
||||
const qrcodeDataURL = ref<string>('')
|
||||
|
||||
// 更多操作右键菜单
|
||||
const moreMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
const cardOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
@@ -712,6 +675,7 @@
|
||||
carrier_id: undefined,
|
||||
iccid: '',
|
||||
msisdn: '',
|
||||
virtual_no: '',
|
||||
is_distributed: undefined
|
||||
}
|
||||
|
||||
@@ -861,6 +825,15 @@
|
||||
placeholder: '请输入卡接入号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '虚拟号',
|
||||
prop: 'virtual_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入虚拟号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '是否已分销',
|
||||
prop: 'is_distributed',
|
||||
@@ -880,6 +853,7 @@
|
||||
const columnOptions = [
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: '卡接入号', prop: 'msisdn' },
|
||||
{ label: '虚拟号', prop: 'virtual_no' },
|
||||
{ label: '卡业务类型', prop: 'card_category' },
|
||||
{ label: '运营商', prop: 'carrier_name' },
|
||||
{ label: '店铺名称', prop: 'shop_name' },
|
||||
@@ -1010,6 +984,12 @@
|
||||
label: '卡接入号',
|
||||
width: 130
|
||||
},
|
||||
{
|
||||
prop: 'virtual_no',
|
||||
label: '虚拟号',
|
||||
width: 130,
|
||||
formatter: (row: StandaloneIotCard) => row.virtual_no || '-'
|
||||
},
|
||||
{
|
||||
prop: 'card_category',
|
||||
label: '卡业务类型',
|
||||
@@ -1569,24 +1549,17 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('iot_card:get_realname_link')) {
|
||||
items.push({
|
||||
key: 'realname-link',
|
||||
label: '获取实名链接'
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('iot_card:start_card')) {
|
||||
items.push({
|
||||
key: 'start-card',
|
||||
label: '启用卡片'
|
||||
label: '启用此卡'
|
||||
})
|
||||
}
|
||||
|
||||
if (hasAuth('iot_card:stop_card')) {
|
||||
items.push({
|
||||
key: 'stop-card',
|
||||
label: '停用卡片'
|
||||
label: '停用此卡'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1681,9 +1654,6 @@
|
||||
case 'card-status':
|
||||
showCardStatusDialog(iccid)
|
||||
break
|
||||
case 'realname-link':
|
||||
showRealnameLinkDialog(iccid)
|
||||
break
|
||||
case 'start-card':
|
||||
handleStartCard(iccid)
|
||||
break
|
||||
@@ -1700,9 +1670,16 @@
|
||||
flowUsageData.value = null
|
||||
|
||||
try {
|
||||
const res = await CardService.getGatewayFlow(iccid)
|
||||
if (res.code === 0) {
|
||||
flowUsageData.value = res.data
|
||||
// 通过 ICCID 解析获取资产信息,resolveAsset 接口已包含所有需要的数据
|
||||
const res = await AssetService.resolveAsset(iccid)
|
||||
if (res.code === 0 && res.data) {
|
||||
// 直接使用 resolveAsset 返回的流量信息
|
||||
flowUsageData.value = {
|
||||
totalFlow: res.data.package_total_mb || 0,
|
||||
usedFlow: res.data.package_used_mb || 0,
|
||||
remainFlow: res.data.package_remain_mb || 0,
|
||||
extend: res.data.extend
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.message || '查询失败')
|
||||
flowUsageDialogVisible.value = false
|
||||
@@ -1723,9 +1700,26 @@
|
||||
realnameStatusData.value = null
|
||||
|
||||
try {
|
||||
const res = await CardService.getGatewayRealname(iccid)
|
||||
if (res.code === 0) {
|
||||
realnameStatusData.value = res.data
|
||||
// 通过 ICCID 解析获取资产信息,resolveAsset 接口已包含所有需要的数据
|
||||
const res = await AssetService.resolveAsset(iccid)
|
||||
if (res.code === 0 && res.data) {
|
||||
// 直接使用 resolveAsset 返回的实名状态,real_name_status: 0未实名 1实名中 2已实名
|
||||
let statusText = '未知'
|
||||
switch (res.data.real_name_status) {
|
||||
case 0:
|
||||
statusText = '未实名'
|
||||
break
|
||||
case 1:
|
||||
statusText = '实名中'
|
||||
break
|
||||
case 2:
|
||||
statusText = '已实名'
|
||||
break
|
||||
}
|
||||
realnameStatusData.value = {
|
||||
status: statusText,
|
||||
extend: res.data.extend
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.message || '查询失败')
|
||||
realnameStatusDialogVisible.value = false
|
||||
@@ -1746,9 +1740,15 @@
|
||||
cardStatusData.value = null
|
||||
|
||||
try {
|
||||
const res = await CardService.getGatewayStatus(iccid)
|
||||
if (res.code === 0) {
|
||||
cardStatusData.value = res.data
|
||||
// 通过 ICCID 解析获取资产信息,resolveAsset 接口已包含所有需要的数据
|
||||
const res = await AssetService.resolveAsset(iccid)
|
||||
if (res.code === 0 && res.data) {
|
||||
// 直接使用 resolveAsset 返回的网络状态
|
||||
cardStatusData.value = {
|
||||
iccid: iccid,
|
||||
cardStatus: res.data.network_status === 1 ? '开机' : '停机',
|
||||
extend: res.data.extend
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res.message || '查询失败')
|
||||
cardStatusDialogVisible.value = false
|
||||
@@ -1762,36 +1762,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 获取实名认证链接
|
||||
const showRealnameLinkDialog = async (iccid: string) => {
|
||||
realnameLinkDialogVisible.value = true
|
||||
realnameLinkLoading.value = true
|
||||
realnameLinkData.value = null
|
||||
qrcodeDataURL.value = ''
|
||||
|
||||
try {
|
||||
const res = await CardService.getRealnameLink(iccid)
|
||||
if (res.code === 0 && res.data?.link) {
|
||||
realnameLinkData.value = res.data
|
||||
// 生成二维码
|
||||
qrcodeDataURL.value = await QRCode.toDataURL(res.data.link, {
|
||||
width: 200,
|
||||
margin: 1
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(res.message || '获取失败')
|
||||
realnameLinkDialogVisible.value = false
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('获取实名链接失败:', error)
|
||||
ElMessage.error(error?.message || '获取失败')
|
||||
realnameLinkDialogVisible.value = false
|
||||
} finally {
|
||||
realnameLinkLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 启用卡片(复机)
|
||||
// 启用此卡(复机)
|
||||
const handleStartCard = (iccid: string) => {
|
||||
ElMessageBox.confirm('确定要启用该卡片吗?', '确认启用', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -1800,16 +1771,14 @@
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
const res = await CardService.startCard(iccid)
|
||||
// 使用新接口:直接通过 ICCID 启用此卡
|
||||
const res = await AssetService.startCard(iccid)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('启用成功')
|
||||
getTableData()
|
||||
} else {
|
||||
ElMessage.error(res.message || '启用失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('启用卡片失败:', error)
|
||||
ElMessage.error(error?.message || '启用失败')
|
||||
console.error('启用此卡失败:', error)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -1817,7 +1786,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 停用卡片(停机)
|
||||
// 停用此卡(停机)
|
||||
const handleStopCard = (iccid: string) => {
|
||||
ElMessageBox.confirm('确定要停用该卡片吗?', '确认停用', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -1826,16 +1795,14 @@
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
const res = await CardService.stopCard(iccid)
|
||||
// 使用新接口:直接通过 ICCID 停用此卡
|
||||
const res = await AssetService.stopCard(iccid)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('停用成功')
|
||||
getTableData()
|
||||
} else {
|
||||
ElMessage.error(res.message || '停用失败')
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('停用卡片失败:', error)
|
||||
ElMessage.error(error?.message || '停用失败')
|
||||
console.error('停用此卡失败:', error)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
Reference in New Issue
Block a user