Explorar el Código

نمایش و ساخت کد تخفیف

hgh hace 1 año
padre
commit
fae5a17e1f

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

@@ -193,6 +193,13 @@ export default {
               show: true,
               active: false
             },
+            {
+              title: 'کد تخفیف',
+              roles: ['superuser'],
+              routeName: 'Admin.Invoice.Discount.List',
+              show: true,
+              active: false
+            },
             {
               title: 'درخواست ها',
               roles: ['superuser', 'financial_department_head'],
@@ -246,13 +253,6 @@ export default {
               show: true,
               active: false
             },
-            {
-              title: 'کد تخفیف',
-              roles: ['superuser'],
-              routeName: 'Admin.Store.Discount.List',
-              show: true,
-              active: false
-            },
             {
               title: 'هزینه ارسال',
               roles: ['superuser'],

+ 4 - 2
src/components/Widgets/Store/Discount/AdminStoreDiscountCreate/AdminStoreDiscountCreate.vue

@@ -32,6 +32,7 @@ import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import BtnControl from 'components/Control/btn.vue'
 import FormBuilderDateTime from 'src/components/FormBuilderCustumComponents/FormBuilderDateTime.vue'
+import { Discount } from 'src/models/Discount'
 
 const BtnControlComp = shallowRef(BtnControl)
 const FormBuilderDateTimeComp = shallowRef(FormBuilderDateTime)
@@ -47,11 +48,12 @@ export default {
       api: APIGateway.discount.APIAdresses.base,
       entityIdKey: 'id',
       entityParamKey: 'id',
-      showRouteName: 'Admin.Store.Discount.Show',
+      showRouteName: 'Admin.Invoice.Discount.Show',
       inputs: [
+        { type: 'select', name: 'target', responseKey: 'target', options: (new Discount()).targetEnums, label: 'هدف', placeholder: ' ', col: 'col-md-4 col-12' },
         { type: 'input', name: 'code', responseKey: 'code', label: 'کد', placeholder: ' ', col: 'col-md-4 col-12' },
         { type: 'input', name: 'percent', responseKey: 'percent', label: 'درصد', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: FormBuilderDateTimeComp, name: 'expire_time', responseKey: 'expire_time', outsideLabel: 'تاریخ انقضا', col: 'col-md-4 col-12' },
+        { type: FormBuilderDateTimeComp, name: 'expire_time', responseKey: 'expire_time', outsideLabel: 'تاریخ انقضا', col: 'col-md-6 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ایجاد تخفیف', placeholder: ' ', atClick: () => {}, col: 'col-md-6' }
       ]
     }

+ 11 - 3
src/components/Widgets/Store/Discount/AdminStoreDiscountList/AdminStoreDiscountList.vue

@@ -5,7 +5,7 @@
          class="more-action">
       <q-btn label="ایجاد تخفیف جدید"
              color="primary"
-             :to="{name: 'Admin.Store.Discount.Create'}" />
+             :to="{name: 'Admin.Invoice.Discount.Create'}" />
     </div>
     <entity-index v-if="mounted"
                   v-model:value="inputs"
@@ -27,7 +27,7 @@
         </template>
         <template v-else-if="inputData.col.name === 'action'">
           <q-btn color="primary"
-                 :to="{name: 'Admin.Store.Discount.Show', params: {id: inputData.props.row.id}}">
+                 :to="{name: 'Admin.Invoice.Discount.Show', params: {id: inputData.props.row.id}}">
             مشاهده جزییات
           </q-btn>
         </template>
@@ -44,9 +44,10 @@ import { EntityIndex } from 'quasar-crud'
 import Assist from 'src/assets/js/Assist.js'
 import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
+import { Discount } from 'src/models/Discount'
 
 export default {
-  name: 'AdminStoreDiscountList',
+  name: 'AdminInvoiceDiscountList',
   components: { EntityIndex },
   mixins: [mixinWidget],
   props: {
@@ -82,6 +83,13 @@ export default {
             align: 'left',
             field: row => row.id
           },
+          {
+            name: 'target',
+            required: true,
+            label: 'هدف',
+            align: 'left',
+            field: row => (new Discount(row)).target_info.label
+          },
           {
             name: 'code',
             required: true,

+ 3 - 1
src/components/Widgets/Store/Discount/AdminStoreDiscountShow/AdminStoreDiscountShow.vue

@@ -34,6 +34,7 @@ import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import BtnControl from 'src/components/Control/btn.vue'
 import FormBuilderDateTime from 'src/components/FormBuilderCustumComponents/FormBuilderDateTime.vue'
+import { Discount } from 'src/models/Discount'
 
 const BtnControlComp = shallowRef(BtnControl)
 const FormBuilderDateTimeComp = shallowRef(FormBuilderDateTime)
@@ -54,9 +55,10 @@ export default {
       showRouteName: 'Admin.Store.Discount.Show',
       indexRouteName: 'Admin.Store.Discount.List',
       inputs: [
+        { type: 'select', name: 'target', responseKey: 'target', options: (new Discount()).targetEnums, label: 'هدف', placeholder: ' ', col: 'col-md-4 col-12' },
         { type: 'input', name: 'code', responseKey: 'code', label: 'کد', placeholder: ' ', col: 'col-md-4 col-12' },
         { type: 'input', name: 'percent', responseKey: 'percent', label: 'درصد', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: FormBuilderDateTimeComp, name: 'expire_time', responseKey: 'expire_time', outsideLabel: 'تاریخ انقضا', col: 'col-md-4 col-12' },
+        { type: FormBuilderDateTimeComp, name: 'expire_time', responseKey: 'expire_time', outsideLabel: 'تاریخ انقضا', col: 'col-md-6 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ویرایش تخفیف', placeholder: ' ', ignoreValue: true, atClick: () => {}, col: 'col-md-6' }
       ]
     }

+ 1 - 1
src/models/Discount.js

@@ -14,7 +14,7 @@ class Discount extends Model {
       },
       { key: 'expire_time' }
     ], {
-      status: {
+      target: {
         infoKey: 'target_info',
         enumListKey: 'targetEnums',
         enums: [

+ 23 - 0
src/pages/Admin/InvoiceDiscount/Create.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.Discount.Create',
+  mixins: [mixinPageOptions],
+  data: () => {
+    return {
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminStoreDiscountCreate' }], 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>

+ 23 - 0
src/pages/Admin/InvoiceDiscount/List.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.Discount.List',
+  mixins: [mixinPageOptions],
+  data: () => {
+    return {
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminStoreDiscountList' }], 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>

+ 23 - 0
src/pages/Admin/InvoiceDiscount/Show.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.Discount.Show',
+  mixins: [mixinPageOptions],
+  data: () => {
+    return {
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminStoreDiscountShow' }], 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>

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

@@ -383,6 +383,16 @@ export default {
               component: () => import('src/pages/Admin/Invoice/Ticket/Show.vue')
             }
           ]
+        },
+        {
+          path: 'discount',
+          name: 'Admin.Invoice.Discount',
+          component: () => import('layouts/bareLayout.vue'),
+          children: [
+            { path: '', name: 'Admin.Invoice.Discount.List', component: () => import('src/pages/Admin/InvoiceDiscount/List.vue') },
+            { path: 'create', name: 'Admin.Invoice.Discount.Create', component: () => import('src/pages/Admin/StoreDiscount/Create.vue') },
+            { path: ':id', name: 'Admin.Invoice.Discount.Show', component: () => import('src/pages/Admin/InvoiceDiscount/Show.vue') }
+          ]
         }
       ]
     },