fix(operator): fix operator edit issue
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m51s

This commit is contained in:
sexygoat
2026-04-10 14:00:21 +08:00
parent 9a6f085cde
commit 2b3119c549
53 changed files with 547 additions and 418 deletions

View File

@@ -40,6 +40,7 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRoute } from 'vue-router'
import { ElCard, ElInput, ElButton } from 'element-plus'
import { Search, Refresh } from '@element-plus/icons-vue'
import { useAssetFormatters } from '../composables/useAssetFormatters'
@@ -47,6 +48,8 @@
// Use formatters
const { formatIccidWithDashes } = useAssetFormatters()
const route = useRoute()
// Props
interface Props {
hasCardInfo?: boolean
@@ -66,6 +69,26 @@
const searchIccid = ref('')
const iccidInputFocused = ref(false)
// 从URL参数中获取初始值
const initializeFromQuery = () => {
const iccid = route.query.iccid as string
const virtualNo = route.query.virtual_no as string
const deviceNo = route.query.device_no as string
const identifier = iccid || virtualNo || deviceNo
if (identifier) {
searchIccid.value = identifier
}
}
// 初始化时从URL参数加载
initializeFromQuery()
// 暴露方法供父组件调用,用于更新搜索框值
const updateSearchValue = (value: string) => {
searchIccid.value = value
}
// Methods
const handleSearch = () => {
if (!searchIccid.value.trim()) {
@@ -77,6 +100,11 @@
const handleRefresh = () => {
emit('refresh')
}
// 暴露给父组件
defineExpose({
updateSearchValue
})
</script>
<style scoped lang="scss">

View File

@@ -477,9 +477,10 @@
(e: 'resetDevice'): void
(e: 'showSpeedLimit'): void
(e: 'showSwitchCard'): void
(e: 'showSetWiFi'): void
(e: 'show-set-wifi'): void
(e: 'enableBindingCard', payload: { card: BindingCard }): void
(e: 'disableBindingCard', payload: { card: BindingCard }): void
(e: 'navigateToCard', iccid: string): void
}
const emit = defineEmits<Emits>()
@@ -528,8 +529,8 @@
// 跳转到卡片信息
const handleNavigateToCardInfo = (iccid: string) => {
// 可以通过路由跳转或触发搜索
console.log('Navigate to card:', iccid)
// 触发搜索事件,让父组件处理
emit('navigateToCard', iccid)
}
// 卡操作
@@ -559,7 +560,7 @@
}
const handleShowSetWiFi = () => {
emit('showSetWiFi')
emit('show-set-wifi')
}
// 绑定卡操作

View File

@@ -69,27 +69,27 @@
.wallet-balance-cards {
display: flex;
flex-direction: column;
gap: 8px;
gap: 12px;
.balance-card {
display: flex;
gap: 10px;
gap: 14px;
align-items: center;
padding: 10px 14px;
padding: 16px 18px;
background: var(--el-fill-color-light);
border: 1px solid var(--el-border-color-lighter);
border-radius: 4px;
border-radius: 6px;
transition: all 0.3s ease;
&:hover {
border-color: var(--el-color-primary);
box-shadow: 0 2px 6px rgb(0 0 0 / 6%);
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
transform: translateX(2px);
}
.balance-icon {
flex-shrink: 0;
font-size: 20px;
font-size: 26px;
line-height: 1;
}
@@ -97,16 +97,18 @@
display: flex;
flex: 1;
flex-direction: column;
gap: 2px;
gap: 4px;
.balance-label {
font-size: 12px;
font-size: 11px;
font-weight: 500;
color: var(--el-text-color-secondary);
}
.balance-value {
font-size: 18px;
font-size: 20px;
font-weight: 600;
line-height: 1.2;
color: var(--el-text-color-primary);
}
}

View File

@@ -25,10 +25,9 @@
start-placeholder="开始时间"
end-placeholder="结束时间"
style="width: 360px"
@change="handleDateChange"
/>
<ElButton type="primary" @click="handleFilterChange">查询</ElButton>
<ElButton @click="handleResetFilter">重置</ElButton>
<ElButton type="primary" @click="handleQuery">查询</ElButton>
<ElButton @click="handleReset">重置</ElButton>
</div>
</div>
</template>
@@ -194,28 +193,26 @@
}
}
// 处理日期范围变化
const handleDateChange = (value: [Date, Date] | null) => {
if (value && value.length === 2) {
// 转换为 RFC3339 格式
queryParams.value.start_time = value[0].toISOString()
queryParams.value.end_time = value[1].toISOString()
// 处理查询按钮点击
const handleQuery = () => {
queryParams.value.page = 1
pagination.value.page = 1
queryParams.value.transaction_type = filterForm.value.transaction_type
// 处理日期范围
if (filterForm.value.date_range && filterForm.value.date_range.length === 2) {
queryParams.value.start_time = filterForm.value.date_range[0].toISOString()
queryParams.value.end_time = filterForm.value.date_range[1].toISOString()
} else {
queryParams.value.start_time = null
queryParams.value.end_time = null
}
}
// 处理筛选条件变化
const handleFilterChange = () => {
queryParams.value.page = 1
pagination.value.page = 1
queryParams.value.transaction_type = filterForm.value.transaction_type
loadTransactions()
}
// 重置筛选条件
const handleResetFilter = () => {
// 处理重置按钮点击
const handleReset = () => {
filterForm.value = {
transaction_type: null,
date_range: null
@@ -254,7 +251,7 @@
(newVal) => {
if (newVal) {
// 重置状态
handleResetFilter()
handleReset()
}
},
{ immediate: true }

View File

@@ -144,7 +144,7 @@
}
} catch (error) {
console.error('加载流量详单失败:', error)
ElMessage.error('加载流量详单失败')
console.log('加载流量详单失败')
} finally {
loading.value = false
}

View File

@@ -194,7 +194,7 @@
}
} catch (error: any) {
console.error('加载往期订单失败:', error)
ElMessage.error(error?.message || '加载往期订单失败')
console.log(error?.message || '加载往期订单失败')
} finally {
loading.value = false
}

View File

@@ -141,7 +141,7 @@
}
} catch (error: any) {
console.error('加载套餐列表失败:', error)
ElMessage.error(error?.message || '加载套餐列表失败')
console.log(error?.message || '加载套餐列表失败')
} finally {
packageSearchLoading.value = false
}

