Browse Source

蛇形排序。

jxq 2 weeks ago
parent
commit
8076bc18eb

+ 8 - 1
src/api/craft/route/index.ts

@@ -25,6 +25,14 @@ export function saveProcessInRoute(data: object) {
     data: data,
   });
 }
+// 后端蛇形排序
+export function toJavaSnake(data: object) {
+  return request({
+    url: `/api/v1/op/routeOperation/serpentine/sort`,
+    method: "post",
+    data: data,
+  });
+}
 
 // 保存xx关系表中的工序
 export function updateProcess(data: object) {
@@ -44,7 +52,6 @@ export function editRouteWith(data: object) {
   });
 }
 
-
 // 编辑工艺 针对产品负责人的修改
 export function copyList(data: object) {
   return request({

+ 20 - 5
src/views/base/craftManagement/route/bindProcess.vue

@@ -268,6 +268,7 @@ import { useCommonStoreHook, useDictionaryStore } from "@/store";
 import {
   processesByRouteId,
   saveProcessInRoute,
+  toJavaSnake,
   updateProcess,
 } from "@/api/craft/route/index";
 import { formOption } from "./bindConfig";
@@ -501,6 +502,8 @@ const errArray = ref([]);
 provide("errArray", errArray);
 // 保存中间的工序列表
 const saveFlow = async () => {
+  console.log("saveFlow", flowData);
+  return;
   const { code, msg } = await saveProcessInRoute({
     processRouteId: route.fullPath.split("/")[4],
     routeData: JSON.stringify({ ...flowData }),
@@ -711,12 +714,24 @@ async function layoutGraph(direction) {
   });
 }
 // 转换为蛇形布局
-const convertToSnakeLayout = () => {
-  addHistory();
-  nodes.value = useSnakeLayoutHook(nodes.value, edges.value);
-  nextTick(() => {
-    fitView();
+// const convertToSnakeLayout = () => {
+//   addHistory();
+//   nodes.value = useSnakeLayoutHook(nodes.value, edges.value);
+//   nextTick(() => {
+//     fitView();
+//   });
+// };
+const convertToSnakeLayout = async () => {
+  const res = await toJavaSnake({
+    id: route.fullPath.split("/")[4],
+    routeData: JSON.stringify({ ...flowData }),
   });
+  let jsonData = JSON.parse(res.data.routeData);
+  flowData.nodes = jsonData.nodes;
+  flowData.edges = jsonData.edges;
+
+  // await loadProcessesFlow();
+  // flowBoxScreen();
 };
 </script>
 

+ 29 - 16
src/views/base/craftManagement/route/components/CustomNode/index.vue

@@ -47,14 +47,6 @@ console.log(props.data);
 
 <template>
   <div class="nodes" :class="getBorderClass">
-    <Handle
-      :style="{
-        height: '13px',
-        width: '13px',
-      }"
-      type="target"
-      :position="Position.Top"
-    />
     <div
       style="
         text-align: center;
@@ -66,14 +58,30 @@ console.log(props.data);
       {{ data.lineTag ? data.label + "(" + data.lineTag + ")" : data.label }}
     </div>
 
-    <Handle
-      :style="{
-        height: '13px',
-        width: '13px',
-      }"
-      type="source"
-      :position="Position.Bottom"
-    />
+    <!--    <div v-if="props.sourcePosition && props.targetPosition">-->
+    <!--      <Handle-->
+    <!--        class="handle-style"-->
+    <!--        type="source"-->
+    <!--        :position="props.sourcePosition"-->
+    <!--      />-->
+    <!--      <Handle-->
+    <!--        class="handle-style"-->
+    <!--        type="target"-->
+    <!--        :position="props.targetPosition"-->
+    <!--      />-->
+    <!--    </div>-->
+    <div v-if="data.handles && data.handles.length">
+      <Handle
+        class="handle-style"
+        v-for="(handle, index) in data.handles"
+        :type="handle.type"
+        :position="handle.position"
+      />
+    </div>
+    <div v-else>
+      <Handle class="handle-style" type="target" :position="Position.Top" />
+      <Handle class="handle-style" type="source" :position="Position.Bottom" />
+    </div>
   </div>
 </template>
 <style lang="scss">
@@ -110,4 +118,9 @@ console.log(props.data);
   border-width: 2px;
   color: green;
 }
+
+.handle-style {
+  width: 13px;
+  height: 13px;
+}
 </style>