修改通讯设置

This commit is contained in:
jingna 2026-06-26 18:39:33 +08:00
parent 14c50ac913
commit 15e3dce02a
3 changed files with 54 additions and 37 deletions

View File

@ -130,3 +130,11 @@ export async function saveDevicePassword(payload: { password: string }): Promise
const response = await http.post<ApiResponse<{ send_status: string }>>('/config/device/password', payload)
return response.data
}
export async function saveDeviceNet(payload: any[]): Promise<any> {
const response = await http.post<ApiResponse<any>>('/config/device/net', payload)
return response.data.data
}
export async function saveDeviceUart(payload: any[]): Promise<any> {
const response = await http.post<ApiResponse<any>>('/config/device/uart', payload)
return response.data.data
}

View File

@ -87,9 +87,9 @@ onMounted(() => {
const month = (now.getMonth() + 1).toString().padStart(2, '0')
const dayOfMonth = now.getDate().toString().padStart(2, '0')
time.value = `${hours}:${minutes}:${seconds}`
date.value = `${year}-${month}-${dayOfMonth}`
day.value = weekDays[now.getDay()]
// time.value = `${hours}:${minutes}:${seconds}`
// date.value = `${year}-${month}-${dayOfMonth}`
// day.value = weekDays[now.getDay()]
// WebSocket
ws = connectTimeSync((event) => {

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { fetchDeviceNet, fetchDevicePort, getDeviceNetConfig, saveDevicePortConfig, fetchChannelConfig } from '@/api/platform'
import { fetchDeviceNet, fetchDevicePort, getDeviceNetConfig, saveDeviceNet, saveDeviceUart } from '@/api/platform'
import NumericKeyboard from '@/components/NumericKeyboard.vue'
import PasswordDialog from '@/components/passwordValie.vue'
@ -109,9 +109,10 @@ const handleKeyboardConfirm = (value: string) => {
}
keyboardVisible.value = false
}
const currentType = ref('')
//
const handleSave = () => {
const handleSave = (type: string) => {
currentType.value = type
passwordDialogVisible.value = true
}
@ -120,25 +121,33 @@ const handlePasswordConfirm = async () => {
if (isswitch.value) return
isswitch.value = true
try {
const submitData: any = {
hardware_version: netConfig.value.hardware_version,
software_version: netConfig.value.software_version,
password: netConfig.value.password,
net: [formData.value, formDataRight.value],
uart: [formData2.value, formData2Right.value]
}
const res = await saveDevicePortConfig(submitData)
if (currentType.value === 'net') {
const res = await saveDeviceNet([formData.value, formDataRight.value])
if (res.code === 200) {
ElMessage({
type: 'success',
message: '全部配置保存成功',
message: '网卡配置保存成功',
})
} else {
ElMessage({
type: 'error',
message: '全部配置保存失败',
message: '网卡配置保存失败',
})
}
} else {
const res = await saveDeviceUart([formData2.value, formData2Right.value])
if (res.code === 200) {
ElMessage({
type: 'success',
message: '串口配置保存成功',
})
} else {
ElMessage({
type: 'error',
message: '串口配置保存失败',
})
}
}
} catch (err: any) {
ElMessage({
type: 'error',
@ -181,12 +190,15 @@ onMounted(() => {
<template>
<div class="communication-container">
<el-form label-width="100px" class="form-wrapper">
<!-- 常规配置左右两栏 网卡一 / 网卡二 -->
<div class="section">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div class="section-title">
<div class="icon"></div>
<div>常规配置</div>
</div>
<el-button type="primary" @click="handleSave('net')">保存</el-button>
</div>
<el-row :gutter="40">
<el-col :span="12">
<el-form-item label="网卡号">
@ -241,10 +253,13 @@ onMounted(() => {
</el-row>
</div>
<div class="section">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div class="section-title">
<div class="icon"></div>
<div>串口设置</div>
</div>
<el-button type="primary" @click="handleSave('port')">保存</el-button>
</div>
<el-row :gutter="40">
<el-col :span="12">
<el-form-item label="串口号">
@ -323,12 +338,6 @@ onMounted(() => {
</el-row>
</div>
</el-form>
<div class="btn-wrapper">
<el-button type="primary" style="background-color: #0099ff;width: 150px;height: 40px;"
@click="handleSave">保存</el-button>
</div>
<el-dialog v-model="dialogVisible" :close-on-click-modal="false" :show-close="false" title="错误提示" width="300">
<div style="color: #FF4D4F;font-size: 16px;text-align: center;">原密码验证错误</div>
<template #footer>