ali 1 рік тому
батько
коміт
9fefa031d8

+ 2 - 0
src/api/APIGateway.js

@@ -25,6 +25,7 @@ import DonationAPI from 'src/api/models/Donation.js'
 import QuestionApi from 'src/api/models/Question.js'
 import DiscountAPI from 'src/api/models/Discount.js'
 import ClassroomAPI from 'src/api/models/Classroom.js'
+import AppSettingAPI from 'src/api/models/AppSetting.js'
 import AnswerBookApi from 'src/api/models/AnswerBook.js'
 import InstalmentAPI from 'src/api/models/Instalment.js'
 import BasketItemAPI from 'src/api/models/BasketItem.js'
@@ -84,6 +85,7 @@ export const APIGateway = {
   question: new QuestionApi(),
   discount: new DiscountAPI(),
   classroom: new ClassroomAPI(),
+  appSetting: new AppSettingAPI(),
   answerBook: new AnswerBookApi(),
   instalment: new InstalmentAPI(),
   basketItem: new BasketItemAPI(),

+ 100 - 0
src/api/models/AppSetting.js

@@ -0,0 +1,100 @@
+import { appApi } from 'src/boot/axios.js'
+import APIRepository from '../classes/APIRepository.js'
+
+export default class PageSettingAPI extends APIRepository {
+  constructor() {
+    super('page-setting', appApi)
+    this.APIAdresses = {
+      base: '/cma/settings',
+      getWithKey: (key) => '/cma/settings/key/' + key,
+      updateWithKey: (key) => '/admin/setting/' + key
+    }
+    this.CacheList = {
+      base: this.name + this.APIAdresses.base,
+      getWithKey: (key) => this.name + this.APIAdresses.getWithKey(key)
+    }
+  }
+
+  index (data, cache = { TTL: 1000 }) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.base,
+      cacheKey: this.CacheList.base,
+      ...(cache !== undefined && { cache }),
+      resolveCallback: (response) => {
+        return {
+          referralCodeList: response.data.data,
+          paginate: response.data.meta
+          // {
+          //   current_page: 1,
+          //   from: 1,
+          //   last_page: 1,
+          //   path: '...',
+          //   per_page: 15,
+          //   to: 10,
+          //   total: 10
+          // }
+        }
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  create (data) {
+    const formData = new FormData()
+    formData.append('key', data.key)
+    formData.append('value', data.value)
+    return this.sendRequest({
+      apiMethod: 'post',
+      api: this.api,
+      request: this.APIAdresses.base,
+      data: formData,
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  update (data) {
+    // const settingKey = encodeURI(data.key)
+    const settingKey = data.key
+    const settingValue = data.value
+    return this.sendRequest({
+      apiMethod: 'post',
+      api: this.api,
+      request: this.APIAdresses.base,
+      data: {
+        key: settingKey,
+        value: settingValue
+      },
+      resolveCallback: (response) => {
+        return response
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  get (data, cache = { TTL: 1000 }) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.getWithKey(encodeURI(data)),
+      cacheKey: this.CacheList.getWithKey(encodeURI(data)),
+      ...(cache !== undefined && { cache }),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+}

+ 7 - 0
src/components/Template/SideBar/AdminPanelSideBar.vue

@@ -252,6 +252,13 @@ export default {
               routeName: 'Admin.Store.Discount.List',
               show: true,
               active: false
+            },
+            {
+              title: 'آیین نامه خرید',
+              roles: ['superuser'],
+              routeName: 'Admin.Store.Basket.PurchaseRegulations',
+              show: true,
+              active: false
             }
             // {
             //   title: 'تنظیمات',

+ 135 - 0
src/components/Widgets/Store/Basket/AdminStoreBasketPurchaseRegulations/AdminStoreBasketPurchaseRegulations.vue

@@ -0,0 +1,135 @@
+<template>
+  <div class="AdminPostCreate"
+       :style="localOptions.style">
+    <div class="flex justify-end">
+      <q-btn flat
+             color="grey"
+             @click="$router.go(-1)">
+        بازگشت
+        >
+      </q-btn>
+    </div>
+    <entity-create v-if="mounted"
+                   ref="entityCreate"
+                   v-model:value="inputs"
+                   title="آیین نامه خرید"
+                   :api="api"
+                   :entity-id-key="entityIdKey"
+                   :entity-param-key="entityParamKey"
+                   :show-route-name="showRouteName"
+                   :show-close-button="false"
+                   :show-edit-button="false"
+                   :show-expand-button="false"
+                   :show-save-button="false"
+                   :show-reload-button="false" />
+  </div>
+</template>
+
+<script>
+import { shallowRef } from 'vue'
+import { EntityCreate } from 'quasar-crud'
+import { mixinWidget } from 'src/mixin/Mixins.js'
+import { APIGateway } from 'src/api/APIGateway.js'
+import BtnControl from 'src/components/Control/btn.vue'
+import PostMixin from 'src/components/Widgets/Post/PostMixin.js'
+import FormBuilderTiptapEditor from 'src/components/FormBuilderCustumComponents/FormBuilderTiptapEditor.vue'
+import { FormBuilderAssist } from 'quasar-form-builder'
+
+const BtnControlComp = shallowRef(BtnControl)
+const FormBuilderTiptapEditorComp = shallowRef(FormBuilderTiptapEditor)
+
+export default {
+  name: 'AdminPostCreate',
+  components: { EntityCreate },
+  mixins: [mixinWidget, PostMixin],
+  data () {
+    const authorization = 'Bearer ' + this.$store.getters['Auth/accessToken']
+    const uploadVideo = this.uploadVideo
+    const uploadAudio = this.uploadAudio
+    return {
+      mounted: false,
+      entityLoading: false,
+      api: APIGateway.post.APIAdresses.base,
+      entityIdKey: 'id',
+      entityParamKey: 'id',
+      showRouteName: 'Admin.Post.Show',
+      inputs: [
+        {
+          type: FormBuilderTiptapEditorComp,
+          name: 'text',
+          responseKey: 'text',
+          label: 'متن آیین نامه خرید',
+          options: {
+            bubbleMenu: false,
+            floatingMenu: false,
+            poem: false,
+            reading: false,
+            loadBareHtml: true,
+            persianKeyboard: true,
+            mathliveOptions: { smartFence: false },
+            uploadServer: {
+              url: '/api' + APIGateway.media.APIAdresses.base,
+              instantUpload: true,
+              responseKey: 'file',
+              headers: { Authorization: authorization }
+            },
+            uploadVideo,
+            uploadAudio
+          },
+          col: 'col-md-12 col-12'
+        },
+        { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ثبت', placeholder: ' ', atClick: this.onSubmit, col: 'col-md-6' }
+      ]
+    }
+  },
+  mounted () {
+    this.getPurchaseRegulations()
+  },
+  methods: {
+    getPurchaseRegulations () {
+      this.purchaseRegulationsLoading = true
+      APIGateway.appSetting.get('PurchaseRegulations')
+        .then((purchaseRegulations) => {
+          FormBuilderAssist.setAttributeByName(this.inputs, 'text', 'value', purchaseRegulations.value)
+          this.mounted = true
+        })
+        .finally(() => {
+          this.purchaseRegulationsLoading = false
+        })
+    },
+    onSubmit () {
+      const formData = FormBuilderAssist.getFormData(this.inputs)
+      this.purchaseRegulationsLoading = true
+      APIGateway.appSetting.update({ key: 'PurchaseRegulations', value: formData.text })
+        .then((purchaseRegulations) => {
+          this.purchaseRegulations = purchaseRegulations
+        })
+        .finally(() => {
+          this.purchaseRegulationsLoading = false
+        })
+    }
+  }
+}
+</script>
+
+<style scoped lang="scss">
+.AdminPostCreate {
+  .title {
+    font-style: normal;
+    font-weight: 700;
+    font-size: 24px;
+    line-height: 140%;
+    color: #424242;
+    margin-bottom: 27px;
+    position: relative;
+    .back-action {
+      position: absolute;
+      right: 0;
+      top: 0;
+    }
+  }
+  :deep(.form) {
+    padding: 24px;
+  }
+}
+</style>

+ 21 - 0
src/components/Widgets/Store/Basket/AdminStoreBasketPurchaseRegulations/OptionPanel.vue

@@ -0,0 +1,21 @@
+<template>
+  <option-panel-tabs v-model:options="localOptions">
+    <template #main-tab>
+      ...
+    </template>
+  </option-panel-tabs>
+</template>
+
+<script>
+import { defineComponent } from 'vue'
+import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
+import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
+
+export default defineComponent({
+  name: 'OptionPanel',
+  components: {
+    OptionPanelTabs
+  },
+  mixins: [mixinOptionPanel]
+})
+</script>

Різницю між файлами не показано, бо вона завелика
+ 0 - 1
src/components/Widgets/Store/Cart/components/step2/step2.vue


+ 5 - 5
src/components/cart/cartCountAction/cartCountAction.vue

@@ -4,24 +4,24 @@
       <q-btn outline
              color="primary"
              icon="add"
-             :loading="basketItem.loading"
+             :loading="basketItem?.loading || loading"
              @click="onIncrease" />
     </div>
     <div class="cart-count-action-count">
-      {{ basketItem.count }}
+      {{ basketItem?.count }}
     </div>
     <div class="cart-count-action-decrease">
-      <q-btn v-if="basketItem.count > 1"
+      <q-btn v-if="basketItem?.count > 1"
              outline
              color="red"
              icon="remove"
-             :loading="basketItem.loading || loading"
+             :loading="basketItem?.loading || loading"
              @click="onDecrease" />
       <q-btn v-else
              flat
              color="red"
              icon="delete_outline"
-             :loading="basketItem.loading || loading"
+             :loading="basketItem?.loading || loading"
              @click="onRemove" />
     </div>
   </div>

+ 23 - 0
src/pages/Admin/StoreBasket/PurchaseRegulations.vue

@@ -0,0 +1,23 @@
+<template>
+  <q-page-builder v-model:sections="currenSections"
+                  v-model:options="pageConfig"
+                  :editable="pageBuilderEditable"
+                  :loading="pageBuilderLoading" />
+</template>
+
+<script>
+import { mixinPageOptions } from 'src/mixin/Mixins.js'
+
+export default {
+  name: 'Admin.Store.Basket.Show',
+  mixins: [mixinPageOptions],
+  data: () => {
+    return {
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminStoreBasketPurchaseRegulations' }], options: {} }], options: { className: '', height: 'auto', boxed: true, boxedWidth: 1200, gutterXSize: 'md', gutterYSize: 'md', absolute: 'none', paddingOfBoxedInFullWidth: '10px', alignment: { justifyContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignItems: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null } }, style: { maxWidth: '1200px', width: '1200px' } } }] } }]
+    }
+  },
+  created() {
+    this.currenSections = this.sections
+  }
+}
+</script>

+ 1 - 0
src/router/routes/Admin.js

@@ -445,6 +445,7 @@ export default {
           component: () => import('layouts/bareLayout.vue'),
           children: [
             { path: '', name: 'Admin.Store.Basket.List', component: () => import('src/pages/Admin/StoreBasket/List.vue') },
+            { path: 'purchase-regulations', name: 'Admin.Store.Basket.PurchaseRegulations', component: () => import('src/pages/Admin/StoreBasket/PurchaseRegulations.vue') },
             { path: ':id', name: 'Admin.Store.Basket.Show', component: () => import('src/pages/Admin/StoreBasket/Show.vue') }
           ]
         }

Деякі файли не було показано, через те що забагато файлів було змінено