Browse Source

fix eslint: Unexpected side effect in 'cacheParams' computed property

chengshiwen 4 years ago
parent
commit
9234e46b22

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/flink.vue

@@ -426,10 +426,22 @@
       // Watch the cacheParams
       cacheParams (val) {
         this.$emit('on-cache-params', val)
+      },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -444,23 +456,16 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
           mainClass: this.mainClass,
           mainJar: {
             id: this.mainJar
           },
           deployMode: this.deployMode,
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams,
           slot: this.slot,
           taskManager: this.taskManager,

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/mr.vue

@@ -303,10 +303,22 @@
       // Watch the cacheParams
       cacheParams (val) {
         this.$emit('on-cache-params', val)
+      },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -321,22 +333,15 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
           mainClass: this.mainClass,
           mainJar: {
             id: this.mainJar
           },
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams,
           mainArgs: this.mainArgs,
           others: this.others,

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/python.vue

@@ -259,10 +259,22 @@
       // Watch the cacheParams
       cacheParams (val) {
         this.$emit('on-cache-params', val)
+      },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -277,18 +289,11 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams
         }
       }

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/shell.vue

@@ -268,10 +268,22 @@
       // Watch the cacheParams
       cacheParams (val) {
         this.$emit('on-cache-params', val)
+      },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -286,18 +298,11 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams
         }
       }

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/spark.vue

@@ -457,10 +457,22 @@
       // Watch the cacheParams
       cacheParams (val) {
         this.$emit('on-cache-params', val)
+      },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -475,23 +487,16 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
           mainClass: this.mainClass,
           mainJar: {
             id: this.mainJar
           },
           deployMode: this.deployMode,
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams,
           driverCores: this.driverCores,
           driverMemory: this.driverMemory,

+ 17 - 12
dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/waterdrop.vue

@@ -312,6 +312,18 @@
         this.resourceNameVal = val
         this.$emit('on-cache-params', val)
       },
+      resourceIdArr (arr) {
+        let result = []
+        arr.forEach(item => {
+          this.allNoResources.forEach(item1 => {
+            if (item.id === item1.id) {
+              // resultBool = true
+              result.push(item1)
+            }
+          })
+        })
+        this.noRes = result
+      },
       master: {
         handler (code) {
           if (code === 'spark://') {
@@ -326,7 +338,7 @@
       }
     },
     computed: {
-      cacheParams () {
+      resourceIdArr () {
         let isResourceId = []
         let resourceIdArr = []
         if (this.resourceList.length > 0) {
@@ -341,18 +353,11 @@
             return { id: item.id, name: item.name, res: item.fullName }
           })
         }
-        let result = []
-        resourceIdArr.forEach(item => {
-          this.allNoResources.forEach(item1 => {
-            if (item.id === item1.id) {
-              // resultBool = true
-              result.push(item1)
-            }
-          })
-        })
-        this.noRes = result
+        return resourceIdArr
+      },
+      cacheParams () {
         return {
-          resourceList: resourceIdArr,
+          resourceList: this.resourceIdArr,
           localParams: this.localParams,
           deployMode: this.deployMode,
           master: this.master,