View File

@@ -138,7 +138,7 @@
}
} catch (error) {
console.error('加载设备绑定卡列表失败:', error)
ElMessage.error('加载卡列表失败')
console.log('加载卡列表失败')
} finally {
loading.value = false
}

View File

@@ -1,5 +1,5 @@
<template>
<ElDialog v-model="visible" title="设置WiFi" width="500px">
<ElDialog v-model="visible" title="设置WiFi" width="500px" :append-to-body="true">
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
<ElFormItem label="WiFi状态" prop="enabled">
<ElRadioGroup v-model="form.enabled">

View File

@@ -6,7 +6,7 @@
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { AssetService } from '@/api/modules'
import type { AssetWalletResponse } from '@/types/api'
import type { AssetWalletResponse, DeviceGatewayInfo, AssetPackageUsageRecord } from '@/types/api'
/**
* 格式化数据大小(MB -> GB/MB)
@@ -22,11 +22,11 @@ export function useAssetInfo() {
// 状态管理
const loading = ref(false)
const cardInfo = ref<any>(null) // 使用 any 以保持与原始实现一致
const deviceRealtime = ref<DeviceRealtimeInfo | null>(null)
const currentPackage = ref<PackageInfo | null>(null)
const deviceRealtime = ref<DeviceGatewayInfo | null>(null)
const currentPackage = ref<AssetPackageUsageRecord | null>(null)
const currentPackageLoading = ref(false)
const currentPackageErrorMsg = ref('')
const packageList = ref<PackageInfo[]>([])
const packageList = ref<AssetPackageUsageRecord[]>([])
const walletInfo = ref<AssetWalletResponse | null>(null)
const walletLoading = ref(false)
@@ -111,7 +111,7 @@ export function useAssetInfo() {
const assetIdentifier = data.asset_type === 'card' ? data.iccid : data.virtual_no
if (assetIdentifier) {
// 并行调用多个接口: 当前生效套餐、套餐列表、实时状态、钱包概况
Promise.all([
await Promise.all([
loadCurrentPackage(assetIdentifier),
loadPackageList(assetIdentifier),
loadRealtimeStatus(assetIdentifier, data.asset_type),
@@ -319,11 +319,9 @@ export function useAssetInfo() {
await loadRealtimeStatus(identifier, assetType)
}
} catch (error: any) {
// 检查429错误(冷却期)
// 检查 429 错误(冷却期)
if (error?.response?.status === 429) {
ElMessage.warning('刷新过于频繁,请稍后再试')
} else {
ElMessage.error(error?.message || '刷新失败')
}
throw error
}

View File

@@ -101,7 +101,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
} catch (error: any) {
if (error !== 'cancel') {
console.error('手动停用失败:', error)
ElMessage.error(error?.message || '手动停用失败')
console.log(error?.message || '手动停用失败')
}
} finally {
manualDeactivateCardLoading.value = false
@@ -186,7 +186,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
}
} catch (error: any) {
console.error('设置限速失败:', error)
ElMessage.error(error?.message || '设置失败')
console.log(error?.message || '设置失败')
return false
} finally {
speedLimitLoading.value = false
@@ -214,7 +214,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
}
} catch (error: any) {
console.error('切换SIM卡失败:', error)
ElMessage.error(error?.message || '切换失败')
console.log(error?.message || '切换失败')
return false
} finally {
switchCardLoading.value = false
@@ -244,7 +244,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
}
} catch (error: any) {
console.error('设置WiFi失败:', error)
ElMessage.error(error?.message || '设置WiFi失败')
console.log(error?.message || '设置WiFi失败')
return false
} finally {
setWiFiLoading.value = false
@@ -282,7 +282,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
}
} catch (error: any) {
console.error('更新轮询状态失败:', error)
ElMessage.error(error?.message || '更新轮询状态失败')
console.log(error?.message || '更新轮询状态失败')
return false
} finally {
pollingLoading.value = false

View File

@@ -1,7 +1,12 @@
<template>
<div class="single-card-page">
<!-- 资产查询区域 -->
<AssetSearchCard :has-card-info="!!cardInfo" @search="handleSearch" @refresh="handleRefresh" />
<AssetSearchCard
ref="assetSearchCardRef"
:has-card-info="!!cardInfo"
@search="handleSearch"
@refresh="handleRefresh"
/>
<!-- 卡片内容区域 -->
<div v-if="cardInfo" class="card-content-area slide-in">
@@ -21,6 +26,7 @@
@show-set-wifi="showSetWiFiDialog"
@enable-binding-card="handleEnableBindingCard"
@disable-binding-card="handleDisableBindingCard"
@navigate-to-card="handleNavigateToCard"
/>
</div>
@@ -120,6 +126,9 @@
const route = useRoute()
// ========== 组件引用 ==========
const assetSearchCardRef = ref<InstanceType<typeof AssetSearchCard>>()
// ========== 核心数据状态(使用 composable ==========
const {
cardInfo,
@@ -174,16 +183,11 @@
* 处理资产搜索
*/
const handleSearch = async ({ identifier }: { identifier: string }) => {
// 更新搜索框的值
assetSearchCardRef.value?.updateSearchValue(identifier)
// fetchAssetDetail 内部已经会并行加载所有相关数据,不需要重复调用
await fetchAssetDetail(identifier)
if (cardInfo.value) {
// 并行加载相关数据
await Promise.all([
loadPackageList(cardInfo.value.identifier),
loadCurrentPackage(cardInfo.value.identifier),
loadRealtimeStatus(cardInfo.value.identifier, cardInfo.value.asset_type),
loadAssetWallet(cardInfo.value.identifier)
])
}
}
/**
@@ -269,19 +273,35 @@
/**
* 绑定卡操作 - 启用绑定卡
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleEnableBindingCard = async (_card: any) => {
// TODO: 实现启用绑定卡逻辑
ElMessage.info('启用绑定卡功能待实现')
const handleEnableBindingCard = async (payload: { card: any }) => {
const { card } = payload
try {
const { CardService } = await import('@/api/modules')
await CardService.enableIotCard(card.iccid)
ElMessage.success('启用成功')
// 刷新资产信息
await handleRefresh()
} catch (error: any) {
console.error('启用绑定卡失败:', error)
ElMessage.error(error?.message || '启用失败')
}
}
/**
* 绑定卡操作 - 停用绑定卡
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleDisableBindingCard = async (_card: any) => {
// TODO: 实现停用绑定卡逻辑
ElMessage.info('停用绑定卡功能待实现')
const handleDisableBindingCard = async (payload: { card: any }) => {
const { card } = payload
try {
const { CardService } = await import('@/api/modules')
await CardService.disableIotCard(card.iccid)
ElMessage.success('停用成功')
// 刷新资产信息
await handleRefresh()
} catch (error: any) {
console.error('停用绑定卡失败:', error)
ElMessage.error(error?.message || '停用失败')
}
}
/**
@@ -314,6 +334,13 @@
dailyRecordsDialogVisible.value = true
}
/**
* 跳转到绑定卡信息
*/
const handleNavigateToCard = async (iccid: string) => {
await handleSearch({ identifier: iccid })
}
/**
* URL参数自动加载
*/

