feat: 新增设备切卡模式
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m57s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m57s
This commit is contained in:
@@ -379,6 +379,7 @@
|
||||
|
||||
<!-- 设备操作按钮 -->
|
||||
<div v-else class="device-operations" style="margin-top: 16px; text-align: right">
|
||||
<ElButton type="info" @click="handleShowSwitchMode">设置切卡模式</ElButton>
|
||||
<ElButton type="primary" @click="handleRebootDevice"> 重启设备 </ElButton>
|
||||
<ElButton type="warning" @click="handleResetDevice"> 恢复出厂 </ElButton>
|
||||
<ElButton type="success" @click="handleShowSwitchCard"> 切换SIM卡 </ElButton>
|
||||
@@ -506,6 +507,7 @@
|
||||
(e: 'resetDevice'): void
|
||||
(e: 'showSpeedLimit'): void
|
||||
(e: 'showSwitchCard'): void
|
||||
(e: 'showSwitchMode'): void
|
||||
(e: 'show-set-wifi'): void
|
||||
(e: 'enableBindingCard', payload: { card: BindingCard }): void
|
||||
(e: 'disableBindingCard', payload: { card: BindingCard }): void
|
||||
@@ -600,6 +602,10 @@
|
||||
emit('showSwitchCard')
|
||||
}
|
||||
|
||||
const handleShowSwitchMode = () => {
|
||||
emit('showSwitchMode')
|
||||
}
|
||||
|
||||
const handleShowSetWiFi = () => {
|
||||
emit('show-set-wifi')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<ElDialog v-model="visible" title="设置切卡模式" width="500px">
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElFormItem label="设备标识">
|
||||
<span style="font-weight: bold; color: #409eff">{{ deviceIdentifier }}</span>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="当前模式">
|
||||
<ElTag :type="currentMode === 0 ? 'success' : 'warning'">
|
||||
{{ currentMode === 0 ? '自动切卡' : '手动切卡' }}
|
||||
</ElTag>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="切卡模式" prop="switch_mode">
|
||||
<ElRadioGroup v-model="form.switch_mode">
|
||||
<ElRadio :value="0">自动切卡</ElRadio>
|
||||
<ElRadio :value="1">手动切卡</ElRadio>
|
||||
</ElRadioGroup>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<div style="font-size: 12px; color: #909399; line-height: 1.6">
|
||||
<p>说明:</p>
|
||||
<p>• <strong>自动切卡</strong>:设备根据信号强度自动切换到最优的SIM卡</p>
|
||||
<p>• <strong>手动切卡</strong>:需要手动触发切换SIM卡操作</p>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton @click="handleCancel">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleConfirm" :loading="confirmLoading">确认设置</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElDialog, ElForm, ElFormItem, ElRadioGroup, ElRadio, ElTag } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
deviceIdentifier: string
|
||||
currentMode?: number
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'confirm', data: { switch_mode: number }): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
currentMode: 0
|
||||
})
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const confirmLoading = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
switch_mode: 0
|
||||
})
|
||||
|
||||
const rules: FormRules = {
|
||||
switch_mode: [{ required: true, message: '请选择切卡模式', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const currentMode = computed(() => props.currentMode ?? 0)
|
||||
|
||||
watch(visible, (newVal) => {
|
||||
if (newVal) {
|
||||
form.switch_mode = props.currentMode ?? 0
|
||||
}
|
||||
})
|
||||
|
||||
const handleCancel = () => {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
emit('confirm', { switch_mode: form.switch_mode })
|
||||
} catch (error) {
|
||||
console.error('表单验证失败:', error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,5 +1,6 @@
|
||||
export { default as SpeedLimitDialog } from './SpeedLimitDialog.vue'
|
||||
export { default as SwitchCardDialog } from './SwitchCardDialog.vue'
|
||||
export { default as SwitchModeDialog } from './SwitchModeDialog.vue'
|
||||
export { default as WiFiConfigDialog } from './WiFiConfigDialog.vue'
|
||||
export { default as PackageRechargeDialog } from './PackageRechargeDialog.vue'
|
||||
export { default as DailyRecordsDialog } from './DailyRecordsDialog.vue'
|
||||
|
||||
Reference in New Issue
Block a user