From 84bc29410a945e617248616fde049abffef835eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=99=BD=E8=8F=9C?=
<43331987+JiaLiBai@users.noreply.github.com>
Date: Fri, 26 Dec 2025 20:19:20 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87:TCP?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=96=B0=E5=A2=9E=E4=BB=8E=E7=AB=99=E5=9C=B0?=
=?UTF-8?q?=E5=9D=80=20=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE:=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E6=94=BE=E7=94=B5=E7=8A=B6=E6=80=81=E3=80=81=E5=8F=AF?=
=?UTF-8?q?=E8=BE=93=E5=85=A5=E8=B4=9F=E6=95=B0=E3=80=81=E5=BC=80=E5=A7=8B?=
=?UTF-8?q?=E3=80=81=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?=E6=9B=B4=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/store/modules/ems.js | 2 +-
src/views/ems/dzjk/clpz/xftg/AddTemplate.vue | 445 ++++++++++---------
src/views/ems/site/sblb/AddDevice.vue | 365 ++++++++-------
3 files changed, 453 insertions(+), 359 deletions(-)
diff --git a/src/store/modules/ems.js b/src/store/modules/ems.js
index 2ed38ab..8ea863d 100644
--- a/src/store/modules/ems.js
+++ b/src/store/modules/ems.js
@@ -17,7 +17,7 @@ const ems = {
deviceTypeOptions: {'TCP': 'TCP', 'RTU': 'RTU'},//设备类型
ticketStatusOptions: {1: '待处理', 2: '处理中', 3: '已处理'},//工单处理状态
strategyStatusOptions: {'0': '未启用', '1': '已运行', '2': '已暂停', '3': '禁用', '4': '删除'},//策略状态
- chargeStatusOptions: {'1': '充电', '2': '待机'},//冲放状态
+ chargeStatusOptions: {'1': '充电', '2': '待机', '3': '放电'},//冲放状态
comparisonOperatorOptions: {'>': '>', '<': '<', '=': '=', '>=': '>=', '<=': '<='},
relationWithPoint: {'||': '||', '&&': '&&'}
},
diff --git a/src/views/ems/dzjk/clpz/xftg/AddTemplate.vue b/src/views/ems/dzjk/clpz/xftg/AddTemplate.vue
index 3daea59..4a5b282 100644
--- a/src/views/ems/dzjk/clpz/xftg/AddTemplate.vue
+++ b/src/views/ems/dzjk/clpz/xftg/AddTemplate.vue
@@ -1,119 +1,140 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 新增
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
- 新增
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 保存
- 取消
-
-
-
-
-
+
+
+
+
+
+ 保存
+ 取消
+
+
+
+
+
-
-
-
-
+
-
-
+
-
-
+
-
- {{chargeStatusOptions[scope.row.chargeStatus]}}
-
-
-
+ {{ chargeStatusOptions[scope.row.chargeStatus] }}
+
+
+
-
-
+
- 删除
-
-
-
-
-
- 取消
- 确定
-
-
+ 删除
+
+
+
+
+
+ 取消
+ 确定
+
+
+
\ No newline at end of file
diff --git a/src/views/ems/site/sblb/AddDevice.vue b/src/views/ems/site/sblb/AddDevice.vue
index 6f46b86..0f84776 100644
--- a/src/views/ems/site/sblb/AddDevice.vue
+++ b/src/views/ems/site/sblb/AddDevice.vue
@@ -1,12 +1,15 @@
-
+
-
+
-
+
@@ -15,27 +18,34 @@
-
+
-
+
-
+
-
+
-
-
+
+
@@ -46,7 +56,10 @@
-
+
+
+
+
@@ -60,9 +73,9 @@
-
-
-
+
+
+
@@ -82,28 +95,29 @@
import {mapState} from "vuex";
import {getAllSites} from '@/api/ems/zddt'
import {validText} from '@/utils/validate'
-import {getDeviceDetailInfo,updateDevice,addDevice,getParentDeviceId} from "@/api/ems/site";
+import {addDevice, getDeviceDetailInfo, getParentDeviceId, updateDevice} from "@/api/ems/site";
import {getAllDeviceCategory} from '@/api/ems/search'
+
export default {
- props:{
- mode:{
- type:String,
- default:"add"
+ props: {
+ mode: {
+ type: String,
+ default: "add"
},
- id:{
- type:String|Number,
- required:false
+ id: {
+ type: String | Number,
+ required: false
}
},
data() {
- const validateText=(rule, value, callback) =>{
+ const validateText = (rule, value, callback) => {
if (value !== '' && !validText(value)) {
callback(new Error('只能输入中文、英文、数字和特殊字符!'));
} else {
callback();
}
}
- const validateDeviceId=(rule, value, callback) =>{
+ const validateDeviceId = (rule, value, callback) => {
if (value !== '' && !/^[a-zA-Z0-9]+$/.test(value)) {
callback(new Error('只能输入英文和数字!'));
} else {
@@ -111,76 +125,80 @@ export default {
}
}
return {
- loading:0,
- dccDeviceCategoryList:['CLUSTER','BATTERY'],//需要展示上级设备的设备类型
- dialogTableVisible:false,
- parentDeviceList:[],//上级设备列表 从接口获取数据
- siteList:[],//站点列表 从接口获取数据
- deviceCategoryList:[],//设备类别列表 从接口获取数据
+ loading: 0,
+ dccDeviceCategoryList: ['CLUSTER', 'BATTERY'],//需要展示上级设备的设备类型
+ dialogTableVisible: false,
+ parentDeviceList: [],//上级设备列表 从接口获取数据
+ siteList: [],//站点列表 从接口获取数据
+ deviceCategoryList: [],//设备类别列表 从接口获取数据
formData: {
- id:'',//设备唯一标识
- siteId:'',//站点ID
- deviceId:'',//设备id
- deviceName:'',//设备名称
- description:'',//设备描述
- communicationStatus:'',//工作状态
- deviceType:'',//设备类型
- deviceCategory:'',//设备类别
- parentId:'',//上级设备id
- ipAddress:'',//TCP设备的ip地址
- ipPort:"",//TCP端口号
- serialPort:'',//串口路径
- baudRate:'',//波特率
- dataBits:'',//数据位
- stopBits:'',//停止位
- parity:'',//校验位
- pictureUrl:'',//设备图片
+ id: '',//设备唯一标识
+ siteId: '',//站点ID
+ deviceId: '',//设备id
+ deviceName: '',//设备名称
+ description: '',//设备描述
+ communicationStatus: '',//工作状态
+ deviceType: '',//设备类型
+ deviceCategory: '',//设备类别
+ parentId: '',//上级设备id
+ ipAddress: '',//TCP设备的ip地址
+ ipPort: "",//TCP端口号
+ serialPort: '',//串口路径
+ baudRate: '',//波特率
+ dataBits: '',//数据位
+ stopBits: '',//停止位
+ parity: '',//校验位
+ pictureUrl: '',//设备图片
+ slaveId: '',//从站地址
},
rules: {
- siteId:[
- { required: true, message: '请选择站点', trigger: ['blur','change']}
+ siteId: [
+ {required: true, message: '请选择站点', trigger: ['blur', 'change']}
],
- deviceId:[
- { required: true, message: '请输入设备id', trigger: 'blur'},
- { validator: validateDeviceId, trigger: 'blur' }
+ deviceId: [
+ {required: true, message: '请输入设备id', trigger: 'blur'},
+ {validator: validateDeviceId, trigger: 'blur'}
],
- deviceName:[
- { required: true, message: '请输入设备名称', trigger: 'blur'},
- { validator: validateText, trigger: 'blur' }
+ deviceName: [
+ {required: true, message: '请输入设备名称', trigger: 'blur'},
+ {validator: validateText, trigger: 'blur'}
],
- description:[
- { required: true, message: '请输入设备描述', trigger: 'blur'},
- { validator: validateText, trigger: 'blur' }
+ description: [
+ {required: true, message: '请输入设备描述', trigger: 'blur'},
+ {validator: validateText, trigger: 'blur'}
],
- communicationStatus:[
- { required: true, message: '请选择工作状态', trigger: ['blur','change']}
+ communicationStatus: [
+ {required: true, message: '请选择工作状态', trigger: ['blur', 'change']}
],
- deviceType:[
- { required: true, message: '请选择设备类型', trigger:['blur','change']}
+ deviceType: [
+ {required: true, message: '请选择设备类型', trigger: ['blur', 'change']}
],
- deviceCategory:[
- { required: true, message: '请选择设备类别', trigger: ['blur','change']}
+ deviceCategory: [
+ {required: true, message: '请选择设备类别', trigger: ['blur', 'change']}
],
- ipAddress:[
- { validator: validateText, trigger: 'blur' }
+ ipAddress: [
+ {validator: validateText, trigger: 'blur'}
],
- ipPort:[
- { validator: validateText, trigger: 'blur' }
+ ipPort: [
+ {validator: validateText, trigger: 'blur'}
],
- serialPort:[
- { validator: validateText, trigger: 'blur' }
+ slaveId: [
+ {validator: validateText, trigger: 'blur'}
],
- baudRate:[
- { validator: validateText, trigger: 'blur' }
+ serialPort: [
+ {validator: validateText, trigger: 'blur'}
],
- dataBits:[
- { validator: validateText, trigger: 'blur' }
+ baudRate: [
+ {validator: validateText, trigger: 'blur'}
],
- stopBits:[
- { validator: validateText, trigger: 'blur' }
+ dataBits: [
+ {validator: validateText, trigger: 'blur'}
],
- parity:[
- { validator: validateText, trigger: 'blur' }
+ stopBits: [
+ {validator: validateText, trigger: 'blur'}
+ ],
+ parity: [
+ {validator: validateText, trigger: 'blur'}
],
// pictureUrl:[
// { required: true, message: '请上传图片', trigger: ['blur', 'change']}
@@ -191,144 +209,189 @@ export default {
computed: {
...mapState({
communicationStatusOptions: state => state?.ems?.communicationStatusOptions || {},
- deviceTypeOptions:state=>state?.ems?.deviceTypeOptions || {}
+ deviceTypeOptions: state => state?.ems?.deviceTypeOptions || {}
})
},
- watch:{
- dialogTableVisible:{
- handler(newVal){
+ watch: {
+ dialogTableVisible: {
+ handler(newVal) {
//打开弹窗
- if(newVal){
+ if (newVal) {
this.getZdList()
this.getDeviceCategoryList()
}
},
immediate: true,
},
- id:{
- handler(newVal){
- if((newVal || newVal===0) && this.mode !== 'add'){
- this.loading+=1
+ id: {
+ handler(newVal) {
+ if ((newVal || newVal === 0) && this.mode !== 'add') {
+ this.loading += 1
getDeviceDetailInfo(newVal).then(response => {
this.formData = JSON.parse(JSON.stringify(response?.data || {}));
- if(this.dccDeviceCategoryList.includes(this.formData.deviceCategory)){
+ if (this.dccDeviceCategoryList.includes(this.formData.deviceCategory)) {
this.getParentDeviceList(true)
}
- }).finally(() => {this.loading-=1})
+ }).finally(() => {
+ this.loading -= 1
+ })
}
},
immediate: true,
}
},
methods: {
- changeType(){
- if(this.dccDeviceCategoryList.includes(this.formData.deviceCategory)){
+ changeType() {
+ if (this.dccDeviceCategoryList.includes(this.formData.deviceCategory)) {
this.getParentDeviceList()
}
},
- uploadImage(data){
+ uploadImage(data) {
this.formData.pictureUrl = data
},
//获取站点列表
- getZdList(){
- this.loading+=1
+ getZdList() {
+ this.loading += 1
getAllSites().then(response => {
this.siteList = response?.data || []
- }).finally(() => {this.loading-=1})
+ }).finally(() => {
+ this.loading -= 1
+ })
},
// 获取设备类别
- getDeviceCategoryList(){
- this.loading+=1
+ getDeviceCategoryList() {
+ this.loading += 1
getAllDeviceCategory().then(response => {
this.deviceCategoryList = response?.data || []
- }).finally(() => {this.loading-=1})
+ }).finally(() => {
+ this.loading -= 1
+ })
},
//获取上级id列表
- getParentDeviceList(init=false){
- if(!this.formData.siteId){
- return console.log('请先选择站点')
+ getParentDeviceList(init = false) {
+ if (!this.formData.siteId) {
+ return console.log('请先选择站点')
}
- !init && (this.formData.parentId='')
- this.loading= this.loading+1
- getParentDeviceId({siteId:this.formData.siteId,deviceCategory:this.formData.deviceCategory}).then(response => {
+ !init && (this.formData.parentId = '')
+ this.loading = this.loading + 1
+ getParentDeviceId({siteId: this.formData.siteId, deviceCategory: this.formData.deviceCategory}).then(response => {
this.parentDeviceList = JSON.parse(JSON.stringify(response?.data || []));
}).finally(() => {
- this.loading=this.loading -1
+ this.loading = this.loading - 1
})
},
saveDialog() {
this.$refs.addTempForm.validate(valid => {
if (!valid) return
- this.loading+=1
+ this.loading += 1
const {
- id='',
- siteId='',//站点ID
- deviceId='',//设备id
- deviceName='',//设备名称
- description='',//设备描述
- communicationStatus='',//工作状态
- deviceType='',//设备类型
- deviceCategory='',//设备类别
- parentId='',//上级设备id
- ipAddress='',//TCP设备的ip地址
- ipPort="",//TCP端口号
- serialPort='',//串口路径
- baudRate='',//波特率
- dataBits='',//数据位
- stopBits='',//停止位
- parity='',//校验位
- pictureUrl='',//设备图片
- }= this.formData;
- if(this.mode === 'add'){
- addDevice({siteId,deviceId,deviceName,description,communicationStatus,deviceType,deviceCategory,parentId,ipAddress,ipPort,serialPort,baudRate,dataBits,stopBits,parity,pictureUrl}).then(response => {
- if(response.code === 200){
+ id = '',
+ siteId = '',//站点ID
+ deviceId = '',//设备id
+ deviceName = '',//设备名称
+ description = '',//设备描述
+ communicationStatus = '',//工作状态
+ deviceType = '',//设备类型
+ deviceCategory = '',//设备类别
+ parentId = '',//上级设备id
+ ipAddress = '',//TCP设备的ip地址
+ ipPort = "",//TCP端口号
+ serialPort = '',//串口路径
+ baudRate = '',//波特率
+ dataBits = '',//数据位
+ stopBits = '',//停止位
+ parity = '',//校验位
+ pictureUrl = '',//设备图片
+ slaveId = '',//从站地址
+ } = this.formData;
+ if (this.mode === 'add') {
+ addDevice({
+ siteId,
+ deviceId,
+ deviceName,
+ description,
+ communicationStatus,
+ deviceType,
+ deviceCategory,
+ parentId,
+ ipAddress,
+ ipPort,
+ serialPort,
+ baudRate,
+ dataBits,
+ stopBits,
+ parity,
+ pictureUrl,
+ slaveId
+ }).then(response => {
+ if (response.code === 200) {
//新增成功
// 关闭弹窗 更新表格
this.$emit('update')
this.closeDialog()
}
}).finally(() => {
- this.loading-=1
+ this.loading -= 1
})
- }else{
- updateDevice({id,siteId,deviceId,deviceName,description,communicationStatus,deviceType,deviceCategory,parentId,ipAddress,ipPort,serialPort,baudRate,dataBits,stopBits,parity,pictureUrl}).then(response => {
- if(response.code === 200){
+ } else {
+ updateDevice({
+ id,
+ siteId,
+ deviceId,
+ deviceName,
+ description,
+ communicationStatus,
+ deviceType,
+ deviceCategory,
+ parentId,
+ ipAddress,
+ ipPort,
+ serialPort,
+ baudRate,
+ dataBits,
+ stopBits,
+ parity,
+ pictureUrl,
+ slaveId
+ }).then(response => {
+ if (response.code === 200) {
//新增成功
// 关闭弹窗 更新表格
this.$emit('update')
this.closeDialog()
}
}).finally(() => {
- this.loading-=1
+ this.loading -= 1
})
}
})
},
- closeDialog(){
+ closeDialog() {
this.$emit('clear')
// 清空所有数据
- this.formData= {
- id:'',//设备唯一标识
- siteId:'',//站点ID
- deviceId:'',//设备id
- deviceName:'',//设备名称
- description:'',//设备描述
- communicationStatus:'',//工作状态
- deviceType:'',//设备类型
- deviceCategory:'',//设备类别
- parentId:'',//上级设备id
- ipAddress:'',//TCP设备的ip地址
- ipPort:"",//TCP端口号
- serialPort:'',//串口路径
- baudRate:'',//波特率
- dataBits:'',//数据位
- stopBits:'',//停止位
- parity:'',//校验位
- pictureUrl:'',//设备图片
+ this.formData = {
+ id: '',//设备唯一标识
+ siteId: '',//站点ID
+ deviceId: '',//设备id
+ deviceName: '',//设备名称
+ description: '',//设备描述
+ communicationStatus: '',//工作状态
+ deviceType: '',//设备类型
+ deviceCategory: '',//设备类别
+ parentId: '',//上级设备id
+ ipAddress: '',//TCP设备的ip地址
+ ipPort: "",//TCP端口号
+ serialPort: '',//串口路径
+ baudRate: '',//波特率
+ dataBits: '',//数据位
+ stopBits: '',//停止位
+ parity: '',//校验位
+ pictureUrl: '',//设备图片
+ slaveId: '',//从站地址
}
this.$refs.addTempForm.resetFields()
- this.dialogTableVisible=false
+ this.dialogTableVisible = false
}
}
}