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

Merge branch 'master' of http://git.hghweb.ir/ali.s/palizvani-front-vite into production

hgh 2 лет назад
Родитель
Сommit
0464d221ed

+ 29 - 18
src/components/FormBuilderCustumComponents/PostCategorySelector.vue

@@ -36,7 +36,7 @@ export default {
   props: {
     value: {
       default: () => [],
-      type: [Array, String, Number, Boolean]
+      type: [Array, String, Number, Boolean, Object]
     },
     disable: {
       default: false,
@@ -57,15 +57,19 @@ export default {
   },
   watch: {
     value () {
-      if (this.value.id) {
+      if (this.value?.id) {
         this.getCategories()
-      } else {
+      } else if (this.value) {
         this.inputData = this.value
       }
     },
     mainCategory (newValue) {
       this.subCategory = null
       this.subCategoryOptions = []
+      if (!newValue.item.children) {
+        this.$emit('update:value', newValue.value)
+        return
+      }
       this.subCategoryOptions = newValue.item.children.map(item => {
         return {
           item,
@@ -77,6 +81,10 @@ export default {
     subCategory (newValue) {
       this.bakhshCategory = null
       this.bakhshCategoryOptions = []
+      if (!newValue?.item?.children) {
+        this.$emit('update:value', null)
+        return
+      }
       this.bakhshCategoryOptions = newValue.item.children.map(item => {
         return {
           item,
@@ -94,27 +102,29 @@ export default {
     this.getCategories()
   },
   methods: {
-    setMainCategory () {
-      if (!this.value?.parent?.parent?.id) {
+    setMainCategory (category) {
+      if (!category?.parent?.parent?.id) {
         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
       }
-      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
       }
-      this.bakhshCategory = this.bakhshCategoryOptions.find(item => item.value === this.value.id)
+      this.bakhshCategory = this.bakhshCategoryOptions.find(item => item.value === category.id)
     },
     getCategories () {
       this.postCategories.laoding = true
-      APIGateway.postCategory.index({ parent__isnull: 'true', per_page: 99999 })
+      const args = { parent__isnull: 'true', per_page: 99999 }
+      const apiGateway = APIGateway.postCategory.index(args)
+      apiGateway
         .then(postCategories => {
           this.postCategories = new PostCategoryList(postCategories.list)
           this.postCategories.laoding = false
@@ -126,14 +136,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.setMainCategory()
+              this.setMainCategory(category)
               this.$nextTick(() => {
-                this.setSubCategory()
+                this.setSubCategory(category)
                 this.$nextTick(() => {
-                  this.setBakhshCategory()
-                  this.$emit('update:value', this.value.id)
+                  this.setBakhshCategory(category)
+                  this.$emit('update:value', category.id)
                 })
               })
             })

+ 26 - 20
src/components/Widgets/ContentCategory/ContentCategoryList/ContentCategoryItem.vue

@@ -1,24 +1,27 @@
 <template>
-  <q-card class="ContentCategoryItem"
-          :class="listType"
-          flat>
-    <div class="thumbnail"
-         @click="goToCategoryPageShow">
-      <q-img :src="contentCategory.thumbnail" />
-    </div>
-    <div class="cation">
-      <q-btn color="primary"
-             :to="{name: showCategoryRouteName, params: {category_id: contentCategory.id}}">
-        مشاهده جزییات
-      </q-btn>
-    </div>
-    <div class="title ellipsis-2-lines">
-      {{ contentCategory.title }}
-    </div>
-    <div class="description ellipsis-3-lines">
-      {{ contentCategory.description }}
-    </div>
-  </q-card>
+  <div class="col-md-4 col-sm-6 col-12">
+    <q-card class="ContentCategoryItem"
+            :class="listType"
+            flat>
+      <div class="thumbnail"
+           @click="goToCategoryPageShow">
+        <q-img :src="contentCategory.thumbnail" />
+      </div>
+      <div class="cation">
+        <q-btn color="primary"
+               :to="{name: showCategoryRouteName, params: {category_id: contentCategory.id}}">
+          مشاهده جزییات
+        </q-btn>
+      </div>
+      <div class="title ellipsis-2-lines">
+        {{ contentCategory.title }}
+      </div>
+      <div class="description ellipsis-3-lines">
+        {{ contentCategory.description }}
+      </div>
+    </q-card>
+  </div>
+
 </template>
 
 <script>
@@ -50,10 +53,13 @@ export default {
 
 <style lang="scss" scoped>
 .ContentCategoryItem {
+  background-color: lighten($primary,3%);
   display: flex;
   flex-flow: column;
   position: relative;
   cursor: pointer;
+  //padding: 20px 20px 30px;
+  margin: 8px;
   .thumbnail {
     .q-img {
       width: 100%;

+ 22 - 22
src/components/Widgets/ContentCategory/ContentCategoryList/ContentCategoryList.vue

@@ -218,28 +218,28 @@ export default {
     margin-bottom: 39px;
     margin-top: 50px;
   }
-  :deep(.entity-index) {
-    margin-top: 24px;
-    .quasar-crud-index-table {
-      .q-table__top {
-        display: none;
-      }
-      .q-table__grid-content {
-        $gap: 24px;
-        flex-wrap: wrap;
-        gap: $gap;
-        .ContentCategoryItem {
-          flex: 0 0 calc( 33.33% - #{$gap} );
-          box-sizing: border-box;
-        }
-      }
-      .q-table__bottom {
-        .q-table__control {
-          display: none;
-        }
-      }
-    }
-  }
+  //:deep(.entity-index) {
+  //  margin-top: 24px;
+  //  .quasar-crud-index-table {
+  //    .q-table__top {
+  //      display: none;
+  //    }
+  //    .q-table__grid-content {
+  //      $gap: 24px;
+  //      flex-wrap: wrap;
+  //      gap: $gap;
+  //      .ContentCategoryItem {
+  //        flex: 0 0 calc( 33.33% - #{$gap} );
+  //        box-sizing: border-box;
+  //      }
+  //    }
+  //    .q-table__bottom {
+  //      .q-table__control {
+  //        display: none;
+  //      }
+  //    }
+  //  }
+  //}
   .more-action {
     display: flex;
     flex-flow: row;