This commit is contained in:
朱文强 2023-12-20 14:29:26 +08:00
parent fdaf4f84aa
commit 572f72c213
4 changed files with 239 additions and 4 deletions

96
src/views/common/HJ.vue Normal file
View File

@ -0,0 +1,96 @@
<!--
* @Author: zwq
* @Date: 2023-12-20 14:20:16
* @LastEditors: zwq
* @LastEditTime: 2023-12-20 14:21:39
* @Description:
-->
<template>
<el-dialog
title="更新HJ212配置"
:close-on-click-modal="false"
:visible.sync="visible"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px"
>
<el-form-item label="port" prop="port">
<el-input v-model="dataForm.port" placeholder="port" clearable />
</el-form-item>
<el-form-item label="isstart" prop="isstart">
<el-switch v-model="dataForm.isstart"> </el-switch>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: '',
port: '',
isstart: ''
},
dataRule: {
port: [{ required: true, message: '端口不能为空', trigger: 'blur' }],
isstart: [
{ required: true, message: 'isstart不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.$http({
url: this.$http.adornUrl('api/server/main-config/getHJ212Config'),
method: 'post'
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataForm = data.data
}
})
})
},
//
dataFormSubmit () {
this.$refs['dataForm'].validate(valid => {
if (valid) {
this.$http({
url: this.$http.adornUrl('api/server/main-config/updateMqConfig'),
method: 'post',
data: this.$http.adornData(this.dataForm)
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>

View File

@ -68,7 +68,7 @@ export default {
{ required: true, message: 'isstart不能为空', trigger: 'blur' } { required: true, message: 'isstart不能为空', trigger: 'blur' }
], ],
virtualhost: [ virtualhost: [
{ required: true, message: 'isstart不能为空', trigger: 'blur' } { required: true, message: 'virtualhost不能为空', trigger: 'blur' }
] ]
} }
} }

101
src/views/common/MQTT.vue Normal file
View File

@ -0,0 +1,101 @@
<template>
<el-dialog
title="更新MQTT配置"
:close-on-click-modal="false"
:visible.sync="visible"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px"
>
<el-form-item label="port" prop="port">
<el-input v-model="dataForm.port" placeholder="port" clearable />
</el-form-item>
<el-form-item label="host" prop="host">
<el-input v-model="dataForm.host" placeholder="host" clearable />
</el-form-item>
<el-form-item label="isstart" prop="isstart">
<el-switch v-model="dataForm.isstart"> </el-switch>
</el-form-item>
<el-form-item label="topic" prop="virtualhost">
<el-input v-model="dataForm.virtualhost" placeholder="" clearable />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: '',
port: '',
host: '',
isstart: '',
virtualhost: ''
},
dataRule: {
port: [{ required: true, message: '端口不能为空', trigger: 'blur' }],
host: [{ required: true, message: 'IP不能为空', trigger: 'blur' }],
isstart: [
{ required: true, message: 'isstart不能为空', trigger: 'blur' }
],
virtualhost: [
{ required: true, message: 'topic不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.$http({
url: this.$http.adornUrl('api/server/main-config/getMQTTConfig'),
method: 'post'
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataForm = data.data
}
})
})
},
//
dataFormSubmit () {
this.$refs['dataForm'].validate(valid => {
if (valid) {
this.$http({
url: this.$http.adornUrl('api/server/main-config/updateMqConfig'),
method: 'post',
data: this.$http.adornData(this.dataForm)
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>

View File

@ -2,7 +2,7 @@
* @Author: zwq * @Author: zwq
* @Date: 2023-11-21 09:51:45 * @Date: 2023-11-21 09:51:45
* @LastEditors: zwq * @LastEditors: zwq
* @LastEditTime: 2023-11-23 15:22:37 * @LastEditTime: 2023-12-20 14:24:28
* @Description: * @Description:
--> -->
<template> <template>
@ -21,9 +21,15 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button type="primary" @click="addOrUpdateHandle()" <el-button type="primary" @click="addOrUpdateMQ()"
>更新MQ配置</el-button >更新MQ配置</el-button
> >
<el-button type="primary" @click="addOrUpdateHJ()"
>更新HJ212配置</el-button
>
<el-button type="primary" @click="addOrUpdateMQTT()"
>更新MQTT配置</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table
@ -165,6 +171,18 @@
ref="addOrUpdate" ref="addOrUpdate"
@refreshDataList="getDataList" @refreshDataList="getDataList"
></add-or-update> ></add-or-update>
<!-- MQTT -->
<MQTT
v-if="MQTTVisible"
ref="MQTTRef"
@refreshDataList="getDataList"
></MQTT>
<!-- HJ -->
<HJ
v-if="HJVisible"
ref="HJRef"
@refreshDataList="getDataList"
></HJ>
<!-- PLC --> <!-- PLC -->
<plc-create <plc-create
v-if="plcCreate" v-if="plcCreate"
@ -182,6 +200,8 @@
<script> <script>
import AddOrUpdate from './MQ' import AddOrUpdate from './MQ'
import MQTT from './MQTT'
import HJ from './HJ'
import plcCreate from './plc-create' import plcCreate from './plc-create'
import Parameter from './parameter' import Parameter from './parameter'
export default { export default {
@ -196,12 +216,16 @@ export default {
totalPage: 0, totalPage: 0,
dataListLoading: false, dataListLoading: false,
addOrUpdateVisible: false, addOrUpdateVisible: false,
HJVisible: false,
MQTTVisible: false,
plcCreate: false, plcCreate: false,
parameter: false parameter: false
} }
}, },
components: { components: {
AddOrUpdate, AddOrUpdate,
MQTT,
HJ,
plcCreate, plcCreate,
Parameter Parameter
}, },
@ -243,12 +267,26 @@ export default {
this.getDataList() this.getDataList()
}, },
// MQ // MQ
addOrUpdateHandle () { addOrUpdateMQ () {
this.addOrUpdateVisible = true this.addOrUpdateVisible = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init() this.$refs.addOrUpdate.init()
}) })
}, },
// HJ
addOrUpdateHJ () {
this.HJVisible = true
this.$nextTick(() => {
this.$refs.HJRef.init()
})
},
// MQTT
addOrUpdateMQTT () {
this.MQTTVisible = true
this.$nextTick(() => {
this.$refs.MQTTRef.init()
})
},
Edit (id, type) { Edit (id, type) {
this.plcCreate = true this.plcCreate = true
this.$nextTick(() => { this.$nextTick(() => {