|
@@ -0,0 +1,72 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" size="small" @click="submit()" plain style="margin-bottom: 10px;margin-top: -10px">导 出</el-button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props:['tablecols','param','excelTitle','total'],
|
|
|
+ data () {
|
|
|
+ return {}
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ async submit () {
|
|
|
+ let data = {}
|
|
|
+ // 如果传入了total,需要赋值保证数量准确性
|
|
|
+ if (this.total) {
|
|
|
+ this.param.content.pageSize = this.total
|
|
|
+ }
|
|
|
+ data = JSON.parse(JSON.stringify(this.param))
|
|
|
+
|
|
|
+ data.content.isAll = true
|
|
|
+ const res = await this.$api.requested(data)
|
|
|
+ console.log(res,"res111")
|
|
|
+ let table = JSON.parse(JSON.stringify(this.tablecols))
|
|
|
+ table.forEach((e,index) => {
|
|
|
+ // 由于表格数据结构问题这里需要判断一下
|
|
|
+ /* console.log(res)*/
|
|
|
+ console.log(index)
|
|
|
+ if (e.title === '省市县') {
|
|
|
+ table[index].title = '省'
|
|
|
+ table.splice(index + 1,0,{title:'市',columnname:'city'},{title:'县',columnname:'county'})
|
|
|
+ }else if(e.title === '型号/规格'){
|
|
|
+ res.data.forEach(e => {
|
|
|
+ e.model = e.model + '/' + e.spec
|
|
|
+ })
|
|
|
+ }else if(e.title === '需求日期'){
|
|
|
+ res.data.forEach(e => {
|
|
|
+ if (e.delivery === 0){
|
|
|
+ e.needdate = '不管控交期'
|
|
|
+ }else {
|
|
|
+ e.needdate = e.needdate
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else if(e.title === '回复交期'){
|
|
|
+ res.data.forEach(e => {
|
|
|
+ if (e.delivery === 0){
|
|
|
+ e.deliverydate = '不管控交期'
|
|
|
+ }else {
|
|
|
+ e.deliverydate = e.deliverydate
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else if(e.title === '小计'){
|
|
|
+ res.data.forEach(e => {
|
|
|
+ e.totalprice = e.price * e.qty
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let hd = table.map(e=>{
|
|
|
+ return e.title
|
|
|
+ })
|
|
|
+ let ft = table.map(e=>{
|
|
|
+ return e.columnname
|
|
|
+ })
|
|
|
+ this.tool.exportExcel(hd,ft,res.data,this.excelTitle)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+</style>
|