ali 1 vuosi sitten
vanhempi
commit
b3729ca983

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

@@ -253,6 +253,13 @@ export default {
               show: true,
               active: false
             },
+            {
+              title: 'هزینه ارسال',
+              roles: ['superuser'],
+              routeName: 'Admin.Store.Basket.DeliveryCost',
+              show: true,
+              active: false
+            },
             {
               title: 'آیین نامه خرید',
               roles: ['superuser'],

+ 1 - 1
src/components/Widgets/Other/Shop/ShopCompleteInfo/ShopCompleteInfo.vue

@@ -340,7 +340,7 @@ export default {
         return
       }
 
-      const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
+      const filteredCities = getCitiesOfProvince(this.selectedLivingProvince)
 
       // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
       FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'options', filteredCities)

+ 113 - 0
src/components/Widgets/Store/Basket/AdminStoreDeliveryCost/AdminStoreDeliveryCost.vue

@@ -0,0 +1,113 @@
+<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 { FormBuilderAssist } from 'quasar-form-builder'
+import PostMixin from 'src/components/Widgets/Post/PostMixin.js'
+
+const BtnControlComp = shallowRef(BtnControl)
+
+export default {
+  name: 'AdminPostCreate',
+  components: { EntityCreate },
+  mixins: [mixinWidget, PostMixin],
+  data () {
+    return {
+      mounted: false,
+      entityLoading: false,
+      api: null,
+      entityIdKey: 'id',
+      entityParamKey: 'id',
+      showRouteName: null,
+      inputs: [
+        {
+          type: 'input',
+          name: 'text',
+          responseKey: 'text',
+          label: 'هزینه ارسال با پست پیشتاز',
+          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('DeliveryCost-post-pishtaz')
+        .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: 'DeliveryCost-post-pishtaz', 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/AdminStoreDeliveryCost/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>

+ 6 - 6
src/components/Widgets/Store/Cart/components/step2/cartAddress.vue

@@ -74,7 +74,7 @@ export default {
       setAddressLoading: false,
       addressInputs: [
         {
-          type: 'input',
+          type: 'select',
           name: 'province',
           options: Provinces,
           optionLabel: 'name',
@@ -84,10 +84,10 @@ export default {
           responseKey: 'province',
           label: 'استان',
           placeholder: ' ',
-          col: 'col-md-4 col-12'
+          col: 'col-md-6 col-12'
         },
         {
-          type: 'input',
+          type: 'select',
           name: 'city',
           options: Cities,
           optionLabel: 'name',
@@ -97,9 +97,9 @@ export default {
           responseKey: 'city',
           label: 'شهر',
           placeholder: ' ',
-          col: 'col-md-4 col-12'
+          col: 'col-md-6 col-12'
         },
-        { type: 'input', name: 'postal_code', responseKey: 'postal_code', label: 'کد پستی', placeholder: ' ', col: 'col-md-4 col-12' },
+        { type: 'input', name: 'postal_code', responseKey: 'postal_code', label: 'کد پستی', placeholder: ' ', col: 'col-12' },
         { type: 'input', name: 'address', responseKey: 'address', label: 'آدرس پستی', placeholder: ' ', col: 'col-12' }
       ]
     }
@@ -120,7 +120,7 @@ export default {
         return
       }
 
-      const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
+      const filteredCities = getCitiesOfProvince(this.selectedProvince)
 
       // FormBuilderAssist.setAttributeByName(this.addressInputs, 'city', 'value', null)
       FormBuilderAssist.setAttributeByName(this.addressInputs, 'city', 'options', filteredCities)

+ 27 - 3
src/components/Widgets/Store/Cart/components/step2/deliveryInfo.vue

@@ -28,8 +28,13 @@
           هزینه ارسال
         </div>
         <div class="delivery-info__price-value">
-          {{ basket.delivery_cost.toLocaleString('fa') }}
-          ریال
+          <q-linear-progress v-if="deliveryCostLoading"
+                             indeterminate />
+          <template v-else>
+            <!--            {{ basket.delivery_cost.toLocaleString('fa') }}-->
+            {{ deliveryCost.toLocaleString('fa') }}
+            ریال
+          </template>
         </div>
       </div>
     </div>
@@ -38,6 +43,7 @@
 
 <script>
 import { Basket } from 'src/models/Basket.js'
+import { APIGateway } from 'src/api/APIGateway.js'
 
 export default {
   name: 'DeliveryInfo',
@@ -49,7 +55,25 @@ export default {
   },
   data () {
     return {
-      radioValue: 1
+      radioValue: 1,
+      deliveryCost: 0,
+      deliveryCostLoading: false
+    }
+  },
+  mounted() {
+    this.getDeliveryCost()
+  },
+  methods: {
+    getDeliveryCost () {
+      this.deliveryCostLoading = true
+      APIGateway.appSetting.get('DeliveryCost-post-pishtaz')
+        .then((deliveryCost) => {
+          this.deliveryCost = parseInt(deliveryCost.value || 0)
+          this.mounted = true
+        })
+        .finally(() => {
+          this.deliveryCostLoading = false
+        })
     }
   }
 }

+ 25 - 3
src/components/Widgets/Store/Cart/components/step2/sidebar.vue

@@ -23,8 +23,13 @@
         هزینه ارسال
       </div>
       <div class="step2__sidebar-delivery-cost-value">
-        {{ basket.delivery_cost.toLocaleString('fa') }}
-        ریال
+        <q-linear-progress v-if="deliveryCostLoading"
+                           indeterminate />
+        <template v-else>
+          <!--          {{ basket.delivery_cost.toLocaleString('fa') }}-->
+          {{ deliveryCost.toLocaleString('fa') }}
+          ریال
+        </template>
       </div>
     </div>
     <div class="step2__sidebar-separator" />
@@ -49,6 +54,7 @@
 
 <script>
 import { Basket } from 'src/models/Basket.js'
+import { APIGateway } from 'src/api/APIGateway.js'
 
 export default {
   name: 'cartItem',
@@ -61,12 +67,28 @@ export default {
   emits: ['complete'],
   data () {
     return {
-      step: 1
+      step: 1,
+      deliveryCost: 0,
+      deliveryCostLoading: false
     }
   },
+  mounted() {
+    this.getDeliveryCost()
+  },
   methods: {
     onComplete () {
       this.$emit('complete')
+    },
+    getDeliveryCost () {
+      this.deliveryCostLoading = true
+      APIGateway.appSetting.get('DeliveryCost-post-pishtaz')
+        .then((deliveryCost) => {
+          this.deliveryCost = parseInt(deliveryCost.value || 0)
+          this.mounted = true
+        })
+        .finally(() => {
+          this.deliveryCostLoading = false
+        })
     }
   }
 }

+ 3 - 3
src/components/Widgets/Team/AdminTeamShow/AdminTeamShow.vue

@@ -292,7 +292,7 @@ export default {
         { type: 'hidden', name: 'team', value: teamId },
         { type: 'select', name: 'owner__gender', value: null, options: (new User()).genderEnums, col: 'col-md-2 col-12', label: 'جنسیت', placeholder: ' ' },
         {
-          type: 'input',
+          type: 'select',
           name: 'owner__living_province',
           options: Provinces,
           optionLabel: 'name',
@@ -305,7 +305,7 @@ export default {
           placeholder: ' '
         },
         {
-          type: 'input',
+          type: 'select',
           name: 'owner__living_city',
           options: Cities,
           optionLabel: 'name',
@@ -410,7 +410,7 @@ export default {
         return
       }
 
-      const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
+      const filteredCities = getCitiesOfProvince(this.selectedProvince)
 
       // FormBuilderAssist.setAttributeByName(this.teamRegistrationListInputs, 'owner__living_city', 'value', null)
       FormBuilderAssist.setAttributeByName(this.teamRegistrationListInputs, 'owner__living_city', 'options', filteredCities)

+ 23 - 0
src/pages/Admin/StoreBasket/DeliveryCost.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: 'AdminStoreDeliveryCost' }], 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 - 1
src/pages/Admin/User/show.vue

@@ -934,7 +934,7 @@ export default {
         return
       }
 
-      const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
+      const filteredCities = getCitiesOfProvince(this.selectedLivingProvince)
 
       // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
       FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'options', filteredCities)

+ 1 - 1
src/pages/User/Profile/profile.vue

@@ -217,7 +217,7 @@ export default {
         return
       }
 
-      const filteredCities = getCitiesOfProvince(this.selectedBirthProvince)
+      const filteredCities = getCitiesOfProvince(this.selectedLivingProvince)
 
       // FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'value', null)
       FormBuilderAssist.setAttributeByName(this.inputs, 'living_city', 'options', filteredCities)

+ 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: 'delivery-cost', name: 'Admin.Store.Basket.DeliveryCost', component: () => import('src/pages/Admin/StoreBasket/DeliveryCost.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') }
           ]