Browse Source

工资单-列表下载

jingbb 1 year ago
parent
commit
a225faa525
1 changed files with 20 additions and 5 deletions
  1. 20 5
      src/views/oa/salary_management/personnelSalary/Payroll.vue

+ 20 - 5
src/views/oa/salary_management/personnelSalary/Payroll.vue

@@ -90,7 +90,7 @@
   <script>
   
     import { JeecgListMixin } from '@/mixins/JeecgListMixin'
-    import { getAction } from '@/api/manage'
+    import { getAction,downFile } from '@/api/manage'
     import moment from 'moment'
     import PayrollDetail from './modules/PayrollDetail.vue'
     import AnnualLeavePayroll from './modules/AnnualLeavePayroll.vue'
@@ -230,10 +230,25 @@
           }
         },
         handleDownload(record){
-
-        },
-        handleexport(record){
-
+          downFile('/salary/salaryManagement/exportXls',{id:record.id,type:record.type}).then(data => {
+            if (!data) {
+              this.$message.warning('文件下载失败')
+              return
+            }
+            if (typeof window.navigator.msSaveBlob !== 'undefined') {
+                window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }),  record.type + '.xlsx')
+            } else {
+              let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
+              let link = document.createElement('a')
+              link.style.display = 'none'
+              link.href = url
+              link.setAttribute('download',  record.type+'.xlsx')
+              document.body.appendChild(link)
+              link.click()
+              document.body.removeChild(link) // 下载完成移除元素
+              window.URL.revokeObjectURL(url) // 释放掉blob对象
+            }
+          })
         },
         onSelectChange(selectedRowKeys, selectionRows) {
             this.selectedRowKeys = selectedRowKeys;