|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<el-card class="system-dic-container" style="position: relative;">
|
|
|
- <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
|
|
+ <el-tabs v-model="activeName" class="demo-tabs">
|
|
|
<el-tab-pane label="编辑通道" name="first">
|
|
|
<el-collapse v-model="activeViewName">
|
|
|
<el-collapse-item title="基本信息" name="1">
|
|
@@ -36,24 +36,6 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="波特率">
|
|
|
<el-select v-model="form.serial.baud_rate" placeholder="请选择波特率">
|
|
|
- <!-- <el-option label="150" :value="150" />
|
|
|
- <el-option label="200" :value="200" />
|
|
|
- <el-option label="300" :value="300" />
|
|
|
- <el-option label="600" :value="600" />
|
|
|
- <el-option label="1200" :value="1200" />
|
|
|
- <el-option label="1800" :value="1800" />
|
|
|
- <el-option label="2400" :value="2400" />
|
|
|
- <el-option label="4800" :value="4800" />
|
|
|
- <el-option label="7200" :value="7200" />
|
|
|
- <el-option label="9600" :value="9600" />
|
|
|
- <el-option label="14400" :value="14400" />
|
|
|
- <el-option label="19200" :value="19200" />
|
|
|
- <el-option label="28800" :value="28800" />
|
|
|
- <el-option label="38400" :value="38400" />
|
|
|
- <el-option label="57600" :value="57600" />
|
|
|
- <el-option label="76800" :value="76800" />
|
|
|
- <el-option label="115200" :value="115200" />
|
|
|
- <el-option label="230400" :value="230400" /> -->
|
|
|
<el-option
|
|
|
v-for="dict in tunnel_serial_baudrate"
|
|
|
:key="dict.value"
|
|
@@ -64,10 +46,6 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="数据位">
|
|
|
<el-select v-model="form.serial.data_bits" placeholder="请选择数据位">
|
|
|
- <!-- <el-option label="5" :value="5" />
|
|
|
- <el-option label="6" :value="6" />
|
|
|
- <el-option label="7" :value="7" />
|
|
|
- <el-option label="8" :value="8" /> -->
|
|
|
<el-option
|
|
|
v-for="dict in tunnel_serial_databits"
|
|
|
:key="dict.value"
|
|
@@ -78,8 +56,6 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="停止位">
|
|
|
<el-select v-model="form.serial.stop_bits" placeholder="请选择停止位">
|
|
|
- <!-- <el-option label="1" :value="1" />
|
|
|
- <el-option label="2" :value="2" /> -->
|
|
|
<el-option
|
|
|
v-for="dict in tunnel_serial_stopbits"
|
|
|
:key="dict.value"
|
|
@@ -90,9 +66,6 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="检验位">
|
|
|
<el-select v-model="form.serial.parity" placeholder="请选择检验位">
|
|
|
- <!-- <el-option label="无" :value="0" />
|
|
|
- <el-option label="偶" :value="1" />
|
|
|
- <el-option label="奇" :value="2" /> -->
|
|
|
<el-option
|
|
|
v-for="dict in tunnel_serial_parity"
|
|
|
:key="dict.value"
|
|
@@ -128,17 +101,6 @@
|
|
|
<el-form style="width: 600px;margin: 0 auto;" :model="form" label-width="68px">
|
|
|
<el-form-item label="协议">
|
|
|
<el-select v-model="form.protoccol.name" placeholder="请选择协议适配">
|
|
|
- <!-- <el-option label="Modbus RTU" value="Modbus RTU" />
|
|
|
- <el-option label="Modbus TCP" value="Modbus TCP" />
|
|
|
- <el-option label="Omron Hostlink" value="Omron Hostlink" />
|
|
|
- <el-option label="Omron FINS UDP" value="Omron FINS UDP" />
|
|
|
- <el-option label="Omron FINS TCP" value="Omron FINS TCP" />
|
|
|
- <el-option label="Simatic S7-200 Smart" value="Simatic S7-200 Smart" />
|
|
|
- <el-option label="Simatic S7-200" value="Simatic S7-200" />
|
|
|
- <el-option label="Simatic S7-300" value="Simatic S7-300" />
|
|
|
- <el-option label="Simatic S7-400" value="Simatic S7-400" />
|
|
|
- <el-option label="Simatic S7-1200" value="Simatic S7-1200" />
|
|
|
- <el-option label="Simatic S7-1500" value="Simatic S7-1500" /> -->
|
|
|
<el-option
|
|
|
v-for="dict in network_protocols"
|
|
|
:key="dict.value"
|
|
@@ -158,25 +120,15 @@
|
|
|
</el-collapse-item>
|
|
|
</el-collapse>
|
|
|
</el-tab-pane>
|
|
|
- <!-- <el-tab-pane label="专家视图" name="second">
|
|
|
- <h1>专家视图</h1>
|
|
|
- </el-tab-pane> -->
|
|
|
</el-tabs>
|
|
|
<div style="position: absolute;right:20px;top: 20px;">
|
|
|
<el-button size="medium">取消</el-button>
|
|
|
<el-button @click="submit" size="medium" type="primary">提交</el-button>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- <codeEditor ref="mirrorRef"
|
|
|
- :mode="resourceModalPro.mode"
|
|
|
- :content="resourceModalPro.content"
|
|
|
- >
|
|
|
- </codeEditor> -->
|
|
|
</el-card>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { toRefs, reactive, onMounted, ref, defineComponent, getCurrentInstance } from 'vue';
|
|
|
-import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue';
|
|
|
import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
|
|
|
import type { TabsPaneContext } from 'element-plus'
|
|
|
import codeEditor from '/@/components/codeEditor/index.vue'
|
|
@@ -188,13 +140,10 @@ import { useRoute, useRouter } from 'vue-router';
|
|
|
import api from '/@/api/network';
|
|
|
|
|
|
interface TableDataState {
|
|
|
- // ids: number[];
|
|
|
- // id: string;
|
|
|
activeViewName: string[];
|
|
|
resourceModalPro: {
|
|
|
mode: string,
|
|
|
content: string,
|
|
|
- // content: object,
|
|
|
},
|
|
|
detail: object,
|
|
|
form: object
|
|
@@ -216,7 +165,6 @@ export default defineComponent({
|
|
|
const { network_tunnel_type, tunnel_serial_baudrate, tunnel_serial_databits, tunnel_serial_stopbits, tunnel_serial_parity, network_protocols } = proxy.useDict('network_tunnel_type', 'tunnel_serial_baudrate', 'tunnel_serial_databits', 'tunnel_serial_stopbits', 'tunnel_serial_parity', 'network_protocols');
|
|
|
|
|
|
const state = reactive<TableDataState>({
|
|
|
- // id: "",
|
|
|
resourceModalPro: {
|
|
|
mode: '',
|
|
|
content: ''
|
|
@@ -264,7 +212,6 @@ export default defineComponent({
|
|
|
const activeName = ref('first')
|
|
|
const mirrorRef = ref('mirrorRef')
|
|
|
const submit = () => {
|
|
|
- console.log(state.form)
|
|
|
// 串口参数-检验位-无
|
|
|
if(state.form.serial.parity == 0) {
|
|
|
state.form.serial.rs485 = false
|
|
@@ -275,13 +222,8 @@ export default defineComponent({
|
|
|
state.form.serial.port = null
|
|
|
delete state.form.serial.rs485
|
|
|
}
|
|
|
- let params = {
|
|
|
- ...state.form
|
|
|
- }
|
|
|
- console.log(params)
|
|
|
// return
|
|
|
api.tunnel.editItem({...state.form}).then((res: any) => {
|
|
|
- console.log(res);
|
|
|
ElMessage.success('修改成功')
|
|
|
router.go(-1);
|
|
|
});
|
|
@@ -289,7 +231,6 @@ export default defineComponent({
|
|
|
const getDetail = () => {
|
|
|
const id = route.params && route.params.id;
|
|
|
api.tunnel.getDetail({"id": id}).then((res: any) => {
|
|
|
- console.log(res)
|
|
|
const {id, name, types, status, addr, serial, retry, protoccol, heartbeat } = res
|
|
|
state.form['name'] = name
|
|
|
state.form['types'] = types
|
|
@@ -300,67 +241,24 @@ export default defineComponent({
|
|
|
state.form['heartbeat'] = JSON.parse(heartbeat)
|
|
|
state.form['protoccol'] = protoccol?JSON.parse(protoccol):{name: "Modbus RTU",options: {}}
|
|
|
state.form['id'] = id
|
|
|
- console.log(JSON.parse(protoccol).options)
|
|
|
let jsonData = JSON.stringify(JSON.parse(protoccol).options);
|
|
|
state.resourceModalPro.content = JSON.stringify(JSON.parse(jsonData),null,4);
|
|
|
- console.log(state.resourceModalPro.content)
|
|
|
mirrorRef.value.setValue(state.resourceModalPro.content);
|
|
|
})
|
|
|
};
|
|
|
onMounted(() => {
|
|
|
- getDetail()
|
|
|
- // let obj = {
|
|
|
- // // "id": 1,
|
|
|
- // // "name": "新建服务器",
|
|
|
- // // "type": "tcp",
|
|
|
- // // "addr": "10010",
|
|
|
- // // "register": {
|
|
|
- // // "regex": "^\\w+$"
|
|
|
- // // },
|
|
|
- // // "heartbeat": {
|
|
|
- // // "enable": false,
|
|
|
- // // "timeout": 30,
|
|
|
- // // "regex": "^\\w+$"
|
|
|
- // // },
|
|
|
- // // "protocol": {
|
|
|
- // // "name": "ModbusTCP",
|
|
|
- // // "options": {}
|
|
|
- // // },
|
|
|
- // // "devices": [
|
|
|
- // // {
|
|
|
- // // "station": 1,
|
|
|
- // // "product_id": ""
|
|
|
- // // }
|
|
|
- // // ],
|
|
|
- // // "disabled": false,
|
|
|
- // // "updated": "2022-08-26T15:10:07+08:00",
|
|
|
- // // "created": "2022-08-20T18:44:20+08:00",
|
|
|
- // // "running": true
|
|
|
- // }
|
|
|
- // var jsonData = JSON.stringify(obj);
|
|
|
- // state.resourceModalPro.content = JSON.stringify(JSON.parse(jsonData),null,4);
|
|
|
+ getDetail();
|
|
|
});
|
|
|
- const handleClick = (tab: TabsPaneContext, event: Event) => {
|
|
|
- console.log(tab, event)
|
|
|
- }
|
|
|
-
|
|
|
return {
|
|
|
- Edit,
|
|
|
mirrorRef,
|
|
|
activeName,
|
|
|
getDetail,
|
|
|
- handleClick,
|
|
|
network_tunnel_type,
|
|
|
tunnel_serial_baudrate,
|
|
|
tunnel_serial_databits,
|
|
|
tunnel_serial_stopbits,
|
|
|
tunnel_serial_parity,
|
|
|
network_protocols,
|
|
|
- // editDicRef,
|
|
|
- // editAttrRef,
|
|
|
- // editFunRef,
|
|
|
- // editEventRef,
|
|
|
- // editTabRef,
|
|
|
submit,
|
|
|
...toRefs(props),
|
|
|
...toRefs(state),
|