|
@@ -13,14 +13,14 @@
|
|
|
>
|
|
>
|
|
|
<div style="font-size: 12px; width: 80px">协议名称:</div>
|
|
<div style="font-size: 12px; width: 80px">协议名称:</div>
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="searchform.protocolname"
|
|
|
|
|
|
|
+ v-model="searchform.protocolName"
|
|
|
placeholder="协议名称"
|
|
placeholder="协议名称"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div>
|
|
<div>
|
|
|
- <el-button type="primary" plain>重置</el-button>
|
|
|
|
|
- <el-button type="primary">搜索</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" plain @click="initdata">重置</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="getalldata">搜索</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -33,8 +33,8 @@
|
|
|
<span>Modbus RTU 协议配置</span>
|
|
<span>Modbus RTU 协议配置</span>
|
|
|
<div>
|
|
<div>
|
|
|
<el-button type="primary" @click="goadd">添加</el-button>
|
|
<el-button type="primary" @click="goadd">添加</el-button>
|
|
|
- <el-button type="danger">批量删除</el-button>
|
|
|
|
|
- <el-button type="primary" plain>显示字段</el-button>
|
|
|
|
|
|
|
+ <el-button type="danger" @click="deleteall">批量删除</el-button>
|
|
|
|
|
+ <el-button type="primary" plain @click="ziduanshow=true">显示字段</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -46,18 +46,40 @@
|
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
|
<el-table :data="tabledata" border>
|
|
<el-table :data="tabledata" border>
|
|
|
<el-table-column type="selection" width="55" />
|
|
<el-table-column type="selection" width="55" />
|
|
|
- <el-table-column label="协议名称"></el-table-column>
|
|
|
|
|
- <el-table-column label="Modbus串口"></el-table-column>
|
|
|
|
|
- <el-table-column label="串口类型"></el-table-column>
|
|
|
|
|
- <el-table-column label="波特率"></el-table-column>
|
|
|
|
|
- <el-table-column label="数据位"></el-table-column>
|
|
|
|
|
- <el-table-column label="奇偶校验"></el-table-column>
|
|
|
|
|
- <el-table-column label="停止位"></el-table-column>
|
|
|
|
|
- <el-table-column label="API接口地址"></el-table-column>
|
|
|
|
|
- <el-table-column label="UUID"></el-table-column>
|
|
|
|
|
- <el-table-column label="轮询时间(毫秒)"></el-table-column>
|
|
|
|
|
- <el-table-column label="描述"></el-table-column>
|
|
|
|
|
- <el-table-column label="操作" fixed="right"></el-table-column>
|
|
|
|
|
|
|
+ <el-table-column v-for="item in cloumdata.filter(i=>i.visible)" :prop="item.prop" :label="item.label" ></el-table-column>
|
|
|
|
|
+ <el-table-column label="操作">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link @click="showdmodeletail(scope.row,1)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-tooltip effect="dark" content="详情">
|
|
|
|
|
+ <el-icon>
|
|
|
|
|
+ <Memo />
|
|
|
|
|
+ </el-icon>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link @click="showdmodeletail(scope.row,2)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-tooltip effect="dark" content="编辑">
|
|
|
|
|
+ <el-icon>
|
|
|
|
|
+ <Edit />
|
|
|
|
|
+ </el-icon>
|
|
|
|
|
+ </el-tooltip>
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+
|
|
|
|
|
+ <el-popconfirm title="确定删除该协议?" @confirm="deleterow(scope.row)">
|
|
|
|
|
+ <template #reference>
|
|
|
|
|
+ <el-button link
|
|
|
|
|
+ ><el-tooltip effect="dark" content="删除"
|
|
|
|
|
+ ><el-icon><Delete /></el-icon></el-tooltip
|
|
|
|
|
+ ></el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-popconfirm>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
|
|
|
</el-table>
|
|
</el-table>
|
|
|
</el-col>
|
|
</el-col>
|
|
@@ -66,7 +88,9 @@
|
|
|
small
|
|
small
|
|
|
background
|
|
background
|
|
|
layout="prev, pager, next"
|
|
layout="prev, pager, next"
|
|
|
- :total="50"
|
|
|
|
|
|
|
+ :total="pagedata.total"
|
|
|
|
|
+ :page-size="pagedata.size"
|
|
|
|
|
+ :current-page="pagedata.current"
|
|
|
class="mt-4"
|
|
class="mt-4"
|
|
|
/>
|
|
/>
|
|
|
</el-col>
|
|
</el-col>
|
|
@@ -76,6 +100,167 @@
|
|
|
</div>
|
|
</div>
|
|
|
</el-card>
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ title="字段显示"
|
|
|
|
|
+ v-model="ziduanshow"
|
|
|
|
|
+ width="50%"
|
|
|
|
|
+ @close="ziduanshow = false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div style="display: flex;flex-wrap: wrap;align-content: center;justify-content: center;align-items: center;">
|
|
|
|
|
+ <el-checkbox v-for="item in cloumdata" v-model="item.visible" :label="item.label" size="large" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :title="`${showdetailtype==1?'协议详情':'编辑协议'}`"
|
|
|
|
|
+ v-model="showdetail"
|
|
|
|
|
+ width="50%"
|
|
|
|
|
+ @close="showdetail = false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div >
|
|
|
|
|
+ <el-descriptions :column="2">
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 协议名称
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.protocolName" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-descriptions-item >
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> Api接口地址
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.apiUrl" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> Modbus串口
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.commPortId" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 串口类型
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.commPortType" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 波特率
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.baudRate" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 数据位
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.dateBits" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 奇偶校验
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.parity" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item>
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ <span style="color: red">*</span> 停止位
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.stopBits" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-descriptions-item >
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ 轮询间隔时间(毫秒)
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" v-model="currentdata.intervals" placeholder="请输入"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-descriptions-item :span="3">
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right">
|
|
|
|
|
+ UUID
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div style="display: inline">
|
|
|
|
|
+ {{currentdata.uuid}}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item :span="2">
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right; vertical-align: top;">
|
|
|
|
|
+ 描述
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w" style="min-width: 400px">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" type="textarea" v-model="currentdata.protocolDesc" :line-count="5" show-word-limit maxlength="200" placeholder="请输入描述"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ <el-descriptions-item :span="2">
|
|
|
|
|
+ <template #label>
|
|
|
|
|
+ <div style="display: inline-block;min-width: 100px;text-align: right; vertical-align: top;">
|
|
|
|
|
+ 备注
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <div class="content-w" style="min-width: 400px">
|
|
|
|
|
+ <el-input :disabled="showdetailtype==1" type="textarea" v-model="currentdata.remark" :line-count="5" show-word-limit maxlength="200" placeholder="请输入备注"/>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
|
+ </el-descriptions>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div slot="footer" class="dialog-footer" style="text-align: right" v-if="showdetailtype!=1">
|
|
|
|
|
+ <el-button @click="showdetail = false">取 消</el-button>
|
|
|
|
|
+ <el-button type="primary" @click="dosave">保 存</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -83,16 +268,124 @@
|
|
|
<script setup lang="ts" name="Units">
|
|
<script setup lang="ts" name="Units">
|
|
|
import {ref} from "vue";
|
|
import {ref} from "vue";
|
|
|
import {useRoute, useRouter} from "vue-router";
|
|
import {useRoute, useRouter} from "vue-router";
|
|
|
|
|
+import {listModbusRtu,delModbusRtu,updateModbusRtu} from "@/api/data/modbusRtu"
|
|
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+const showdetail = ref(false);
|
|
|
|
|
+const showdetailtype = ref(1);
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const searchform = ref({
|
|
const searchform = ref({
|
|
|
- protocolname: '',
|
|
|
|
|
|
|
+ protocolName: '',
|
|
|
})
|
|
})
|
|
|
|
|
+const tableref = ref(null);
|
|
|
|
|
|
|
|
const tabledata = ref([1])
|
|
const tabledata = ref([1])
|
|
|
|
|
+
|
|
|
|
|
+const initdata = ()=>{
|
|
|
|
|
+ searchform.value = {
|
|
|
|
|
+ protocolName: '',
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+const currentdata = ref({
|
|
|
|
|
+
|
|
|
|
|
+ "protocolName": "",
|
|
|
|
|
+ "protocolDesc": "",
|
|
|
|
|
+ "protocolType": "",
|
|
|
|
|
+ "apiUrl": "",
|
|
|
|
|
+ "commPortId": "",
|
|
|
|
|
+ "commPortType": "",
|
|
|
|
|
+ "baudRate": 0,
|
|
|
|
|
+ "dateBits": 0,
|
|
|
|
|
+ "parity": 0,
|
|
|
|
|
+ "stopBits": 0,
|
|
|
|
|
+ "uuid": "",
|
|
|
|
|
+ "intervals": 0,
|
|
|
|
|
+ "remark": ""
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const showdmodeletail = (item,type)=>{
|
|
|
|
|
+ showdetailtype.value = type;
|
|
|
|
|
+ currentdata.value = item;
|
|
|
|
|
+ showdetail.value = true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const deleterow =(item)=>{
|
|
|
|
|
+ delModbusRtu(item.id).then((res)=>{
|
|
|
|
|
+ ElMessage.success("删除成功");
|
|
|
|
|
+ getalldata();
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const deleteall = ()=>{
|
|
|
|
|
+ let selected = tableref.value.getSelectionRows();
|
|
|
|
|
+ if(selected.length==0) {
|
|
|
|
|
+ ElMessage.warning("请选择要删除的行");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (selected.length > 0) {
|
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
|
+ `是否删除${selected.length}条数据`,
|
|
|
|
|
+ "警告",
|
|
|
|
|
+ {
|
|
|
|
|
+ confirmButtonText: "确认",
|
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ }
|
|
|
|
|
+ ).then(() => {
|
|
|
|
|
+
|
|
|
|
|
+ delModbusRtu(selected.map(i => i.id).join(",")).then((res) => {
|
|
|
|
|
+ ElMessage.success("删除成功");
|
|
|
|
|
+ getalldata();
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const dosave = ()=>{
|
|
|
|
|
+ if(showdetailtype.value==2){
|
|
|
|
|
+ updateModbusRtu(currentdata.value).then(res=>{
|
|
|
|
|
+ ElMessage.success("保存成功");
|
|
|
|
|
+ showdetail.value = false;
|
|
|
|
|
+ getalldata();
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const cloumdata = ref([
|
|
|
|
|
+ {label: '协议名称', prop:'protocolName',visible:true},
|
|
|
|
|
+ {label: 'Modbus串口', prop:'commPortId',visible:true},
|
|
|
|
|
+ {label: '串口类型', prop:'commPortType',visible:true},
|
|
|
|
|
+ {label: '波特率', prop:'baudRate',visible:true},
|
|
|
|
|
+ {label: '数据位', prop:'dateBits',visible:true},
|
|
|
|
|
+ {label: '奇偶校验', prop:'parity',visible:true},
|
|
|
|
|
+ {label: '停止位', prop:'stopBits',visible:true},
|
|
|
|
|
+ {label: 'API接口地址', prop:'apiUrl',visible:true},
|
|
|
|
|
+ {label: 'UUID', prop:'uuid',visible:true},
|
|
|
|
|
+ {label: '轮询时间(毫秒)', prop:'intervals',visible:true},
|
|
|
|
|
+ {label: '描述', prop:'remark',visible:true},
|
|
|
|
|
+]);
|
|
|
|
|
+const ziduanshow = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+const pagedata = ref({
|
|
|
|
|
+ total:0,
|
|
|
|
|
+ size:10,
|
|
|
|
|
+ current:1
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const getalldata = () => {
|
|
|
|
|
+ listModbusRtu(searchform.value).then(res => {
|
|
|
|
|
+ const {rows,total,page,size} = res;
|
|
|
|
|
+ pagedata.value = {total:total,current:page, size:10};
|
|
|
|
|
+ tabledata.value = rows
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+getalldata()
|
|
|
const goadd = ()=>{
|
|
const goadd = ()=>{
|
|
|
router.push("/gateway/modbusrtu/add");
|
|
router.push("/gateway/modbusrtu/add");
|
|
|
}
|
|
}
|
|
@@ -106,4 +399,8 @@ const goadd = ()=>{
|
|
|
flex-direction: row;
|
|
flex-direction: row;
|
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
|
}
|
|
}
|
|
|
|
|
+.content-w {
|
|
|
|
|
+ display: inline-flex;
|
|
|
|
|
+ max-width: 160px;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|