Просмотр исходного кода

fix AdminContentShow.vue select content category

ali 2 лет назад
Родитель
Сommit
196abbe0a2

+ 18 - 17
src/components/FormBuilderCustumComponents/ContentCategorySelector.vue

@@ -88,7 +88,7 @@ export default {
     value () {
     value () {
       if (this.value?.id) {
       if (this.value?.id) {
         this.getCategories()
         this.getCategories()
-      } else {
+      } else if (this.value) {
         this.inputData = this.value
         this.inputData = this.value
       }
       }
     },
     },
@@ -110,8 +110,8 @@ export default {
     subCategory (newValue) {
     subCategory (newValue) {
       this.bakhshCategory = null
       this.bakhshCategory = null
       this.bakhshCategoryOptions = []
       this.bakhshCategoryOptions = []
-      if (!newValue.item.children) {
-        this.$emit('update:value', newValue.value)
+      if (!newValue?.item?.children) {
+        this.$emit('update:value', null)
         return
         return
       }
       }
       this.bakhshCategoryOptions = newValue.item.children.map(item => {
       this.bakhshCategoryOptions = newValue.item.children.map(item => {
@@ -131,23 +131,23 @@ export default {
     this.getCategories()
     this.getCategories()
   },
   },
   methods: {
   methods: {
-    setMainCategory () {
-      if (!this.value?.parent?.parent?.id) {
+    setMainCategory (category) {
+      if (!category?.parent?.parent?.id) {
         return
         return
       }
       }
-      this.mainCategory = this.mainCategoryOptions.find(item => item.value === this.value.parent.parent.id)
+      this.mainCategory = this.mainCategoryOptions.find(item => item.value === category.parent.parent.id)
     },
     },
-    setSubCategory () {
-      if (!this.value?.parent?.id) {
+    setSubCategory (category) {
+      if (!category?.parent?.id) {
         return
         return
       }
       }
-      this.subCategory = this.subCategoryOptions.find(item => item.value === this.value.parent.id)
+      this.subCategory = this.subCategoryOptions.find(item => item.value === category.parent.id)
     },
     },
-    setBakhshCategory () {
-      if (!this.value?.id) {
+    setBakhshCategory (category) {
+      if (!category?.id) {
         return
         return
       }
       }
-      this.bakhshCategory = this.bakhshCategoryOptions.find(item => item.value === this.value.id)
+      this.bakhshCategory = this.bakhshCategoryOptions.find(item => item.value === category.id)
     },
     },
     getCategories () {
     getCategories () {
       this.categories.laoding = true
       this.categories.laoding = true
@@ -180,14 +180,15 @@ export default {
             }
             }
           })
           })
 
 
-          if (this.value?.parent?.parent?.id && this.value.id) {
+          if (this.value?.parent?.parent?.id && this.value?.id) {
+            const category = this.value
             this.$nextTick(() => {
             this.$nextTick(() => {
-              this.setMainCategory()
+              this.setMainCategory(category)
               this.$nextTick(() => {
               this.$nextTick(() => {
-                this.setSubCategory()
+                this.setSubCategory(category)
                 this.$nextTick(() => {
                 this.$nextTick(() => {
-                  this.setBakhshCategory()
-                  this.$emit('update:value', this.value.id)
+                  this.setBakhshCategory(category)
+                  this.$emit('update:value', category.id)
                 })
                 })
               })
               })
             })
             })

+ 1 - 5
src/components/Widgets/Content/AdminContentShow/AdminContentShow.vue

@@ -109,11 +109,7 @@ export default {
     edit() {
     edit() {
       this.entityLoading = true
       this.entityLoading = true
       this.$refs.entityEdit.editEntity(false)
       this.$refs.entityEdit.editEntity(false)
-        .then(() => {
-          this.$refs.entityEdit.getData()
-          this.entityLoading = false
-        })
-        .catch(() => {
+        .finally(() => {
           this.$refs.entityEdit.getData()
           this.$refs.entityEdit.getData()
           this.entityLoading = false
           this.entityLoading = false
         })
         })