2022-08-13 16:20:48 +08:00
|
|
|
|
<template>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
<el-container>
|
|
|
|
|
|
<el-aside width="15%">
|
|
|
|
|
|
<div class="menu-box">
|
|
|
|
|
|
<el-card class="box-card">
|
|
|
|
|
|
<div slot="header" class="menu-header">
|
|
|
|
|
|
<div class="header-title">设备</div>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<el-dropdown
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="vertical-align: middle"
|
|
|
|
|
|
@command="handleCommand"
|
|
|
|
|
|
>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
<el-button type="primary" round>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<i class="el-icon-s-tools" style="font-size: 14px"></i
|
|
|
|
|
|
><i
|
|
|
|
|
|
class="el-icon-arrow-down el-icon--right"
|
|
|
|
|
|
style="font-size: 14px"
|
|
|
|
|
|
></i>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
|
|
<el-dropdown-item command="add">新加设备</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item command="del">删除设备</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>设备重启</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>导入配置</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>导出配置</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
2022-08-13 16:20:48 +08:00
|
|
|
|
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<el-menu
|
|
|
|
|
|
:style="{ borderRight: 'none' }"
|
|
|
|
|
|
:defaultActive="deviceActiveStatus"
|
|
|
|
|
|
@select="getDeviceConfigure"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-menu-item
|
|
|
|
|
|
class="serve-item"
|
|
|
|
|
|
shadow="always"
|
|
|
|
|
|
v-for="(item, i) in deviceData"
|
|
|
|
|
|
:key="i"
|
|
|
|
|
|
:index="i + ''"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div style="position: relative">
|
|
|
|
|
|
<div style="display: inline-block">{{ item.name }}</div>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
<div
|
2022-08-23 10:07:32 +08:00
|
|
|
|
:class="{
|
|
|
|
|
|
'device-status': true,
|
|
|
|
|
|
'device-status-online': item.status,
|
|
|
|
|
|
'device-status-offline': !item.status,
|
|
|
|
|
|
}"
|
|
|
|
|
|
></div>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-menu-item>
|
|
|
|
|
|
</el-menu>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-aside>
|
|
|
|
|
|
<el-main :style="{ padding: '10px' }">
|
|
|
|
|
|
<el-card class="box-card">
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<div slot="header" style="position: relative">
|
2022-08-17 00:05:22 +08:00
|
|
|
|
<div class="header-title">设备配置</div>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
class="header-button"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
@click="setDeviceConfigure"
|
|
|
|
|
|
>应用</el-button
|
|
|
|
|
|
>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
</div>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<device-configure
|
|
|
|
|
|
ref="deviceConfigure"
|
|
|
|
|
|
:defaultDeviceName="defaultDeviceName"
|
|
|
|
|
|
:defaultFormData="defaultFormData"
|
|
|
|
|
|
/>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
</el-card>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
<el-card class="box-card" style="margin-top: 5px">
|
|
|
|
|
|
<d2-crud
|
|
|
|
|
|
ref="d2Crud"
|
|
|
|
|
|
:columns="columns"
|
|
|
|
|
|
:data="devicePointData"
|
|
|
|
|
|
:rowHandle="rowHandle"
|
|
|
|
|
|
add-title="新增"
|
|
|
|
|
|
edit-title="绑定"
|
|
|
|
|
|
:add-template="addTemplate"
|
|
|
|
|
|
:add-rules="addRules"
|
|
|
|
|
|
:form-options="formOptions"
|
|
|
|
|
|
@row-add="addDevicePoint"
|
|
|
|
|
|
@row-edit="devicePointBandingNode"
|
|
|
|
|
|
@row-remove="delDevicePoint"
|
|
|
|
|
|
@dialog-cancel="handleDialogCancel"
|
|
|
|
|
|
@banding="bandingNodeTemplate"
|
|
|
|
|
|
@cell-data-change="handleCellDataChange"
|
|
|
|
|
|
@form-data-change="handleFormDataChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button slot="header" style="margin-bottom: 5px" @click="addRow"
|
|
|
|
|
|
>新增</el-button
|
|
|
|
|
|
>
|
2022-08-17 00:05:22 +08:00
|
|
|
|
</d2-crud>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</el-main>
|
|
|
|
|
|
</el-container>
|
2022-08-13 16:20:48 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-23 10:07:32 +08:00
|
|
|
|
import {
|
|
|
|
|
|
each,
|
|
|
|
|
|
assign,
|
|
|
|
|
|
unset,
|
|
|
|
|
|
filter,
|
|
|
|
|
|
isArray,
|
|
|
|
|
|
map,
|
|
|
|
|
|
capitalize,
|
|
|
|
|
|
split,
|
|
|
|
|
|
toUpper,
|
|
|
|
|
|
} from "lodash";
|
2022-08-17 00:05:22 +08:00
|
|
|
|
|
2022-08-13 16:20:48 +08:00
|
|
|
|
export default {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
props: {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
server: {
|
|
|
|
|
|
default: {
|
|
|
|
|
|
id: 0,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
url: "",
|
|
|
|
|
|
port: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
components: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
DeviceConfigure: () => import("./deviceConfigure"),
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
data() {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
return {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
active: "",
|
|
|
|
|
|
timing:null,
|
2022-08-14 18:30:55 +08:00
|
|
|
|
columns: [
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "序号",
|
|
|
|
|
|
key: "id",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "名称",
|
|
|
|
|
|
key: "@Name",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "绑定",
|
|
|
|
|
|
key: "@Binding",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "地址",
|
|
|
|
|
|
key: "@Address",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "类型",
|
|
|
|
|
|
key: "@DataTypeCode",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-select",
|
|
|
|
|
|
size: "small",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
options: [
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "string",
|
|
|
|
|
|
label: "string (字符串)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "int",
|
|
|
|
|
|
label: "int (整数)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "float",
|
|
|
|
|
|
label: "float (浮点数)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "bool",
|
|
|
|
|
|
label: "bool (逻辑值)",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "uint",
|
|
|
|
|
|
label: "uint",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "short",
|
|
|
|
|
|
label: "short",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "ushort",
|
|
|
|
|
|
label: "ushort",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "long",
|
|
|
|
|
|
label: "long",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "ulong",
|
|
|
|
|
|
label: "ulong",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "double",
|
|
|
|
|
|
label: "double",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "byte",
|
|
|
|
|
|
label: "byte",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "sbyte",
|
|
|
|
|
|
label: "sbyte",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "采集周期",
|
|
|
|
|
|
key: "@RequestInterval",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "长度",
|
|
|
|
|
|
key: "@Length",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "说明",
|
|
|
|
|
|
key: "@Description",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "当前值",
|
|
|
|
|
|
key: "@Value",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-input",
|
|
|
|
|
|
size: "small",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
],
|
|
|
|
|
|
rowHandle: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
minWidth: "200",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
custom: [
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
text: "绑定",
|
|
|
|
|
|
size: "mini",
|
|
|
|
|
|
emit: "banding",
|
|
|
|
|
|
show(index, row) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (row.showBindButton) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return true;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
text: "发送",
|
|
|
|
|
|
size: "mini",
|
|
|
|
|
|
show(index, row) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (row.showSendButton) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return true;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
text: "复制",
|
|
|
|
|
|
size: "mini",
|
|
|
|
|
|
show(index, row) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (row.showCopyButton) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return true;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
],
|
|
|
|
|
|
remove: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
size: "mini",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
|
|
|
|
|
|
confirm: true,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
show(index, row) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (row.showRemoveButton) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return true;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
formOptions: {
|
|
|
|
|
|
modal: false,
|
|
|
|
|
|
saveLoading: false,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
showOverflowTooltip: true,
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
addTemplate: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@Name": {
|
|
|
|
|
|
title: "名称",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@Address": {
|
|
|
|
|
|
title: "地址",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@DisplayName": {
|
|
|
|
|
|
title: "显示名称",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@RequestType": {
|
|
|
|
|
|
title: "请求类型",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@DataTypeCode": {
|
|
|
|
|
|
title: "数据类型",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-select",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
options: [
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "string",
|
|
|
|
|
|
label: "string (字符串)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "int",
|
|
|
|
|
|
label: "int (整数)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "float",
|
|
|
|
|
|
label: "float (浮点数)",
|
2022-08-18 14:21:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "bool",
|
|
|
|
|
|
label: "bool (逻辑值)",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "uint",
|
|
|
|
|
|
label: "uint",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "short",
|
|
|
|
|
|
label: "short",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "ushort",
|
|
|
|
|
|
label: "ushort",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "long",
|
|
|
|
|
|
label: "long",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "ulong",
|
|
|
|
|
|
label: "ulong",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "double",
|
|
|
|
|
|
label: "double",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "byte",
|
|
|
|
|
|
label: "byte",
|
2022-08-22 13:53:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-23 10:07:32 +08:00
|
|
|
|
value: "sbyte",
|
|
|
|
|
|
label: "sbyte",
|
|
|
|
|
|
},
|
2022-08-18 14:21:08 +08:00
|
|
|
|
],
|
2022-08-23 10:07:32 +08:00
|
|
|
|
span: 12,
|
|
|
|
|
|
},
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@RequestInterval": {
|
|
|
|
|
|
title: "采集周期(ms)",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@Length": {
|
|
|
|
|
|
title: "长度",
|
|
|
|
|
|
},
|
|
|
|
|
|
"@Description": {
|
|
|
|
|
|
title: "说明",
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
addRules: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
"@Name": [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
message: "请输入名称",
|
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
"@Address": [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
message: "请输入地址",
|
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
"@DisplayName": [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
message: "请输入显示名称",
|
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
"@RequestType": [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
message: "请输入请求类型",
|
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
"@DataTypeCode": [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
type: "string",
|
|
|
|
|
|
message: "请选择类型",
|
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
"@RequestInterval": [
|
|
|
|
|
|
{ required: true, message: "请输入采集周期(ms)", trigger: "blur" },
|
|
|
|
|
|
],
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-17 00:05:22 +08:00
|
|
|
|
serverData: {},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
devicePointData: [],
|
|
|
|
|
|
nodeCodeData: [],
|
|
|
|
|
|
workingSubclasses: [],
|
|
|
|
|
|
dialogVisible: false,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceActiveStatus: "0",
|
|
|
|
|
|
defaultDeviceName: "",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
defaultFormData: {},
|
|
|
|
|
|
deviceData: [],
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceConfigure: {},
|
|
|
|
|
|
};
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
server: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
handler(val) {
|
|
|
|
|
|
this.serverData = val;
|
|
|
|
|
|
this.getDevice();
|
2022-08-20 00:11:27 +08:00
|
|
|
|
if (val.id) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.getDeviceStatus();
|
2022-08-20 00:11:27 +08:00
|
|
|
|
}
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
immediate: true,
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
addRow() {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$refs.d2Crud.showDialog({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
mode: "add",
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
handleFormDataChange({ key }) {
|
|
|
|
|
|
if (key === "workingSubclass") {
|
|
|
|
|
|
const { workingSubclass } = this.$refs.d2Crud.formData;
|
|
|
|
|
|
this.getCodesByWorkingSubclass(workingSubclass);
|
|
|
|
|
|
this.$refs.d2Crud.$forceUpdate();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
handleCellDataChange({ rowIndex, row, key, value }) {
|
|
|
|
|
|
let type = undefined;
|
|
|
|
|
|
if (row["@DataTypeCode"][0] === "u") {
|
|
|
|
|
|
type = split(row["@DataTypeCode"], "")
|
|
|
|
|
|
type[1] = toUpper(type[0] + type[1])
|
|
|
|
|
|
type = type.join("")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
type = capitalize(row["@DataTypeCode"])
|
|
|
|
|
|
}
|
|
|
|
|
|
if (key === "@Value") {
|
|
|
|
|
|
this.$api.SET_DEVICE_POINT_VALUE(
|
|
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port,
|
|
|
|
|
|
this.deviceData[this.deviceActiveStatus].name,
|
|
|
|
|
|
row["@Address"],
|
|
|
|
|
|
type,
|
|
|
|
|
|
value
|
|
|
|
|
|
).then(res=>{
|
|
|
|
|
|
if(!res.IsSuccess){
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: res.Message,
|
|
|
|
|
|
type: "error",
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
this.devicePointData[rowIndex] = row;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
bandingNodeTemplate({ index }) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$refs.d2Crud.showDialog({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
mode: "edit",
|
2022-08-17 00:05:22 +08:00
|
|
|
|
rowIndex: index,
|
2022-08-14 18:30:55 +08:00
|
|
|
|
template: {
|
|
|
|
|
|
workingSubclass: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "工序编码",
|
|
|
|
|
|
value: "",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-select",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
options: this.workingSubclasses,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
span: 12,
|
|
|
|
|
|
},
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
nodeCode: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
title: "节点名称",
|
|
|
|
|
|
value: "",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
component: {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: "el-select",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
options: this.nodeCodeData,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
span: 12,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
handleDialogCancel(done) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "用户取消保存",
|
|
|
|
|
|
type: "warning",
|
|
|
|
|
|
});
|
|
|
|
|
|
done();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
handleCommand(command) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
switch (command) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
case "add":
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.addDevice()
|
2022-08-23 10:07:32 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case "del":
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.delDevice()
|
2022-08-23 10:07:32 +08:00
|
|
|
|
break;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async getCodesByWorkingSubclass(workingSubclass) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const nodeCode = await this.$api.QUERY_CODES(workingSubclass)
|
2022-08-23 10:07:32 +08:00
|
|
|
|
let nodeCodeData = []
|
2022-08-14 18:30:55 +08:00
|
|
|
|
each(nodeCode, (o) => {
|
|
|
|
|
|
nodeCodeData.push({ value: o, label: o })
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.nodeCodeData = nodeCodeData
|
|
|
|
|
|
this.$nextTick(() => {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.$refs.d2Crud.handleFormTemplateMode(
|
|
|
|
|
|
"nodeCode"
|
|
|
|
|
|
).component.options = this.nodeCodeData
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$refs.d2Crud.$forceUpdate()
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
} catch (e) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
console.log(e);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async getworkingSubclasses() {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
try {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
const workingSubclasses = await this.$api.QUERY_WORKING_SUBCLASSES();
|
2022-08-20 17:03:52 +08:00
|
|
|
|
const workingSubclassesData = []
|
2022-08-14 18:30:55 +08:00
|
|
|
|
each(workingSubclasses, (o) => {
|
|
|
|
|
|
workingSubclassesData.push({ value: o, label: o })
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.workingSubclasses = workingSubclassesData
|
|
|
|
|
|
} catch (e) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
console.log(e);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async getDevice() {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
try {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
this.deviceData = await this.$api.GET_DEVICE(this.serverData.id)
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (this.deviceData.length > 0) {
|
|
|
|
|
|
this.getDeviceConfigure(this.deviceActiveStatus)
|
2022-08-21 00:54:49 +08:00
|
|
|
|
} else {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.devicePointData = []; // 如果没有设备,防止显示上一次打开的设备数据先清空数据
|
|
|
|
|
|
this.defaultDeviceName = ""
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
console.log(e);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async getDeviceConfigure(e) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.deviceActiveStatus = e
|
|
|
|
|
|
this.devicePointData = [] // 当切换设备时把保存configure、point的数据清空
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.defaultDeviceName = ""
|
|
|
|
|
|
clearInterval(this.timing) //当切换设备时先关闭定时器,防止一直执行上一设备的定时器
|
|
|
|
|
|
const deviceData = await this.$api.GET_DEVICE_CONFIGURE(
|
|
|
|
|
|
this.deviceData[e].id
|
|
|
|
|
|
);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (deviceData[0].conf) {
|
|
|
|
|
|
const conf = JSON.parse(deviceData[0].conf)
|
2022-08-17 00:05:22 +08:00
|
|
|
|
if (conf.DeviceTypeName !== undefined) {
|
|
|
|
|
|
this.defaultDeviceName = conf.DeviceTypeName
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.defaultFormData = conf
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取point信息
|
2022-08-23 10:07:32 +08:00
|
|
|
|
let devicePointAddress = []
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (conf.RequestNode !== undefined && conf.RequestNode.length > 0) {
|
2022-08-21 13:00:46 +08:00
|
|
|
|
this.devicePointData = each(conf.RequestNode, (o, i) => {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
let type = undefined;
|
|
|
|
|
|
if (o["@DataTypeCode"][0] === "u") {
|
|
|
|
|
|
type = split(o["@DataTypeCode"], "")
|
|
|
|
|
|
type[1] = toUpper(type[0] + type[1])
|
|
|
|
|
|
type = type.join("")
|
|
|
|
|
|
} else {
|
|
|
|
|
|
type = capitalize(o["@DataTypeCode"])
|
|
|
|
|
|
}
|
|
|
|
|
|
devicePointAddress.push({
|
|
|
|
|
|
key: i,
|
|
|
|
|
|
value: o["@Address"],
|
|
|
|
|
|
type:
|
|
|
|
|
|
o["@DataTypeCode"][0] === "u"
|
|
|
|
|
|
? replace(o["@DataTypeCode"])
|
|
|
|
|
|
: capitalize(o["@DataTypeCode"]),
|
|
|
|
|
|
})
|
2022-08-14 18:30:55 +08:00
|
|
|
|
assign(o, {
|
|
|
|
|
|
id: i + 1,
|
|
|
|
|
|
showBindButton: true,
|
|
|
|
|
|
showSendButton: true,
|
|
|
|
|
|
showCopyButton: true,
|
2022-08-21 13:00:46 +08:00
|
|
|
|
showRemoveButton: true,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
if (devicePointAddress.length > 0) {
|
|
|
|
|
|
this.getDevicePoint(devicePointAddress);
|
|
|
|
|
|
}
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-13 16:20:48 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
addDevice() {
|
|
|
|
|
|
const that = this;
|
|
|
|
|
|
this.$prompt("输入设备名称", "新加设备", {
|
|
|
|
|
|
confirmButtonText: "确定",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
inputErrorMessage: "请输入设备名称",
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}).then(({ value }) => {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.$api.ADD_DEVICE({
|
|
|
|
|
|
action: "add_device",
|
|
|
|
|
|
name: value,
|
|
|
|
|
|
server_id: this.serverData.id,
|
|
|
|
|
|
});
|
|
|
|
|
|
that.getDevice();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "新加设备成功",
|
|
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async delDevice() {
|
|
|
|
|
|
const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE(
|
|
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port,
|
|
|
|
|
|
);
|
|
|
|
|
|
let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
if (deviceNode !== undefined && isArray(deviceNode)) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceNode = filter(deviceNode, (item) => {
|
|
|
|
|
|
return item["@Name"] === this.deviceData[this.deviceActiveStatus].name
|
|
|
|
|
|
? null
|
|
|
|
|
|
: item;
|
|
|
|
|
|
});
|
|
|
|
|
|
deviceConfigure.Content.Settings.GroupNode[0].DeviceNode = deviceNode;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
} else {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
unset(deviceConfigure, "Content.Settings.GroupNode[0].DeviceNode");
|
2022-08-17 00:05:22 +08:00
|
|
|
|
}
|
2022-08-18 14:21:08 +08:00
|
|
|
|
|
2022-08-14 18:30:55 +08:00
|
|
|
|
try {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
await this.$api.SET_HSLSERVER_CONFIGURE(
|
|
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port,
|
|
|
|
|
|
{ data: deviceConfigure.Content }
|
|
|
|
|
|
);
|
|
|
|
|
|
await this.$api.DEL_DEVICE({
|
|
|
|
|
|
action: "remove_device",
|
|
|
|
|
|
id: this.deviceData[this.deviceActiveStatus].id,
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "删除设备成功",
|
|
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
this.getDevice();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
} catch (e) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
console.log(e);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async addDevicePoint(row, done) {
|
|
|
|
|
|
this.formOptions.saveLoading = true;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
if (!this.$refs.deviceConfigure.defaultDeviceTypeNameValue) {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "请先应用设备配置",
|
|
|
|
|
|
type: "error",
|
|
|
|
|
|
});
|
|
|
|
|
|
done(false);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
} else {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
if (row["@DataTypeCode"] === "string" && !row["@Length"]) {
|
2022-08-20 18:17:53 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "数据类型为string,长度不能为空",
|
|
|
|
|
|
type: "error",
|
|
|
|
|
|
});
|
|
|
|
|
|
this.formOptions.saveLoading = false;
|
|
|
|
|
|
return false;
|
2022-08-20 18:17:53 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
assign(row, {
|
|
|
|
|
|
id: this.devicePointData.length + 1,
|
|
|
|
|
|
showBindButton: true,
|
|
|
|
|
|
showCopyButton: true,
|
|
|
|
|
|
showRemoveButton: true,
|
|
|
|
|
|
showSendButton: true,
|
|
|
|
|
|
});
|
|
|
|
|
|
this.devicePointData.push(row);
|
|
|
|
|
|
done();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.formOptions.saveLoading = false;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async delDevicePoint({ index, row }, done) {
|
|
|
|
|
|
this.$delete(this.devicePointData, index);
|
|
|
|
|
|
done();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
getDevicePoint(devicePointAddress) {
|
|
|
|
|
|
clearInterval(this.timing)
|
|
|
|
|
|
this.timing = setInterval(() => {
|
|
|
|
|
|
each(devicePointAddress, async (item) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
this.$api
|
|
|
|
|
|
.GET_DEVICE_POINT_VALUE(
|
|
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port,
|
|
|
|
|
|
this.deviceData[this.deviceActiveStatus].name,
|
|
|
|
|
|
item.value,
|
|
|
|
|
|
item.type
|
|
|
|
|
|
)
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
this.$set(
|
|
|
|
|
|
this.devicePointData[item.key],
|
|
|
|
|
|
"@Value",
|
|
|
|
|
|
res.Content
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}, 10000);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async devicePointBandingNode({ index, row }, done) {
|
2022-08-23 14:09:19 +08:00
|
|
|
|
this.$delete(this.devicePointData[index], "@Binding")
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.$set(this.devicePointData[index], "@Binding", row.nodeCode)
|
|
|
|
|
|
done();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async setDeviceConfigure() {
|
2022-08-14 18:30:55 +08:00
|
|
|
|
try {
|
2022-08-18 14:21:08 +08:00
|
|
|
|
// 验证表单
|
|
|
|
|
|
this.$refs.deviceConfigure.$refs.form.validate((valid) => {
|
|
|
|
|
|
if (!valid) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return false;
|
2022-08-18 14:21:08 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
|
|
|
|
|
const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE(
|
2022-08-23 11:18:12 +08:00
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port
|
2022-08-23 10:07:32 +08:00
|
|
|
|
);
|
2022-08-20 17:03:52 +08:00
|
|
|
|
const deviceConfigureModelValue = this.$refs.deviceConfigure.deviceConfigureModelValue
|
2022-08-14 18:30:55 +08:00
|
|
|
|
if (this.devicePointData.length > 0) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
let devicePointData = this.devicePointData
|
2022-08-20 00:11:27 +08:00
|
|
|
|
devicePointData = each(devicePointData, (item) => {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
if (item["@DataTypeCode"] !== "string") {
|
|
|
|
|
|
unset(item, "@Length");
|
2022-08-20 18:17:53 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
unset(item, "id");
|
|
|
|
|
|
unset(item, "showBindButton");
|
|
|
|
|
|
unset(item, "showCopyButton");
|
|
|
|
|
|
unset(item, "showRemoveButton");
|
|
|
|
|
|
unset(item, "showSendButton");
|
2022-08-23 14:09:19 +08:00
|
|
|
|
unset(item, "@Value");
|
2022-08-23 10:07:32 +08:00
|
|
|
|
item["@Binding"] = item["@Binding"] || ""
|
|
|
|
|
|
});
|
|
|
|
|
|
deviceConfigureModelValue.RequestNode = devicePointData;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
}
|
2022-08-20 18:17:53 +08:00
|
|
|
|
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceConfigureModelValue["@Name"] = this.deviceData[this.deviceActiveStatus].name
|
|
|
|
|
|
let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode || [];
|
|
|
|
|
|
let isExist = false;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
if (deviceNode !== undefined) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceNode = isArray(deviceNode) ? deviceNode : [deviceNode];
|
2022-08-17 00:05:22 +08:00
|
|
|
|
deviceNode = map(deviceNode, (item) => {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
if (
|
|
|
|
|
|
item["@Name"] === this.deviceData[this.deviceActiveStatus].name
|
|
|
|
|
|
) {
|
|
|
|
|
|
isExist = true;
|
|
|
|
|
|
item = deviceConfigureModelValue;
|
2022-08-17 00:05:22 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
return item;
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-17 00:05:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (!isExist) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceNode.push(deviceConfigureModelValue);
|
2022-08-17 00:05:22 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
deviceConfigure.Content.Settings.GroupNode[0].DeviceNode = deviceNode;
|
|
|
|
|
|
await this.$api.SET_HSLSERVER_CONFIGURE(
|
|
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port,
|
|
|
|
|
|
{ data: deviceConfigure.Content }
|
|
|
|
|
|
);
|
|
|
|
|
|
deviceConfigureModelValue.DeviceTypeName =
|
|
|
|
|
|
this.$refs.deviceConfigure.defaultDeviceTypeNameValue;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
const data = {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
action: "update_device",
|
2022-08-20 00:11:27 +08:00
|
|
|
|
conf: JSON.stringify(deviceConfigureModelValue),
|
2022-08-23 10:07:32 +08:00
|
|
|
|
id: this.deviceData[this.deviceActiveStatus].id,
|
|
|
|
|
|
};
|
|
|
|
|
|
this.$api.SET_DEVICE_CONFIGURE(data);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
this.$message({
|
2022-08-23 10:07:32 +08:00
|
|
|
|
message: "操作成功",
|
|
|
|
|
|
type: "success",
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$emit("changeServerConfig", "t");
|
2022-08-14 18:30:55 +08:00
|
|
|
|
} catch (e) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
console.log(e);
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
async getDeviceStatus() {
|
|
|
|
|
|
const res = await this.$api.GET_SERVER_DEVICE_STATUS(
|
2022-08-23 11:18:12 +08:00
|
|
|
|
"http://" + this.serverData.url + ":" + this.serverData.port
|
2022-08-23 10:07:32 +08:00
|
|
|
|
);
|
2022-08-20 00:11:27 +08:00
|
|
|
|
if (res) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.$emit("changeStatus", "online");
|
|
|
|
|
|
const deviceStatus = {};
|
2022-08-20 00:11:27 +08:00
|
|
|
|
each(res.Content.__deviceList, (item) => {
|
|
|
|
|
|
deviceStatus[item.__name] = {
|
|
|
|
|
|
status: item.__requestEnable,
|
2022-08-23 10:07:32 +08:00
|
|
|
|
name: item.__name,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2022-08-14 18:30:55 +08:00
|
|
|
|
each(this.deviceData, (item) => {
|
2022-08-20 00:11:27 +08:00
|
|
|
|
if (deviceStatus[item.name]) {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
item.status = deviceStatus[item.name].status;
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
});
|
2022-08-20 00:11:27 +08:00
|
|
|
|
} else {
|
2022-08-23 10:07:32 +08:00
|
|
|
|
this.$emit("changeStatus", false);
|
2022-08-20 00:11:27 +08:00
|
|
|
|
}
|
2022-08-21 13:00:46 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
clearTime(){
|
|
|
|
|
|
clearInterval(this.timing)
|
|
|
|
|
|
this.timing = null
|
|
|
|
|
|
}
|
2022-08-14 18:30:55 +08:00
|
|
|
|
},
|
2022-08-23 10:07:32 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getDevice();
|
|
|
|
|
|
this.getworkingSubclasses();
|
|
|
|
|
|
this.getDeviceStatus();
|
2022-08-14 18:30:55 +08:00
|
|
|
|
}
|
2022-08-23 10:07:32 +08:00
|
|
|
|
};
|
2022-08-13 16:20:48 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.menu-box {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
vertical-align: middle;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-dropdown {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
vertical-align: top;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-23 10:07:32 +08:00
|
|
|
|
.el-dropdown + .el-dropdown {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
margin-left: 15px;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-icon-arrow-down {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
font-size: 12px;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.menu-header {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
position: relative;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-title {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
width: 60%;
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
color: black;
|
|
|
|
|
|
vertical-align: middle;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.header-button {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
float: right;
|
|
|
|
|
|
vertical-align: middle;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.serve-item {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
border: none;
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
outline: 0;
|
|
|
|
|
|
border-radius: 4px;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.device-status {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
width: 10px;
|
|
|
|
|
|
height: 10px;
|
|
|
|
|
|
border-radius: 50%;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
|
2022-08-17 00:05:22 +08:00
|
|
|
|
right: 0;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
transform: translate(0, -50%);
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.device-status-online {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
background-color: #67c23a;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.device-status-offline {
|
2022-08-17 00:05:22 +08:00
|
|
|
|
background-color: #ccc;
|
2022-08-13 16:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|