123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template></template>
- <script setup>
- import { ref, onMounted, reactive } from "vue";
- import { RouterView, RouterLink } from "vue-router";
- import { request, uploadFile } from "@/utils/request";
- import { vtkmodel } from "@/control/vtkModel.js";
- import { throttle } from "@kitware/vtk.js/macros";
- import vtkSphereSource from "@kitware/vtk.js/Filters/Sources/SphereSource";
- import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
- import vtkMapper from "@kitware/vtk.js/Rendering/Core/Mapper";
- import vtkLineSource from "@kitware/vtk.js/Filters/Sources/LineSource";
- import vtkPointSource from "@kitware/vtk.js/Filters/Sources/PointSource";
- onMounted(() => {
- readNodeAndPipe();
- vtkmodel.clearJgAddMode();
- });
- const nodes = ref([]); //节点数据
- const pipes = ref([]); //管道数据
- const delNodes = ref([]); //无效节点
- const validNodes = ref([]); //有效节点
- async function readNodeAndPipe() {
- const params = {
- transCode: "D00000",
- count: 1000,
- page: 1,
- };
- await request(params)
- .then((res) => {
- if (res.returnCode == "000000000") {
- nodes.value = res.rows;
- readePipe();
- } else {
- ElMessage({
- message: res.returnMsg,
- type: "error",
- });
- }
- })
- .catch((err) => {});
- }
- async function readePipe() {
- const params = {
- transCode: "D00001",
- count: 1000,
- page: 1,
- };
- await request(params)
- .then((res) => {
- if (res.returnCode == "000000000") {
- pipes.value = res.rows;
- lineShow();
- } else {
- ElMessage({
- message: res.returnMsg,
- type: "error",
- });
- }
- })
- .catch((err) => {});
- }
- /**
- * 在管道中已存在的点才可以使用
- */
- function nodeIsValid(node) {
- let isValid = false;
- pipes.value.forEach((pipe) => {
- if (node.id == pipe.snId || node.id == pipe.enId) {
- isValid = true;
- return isValid;
- }
- });
- return isValid;
- }
- function lineShow() {
- console.log("模板加载..");
- //判断NODE 是否在管道中使用
- nodes.value.forEach((node) => {
- if (!nodeIsValid(node)) {
- delNodes.value.push(node);
- } else {
- validNodes.value.push(node);
- }
- });
- vtkmodel.modelInit(validNodes.value, pipes.value);
- // vtkmodel.selectNodes();
- vtkmodel.selectPipes();
- }
- </script>
- <style scoped>
- .vtk {
- position: absolute;
- z-index: 150;
- top: 70px;
- }
- span {
- position: absolute;
- top: 2px;
- }
- </style>
|