View File

@@ -583,7 +583,7 @@
getEnterpriseInfo()
getTableData()
} else {
ElMessage.error('缺少企业ID')
console.log('缺少企业ID')
goBack()
}
})
@@ -631,7 +631,7 @@
}
} catch (error) {
console.error(error)
ElMessage.error('获取企业卡列表失败')
console.log('获取企业卡列表失败')
} finally {
loading.value = false
}
@@ -811,7 +811,7 @@
}
} catch (error) {
console.error(error)
ElMessage.error('获取卡列表失败')
console.log('获取卡列表失败')
} finally {
availableCardsLoading.value = false
}
@@ -889,7 +889,7 @@
}
} catch (error) {
console.error(error)
ElMessage.error('授权失败')
console.log('授权失败')
} finally {
allocateLoading.value = false
}
@@ -939,7 +939,7 @@
}
} catch (error) {
console.error(error)
ElMessage.error('回收失败')
console.log('回收失败')
} finally {
recallLoading.value = false
}
@@ -1023,7 +1023,7 @@
getTableData()
} catch (error) {
console.error(error)
ElMessage.error('停机失败')
console.log('停机失败')
}
})
.catch(() => {})
@@ -1043,7 +1043,7 @@
getTableData()
} catch (error) {
console.error(error)
ElMessage.error('复机失败')
console.log('复机失败')
}
})
.catch(() => {})

