Explorar el Código

选择核查文件组件回显问题bug修复

cyy hace 1 mes
padre
commit
9c83222f98
Se han modificado 1 ficheros con 49 adiciones y 0 borrados
  1. 49 0
      src/views/component/selectFileTypeToShenCha.vue

+ 49 - 0
src/views/component/selectFileTypeToShenCha.vue

@@ -11,6 +11,12 @@
 import TreeUtils from '@/utils/tree'
 import TreeUtils from '@/utils/tree'
 
 
 export default {
 export default {
+  props: {
+    formData: {
+      type: Object,
+      default: () => {}
+    }
+  },
   data() {
   data() {
     const { level, userId, userInfo } = this.$store.getters
     const { level, userId, userInfo } = this.$store.getters
     return {
     return {
@@ -31,6 +37,24 @@ export default {
     }
     }
   },
   },
   watch: {
   watch: {
+    options: {
+      handler(value, old) {
+        if (
+          value &&
+          value.length > 0 &&
+          this.formData.xiLeiId != '' &&
+          typeof this.formData.xiLeiId !== 'undefined' &&
+          this.formData.xiLeiId !== null
+        ) {
+          this.selectDatas = []
+          this.formData.xiLeiId.split(',').forEach((element) => {
+            let mid = this.getFullPath(element)
+            this.selectDatas.push(mid)
+          })
+        }
+      },
+      immediate: true
+    },
     selectDatas(v) {
     selectDatas(v) {
       const typeId = []
       const typeId = []
       const typeNames = []
       const typeNames = []
@@ -47,6 +71,9 @@ export default {
         }
         }
         this.$emit('change-data', 'xiLeiId', typeId.join(','))
         this.$emit('change-data', 'xiLeiId', typeId.join(','))
         this.$emit('change-data', 'xiLeiXuanZe', typeNames.join(','))
         this.$emit('change-data', 'xiLeiXuanZe', typeNames.join(','))
+      } else {
+        this.$emit('change-data', 'xiLeiId', '')
+        this.$emit('change-data', 'xiLeiXuanZe', '')
       }
       }
     }
     }
   },
   },
@@ -54,6 +81,28 @@ export default {
     this.getPositionList()
     this.getPositionList()
   },
   },
   methods: {
   methods: {
+    getFullPath(val) {
+      let stack = []
+      stack = this.options.map((item) => ({
+        path: [item.ID_],
+        ...item
+      }))
+      while (stack.length) {
+        const curr = stack.pop()
+        const { children, ID_, path } = curr
+        if (ID_ === val) {
+          return curr.path
+        } else if (children?.length) {
+          stack = [
+            ...stack,
+            ...children.map((item) => ({
+              ...item,
+              path: path.concat(item.ID_)
+            }))
+          ]
+        }
+      }
+    },
     // 获取本账户所在的部门
     // 获取本账户所在的部门
     getPositionList() {
     getPositionList() {
       const { first, second } = this.$store.getters.level || {}
       const { first, second } = this.$store.getters.level || {}