Ver código fonte

Merge branch 'master' of http://git.hghweb.ir/ali.s/palizvani-front-vite

ali 2 anos atrás
pai
commit
cae9311dcd

+ 20 - 1
src/api/models/Invoice.js

@@ -9,7 +9,8 @@ export default class InvoiceAPI extends APIRepository {
       base: '/accounting/invoices',
       byId: (id) => '/accounting/invoices/' + id,
       pay: (id) => '/accounting/invoices/' + id + '/pay',
-      cancel: (id) => '/accounting/invoices/' + id + '/cancel'
+      cancel: (id) => '/accounting/invoices/' + id + '/cancel',
+      exportInvoiceReport: '/accounting/invoices/export_report'
     }
     this.CacheList = {
       base: this.name + this.APIAdresses.base
@@ -142,4 +143,22 @@ export default class InvoiceAPI extends APIRepository {
       }
     })
   }
+
+  exportInvoiceReport(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.exportInvoiceReport,
+      data: this.getNormalizedSendData({
+        report_type: null // String
+      }, data),
+      responseType: 'blob',
+      resolveCallback: (response) => {
+        return response.data // xlsxData
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 23 - 8
src/components/Widgets/Invoice/AdminInvoiceList/AdminInvoiceList.vue

@@ -12,6 +12,13 @@
                   :show-search-button="false"
                   :show-expand-button="false"
                   :show-reload-button="false">
+      <template #toolbar>
+        <q-btn color="primary"
+               :loading="exportReportLoading"
+               @click="getInvoicesListExcel">
+          دریافت
+        </q-btn>
+      </template>
       <template #entity-index-table-cell="{inputData}">
         <template v-if="inputData.col.name === 'number'">
           {{ inputData.rowNumber }}
@@ -138,17 +145,10 @@ export default {
           {
             name: 'creation_time',
             required: true,
-            label: 'زمان ثبت',
+            label: 'زمان',
             align: 'left',
             field: row => Assist.miladiToShamsi(row.creation_time)
           },
-          {
-            name: 'last_modification_time',
-            required: true,
-            label: 'زمان آخرین بروز رسانی',
-            align: 'left',
-            field: row => Assist.miladiToShamsi(row.last_modification_time)
-          },
           {
             name: 'action',
             required: true,
@@ -159,6 +159,7 @@ export default {
         ]
       },
       mounted: false,
+      exportReportLoading: false,
       createRouteName: ''
     }
   },
@@ -175,6 +176,20 @@ export default {
     },
     search () {
       this.$refs.entityIndex.search()
+    },
+    getInvoicesListExcel () {
+      this.exportReportLoading = true
+      const filter = this.$refs.entityIndex.createParams()
+      filter.report_type = 'invoices_list'
+      APIGateway.invoice.exportInvoiceReport(filter)
+        .then((xlsxData) => {
+          // Assist.saveXlsx(xlsxData, this.classroomId)
+          Assist.saveXlsx(xlsxData, 'صورتحساب ها')
+          this.exportReportLoading = false
+        })
+        .catch((e) => {
+          this.exportReportLoading = false
+        })
     }
   }
 }