Selaa lähdekoodia

工资单-导出

jingbb 1 vuosi sitten
vanhempi
commit
f9dba83d0a
1 muutettua tiedostoa jossa 23 lisäystä ja 0 poistoa
  1. 23 0
      src/views/oa/salary_management/personnelSalary/Payroll.vue

+ 23 - 0
src/views/oa/salary_management/personnelSalary/Payroll.vue

@@ -74,6 +74,8 @@
                 <a @click="handleDetail(record)" >查看详情</a>
                 <a-divider type="vertical" />
                 <a @click="handleDownload(record)" >下载</a>
+                <a-divider type="vertical" />
+                <a @click="handleExport(record)" >导出</a>
            </span>
         </a-table>
       </div>
@@ -251,6 +253,27 @@
             }
           })
         },
+        handleExport(record){
+          downFile('/salary/salaryManagement/exportXls2',{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;
             this.selectedRows = selectionRows;