project-config.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <script setup lang="ts">
  2. import HJFlow from "@/components/hjflow/src/hjflow/index.vue";
  3. import {
  4. HJFlowInstance,
  5. HJMethodName,
  6. HJNodeData,
  7. } from "@/components/hjflow/src/types/comTypes";
  8. import { Edge } from "@vue-flow/core";
  9. import ProjectMessage from "./com/project-message.vue";
  10. import FunctionModule from "./com/function-col.vue";
  11. import TitleHeader from "@/views/modules/project-config/com/titleHeader.vue";
  12. import { AutoTestNodeData, InforPropertyModel } from "./configs/properites";
  13. import type { FormInstance } from "element-plus";
  14. const flowRef = ref<HJFlowInstance>();
  15. const nodes = ref<HJNodeData[]>([]);
  16. const edges = ref<Edge[]>([]);
  17. // vue 的相关操作
  18. const onNodeOperation = (name: HJMethodName, node: HJNodeData): void => {
  19. if (name === HJMethodName.EditNode) {
  20. selectedNode.value = null;
  21. selectedNode.value = JSON.parse(JSON.stringify(node));
  22. infoVisible.value = true;
  23. } else if (name === HJMethodName.SaveTemplate) {
  24. console.log("保存模版数据");
  25. }
  26. };
  27. // 右侧信息
  28. // ======= 信息展示 =======
  29. const infoVisible = ref(false);
  30. const selectedNode = ref<AutoTestNodeData | null>(null); //双击的节点数据
  31. const onSaveConfigs = () => {
  32. console.log("onSaveConfigs", selectedNode.value);
  33. flowRef.value &&
  34. flowRef.value.updateNodeData(
  35. JSON.parse(JSON.stringify(selectedNode.value))
  36. );
  37. infoVisible.value = false;
  38. selectedNode.value = null;
  39. };
  40. onMounted(() => {
  41. // 接口调用完成要初始化 ,为的是保存一个最初的数据
  42. flowRef.value && flowRef.value.initFlow([], []);
  43. });
  44. </script>
  45. <template>
  46. <div class="project-config-container">
  47. <ProjectMessage />
  48. <FunctionModule />
  49. <HJFlow
  50. class="hjflow-box"
  51. ref="flowRef"
  52. v-model:nodes-data="nodes"
  53. v-model:edges-data="edges"
  54. :show-panel="true"
  55. :panel-btns="['toSnake', 'layoutTB', 'saveTemplate']"
  56. @hjMethod="onNodeOperation"
  57. />
  58. <div class="right-message-box">
  59. <TitleHeader>属性配置</TitleHeader>
  60. <div class="form-box" v-if="infoVisible">
  61. <el-form rer="formRef" label-position="top">
  62. <el-form-item label="节点名称">
  63. <el-input
  64. v-model="selectedNode!.data.information.nodeName"
  65. ></el-input>
  66. </el-form-item>
  67. <el-form-item
  68. v-for="property in selectedNode?.data?.information?.properties"
  69. :label="property.proName"
  70. :key="property.proName"
  71. >
  72. <el-input v-model="property.bindValue"></el-input>
  73. </el-form-item>
  74. </el-form>
  75. </div>
  76. <div class="bottom-box">
  77. <div class="save-btn" @click="onSaveConfigs">
  78. <svg-icon icon-class="save" />
  79. 保存节点信息
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <style scoped lang="scss">
  86. .project-config-container {
  87. display: flex;
  88. width: 100%;
  89. height: calc(100vh - $main-header-height);
  90. }
  91. .hjflow-box {
  92. //width: 100%;
  93. flex: 1;
  94. height: 100%;
  95. }
  96. .right-message-box {
  97. width: 296px;
  98. flex-shrink: 0;
  99. background-color: rgba(80, 80, 80, 1);
  100. height: calc(100vh - $main-header-height);
  101. position: relative;
  102. .form-box {
  103. width: 100%;
  104. padding: 24px;
  105. }
  106. .bottom-box {
  107. position: absolute;
  108. bottom: 0;
  109. left: 0;
  110. width: 100%;
  111. //height: 80px;
  112. padding: 10px 0;
  113. background-color: $hj-black-2;
  114. .save-btn {
  115. width: 130px;
  116. height: 36px;
  117. line-height: 36px;
  118. margin: 0 auto;
  119. background: var(--fc-color-7);
  120. color: var(--hj-white-1);
  121. text-align: center;
  122. border-radius: 4px 4px 4px 4px;
  123. cursor: pointer;
  124. }
  125. }
  126. }
  127. :deep(.el-form-item--label-top .el-form-item__label) {
  128. height: 18px;
  129. font-weight: 400;
  130. font-size: 14px;
  131. color: #ffffff;
  132. line-height: 16px;
  133. text-align: left;
  134. }
  135. </style>