| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <el-container>
- <basic-container class="mt-10 content">
- <div class="full-width white-bg" style="width: 100vw">
- <div class="flex flex-center flex-justify-start">
- <el-button type="primary" plain @click="back">返回</el-button>
- <el-button type="primary" @click="exportExcel">导出表格</el-button>
- </div>
- <span class="red full-width text-left flex flex-justify-start mt-10"
- >注:左右滑动,查看更多内容</span
- >
- </div>
- <div class="content mt-10">
- <div class="header flex flex-center flex-justify-start full-width">
- <div
- class="flex flex-center"
- style="background-color: #5acafa"
- v-for="(item, index) in header"
- :key="item.id"
- >
- <div
- class="item flex flex-center"
- :class="index === 0 ? 'item' : 'sub'"
- >
- {{ item }}
- </div>
- </div>
- </div>
- <div class="flex flex-center flex-justify-start flex-col">
- <div
- class="flex flex-center full-width"
- v-for="item in list"
- :key="item.id"
- >
- <div class="flex flex-center flex-justify-start full-width">
- <div class="flex flex-center">
- <div
- v-for="(sub, index) in item"
- :key="sub.id"
- class="item flex flex-center overflow-hide"
- :class="index === 0 ? 'item' : 'sub'"
- >
- <el-tooltip :content="sub" placement="top">
- {{ sub }}
- </el-tooltip>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </basic-container>
- </el-container>
- </template>
- <route>
- {
- name: '导出预览'
- }
- </route>
- <script>
- import BasicContainer from '@/components/basic-container/main.vue'
- export default {
- name: 'excel',
- components: { BasicContainer },
- data() {
- return {
- header: [],
- list: [],
- query: null
- }
- },
- created() {
- this.query = this.$route.query
- console.log(this.query)
- this.getList()
- },
- methods: {
- back() {
- this.$router.back()
- },
- getList() {
- this.$api.params.preview(this.query).then(res => {
- if (res.code === 200) {
- this.header = res.data.header
- this.list = res.data.list
- } else {
- this.$message.error(res.msg)
- }
- })
- },
- exportExcel() {
- if (this.query.previewType === '1') {
- this.$api.params.exportResult(this.query).then(res => {
- if (res.hasOwnProperty('code')) {
- this.$message.error(res.msg)
- return
- }
- this.download(res)
- })
- } else {
- this.$api.params.summaryExport(this.query).then(res => {
- if (res.hasOwnProperty('code')) {
- this.$message.error(res.msg)
- return
- }
- this.download(res)
- })
- }
- },
- download(res) {
- const url = window.URL.createObjectURL(
- new Blob([res], { type: 'application/vnd.ms-excel' })
- )
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- const excelName = new Date().getTime() + '.xlsx'
- link.setAttribute('download', excelName)
- document.body.appendChild(link)
- link.click()
- link.remove()
- this.diaType = -1
- this.$message.success('导出成功')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- white-space: nowrap;
- overflow-x: scroll;
- }
- .header {
- background-color: #5acafa;
- border-top: #1a1a1a solid 1px;
- }
- .item {
- width: 80px;
- text-wrap: normal;
- height: 50px;
- border-collapse: collapse;
- border: #1a1a1a solid 1px;
- margin-right: -1px;
- margin-top: -1px;
- padding: 5px;
- white-space: pre-wrap;
- }
- .top {
- position: static;
- top: 0;
- z-index: 3;
- left: 0;
- }
- .sub {
- width: 200px;
- height: 50px;
- text-wrap: normal;
- }
- </style>
|