库存明细页面增加导出excel
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<div class="app-container" v-loading="loading">
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<h2 style="text-align: center; margin-bottom: 16px;">{{ title }}</h2>
|
<div style="text-align: center; margin-bottom: 16px; position: relative;">
|
||||||
|
<h2>{{ title }}</h2>
|
||||||
|
<el-button size="small" type="primary" style="position: absolute; right: 0; top: 0;" @click="exportExcel">导出</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 空数据 -->
|
<!-- 空数据 -->
|
||||||
<el-empty v-if="!loading && tableData.length === 0" description="暂无数据" />
|
<el-empty v-if="!loading && tableData.length === 0" description="暂无数据" />
|
||||||
@@ -37,6 +40,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import { listCoilWithIds } from "@/api/wms/coil";
|
||||||
|
import * as XLSX from 'xlsx'
|
||||||
|
|
||||||
const CATEGORIES = [
|
const CATEGORIES = [
|
||||||
{ key: '冷硬钢卷', label: '冷硬钢卷', match: ['冷硬'] },
|
{ key: '冷硬钢卷', label: '冷硬钢卷', match: ['冷硬'] },
|
||||||
@@ -221,6 +225,16 @@ export default {
|
|||||||
else return [0, 0] // CDO 列 → 隐藏
|
else return [0, 0] // CDO 列 → 隐藏
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
exportExcel() {
|
||||||
|
const table = this.$el.querySelector('.el-table__header-wrapper table')
|
||||||
|
const sheet = XLSX.utils.table_to_sheet(table)
|
||||||
|
// 追加数据行
|
||||||
|
const dataRows = this.$el.querySelector('.el-table__body-wrapper table')
|
||||||
|
XLSX.utils.sheet_add_dom(sheet, dataRows, { origin: -1 /* 接在表头后面 */ })
|
||||||
|
const wb = XLSX.utils.book_new()
|
||||||
|
XLSX.utils.book_append_sheet(wb, sheet, '库存明细')
|
||||||
|
XLSX.writeFile(wb, `${this.title}.xlsx`)
|
||||||
|
},
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.rawList = []
|
this.rawList = []
|
||||||
|
|||||||
Reference in New Issue
Block a user