正在显示
5 个修改的文件
包含
603 行增加
和
0 行删除
@@ -79,6 +79,17 @@ export default { | @@ -79,6 +79,17 @@ export default { | ||
79 | } | 79 | } |
80 | }); | 80 | }); |
81 | }, | 81 | }, |
82 | + getPDF(url, params) { | ||
83 | + return axios({ | ||
84 | + method: 'GET', | ||
85 | + url: url, | ||
86 | + responseType: 'blob', | ||
87 | + params: params, | ||
88 | + headers: { | ||
89 | + 'Content-Type': 'application/x-www-form-urlencoded' | ||
90 | + } | ||
91 | + }); | ||
92 | + }, | ||
82 | put(url, params){ | 93 | put(url, params){ |
83 | return axios({ | 94 | return axios({ |
84 | method: 'PUT', | 95 | method: 'PUT', |
src/api/zhidan/zhidan.js
0 → 100644
1 | +import http from "../http"; | ||
2 | +import axios from "axios"; | ||
3 | +let baseUrl = 'zhidan-service' | ||
4 | + | ||
5 | +//pdf导出 | ||
6 | +export const extPdf = params => { return http.getPDF(`${baseUrl}/zhidan/extpdf`, params); }; | ||
7 | +//excel导出 | ||
8 | +export const extExcel = params => { return http.getPDF(`${baseUrl}/zhidan/extexcel`, params); }; | ||
9 | +//导入excel | ||
10 | +export const importExcel = params => { return http.postExcelData(`${baseUrl}/zhidan/importexcel`, params); }; | ||
11 | +//查询列表 | ||
12 | +export const selectLists = params => { return axios.get(`${baseUrl}/zhidan/selectLists`, { params: params }); }; | ||
13 | + | ||
14 | +//费率新增 | ||
15 | +export const addRate = params =>{return http.post(`${baseUrl}/rate/addRate`, params);}; | ||
16 | +//费率删除 | ||
17 | +export const delRate = params => { return axios.get(`${baseUrl}/rate/delRate`, { params: params }); }; | ||
18 | +//费率更新 | ||
19 | +export const ediRate = params =>{return http.post(`${baseUrl}/rate/ediRate`, params);}; | ||
20 | +//费率查询 | ||
21 | +export const selectRate = params => { return axios.get(`${baseUrl}/rate/selectRate`, { params: params }); }; |
@@ -197,6 +197,10 @@ import satellite from "./views/deploy/satellite"; | @@ -197,6 +197,10 @@ import satellite from "./views/deploy/satellite"; | ||
197 | import ExortOrder from './views/exportorder/Exportorder.vue' | 197 | import ExortOrder from './views/exportorder/Exportorder.vue' |
198 | import CustomerConfig from './views/exportorder/CustomerConfig.vue' | 198 | import CustomerConfig from './views/exportorder/CustomerConfig.vue' |
199 | 199 | ||
200 | +/*制单管理*/ | ||
201 | +import ZhiDan from './views/zhidan/zhidan.vue' | ||
202 | +import Rate from './views/zhidan/rate.vue' | ||
203 | + | ||
200 | let routes = [ | 204 | let routes = [ |
201 | { | 205 | { |
202 | path: '/login', | 206 | path: '/login', |
@@ -231,6 +235,16 @@ let routes = [ | @@ -231,6 +235,16 @@ let routes = [ | ||
231 | ] | 235 | ] |
232 | }, | 236 | }, |
233 | { | 237 | { |
238 | + path: '/zhidan', | ||
239 | + component: HomeNew, | ||
240 | + name: '制单管理', | ||
241 | + iconCls: 'el-icon-collection', | ||
242 | + children: [ | ||
243 | + {path: '/ZhiDan', component: ZhiDan, name: '制单信息'}, | ||
244 | + {path: '/Rate', component: Rate, name: '费率设置'} | ||
245 | + ] | ||
246 | + }, | ||
247 | + { | ||
234 | path: '/', | 248 | path: '/', |
235 | component: HomeNew, | 249 | component: HomeNew, |
236 | name: 'Charts', | 250 | name: 'Charts', |
src/views/zhidan/rate.vue
0 → 100644
1 | +<template> | ||
2 | + <div> | ||
3 | + <el-row :gutter="24"> | ||
4 | + <el-col :span="4"> | ||
5 | + <el-input size="medium" v-model="query.carrier" onkeyup="this.value=this.value.toUpperCase()" placeholder="承运人二字码"></el-input> | ||
6 | + </el-col> | ||
7 | + <el-col :span="4"> | ||
8 | + <el-input size="medium" v-model="query.dest" onkeyup="this.value=this.value.toUpperCase()" placeholder="目的港"></el-input> | ||
9 | + </el-col> | ||
10 | + <el-col :span="2"> | ||
11 | + <el-button size="medium" @click="getList" type="primary">查询</el-button> | ||
12 | + </el-col> | ||
13 | + <el-col :span="2"> | ||
14 | + <el-button size="medium" @click="add" type="primary">新增</el-button> | ||
15 | + </el-col> | ||
16 | + </el-row> | ||
17 | + <el-row :gutter="24"> | ||
18 | + <el-col :span="24"> | ||
19 | + <el-table | ||
20 | + :data="tableData" | ||
21 | + border | ||
22 | + style="width: 100%"> | ||
23 | + <el-table-column | ||
24 | + prop="carrier" | ||
25 | + label="承运人二字码" | ||
26 | + width="120"> | ||
27 | + </el-table-column> | ||
28 | + <el-table-column | ||
29 | + prop="dest" | ||
30 | + label="目的港" | ||
31 | + width="120"> | ||
32 | + </el-table-column> | ||
33 | + <el-table-column | ||
34 | + prop="destrate" | ||
35 | + label="目的港费率" | ||
36 | + width="120"> | ||
37 | + </el-table-column> | ||
38 | + <el-table-column | ||
39 | + prop="mycname" | ||
40 | + label="燃油费类型" | ||
41 | + width="120"> | ||
42 | + </el-table-column> | ||
43 | + <el-table-column | ||
44 | + prop="myc" | ||
45 | + label="燃油费率" | ||
46 | + width="120"> | ||
47 | + </el-table-column> | ||
48 | + <el-table-column | ||
49 | + prop="sccname" | ||
50 | + label="战险类型" | ||
51 | + width="120"> | ||
52 | + </el-table-column> | ||
53 | + <el-table-column | ||
54 | + prop="scc" | ||
55 | + label="战险费率" | ||
56 | + width="120"> | ||
57 | + </el-table-column> | ||
58 | + <el-table-column | ||
59 | + prop="zhidanfei" | ||
60 | + label="制单费" | ||
61 | + width="120"> | ||
62 | + </el-table-column> | ||
63 | + <el-table-column | ||
64 | + prop="cgc" | ||
65 | + label="信息传输费" | ||
66 | + width="120"> | ||
67 | + </el-table-column> | ||
68 | + <el-table-column | ||
69 | + fixed="right" | ||
70 | + label="操作" | ||
71 | + width="100"> | ||
72 | + <template slot-scope="scope"> | ||
73 | + <el-button @click="handleClick(scope.row)" type="text" size="small">编辑</el-button> | ||
74 | + <el-button @click="deleteClick(scope.row)" type="text" size="small">删除</el-button> | ||
75 | + </template> | ||
76 | + </el-table-column> | ||
77 | + </el-table> | ||
78 | + </el-col> | ||
79 | + <el-col :span="24"> | ||
80 | + <div class="block"> | ||
81 | + <el-pagination | ||
82 | + @size-change="handleSizeChange" | ||
83 | + @current-change="handleCurrentChange" | ||
84 | + :current-page="query.pageNum" | ||
85 | + :page-sizes="[10, 20, 30, 40]" | ||
86 | + :page-size="query.pageSize" | ||
87 | + layout="total, sizes, prev, pager, next, jumper" | ||
88 | + :total="total"> | ||
89 | + </el-pagination> | ||
90 | + </div> | ||
91 | + </el-col> | ||
92 | + </el-row> | ||
93 | + | ||
94 | + <el-dialog | ||
95 | + title="费率信息" | ||
96 | + :visible.sync="dialogVisible" | ||
97 | + width="30%" | ||
98 | + :before-close="handleClose"> | ||
99 | + <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> | ||
100 | + <el-form-item label="目的港" prop="dest"> | ||
101 | + <el-input v-model="ruleForm.dest" onkeyup="this.value=this.value.toUpperCase()"></el-input> | ||
102 | + </el-form-item> | ||
103 | + <el-form-item label="目的港费率" prop="destrate"> | ||
104 | + <el-input v-model="ruleForm.destrate" type="number"></el-input> | ||
105 | + </el-form-item> | ||
106 | + <el-form-item label="承运人二字码" prop="carrier"> | ||
107 | + <el-input v-model="ruleForm.carrier" onkeyup="this.value=this.value.toUpperCase()"></el-input> | ||
108 | + </el-form-item> | ||
109 | + <el-form-item label="燃油费类型:" prop="mycname"> | ||
110 | + <el-input v-model="ruleForm.mycname" onkeyup="this.value=this.value.toUpperCase()"></el-input> | ||
111 | + </el-form-item> | ||
112 | + <el-form-item label="燃油费率" prop="myc"> | ||
113 | + <el-input v-model="ruleForm.myc" type="number"></el-input> | ||
114 | + </el-form-item> | ||
115 | + <el-form-item label="战险类型" prop="sccname"> | ||
116 | + <el-input v-model="ruleForm.sccname" onkeyup="this.value=this.value.toUpperCase()"></el-input> | ||
117 | + </el-form-item> | ||
118 | + <el-form-item label="战险费率" prop="scc"> | ||
119 | + <el-input v-model="ruleForm.scc" type="number"></el-input> | ||
120 | + </el-form-item> | ||
121 | + <el-form-item label="制单费" prop="zhidanfei"> | ||
122 | + <el-input v-model="ruleForm.zhidanfei" type="number"></el-input> | ||
123 | + </el-form-item> | ||
124 | + <el-form-item label="信息传输费" prop="cgc"> | ||
125 | + <el-input v-model="ruleForm.cgc" type="number"></el-input> | ||
126 | + </el-form-item> | ||
127 | + <el-form-item> | ||
128 | + <el-button type="primary" @click="dialogStatus==='create'?addForm('ruleForm'):ediForm('ruleForm')">保存</el-button> | ||
129 | + <el-button @click="resetForm('ruleForm')">重置</el-button> | ||
130 | + </el-form-item> | ||
131 | + </el-form> | ||
132 | + </el-dialog> | ||
133 | + | ||
134 | + </div> | ||
135 | +</template> | ||
136 | +<script> | ||
137 | + import {addRate,delRate,ediRate,selectRate} from "../../api/zhidan/zhidan"; | ||
138 | + export default { | ||
139 | + data(){ | ||
140 | + return{ | ||
141 | + ruleForm: { | ||
142 | + id:'', | ||
143 | + carrier: '', | ||
144 | + dest:'', | ||
145 | + destrate:0, | ||
146 | + myc:0, | ||
147 | + scc:0, | ||
148 | + zhidanfei:0, | ||
149 | + mycname:'', | ||
150 | + sccname:'', | ||
151 | + cgc:0, | ||
152 | + }, | ||
153 | + rules: { | ||
154 | + | ||
155 | + }, | ||
156 | + query:{ | ||
157 | + carrier:'', | ||
158 | + dest:'', | ||
159 | + pageNum:1, | ||
160 | + pageSize:20 | ||
161 | + }, | ||
162 | + total:0, | ||
163 | + tableData:[], | ||
164 | + dialogVisible:false, | ||
165 | + dialogStatus: '', | ||
166 | + } | ||
167 | + }, | ||
168 | + mounted() { | ||
169 | + this.getList(); | ||
170 | + }, | ||
171 | + methods:{ | ||
172 | + addForm(formName) { | ||
173 | + this.$refs[formName].validate((valid) => { | ||
174 | + if (valid) { | ||
175 | + addRate(this.ruleForm).then((response) => { | ||
176 | + const res = response.data | ||
177 | + if (res.code !== '200') { | ||
178 | + return this.$message.error('费率新增,失败!') | ||
179 | + } | ||
180 | + this.$message.success('费率新增,成功!') | ||
181 | + this.dialogVisible = false; | ||
182 | + this.getList(); | ||
183 | + }).catch(error => { | ||
184 | + // 关闭加载 | ||
185 | + this.$message.warning('费率新增,失败!') | ||
186 | + }) | ||
187 | + } else { | ||
188 | + console.log('error submit!!'); | ||
189 | + return false; | ||
190 | + } | ||
191 | + }); | ||
192 | + }, | ||
193 | + ediForm(formName) { | ||
194 | + this.$refs[formName].validate((valid) => { | ||
195 | + if (valid) { | ||
196 | + ediRate(this.ruleForm).then((response) => { | ||
197 | + const res = response.data | ||
198 | + if (res.code !== '200') { | ||
199 | + return this.$message.error('费率更新,失败!') | ||
200 | + } | ||
201 | + this.$message.success('费率更新,成功!') | ||
202 | + this.dialogVisible = false; | ||
203 | + this.getList(); | ||
204 | + }).catch(error => { | ||
205 | + // 关闭加载 | ||
206 | + this.$message.warning('费率更新,失败!') | ||
207 | + }) | ||
208 | + } else { | ||
209 | + console.log('error submit!!'); | ||
210 | + return false; | ||
211 | + } | ||
212 | + }); | ||
213 | + }, | ||
214 | + resetForm(formName) { | ||
215 | + this.$refs[formName].resetFields(); | ||
216 | + }, | ||
217 | + add(){ | ||
218 | + this.ruleForm={ | ||
219 | + id:'', | ||
220 | + carrier: '', | ||
221 | + dest:'', | ||
222 | + destrate:0, | ||
223 | + myc:0, | ||
224 | + scc:0, | ||
225 | + zhidanfei:0, | ||
226 | + mycname:'', | ||
227 | + sccname:'', | ||
228 | + cgc:0, | ||
229 | + } | ||
230 | + this.dialogVisible=true; | ||
231 | + this.dialogStatus='create'; | ||
232 | + }, | ||
233 | + handleClose(done) { | ||
234 | + this.$confirm('确认关闭?') | ||
235 | + .then(_ => { | ||
236 | + done(); | ||
237 | + }) | ||
238 | + .catch(_ => {}); | ||
239 | + }, | ||
240 | + handleClick(row) { | ||
241 | + this.dialogVisible=true; | ||
242 | + this.dialogStatus='update'; | ||
243 | + this.ruleForm=row; | ||
244 | + }, | ||
245 | + deleteClick(row) { | ||
246 | + this.$confirm('此操作永久删除该消息收发记录, 是否继续?', '警告', { | ||
247 | + confirmButtonText: '确定删除', | ||
248 | + cancelButtonText: '取消', | ||
249 | + type: 'warning' | ||
250 | + } | ||
251 | + ).then(() => { | ||
252 | + delRate({id: row.id}).then((response) => { | ||
253 | + const res = response.data | ||
254 | + this.$message.success(res.msg) | ||
255 | + this.getList(); | ||
256 | + }).catch(error => { | ||
257 | + this.$message.error('删除配置,失败!') | ||
258 | + }) | ||
259 | + }).catch(() => { | ||
260 | + }) | ||
261 | + }, | ||
262 | + handleSizeChange(val) { | ||
263 | + this.query.pageSize=val; | ||
264 | + this.getList(); | ||
265 | + }, | ||
266 | + handleCurrentChange(val) { | ||
267 | + this.query.pageNum=val; | ||
268 | + this.getList(); | ||
269 | + }, | ||
270 | + getList(){ | ||
271 | + selectRate(this.query).then((response) => { | ||
272 | + const res = response.data | ||
273 | + if (res.code !== '200') { | ||
274 | + return this.$message.error('获取消息收发记录,失败!') | ||
275 | + } | ||
276 | + // 获取列表数据 | ||
277 | + this.tableData = res.data.list | ||
278 | + // 获取列表的总记录数 | ||
279 | + this.total = res.data.total | ||
280 | + this.$message.success('获取消息收发记录,成功!'); | ||
281 | + }).catch(error => { | ||
282 | + // 关闭加载 | ||
283 | + this.$message.error(error.toString()) | ||
284 | + }) | ||
285 | + }, | ||
286 | + validateUppercaseInput() { | ||
287 | + // 使用正则表达式来匹配非大写字母,并替换为空字符串 | ||
288 | + this.uppercaseInput = this.uppercaseInput.replace(/[^A-Z]/g, ''); | ||
289 | + } | ||
290 | + } | ||
291 | + } | ||
292 | +</script> |
src/views/zhidan/zhidan.vue
0 → 100644
1 | +<template> | ||
2 | + <div> | ||
3 | + <el-row :gutter="24"> | ||
4 | + <el-col :span="4"> | ||
5 | + <el-input size="medium" v-model="query.waybill" placeholder="运单号"></el-input> | ||
6 | + </el-col> | ||
7 | + <el-col :span="9"> | ||
8 | + <el-date-picker | ||
9 | + size="medium" | ||
10 | + v-model="value2" | ||
11 | + type="datetimerange" | ||
12 | + :picker-options="pickerOptions" | ||
13 | + range-separator="至" | ||
14 | + start-placeholder="开始日期" | ||
15 | + end-placeholder="结束日期" | ||
16 | + align="right"> | ||
17 | + </el-date-picker> | ||
18 | + </el-col> | ||
19 | + <el-col :span="2"> | ||
20 | + <el-button size="medium" @click="getList" type="primary">查询</el-button> | ||
21 | + </el-col> | ||
22 | + <el-col :span="2"> | ||
23 | + <el-upload | ||
24 | + class="upload-demo" | ||
25 | + action="" | ||
26 | + :before-upload="beforeUpload" | ||
27 | + :http-request="impExcel" | ||
28 | + :show-file-list="false"> | ||
29 | + <el-button size="medium" type="success">导入数据</el-button> | ||
30 | + </el-upload> | ||
31 | + </el-col> | ||
32 | + </el-row> | ||
33 | + <el-row :gutter="24"> | ||
34 | + <el-col :span="24"> | ||
35 | + <el-table | ||
36 | + :data="tableData" | ||
37 | + border | ||
38 | + style="width: 100%"> | ||
39 | + <el-table-column | ||
40 | + prop="waybill" | ||
41 | + label="运单号" | ||
42 | + width="120"> | ||
43 | + </el-table-column> | ||
44 | + <!--<el-table-column | ||
45 | + prop="fhl" | ||
46 | + label="分单号" | ||
47 | + width="120"> | ||
48 | + </el-table-column>--> | ||
49 | + <el-table-column | ||
50 | + prop="flightno" | ||
51 | + label="航班号" | ||
52 | + width="120"> | ||
53 | + </el-table-column> | ||
54 | + <el-table-column | ||
55 | + prop="flightdate" | ||
56 | + label="航班日期" | ||
57 | + width="150"> | ||
58 | + </el-table-column> | ||
59 | + <el-table-column | ||
60 | + prop="pcs" | ||
61 | + label="件数" | ||
62 | + width="120"> | ||
63 | + </el-table-column> | ||
64 | + <el-table-column | ||
65 | + prop="weight" | ||
66 | + label="重量" | ||
67 | + width="120"> | ||
68 | + </el-table-column> | ||
69 | + <el-table-column | ||
70 | + prop="feweifht" | ||
71 | + label="计费重" | ||
72 | + width="120"> | ||
73 | + </el-table-column> | ||
74 | + <el-table-column | ||
75 | + prop="vol" | ||
76 | + label="体积" | ||
77 | + width="120"> | ||
78 | + </el-table-column> | ||
79 | + <el-table-column | ||
80 | + prop="descr" | ||
81 | + label="品名" | ||
82 | + width="120"> | ||
83 | + </el-table-column> | ||
84 | + <el-table-column | ||
85 | + fixed="right" | ||
86 | + label="操作" | ||
87 | + width="160"> | ||
88 | + <template slot-scope="scope"> | ||
89 | + <el-button @click="handlePdf(scope.row)" type="text" size="small">下载PDF</el-button> | ||
90 | + <el-button @click="handleExcel(scope.row)" type="text" size="small">下载EXCEL</el-button> | ||
91 | + </template> | ||
92 | + </el-table-column> | ||
93 | + </el-table> | ||
94 | + </el-col> | ||
95 | + <el-col :span="24"> | ||
96 | + <el-pagination | ||
97 | + size="medium" | ||
98 | + @size-change="handleSizeChange" | ||
99 | + @current-change="handleCurrentChange" | ||
100 | + :current-page="query.pageNum" | ||
101 | + :page-sizes="[100, 200, 300, 400]" | ||
102 | + :page-size="query.pageSize" | ||
103 | + layout="total, sizes, prev, pager, next, jumper" | ||
104 | + :total="total"> | ||
105 | + </el-pagination> | ||
106 | + </el-col> | ||
107 | + </el-row> | ||
108 | + </div> | ||
109 | +</template> | ||
110 | +<script> | ||
111 | + import {selectLists,extPdf,extExcel,importExcel} from "../../api/zhidan/zhidan"; | ||
112 | + | ||
113 | + export default { | ||
114 | + data(){ | ||
115 | + return{ | ||
116 | + pickerOptions: { | ||
117 | + shortcuts: [ | ||
118 | + { | ||
119 | + text: '最近一周', | ||
120 | + onClick(picker) { | ||
121 | + const end = new Date(); | ||
122 | + const start = new Date(); | ||
123 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); | ||
124 | + picker.$emit('pick', [start, end]); | ||
125 | + } | ||
126 | + }, { | ||
127 | + text: '最近一个月', | ||
128 | + onClick(picker) { | ||
129 | + const end = new Date(); | ||
130 | + const start = new Date(); | ||
131 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); | ||
132 | + picker.$emit('pick', [start, end]); | ||
133 | + } | ||
134 | + }, { | ||
135 | + text: '最近三个月', | ||
136 | + onClick(picker) { | ||
137 | + const end = new Date(); | ||
138 | + const start = new Date(); | ||
139 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); | ||
140 | + picker.$emit('pick', [start, end]); | ||
141 | + } | ||
142 | + } | ||
143 | + ] | ||
144 | + }, | ||
145 | + query:{ | ||
146 | + waybill:'', | ||
147 | + starttime:'', | ||
148 | + endtime:'', | ||
149 | + pageNum:1, | ||
150 | + pageSize:20 | ||
151 | + }, | ||
152 | + value2:'', | ||
153 | + tableData: [], | ||
154 | + total:0, | ||
155 | + } | ||
156 | + }, | ||
157 | + mounted() { | ||
158 | + this.getList(); | ||
159 | + }, | ||
160 | + methods:{ | ||
161 | + //导入订单excel | ||
162 | + beforeUpload(file) { | ||
163 | + // 检查文件类型 | ||
164 | + const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type === 'application/vnd.ms-excel'; | ||
165 | + if (!isExcel) { | ||
166 | + this.$message.error('上传文件只能是 Excel 格式!'); | ||
167 | + return false; // 取消文件上传 | ||
168 | + } | ||
169 | + return true; // 允许上传 | ||
170 | + | ||
171 | + }, | ||
172 | + impExcel({ file, onSuccess, onError }){ | ||
173 | + // 生成 FormData 对象 | ||
174 | + const formData = new FormData(); | ||
175 | + formData.append('file', file); | ||
176 | + importExcel(formData).then((response) => { | ||
177 | + const res = response.data | ||
178 | + if (res.code !== '200') { | ||
179 | + return this.$message.error(res.msg); | ||
180 | + } | ||
181 | + this.$message.success(res.msg); | ||
182 | + this.getList(); | ||
183 | + onSuccess(response.data); // 调用 onSuccess 回调通知上传成功 | ||
184 | + }).catch(error => { | ||
185 | + // 关闭加载 | ||
186 | + this.$message.error(error.toString()) | ||
187 | + onError(error); // 调用 onError 回调通知上传失败 | ||
188 | + }) | ||
189 | + }, | ||
190 | + getList(){ | ||
191 | + if(this.value2 !== null && this.value2 !== ""){ | ||
192 | + this.query.starttime=this.value2[0]; | ||
193 | + this.query.endtime=this.value2[1]; | ||
194 | + } | ||
195 | + selectLists(this.query).then((response) => { | ||
196 | + const res = response.data | ||
197 | + if (res.code !== '200') { | ||
198 | + return this.$message.error('获取消息收发记录,失败!') | ||
199 | + } | ||
200 | + // 获取列表数据 | ||
201 | + this.tableData = res.data.list | ||
202 | + // 获取列表的总记录数 | ||
203 | + this.total = res.data.total | ||
204 | + this.$message.success('获取消息收发记录,成功!'); | ||
205 | + }).catch(error => { | ||
206 | + // 关闭加载 | ||
207 | + this.$message.error(error.toString()) | ||
208 | + }) | ||
209 | + }, | ||
210 | + handlePdf(row) { | ||
211 | + extPdf({id: row.id}).then(response => { | ||
212 | + const url = window.URL.createObjectURL(new Blob([response.data])); | ||
213 | + const link = document.createElement('a'); | ||
214 | + link.href = url; | ||
215 | + link.setAttribute('download', row.waybill+'.pdf'); // 动态设置文件名 | ||
216 | + document.body.appendChild(link); | ||
217 | + link.click(); | ||
218 | + document.body.removeChild(link); // 清理临时链接 | ||
219 | + window.URL.revokeObjectURL(url); // 清理URL对象 | ||
220 | + }).catch(error => { | ||
221 | + console.error('Error downloading PDF:', error); | ||
222 | + }); | ||
223 | + }, | ||
224 | + handleExcel(row) { | ||
225 | + extExcel({id: row.id}).then(response => { | ||
226 | + if (!response || !response.data) { | ||
227 | + console.error('Response data is empty or not a Blob.'); | ||
228 | + return; | ||
229 | + } | ||
230 | + | ||
231 | + const blob = new Blob([response.data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}); | ||
232 | + const tempFile = URL.createObjectURL(blob); | ||
233 | + | ||
234 | + fetch(tempFile) | ||
235 | + .then(res => res.blob()) | ||
236 | + .then(blob => { | ||
237 | + const url = window.URL.createObjectURL(blob); | ||
238 | + const link = document.createElement('a'); | ||
239 | + link.href = url; | ||
240 | + link.setAttribute('download', row.waybill+'.xlsx'); | ||
241 | + document.body.appendChild(link); | ||
242 | + link.click(); | ||
243 | + document.body.removeChild(link); | ||
244 | + window.URL.revokeObjectURL(url); | ||
245 | + }) | ||
246 | + .catch(error => { | ||
247 | + console.error('Error creating temporary file:', error); | ||
248 | + }); | ||
249 | + | ||
250 | + window.URL.revokeObjectURL(tempFile); | ||
251 | + }).catch(error => { | ||
252 | + console.error('Error downloading Excel:', error); | ||
253 | + }); | ||
254 | + }, | ||
255 | + handleSizeChange(val) { | ||
256 | + this.query.pageSize=val; | ||
257 | + this.getList(); | ||
258 | + }, | ||
259 | + handleCurrentChange(val) { | ||
260 | + this.query.pageNum=val; | ||
261 | + this.getList(); | ||
262 | + } | ||
263 | + } | ||
264 | + } | ||
265 | +</script> |
-
请 注册 或 登录 后发表评论