You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.3 KiB
Vue
98 lines
2.3 KiB
Vue
4 months ago
|
<template>
|
||
|
<div
|
||
|
:style="{width:props.dimensions.width+'px',height:props.dimensions.height+'px'}">
|
||
|
<NodeResizer color="#fff" v-if="!props.isView && !props.isHideHandle && props.selected" @resize="resize" />
|
||
|
|
||
|
<div class="custom-node"
|
||
|
:style="{width:props.dimensions.width+'px',height:props.dimensions.height+'px',pointerEvents:props.isView?'auto': 'none'}">
|
||
|
<el-button type="primary" :style="{width:props.dimensions.width +'px',height:props.dimensions.height+'px'}"
|
||
|
:icon="Connection">设备运行数量
|
||
|
</el-button>
|
||
|
<span style="color:#fff">
|
||
|
</span>
|
||
|
</div>
|
||
|
<Handle v-if="!props.isView" :id="`${props.id}.-t`" type="target" :position="Position.Left" />
|
||
|
<Handle v-if="!props.isView" :id="`${props.id}.-s`" type="source" :position="Position.Right" />
|
||
|
</div>
|
||
|
</template>
|
||
|
<script setup>
|
||
|
import { defineEmits, defineProps, ref } from 'vue';
|
||
|
import { NodeResizer } from '@vue-flow/node-resizer';
|
||
|
import { Connection } from '@element-plus/icons-vue';
|
||
|
import { Handle, Position } from '@vue-flow/core';
|
||
|
import axios from 'axios';
|
||
|
import request from '@/utils/request';
|
||
|
import { options } from '../../tool.js';
|
||
|
|
||
|
const props = defineProps({
|
||
|
isView: {
|
||
|
type: Boolean,
|
||
|
required: false
|
||
|
},
|
||
|
inputData: {
|
||
|
type: Object,
|
||
|
required: false
|
||
|
},
|
||
|
id: {
|
||
|
type: String,
|
||
|
required: true
|
||
|
},
|
||
|
isHideHandle: {
|
||
|
type: Boolean,
|
||
|
required: false
|
||
|
},
|
||
|
selected: {
|
||
|
type: Boolean,
|
||
|
required: false
|
||
|
},
|
||
|
data: {
|
||
|
type: Object,
|
||
|
required: true
|
||
|
},
|
||
|
dimensions: {
|
||
|
type: Object,
|
||
|
required: true
|
||
|
}
|
||
|
});
|
||
|
const service = axios.create({
|
||
|
baseURL: 'http://localhost:3000',
|
||
|
timeout: 10000
|
||
|
});
|
||
|
const getOutputData = () => {
|
||
|
(options.isD ? request : service)({
|
||
|
method: 'post',
|
||
|
url: '/test/getDevice',
|
||
|
data: props.inputData
|
||
|
}).then(res => {
|
||
|
props.data.outputData = {
|
||
|
time: res.data?.data?.map(e => e.time),
|
||
|
value: res.data?.data?.map(e => e.value)
|
||
|
};
|
||
|
});
|
||
|
};
|
||
|
|
||
|
onMounted(() => {
|
||
|
getOutputData();
|
||
|
});
|
||
|
|
||
|
let interval = setInterval(() => {
|
||
|
getOutputData();
|
||
|
}, 1000);
|
||
|
|
||
|
onBeforeUnmount(() => {
|
||
|
clearInterval(interval);
|
||
|
interval = null;
|
||
|
});
|
||
|
const emit = defineEmits(['resize']);
|
||
|
const resize = (e) => {
|
||
|
emit('resize', e, props.id);
|
||
|
};
|
||
|
</script>
|
||
|
<style scoped>
|
||
|
.custom-node {
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
}
|
||
|
|
||
|
</style>
|