Bläddra i källkod

عدم نمایش محصولات مرتبط وقتی محصول مرتبطی تعریف نشده است

hgh 1 år sedan
förälder
incheckning
4e6cc0ffe9

+ 10 - 3
src/components/Widgets/ContentCategory/ContentCategoryShow/ContentCategoryShow.vue

@@ -26,10 +26,11 @@
         <content-item :content="getContent(inputData.props.row)" />
       </template>
     </entity-index>
-    <q-banner class="ContentCategoryShow-banner">
+    <q-banner v-if="showRelatedProduct"
+              class="ContentCategoryShow-banner">
       محصولات مرتبط
     </q-banner>
-    <entity-index v-if="mounted && contentCategory.id"
+    <entity-index v-if="mounted && contentCategory.id && showRelatedProduct"
                   ref="entityIndex"
                   v-model:value="productInputs"
                   class="product-index"
@@ -40,7 +41,8 @@
                   :default-layout="false"
                   :show-search-button="false"
                   :show-expand-button="false"
-                  :show-reload-button="false">
+                  :show-reload-button="false"
+                  @onPageChanged="onProductPageChanged">
       <template #entity-index-table-item-cell="{inputData}">
         <product-item :product="getProduct(inputData.props.row)" />
       </template>
@@ -87,6 +89,7 @@ export default {
         columns: []
       },
       mounted: false,
+      showRelatedProduct: true,
       contentCategory: new ContentCategory(),
       contentCategoryParent: new ContentCategory(),
       contentCategoryParentParent: new ContentCategory(),
@@ -267,6 +270,10 @@ export default {
       }
 
       this.$store.commit('AppLayout/updateBreadcrumbs', breadcrumbs)
+    },
+    onProductPageChanged (response) {
+      console.log(response.data)
+      this.showRelatedProduct = response?.data?.results?.length !== 0
     }
   }
 }