fix(operator): fix operator edit issue
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m51s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m51s
This commit is contained in:
@@ -1,56 +1,49 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="切换SIM卡" width="600px">
|
||||
<div v-if="loading" style="padding: 40px; text-align: center">
|
||||
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
|
||||
<div style="margin-top: 16px">加载设备绑定的卡列表中...</div>
|
||||
</div>
|
||||
<ElAlert
|
||||
v-if="bindingCards.length === 0"
|
||||
title="该设备暂无绑定的SIM卡"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
style="margin-bottom: 20px"
|
||||
>
|
||||
<template #default>
|
||||
<div>当前设备没有绑定任何SIM卡,无法进行切换操作。</div>
|
||||
<div>请先为设备绑定SIM卡后再进行切换。</div>
|
||||
</template>
|
||||
</ElAlert>
|
||||
|
||||
<template v-else>
|
||||
<ElAlert
|
||||
v-if="bindingCards.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="bindingCards.length > 0"
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
>
|
||||
<ElFormItem label="目标ICCID" prop="target_iccid">
|
||||
<ElSelect
|
||||
v-model="form.target_iccid"
|
||||
placeholder="请选择要切换到的目标ICCID"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
<ElForm
|
||||
v-if="bindingCards.length > 0"
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
>
|
||||
<ElFormItem label="目标ICCID" prop="target_iccid">
|
||||
<ElSelect
|
||||
v-model="form.target_iccid"
|
||||
placeholder="请选择要切换到的目标ICCID"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="card in bindingCards"
|
||||
:key="card.iccid"
|
||||
:label="`${card.iccid} - 插槽${card.slot_position} - ${card.carrier_name || '-'}`"
|
||||
:value="card.iccid"
|
||||
>
|
||||
<ElOption
|
||||
v-for="card in bindingCards"
|
||||
:key="card.iccid"
|
||||
:label="`${card.iccid} - 插槽${card.slot_position} - ${card.carrier_name}`"
|
||||
:value="card.iccid"
|
||||
>
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<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">
|
||||
当前设备共绑定 {{ bindingCards.length }} 张SIM卡
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</template>
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<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">
|
||||
当前设备共绑定 {{ bindingCards.length }} 张SIM卡
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton @click="handleCancel">取消</ElButton>
|
||||
@@ -76,17 +69,20 @@
|
||||
ElOption,
|
||||
ElButton,
|
||||
ElAlert,
|
||||
ElIcon,
|
||||
ElTag,
|
||||
ElMessage
|
||||
ElTag
|
||||
} from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import { DeviceService } from '@/api/modules'
|
||||
|
||||
interface BindingCard {
|
||||
iccid: string
|
||||
slot_position?: number
|
||||
carrier_name?: string
|
||||
is_current?: boolean
|
||||
}
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
deviceId: number
|
||||
cards?: BindingCard[]
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
@@ -94,17 +90,15 @@
|
||||
(e: 'confirm', data: { target_iccid: string }): void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
cards: () => []
|
||||
})
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const confirmLoading = ref(false)
|
||||
const bindingCards = ref<any[]>([])
|
||||
|
||||
const form = reactive({
|
||||
target_iccid: ''
|
||||
})
|
||||
const form = reactive({ target_iccid: '' })
|
||||
|
||||
const rules: FormRules = {
|
||||
target_iccid: [{ required: true, message: '请选择目标ICCID', trigger: 'change' }]
|
||||
@@ -115,47 +109,24 @@
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
// 监听对话框打开,加载绑定卡列表
|
||||
watch(visible, async (newVal) => {
|
||||
const bindingCards = computed(() => props.cards || [])
|
||||
|
||||
// 打开时重置选中
|
||||
watch(visible, (newVal) => {
|
||||
if (newVal) {
|
||||
form.target_iccid = ''
|
||||
bindingCards.value = []
|
||||
await loadDeviceCards()
|
||||
}
|
||||
})
|
||||
|
||||
const loadDeviceCards = async () => {
|
||||
if (!props.deviceId) return
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await DeviceService.getDeviceCards(props.deviceId)
|
||||
if (res.code === 0 && res.data) {
|
||||
bindingCards.value = res.data.bindings || []
|
||||
if (bindingCards.value.length === 0) {
|
||||
ElMessage.warning('该设备暂无绑定的SIM卡')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载设备绑定卡列表失败:', error)
|
||||
console.log('加载卡列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
emit('confirm', {
|
||||
target_iccid: form.target_iccid
|
||||
})
|
||||
emit('confirm', { target_iccid: form.target_iccid })
|
||||
} catch (error) {
|
||||
console.error('表单验证失败:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user