exportExcel-agent.vue
6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<template>
<!-- $t is vue-i18n global function to translate lang -->
<div class="app-container">
<!--工具条-->
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
<el-form :inline="true" :model="searchText">
<el-form-item>
<el-date-picker v-model="searchText.startdate" value-format="yyyy-MM-dd" type="date"
placeholder="开始航班日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-date-picker v-model="searchText.enddate" value-format="yyyy-MM-dd" type="date"
placeholder="结束航班日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button :loading="downloadLoading" style="margin:0 0 20px 20px;" type="primary" icon="document" @click="fetchData">查询</el-button>
</el-form-item>
</el-form>
</el-col>
<div>
<FilenameOption v-model="filename" />
<AutoWidthOption v-model="autoWidth" />
<BookTypeOption v-model="bookType" />
<el-button :loading="downloadLoading" style="margin:0 0 20px 20px;" type="primary" icon="document" @click="handleDownload">导出 Excel</el-button>
</div>
<el-table v-loading="listLoading" :data="list" element-loading-text="拼命加载中" border fit highlight-current-row>
<el-table-column align="center" label="Id" width="95">
<template slot-scope="scope">
{{ scope.$index }}
</template>
</el-table-column>
<el-table-column label="运单号">
<template slot-scope="scope">
{{ scope.row.autoid }}
</template>
</el-table-column>
<el-table-column label="承运人" width="110" align="center">
<template slot-scope="scope">
<el-tag>{{ scope.row.totalpiece }}</el-tag>
</template>
</el-table-column>
<el-table-column label="航班号" width="115" align="center">
<template slot-scope="scope">
{{ scope.row.manifesttotalpiece }}
</template>
</el-table-column>
<el-table-column align="center" label="航班日期" width="220" :formatter="dateFormat">
<template slot-scope="scope">
<i class="el-icon-time"/>
<span>{{ scope.row.manifesttotalweight | parseTime('{y}-{m}-{d}')}}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { getAnalysisList } from '@/api/agent-excel'
import { parseTime } from '@/utils'
// options components
import FilenameOption from './components/FilenameOption'
import AutoWidthOption from './components/AutoWidthOption'
import BookTypeOption from './components/BookTypeOption'
import Export2Excel from '@/vendor/Export2Excel'
export default {
name: 'ExportExcel',
components: { FilenameOption, AutoWidthOption, BookTypeOption },
data() {
return {
list: [],
fetchList: [],
listLoading: false,
downloadLoading: false,
filename: '',
autoWidth: true,
bookType: 'xlsx',
searchText: {
startdate: undefined,
enddate: undefined
}
}
},
created() {
// this.fetchData()
},
filters: {
parseTime: parseTime
},
methods: {
dateFormat:function(row,column){
var t=new Date(row.updateTime);//row 表示一行数据, updateTime 表示要格式化的字段名称
return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate();
},
fetchData() {
this.listLoading = true
getAnalysisList(this.searchText).then(response => {
this.list = response.data.data
this.listLoading = false
})
},
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['运单号',
'航空托运人名称',
'航空销售代理人名称',
'航协编号',
'航空公司运输证明',
'运输条件鉴定书',
'承运人',
'航班号',
'航班日期',
'航班起始站',
'航班目的站',
'运单件数',
'运单重量',
'操作时间',
'关区',
'预配品名',
'收货人公司',
'收货人地址',
'收货人城市',
'收货人电话',
'收货人国家',
'收货人名称',
'发货人名称',
'发货人地址',
'发货人城市',
'发货人国家',
'发货人电话',
'发货人名称',
'海关回执状态',
'海关回执信息',
'发货人编码',
'收货人编码',
'货物品名',
'二级类名称',
'一级类名称',
'代理人三字码',
'代理人全称',
'代理人类别',
'代理联系人',
'代理联系人电话'
]
const filterVal = [
'autoid',
'waybillnomaster',
'segment',
'originatingstation',
'destinationstation',
'totalweight',
'totalpiece',
'manifesttotalpiece',
'manifesttotalweight',
'flightno',
'productname',
'customsstatus',
'carrier1',
'arrivalstation1',
'carrier2',
'arrivalstation2',
'carrier3',
'arrivalstation3',
'paymode',
'customscode',
'specialgoodscode',
'shippername',
'shipperaddress',
'consigneename',
'consigneeaddress',
'receiptinformation',
'specificConsigneePhone',
'consigneePhone',
'status',
'isbatch',
'originatingstationBill',
'destinationstationBill',
'reportorder',
'islast',
'shipperCode',
'shipperCountrycode',
'shipperPhone',
'shipperFax',
'consigneeCode',
'consigneeCountrycode'
]
const list = this.list
const data = this.formatJson(filterVal, list)
excel.export_json_to_excel({
header: tHeader,
data,
filename: this.filename,
autoWidth: this.autoWidth,
bookType: this.bookType
})
this.downloadLoading = false
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'timestamp') {
return parseTime(v[j])
} else {
return v[j]
}
}))
}
}
}
</script>
<style>
.radio-label {
font-size: 14px;
color: #606266;
line-height: 40px;
padding: 0 12px 0 30px;
}
</style>