parent
6404534dde
commit
d01a53ff85
6 changed files with 140 additions and 2 deletions
@ -0,0 +1,114 @@ |
||||
<template> |
||||
<div class="wrap"> |
||||
<div class="inner"> |
||||
<el-page-header @back="$router.back()" content="excel预览" style="margin-bottom: 20px"></el-page-header> |
||||
<el-table :data="list" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
||||
<el-table-column type="selection" width="80" align="center"></el-table-column> |
||||
<el-table-column type="index" label="序号" width="55" align="center"></el-table-column> |
||||
<el-table-column v-for="(item,index) in list[0]" :prop="index" :key="index" :label="index" align="center"></el-table-column> |
||||
</el-table> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
export default { |
||||
data() { |
||||
return { |
||||
path: this.$route.query.path, |
||||
thead: [], |
||||
list: [], |
||||
multipleSelection: [] |
||||
}; |
||||
}, |
||||
mounted(){ |
||||
this.getData() |
||||
}, |
||||
methods: { |
||||
// 获取列表 |
||||
getData() { |
||||
this.$post(`${this.api.lookExcel}?excelUrl=${this.path}`).then(res => { |
||||
const { data } = res |
||||
const thead = [] |
||||
if (data.length) { |
||||
const item = data[0] |
||||
for (const i in item) { |
||||
i && thead.push(i) |
||||
} |
||||
const result = [] |
||||
data.map(e => { |
||||
let valid = false |
||||
for (const i in e) { |
||||
if (e[i]) { |
||||
valid = true |
||||
break |
||||
} |
||||
} |
||||
valid && result.push(e) |
||||
}) |
||||
this.thead = thead |
||||
this.list = result |
||||
} |
||||
|
||||
}).catch(res => { |
||||
window.open('https://view.officeapps.live.com/op/view.aspx?src=' + this.path) |
||||
this.$router.back() |
||||
}) |
||||
}, |
||||
handleSelectionChange(val) { |
||||
this.multipleSelection = val |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
.wrap { |
||||
padding: 20px; |
||||
background-color: #f3f6fa; |
||||
.inner { |
||||
padding: 15px; |
||||
background-color: #fff; |
||||
border-radius: 4px; |
||||
} |
||||
.tool { |
||||
display: flex; |
||||
justify-content: space-between; |
||||
margin: 20px 0; |
||||
} |
||||
.action { |
||||
display: inline-flex; |
||||
} |
||||
/deep/.el-table { |
||||
.el-table__cell { |
||||
padding: 10px 0; |
||||
} |
||||
th.el-table__cell { |
||||
& > .cell { |
||||
color: #fff; |
||||
} |
||||
} |
||||
} |
||||
.copy { |
||||
margin-left: 5px; |
||||
cursor: pointer; |
||||
} |
||||
.pagination { |
||||
margin: 20px 0; |
||||
text-align: center; |
||||
button,.number,.more,.el-input__inner{ |
||||
min-width: 32px !important; |
||||
height: 32px !important; |
||||
line-height: 32px; |
||||
color: #333 !important; |
||||
background-color: transparent !important; |
||||
border: 1px solid #ccc !important; |
||||
border-radius: 2px !important; |
||||
} |
||||
button i{ |
||||
color: #333; |
||||
} |
||||
.active{ |
||||
color: #fff !important; |
||||
} |
||||
} |
||||
} |
||||
</style> |
Loading…
Reference in new issue