View File

@@ -157,11 +157,7 @@
</ElDialog>
<!-- 结果对话框 -->
<ElDialog
v-model="resultDialogVisible"
title="操作结果"
width="700px"
>
<ElDialog v-model="resultDialogVisible" title="操作结果" width="700px">
<ElDescriptions :column="2" border>
<ElDescriptionsItem label="成功数量">
<ElTag type="success">{{ operationResult.success_count }}</ElTag>
@@ -178,11 +174,7 @@
>
<ElDivider content-position="left">失败项</ElDivider>
<ElTable :data="operationResult.failed_items" border max-height="300">
<ElTableColumn
prop="virtual_no"
label="设备号"
width="180"
/>
<ElTableColumn prop="virtual_no" label="设备号" width="180" />
<ElTableColumn prop="reason" label="失败原因" />
</ElTable>
</div>
@@ -196,16 +188,8 @@
>
<ElDivider content-position="left">已授权设备</ElDivider>
<ElTable :data="operationResult.authorized_devices" border max-height="200">
<ElTableColumn
prop="virtual_no"
label="设备号"
width="180"
/>
<ElTableColumn
prop="device_id"
label="设备ID"
width="100"
/>
<ElTableColumn prop="virtual_no" label="设备号" width="180" />
<ElTableColumn prop="device_id" label="设备ID" width="100" />
<ElTableColumn label="绑定卡数">
<template #default="{ row }">
{{ row.card_count || 0 }}
@@ -756,7 +740,7 @@
}
} catch (error) {
console.error(error)
ElMessage.error('撤销授权失败')
console.logr('撤销授权失败')
} finally {
recallLoading.value = false
}

View File

@@ -63,7 +63,9 @@
<p>4. <strong>重要列顺序固定不可调整</strong>系统按位置读取不识别列名</p>
<p>5. 必填列虚拟号第1列</p>
<p
>6. 可选列设备名称设备型号设备类型IMEI制造商最大SIM槽数默认4有效范围1-4卡1~卡4 ICCID</p
>6.
可选列设备名称设备型号设备类型IMEI制造商最大SIM槽数默认4有效范围1-4卡1~卡4
ICCID</p
>
</div>
</template>
@@ -566,7 +568,7 @@
})
} catch (error: any) {
console.error('设备导入失败:', error)
ElMessage.error(error.message || '设备导入失败')
console.log(error.message || '设备导入失败')
} finally {
uploading.value = false
}

View File

@@ -775,7 +775,7 @@
})
} catch (error: any) {
console.error('IoT卡导入失败:', error)
ElMessage.error(error.message || 'IoT卡导入失败')
console.log(error.message || 'IoT卡导入失败')
} finally {
uploading.value = false
}