499 lines
19 KiB
Vue
499 lines
19 KiB
Vue
<!-- 斥候的通道配置 -->
|
||
<template>
|
||
<div>
|
||
<!-- 设置树形控件 -->
|
||
<div v-click-outside="closeMenu">
|
||
<el-button type="info" plain @click="dialogVisible = true">斥候通道配置</el-button>
|
||
<div class="tree_menu" v-show="dialogVisible">
|
||
<el-tree :data="datas" :props="defaultProps" @node-contextmenu="rightClick"
|
||
@node-click="treeNodeClick"></el-tree>
|
||
<!-- 树形控件右键组件 -->
|
||
<div v-show="menuShow" class="tree_rightmenu" :style="{ ...rightMenu }">
|
||
|
||
<el-menu class="el-menu-vertical-demo" @select="selectMenuNode" default-active="#0078FE">
|
||
|
||
<el-menu-item id="menuitem" index="1" style="font-size: 12px;">
|
||
<span slot="title">新建通道</span>
|
||
</el-menu-item>
|
||
<el-menu-item index="2" style="font-size: 12px;">
|
||
<span slot="title">取 消</span>
|
||
</el-menu-item>
|
||
</el-menu>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="pas_params">
|
||
<el-dialog title="通道参数设置" :visible.sync="add_passage" width="902px">
|
||
<el-form :label-position="labelPosition" :rules="rules" ref="ruleForm">
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="设备名称:" :label-width="formLabelWidth" prop="device_name">
|
||
<el-select v-model="value1" placeholder="" style="width: 200px;height:30px">
|
||
<el-option v-for="item in options1" :key="item.value" :label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="控制器协议:" :label-width="formLabelWidth" prop="drive_name">
|
||
<el-row>
|
||
<el-col :span="18">
|
||
<el-input v-model="input1" placeholder="" style="width: 200px;height:30px"
|
||
disabled></el-input>
|
||
</el-col>
|
||
<el-col :span="6">
|
||
<el-button style="width: 50px; height: 30px;" @click="getDriveName">...</el-button>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="IP地址:" :label-width="formLabelWidth" prop="ip_address">
|
||
<el-row>
|
||
<el-col :span="5">
|
||
<el-input v-model="input1" style="width: 43px;height:30px"></el-input>
|
||
</el-col>
|
||
<el-col :span="1">.
|
||
</el-col>
|
||
<el-col :span="5">
|
||
<el-input v-model="input1" style="width: 43px;height:30px"></el-input>
|
||
</el-col>
|
||
<el-col :span="1">.</el-col>
|
||
<el-col :span="5">
|
||
<el-input v-model="input1" style="width: 43px;height:30px"></el-input>
|
||
</el-col>
|
||
<el-col :span="1">.</el-col>
|
||
<el-col :span="5">
|
||
<el-input v-model="input1" style="width: 43px;height:30px"></el-input>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="端口号:" :label-width="formLabelWidth" prop="port_number">
|
||
<el-input v-model="input1" placeholder="" style="width: 200px;height:30px"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="从站地址:" :label-width="formLabelWidth" prop="time_exceeded">
|
||
<el-input v-model="input1" placeholder="" style="width: 200px;height:30px"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="轮询周期(ms):" :label-width="formLabelWidth" prop="port_number">
|
||
<el-input v-model="input1" placeholder="" style="width: 200px;height:30px"></el-input>
|
||
<div class="infos">1-3600</div>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<div class="super_parmams">
|
||
<h3>高级参数</h3>
|
||
<div>
|
||
<i class="el-icon-caret-bottom" v-if="is_retract"></i>
|
||
<i class="el-icon-caret-top" v-else="is_retract"></i>
|
||
<el-button type="text" plain @click="getRetract" style="width: 28px;
|
||
color: rgba(16, 16, 16, 1);font-size: 14px;text-align: left; border: none;">
|
||
收起</el-button>
|
||
</div>
|
||
</div>
|
||
<el-divider></el-divider>
|
||
<div class="super_con" v-show="is_retract">
|
||
<el-form :label-position="labelPosition" :rules="rules" ref="ruleForm">
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="启用毫秒采集:" :label-width="formLabelWidth" prop="port_number">
|
||
<el-switch v-model="val1"></el-switch>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="启用批量采集:" :label-width="formLabelWidth" prop="port_number">
|
||
<el-switch v-model="val2"></el-switch>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="最大批量采集数:" label-width="126px" prop="port_number">
|
||
<el-input v-model="input1" placeholder="64" style="width: 200px;height:30px"></el-input>
|
||
<div class="infos">2-125</div>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="采集超过时间(ms):" label-width="140px" prop="port_number">
|
||
<el-input v-model="input1" placeholder="64" style="width: 200px;height:30px"></el-input>
|
||
<div class="infos">2-60000</div>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="周期上报OnChange数据:" label-width="186px" prop="port_number">
|
||
<el-switch v-model="val3"></el-switch>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="通讯事件间隔(ms):" label-width="140px" prop="port_number">
|
||
<el-input v-model="input1" placeholder="64" style="width: 200px;height:30px"></el-input>
|
||
<div class="infos">0-1000</div>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<div class="footer_con">
|
||
<el-row>
|
||
<el-col :span="12">
|
||
<el-form-item label="线圈寄存器写入功能码:" label-width="120px" style="line-height: 20px;">
|
||
<el-select v-model="value" placeholder="" style="width: 200px;height:30px">
|
||
<el-option v-for="item in options2" :key="item.value" :label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="线圈寄存器写入功能码:" label-width="120px">
|
||
<el-select v-model="value" placeholder="" style="width: 200px;height:30px">
|
||
<el-option v-for="item in options3" :key="item.value" :label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
<span slot="footer" class="dialog-footer">
|
||
<el-button type="primary" @click="add_passage = false">保 存</el-button>
|
||
<el-button @click="add_passage = false">取 消</el-button>
|
||
</span>
|
||
</el-dialog>
|
||
</div>
|
||
<div class="drvieName_All">
|
||
<el-dialog title="提示" :visible.sync="diag_drive" width="435px">
|
||
<el-tree :data="datas" :props="defaultProps"></el-tree>
|
||
</el-dialog>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
name: 'ChiDevice',
|
||
|
||
data() {
|
||
return {
|
||
val1: false,
|
||
val2: true,
|
||
val3: false,
|
||
diag_drive: false,
|
||
options1: [{
|
||
value: '有线区精雕2',
|
||
label: '有线区精雕2'
|
||
}, {
|
||
value: '无线区精雕2',
|
||
label: '无线区精雕2'
|
||
}],
|
||
options2: [{
|
||
value: "05(默认)",
|
||
label: "05(默认)",
|
||
}],
|
||
options3: [{
|
||
value: "06(默认)",
|
||
label: "06(默认)"
|
||
}],
|
||
value1: '有线区精雕2',
|
||
isdisabled: true,
|
||
radio: "1",
|
||
checked1: false,
|
||
checked2: true,
|
||
is_retract: true,
|
||
labelPosition: "left",
|
||
formLabelWidth: "116px",
|
||
input1: 192,
|
||
add_passage: false,
|
||
rightMenu: "",
|
||
dialogVisible: false,
|
||
menuShow: false,
|
||
datas: [{
|
||
label: 'Gateway',
|
||
children: [{
|
||
label: '数据采集',
|
||
children: [{
|
||
label: 'I/O点'
|
||
},
|
||
{
|
||
label: '用户点',
|
||
},
|
||
{
|
||
label: '计算点',
|
||
},
|
||
{
|
||
label: '系统点',
|
||
},
|
||
]
|
||
},
|
||
{
|
||
label: "上云服务",
|
||
children: [
|
||
{
|
||
label: "标准 MQTT"
|
||
},
|
||
{
|
||
label: "AWS loT"
|
||
}]
|
||
}]
|
||
}],
|
||
defaultProps: {
|
||
children: 'children',
|
||
label: 'label'
|
||
},
|
||
rules: {
|
||
device_name: [
|
||
{ required: true, message: '请输入通道名称', trigger: 'blur' },
|
||
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
|
||
],
|
||
passage: [
|
||
{ required: true, message: '请输入通道', trigger: 'blur' },
|
||
],
|
||
drive_name: [
|
||
{ required: true, message: '请输入驱动名称', trigger: 'blur' },
|
||
],
|
||
ip_address: [
|
||
{ required: true, message: '请输入ip地址', trigger: 'blur' },
|
||
],
|
||
port_number: [
|
||
{ required: true, message: '请输入端口号', trigger: 'blur' },
|
||
],
|
||
time_exceeded: [
|
||
{ required: true, message: '请输入超出时间', trigger: 'blur' },
|
||
],
|
||
time_interval: [
|
||
{ required: true, message: '请输入间隔时间', trigger: 'blur' },
|
||
],
|
||
repeate_count: [
|
||
{ required: true, message: '请输入重复次数', trigger: 'blur' },
|
||
],
|
||
},
|
||
};
|
||
},
|
||
|
||
mounted() {
|
||
|
||
},
|
||
|
||
methods: {
|
||
rightClick(e, data, node) {
|
||
this.menuShow = false
|
||
this.menuShow = true
|
||
e.preventDefault() //关闭浏览器右键默认事件
|
||
this.rightMenu = { top: e.pageY + 'px', left: e.pageX + 'px' }
|
||
document.addEventListener('click', (ev) => {
|
||
ev.stopImmediatePropagation()
|
||
if (ev.target !== document.querySelector('.el-menu-item.is-active')) {
|
||
this.foo()
|
||
}
|
||
})
|
||
},
|
||
// 点击时候的判断,判断是否为新增网关
|
||
selectMenuNode(index, indexPath) {
|
||
console.log(index);
|
||
if (index == 1) {
|
||
this.add_passage = true;
|
||
|
||
}
|
||
},
|
||
foo() {
|
||
// 取消鼠标监听事件 菜单栏
|
||
this.menuShow = false
|
||
document.removeEventListener('click', this.foo) // 关掉监听,
|
||
},
|
||
treeNodeClick() {
|
||
this.foo()
|
||
},
|
||
// 收起点击事件的判断
|
||
getRetract() {
|
||
if (this.is_retract == true) {
|
||
this.is_retract = false;
|
||
} else {
|
||
this.is_retract = true;
|
||
}
|
||
},
|
||
getDriveName() {
|
||
this.diag_drive = true;
|
||
},
|
||
changeSwitch1() {
|
||
this.val1 = !this.val1;
|
||
},
|
||
changeSwitch2() {
|
||
this.val2 = !this.val2;
|
||
},
|
||
closeMenu(ev) {
|
||
console.log({ ev });
|
||
this.dialogVisible = false;
|
||
}
|
||
},
|
||
watch: {
|
||
checked1: {
|
||
handler(old,) {
|
||
if (old) {
|
||
this.isdisabled = false;
|
||
} else {
|
||
this.isdisabled = true;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
directives: {
|
||
'click-outside': {
|
||
bind: function (el, binding, vnode) {
|
||
console.log('el', el);
|
||
console.log("binding", binding);
|
||
el.event = function (event) {
|
||
// 检查点击是否发生在节点之内(包括子节点)
|
||
if (!(el == event.target || el.contains(event.target))) {
|
||
// 如果没有,则触发调用
|
||
// 若绑定值为函数,则执行
|
||
// 这里我们可以通过钩子函数中的 vnode.context,来获取当前组件的作用域
|
||
if (typeof vnode.context[binding.expression] == 'function') {
|
||
vnode.context[binding.expression](event)
|
||
}
|
||
}
|
||
}
|
||
// 绑定事件
|
||
// 设置为true,代表在DOM树中,注册了该listener的元素,会先于它下方的任何事件目标,接收到该事件。
|
||
document.body.addEventListener('click', el.event, true)
|
||
},
|
||
unbind: function (el) {
|
||
// 解绑事件
|
||
document.body.removeEventListener('click', el.event, true)
|
||
},
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.tree_menu {
|
||
position: absolute;
|
||
width: 286px;
|
||
height: 753px;
|
||
left: 64px;
|
||
top: 104px;
|
||
width: 286px;
|
||
height: 753px;
|
||
line-height: 20px;
|
||
border-radius: 3px;
|
||
background-color: rgba(255, 255, 255, 1);
|
||
text-align: center;
|
||
border: 1px solid rgba(220, 220, 220, 1);
|
||
}
|
||
|
||
.tree_rightmenu {
|
||
position: fixed;
|
||
width: 120px;
|
||
border: 1px solid rgba(0, 0, 0, 0.15);
|
||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||
z-index: 1000;
|
||
}
|
||
|
||
.super_parmams {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
width: 668px;
|
||
|
||
i {
|
||
width: 24px;
|
||
height: 24px;
|
||
display: inline-block;
|
||
}
|
||
}
|
||
|
||
/deep/ .pas_params {
|
||
.el-form-item {
|
||
margin-bottom: 0px;
|
||
}
|
||
|
||
.el-col-12:last-child {
|
||
padding-right: 150px;
|
||
}
|
||
|
||
.el-col-12:first-child {
|
||
padding-right: 102px;
|
||
}
|
||
|
||
.el-divider--horizontal {
|
||
margin: 8px 0px;
|
||
}
|
||
|
||
.el-input__inner {
|
||
height: 30px;
|
||
text-align: left;
|
||
padding: 0px 8px;
|
||
}
|
||
|
||
.el-row {
|
||
display: flex;
|
||
align-items: flex-end;
|
||
|
||
.el-col-1 {
|
||
text-align: center;
|
||
line-height: 20px;
|
||
height: 20px;
|
||
}
|
||
|
||
.el-col-6 {
|
||
height: 40px;
|
||
top: 5px;
|
||
left: 25px;
|
||
position: relative;
|
||
width: 50px;
|
||
}
|
||
}
|
||
}
|
||
|
||
/deep/ .super_con {
|
||
|
||
.el-form-item {
|
||
margin-bottom: 7px;
|
||
}
|
||
|
||
.el-row {
|
||
display: flex;
|
||
align-items: flex-end;
|
||
}
|
||
|
||
.coil {
|
||
display: inline-block;
|
||
width: 98px;
|
||
height: 25px;
|
||
color: rgba(16, 16, 16, 1);
|
||
font-size: 14px;
|
||
text-align: left;
|
||
}
|
||
}
|
||
|
||
.infos {
|
||
width: 60px;
|
||
position: absolute;
|
||
left: 208px;
|
||
top: 0;
|
||
}
|
||
|
||
/deep/ .footer_con {
|
||
.el-form-item__label {
|
||
line-height: 20px;
|
||
}
|
||
}
|
||
</style> |