修改报表导出

master
夜笙歌 7 months ago
parent d4f09a115b
commit fb015fa38a

@ -42,7 +42,7 @@
"core-js": "^3.33.2",
"echarts": "5.4.0",
"element-ui": "2.15.13",
"file-saver": "2.0.5",
"file-saver": "^2.0.5",
"fuse.js": "6.4.3",
"highlight.js": "9.18.5",
"js-beautify": "1.13.0",
@ -61,7 +61,8 @@
"vue-router": "3.4.9",
"vue-seamless-scroll": "^1.1.23",
"vuedraggable": "2.24.3",
"vuex": "3.6.0"
"vuex": "3.6.0",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "4.4.6",

@ -18,10 +18,12 @@
<el-form-item>
<el-button type="primary" @click="onSubmit"></el-button>
<el-button @click="resetForm('form')"></el-button>
<el-button type="success" @click="exportExcel('导出')"></el-button>
</el-form-item>
</el-form>
<el-table
ref="report-table"
:data="tableData"
style="width: 100%">
<el-table-column
@ -63,6 +65,8 @@
</template>
<script>
import FileSaver from 'file-saver'
import {utils,write} from 'xlsx'
import {findProductLineList} from '@//api/base/productLine'
import {parseTime} from '@//utils/ruoyi'
import {
@ -126,6 +130,25 @@ export default {
})
this.tableTimeHead = head
},
exportExcel(excelName) {
try {
//
const $e = this.$refs['report-table'].$el
let $table = $e.querySelector('.el-table__fixed')
if (!$table) {
$table = $e
}
const wb = utils.table_to_book($table, {raw: true})
const wbout = write(wb, {bookType: 'xlsx', bookSST: true, type: 'array'})
FileSaver.saveAs(
new Blob([wbout], {type: 'application/octet-stream'}),
`${excelName}.xlsx`,
)
} catch (e) {
if (typeof console !== 'undefined') console.error(e)
}
}
}
}
</script>

@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
// target: `http://10.11.43.2:8080`,
// target: `http://10.41.11.35:6061`,
target: `http://10.100.72.10:8080`,
// target: `http://192.168.1.118:6061`,
// target: `http://localhost:6061`,

Loading…
Cancel
Save