ali 3 vuotta sitten
vanhempi
commit
1798af068c

+ 16 - 1
src/api/models/Ticket.js

@@ -10,7 +10,8 @@ export default class TicketAPI extends APIRepository {
       repliesBase: '/mma/replies',
       replyById: (id) => '/mma/replies/' + id,
       byId: (id) => '/mma/tickets/' + id,
-      reply: (id) => '/mma/tickets/' + id + '/reply'
+      reply: (id) => '/mma/tickets/' + id + '/reply',
+      close: (id) => '/mma/tickets/' + id + '/close'
     }
     this.restUrl = (id) => this.url + '/' + id
     /* Setting the callback functions for the CRUD operations. */
@@ -70,6 +71,20 @@ export default class TicketAPI extends APIRepository {
     })
   }
 
+  close (ticketId) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.close(ticketId),
+      resolveCallback: (response) => {
+        return new Ticket(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   deleteReplyMessage (replyId) {
     return this.sendRequest({
       apiMethod: 'delete',

+ 25 - 1
src/components/Widgets/Ticket/AdminTicketShow/AdminTicketShow.vue

@@ -100,6 +100,13 @@
                     </template>
                   </q-input>
                 </div>
+                <div>
+                  <q-btn outline
+                         color="red"
+                         @click="closeTicket">
+                    بستن تیکت
+                  </q-btn>
+                </div>
               </template>
             </div>
           </div>
@@ -253,6 +260,23 @@ export default {
       })
   },
   methods: {
+    closeTicket () {
+      this.$q.dialog({
+        title: 'توجه',
+        message: 'آیا از بستن تیکت اطمینان دارید؟',
+        cancel: true,
+        persistent: true
+      }).onOk(() => {
+        this.entityLoading = true
+        APIGateway.ticket.close(this.$route.params.id)
+          .then(() => {
+            this.$refs.entityEdit.getData()
+          })
+          .catch(() => {
+            this.entityLoading = false
+          })
+      })
+    },
     miladiToShamsi (miladi) {
       return Assist.miladiToShamsi(miladi)
     },
@@ -272,7 +296,7 @@ export default {
             this.$refs.entityEdit.getData()
           })
           .catch(() => {
-            this.entityLoading = true
+            this.entityLoading = false
           })
       })
     },