ali %!s(int64=3) %!d(string=hai) anos
pai
achega
b49b6a540a

+ 2 - 21
src/components/Widgets/Ticket/AdminTicketList/AdminTicketList.vue

@@ -204,12 +204,7 @@ export default {
         FormBuilderAssist.setAttributeByName(this.inputs, 'category__type', 'type', 'select')
         FormBuilderAssist.setAttributeByName(this.inputs, 'category__type', 'label', 'معاونت')
         FormBuilderAssist.setAttributeByName(this.inputs, 'category__type', 'placeholder', ' ')
-        FormBuilderAssist.setAttributeByName(this.inputs, 'category__type', 'options', [
-          { label: 'مالی', value: 'FINANCIAL' },
-          { label: 'آموزش', value: 'EDUCATIONAL' },
-          { label: 'محتوا', value: 'CONTENT' },
-          { label: 'عمومی', value: 'GENERAL' }
-        ])
+        FormBuilderAssist.setAttributeByName(this.inputs, 'category__type', 'options', (new TicketCategory()).typeEnums)
       }
     },
     setActionBtn () {
@@ -238,21 +233,7 @@ export default {
     },
     getCategoryTypeFromSourceType () {
       const defaultSourceType = this.localOptions.defaultSourceType
-      if (!defaultSourceType) {
-        return null
-      }
-
-      if (defaultSourceType === 'TRAINING_CLASSROOM') {
-        return 'EDUCATIONAL'
-      } else if (defaultSourceType === 'DISCUSSION_CIRCLE_CLASSROOM') {
-        return 'EDUCATIONAL'
-      } else if (defaultSourceType === 'INVOICE') {
-        return 'FINANCIAL'
-      } else if (defaultSourceType === 'CONTENT') {
-        return 'CONTENT'
-      } else {
-        return 'GENERAL'
-      }
+      return (new TicketCategory()).getCategoryTypeFromSourceType(defaultSourceType)
     },
     loadCategories () {
       return new Promise((resolve, reject) => {

+ 5 - 8
src/components/Widgets/Ticket/AdminTicketList/OptionPanel.vue

@@ -22,6 +22,7 @@
 <script>
 import { defineComponent } from 'vue'
 import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
+import { TicketCategory } from 'src/models/TicketCategory.js'
 import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
 
 export default defineComponent({
@@ -30,7 +31,9 @@ export default defineComponent({
     OptionPanelTabs
   },
   mixins: [mixinOptionPanel],
-  data: () => {
+  data () {
+    const ticketCategoryTypes = (new TicketCategory()).typeEnums
+    ticketCategoryTypes.push({ label: 'قابل انتخاب', value: null })
     return {
       options: [
         { label: 'قابل انتخاب', value: null },
@@ -40,13 +43,7 @@ export default defineComponent({
         { label: 'محتوا', value: 'CONTENT' },
         { label: 'SESSION', value: 'SESSION' }
       ],
-      categoryTypeOptions: [
-        { label: 'قابل انتخاب', value: null },
-        { label: 'آموزشی', value: 'EDUCATIONAL' },
-        { label: 'مالی', value: 'FINANCIAL' },
-        { label: 'محتوایی', value: 'CONTENT' },
-        { label: 'عمومی', value: 'GENERAL' }
-      ]
+      categoryTypeOptions: ticketCategoryTypes
     }
   }
 })

+ 2 - 7
src/components/Widgets/Ticket/AdminTicketShow/AdminTicketShow.vue

@@ -148,8 +148,8 @@ import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import BtnControl from 'src/components/Control/btn.vue'
-import { TicketCategoryList } from 'src/models/TicketCategory.js'
 import { InstalmentOfferList } from 'src/models/InstalmentOffer.js'
+import { TicketCategory, TicketCategoryList } from 'src/models/TicketCategory.js'
 // import ShowSource from 'src/components/Widgets/Ticket/AdminTicketShow/ShowSource.vue'
 import AdminInvoiceShow from 'src/components/Widgets/Invoice/AdminInvoiceShow/AdminInvoiceShow.vue'
 import InstallmentOffers from 'src/components/Widgets/Ticket/AdminTicketShow/InstallmentOffers.vue'
@@ -195,12 +195,7 @@ export default {
           type: 'select',
           name: 'category_info__type',
           responseKey: 'category_info.type',
-          options: [
-            { label: 'مالی', value: 'FINANCIAL' },
-            { label: 'آموزش', value: 'EDUCATIONAL' },
-            { label: 'محتوا', value: 'CONTENT' },
-            { label: 'عمومی', value: 'GENERAL' }
-          ],
+          options: (new TicketCategory()).typeEnums,
           label: 'معاونت',
           placeholder: ' ',
           col: 'col-md-6 col-12'

+ 1 - 6
src/components/Widgets/Ticket/TicketCreate/TicketCreate.vue

@@ -67,12 +67,7 @@ export default {
         {
           type: 'select',
           name: 'category_info__type',
-          options: [
-            { label: 'مالی', value: 'FINANCIAL' },
-            { label: 'آموزش', value: 'EDUCATIONAL' },
-            { label: 'محتوا', value: 'CONTENT' },
-            { label: 'عمومی', value: 'GENERAL' }
-          ],
+          options: (new TicketCategory()).typeEnums,
           label: 'معاونت',
           ignoreValue: true,
           placeholder: ' ',

+ 2 - 7
src/components/Widgets/Ticket/TicketShow/TicketShow.vue

@@ -111,7 +111,7 @@ import { Ticket } from 'src/models/Ticket.js'
 import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
-import { TicketCategoryList } from 'src/models/TicketCategory.js'
+import { TicketCategory, TicketCategoryList } from 'src/models/TicketCategory.js'
 import { InstalmentOfferList } from 'src/models/InstalmentOffer.js'
 import InvoiceShow from 'src/components/Widgets/Invoice/InvoiceShow/InvoiceShow.vue'
 import InstallmentOffers from 'src/components/Widgets/Ticket/TicketShow/InstallmentOffers.vue'
@@ -143,12 +143,7 @@ export default {
           type: 'select',
           name: 'category_info__type',
           responseKey: 'category_info.type',
-          options: [
-            { label: 'مالی', value: 'FINANCIAL' },
-            { label: 'آموزش', value: 'EDUCATIONAL' },
-            { label: 'محتوا', value: 'CONTENT' },
-            { label: 'عمومی', value: 'GENERAL' }
-          ],
+          options: (new TicketCategory()).typeEnums,
           label: 'معاونت',
           placeholder: ' ',
           ignoreValue: true,

+ 52 - 69
src/models/Ticket.js

@@ -15,6 +15,7 @@ class Ticket extends Model {
       { key: 'source_id' },
       { key: 'source' },
       { key: 'category' },
+      { key: 'category' },
       {
         key: 'category_info',
         relatedModel: TicketCategory
@@ -33,77 +34,59 @@ class Ticket extends Model {
         key: 'owner_info',
         relatedModel: User
       }
-    ])
-
-    this.priorityEnums = [
-      {
-        label: 'بالا',
-        value: 'HIGH'
-      }
-    ]
-
-    this.statusEnums = [
-      {
-        label: 'در انتظار پاسخ',
-        value: 'OPENED',
-        color: '#2FA84A'
-      },
-      {
-        label: 'ادمین پاسخ داده',
-        value: 'ADMIN_REPLIED',
-        color: '#0B6AB1'
+    ], {
+      status: {
+        infoKey: 'status_info',
+        enumListKey: 'statusEnums',
+        enums: [
+          {
+            label: 'در انتظار پاسخ',
+            value: 'OPENED',
+            color: '#2FA84A'
+          },
+          {
+            label: 'ادمین پاسخ داده',
+            value: 'ADMIN_REPLIED',
+            color: '#0B6AB1'
+          },
+          {
+            label: 'کاربر پاسخ داده',
+            value: 'USER_REPLIED',
+            color: '#0B6AB1'
+          },
+          // {
+          //   label: 'در حال انتظار',
+          //   value: 'PENDING',
+          //   color: '#2FA84A'
+          // },
+          // {
+          //   label: 'خوانده نشده',
+          //   value: 'UNREAD',
+          //   color: '#2FA84A'
+          // },
+          // {
+          //   label: 'خوانده شده',
+          //   value: 'READ',
+          //   color: '#2FA84A'
+          // },
+          {
+            label: 'بسته شده',
+            value: 'CLOSED',
+            color: '#989898'
+          }
+        ]
       },
-      {
-        label: 'کاربر پاسخ داده',
-        value: 'USER_REPLIED',
-        color: '#0B6AB1'
-      },
-      // {
-      //   label: 'در حال انتظار',
-      //   value: 'PENDING',
-      //   color: '#2FA84A'
-      // },
-      // {
-      //   label: 'خوانده نشده',
-      //   value: 'UNREAD',
-      //   color: '#2FA84A'
-      // },
-      // {
-      //   label: 'خوانده شده',
-      //   value: 'READ',
-      //   color: '#2FA84A'
-      // },
-      {
-        label: 'بسته شده',
-        value: 'CLOSED',
-        color: '#989898'
-      }
-    ]
-
-    this.loadStatusInfo()
-    this.loadPriorityInfo()
-  }
-
-  loadPriorityInfo () {
-    const target = this.priorityEnums.find(type => type.value === this.priority)
-    if (!target) {
-      this.priority_info = null
-    } else {
-      this.priority_info = target
-    }
-  }
-
-  loadStatusInfo () {
-    const target = this.statusEnums.find(type => type.value === this.status)
-    if (!target) {
-      this.status_info = {
-        label: null,
-        value: null,
-        color: ''
+      priority: {
+        infoKey: 'priority_info',
+        enumListKey: 'priorityEnums',
+        enums: [
+          {
+            label: 'بالا',
+            value: 'HIGH'
+          }
+        ]
       }
-    } else {
-      this.status_info = target
-    }
+    })
   }
 }
 

+ 16 - 2
src/models/TicketCategory.js

@@ -4,8 +4,22 @@ class TicketCategory extends Model {
   constructor (data) {
     super(data, [
       { key: 'id' },
-      { key: 'name' }
-    ])
+      { key: 'name' },
+      { key: 'type' }
+    ], {
+      type: {
+        infoKey: 'type_info',
+        enumListKey: 'typeEnums',
+        enums: [
+          { label: 'معاونت آموزش', value: 'EDUCATIONAL' },
+          { label: 'معاونت مالی', value: 'FINANCIAL' },
+          { label: 'معاونت محتوا', value: 'CONTENT' },
+          { label: 'معاونت پژوهش', value: 'RESEARCH' },
+          { label: 'معاونت سرمایه انسانی', value: 'HR' },
+          { label: 'معاونت روابط عمومی', value: 'GENERAL' }
+        ]
+      }
+    })
   }
 
   getCategoryTypeFromSourceType (sourceType) {