Browse Source

工艺复制

damon227 1 year ago
parent
commit
3152c678a4
1 changed files with 20 additions and 5 deletions
  1. 20 5
      src/views/modules/tech/ctafts-add-or-detail.vue

+ 20 - 5
src/views/modules/tech/ctafts-add-or-detail.vue

@@ -102,6 +102,7 @@ import { getInfo, getProduct, getWorkType } from '@/api/crafts'
 import UploadComponent from '../common/upload-component'
 import WorkFlow from '@/components/work-flow/home'
 // import data from "@/components/work-flow/config/data.json";
+import { GenNonDuplicateID } from '@/components/work-flow/until'
 export default {
   name: 'add-or-update',
   components: { UploadComponent, WorkFlow },
@@ -275,14 +276,28 @@ export default {
           if (this.isCopy) {
             this.dataForm.id = 0
             this.dataForm.techId = null
-            if (flowData.lineList != null && flowData.lineList.length > 0) {
-              for (let index = 0; index < flowData.lineList.length; index++) {
-                flowData.lineList[index].techId = null
-              }
-            }
+
             if (flowData.nodeList != null && flowData.nodeList.length > 0) {
               for (let index = 0; index < flowData.nodeList.length; index++) {
+                let oldId = flowData.nodeList[index].id
+                let newId = GenNonDuplicateID(8)
                 flowData.nodeList[index].techId = null
+                flowData.nodeList[index].id = newId
+
+                if (flowData.lineList != null && flowData.lineList.length > 0) {
+                  for (let index = 0; index < flowData.lineList.length; index++) {
+                    flowData.lineList[index].techId = null
+                    flowData.lineList[index].id = GenNonDuplicateID(8)
+                    let from = flowData.lineList[index].from
+                    let to = flowData.lineList[index].to
+                    if (from === oldId) {
+                      flowData.lineList[index].from = newId
+                    }
+                    if (to === oldId) {
+                      flowData.lineList[index].to = newId
+                    }
+                  }
+                }
               }
             }
           }