|
@@ -29,13 +29,29 @@ |
|
@@ -29,13 +29,29 @@ |
29
|
<el-button size="medium" type="success">导入数据</el-button>
|
29
|
<el-button size="medium" type="success">导入数据</el-button>
|
30
|
</el-upload>
|
30
|
</el-upload>
|
31
|
</el-col>
|
31
|
</el-col>
|
|
|
32
|
+ <el-col :span="2">
|
|
|
33
|
+ <el-upload
|
|
|
34
|
+ class="upload-demo"
|
|
|
35
|
+ action=""
|
|
|
36
|
+ :before-upload="beforeUpload"
|
|
|
37
|
+ :http-request="importPlanExcel"
|
|
|
38
|
+ :show-file-list="false">
|
|
|
39
|
+ <el-button size="medium" type="success">导入计划表</el-button>
|
|
|
40
|
+ </el-upload>
|
|
|
41
|
+ </el-col>
|
|
|
42
|
+ <el-col :span="2">
|
|
|
43
|
+ <el-button size="medium" @click="batchExtExcel" type="success" round>批量导出excel</el-button>
|
|
|
44
|
+ </el-col>
|
32
|
</el-row>
|
45
|
</el-row>
|
33
|
<el-row :gutter="24">
|
46
|
<el-row :gutter="24">
|
34
|
<el-col :span="24">
|
47
|
<el-col :span="24">
|
35
|
<el-table
|
48
|
<el-table
|
36
|
:data="tableData"
|
49
|
:data="tableData"
|
37
|
border
|
50
|
border
|
38
|
- style="width: 100%">
|
51
|
+ style="width: 100%"
|
|
|
52
|
+ @selection-change="handleSelectionChange"
|
|
|
53
|
+ >
|
|
|
54
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
39
|
<el-table-column
|
55
|
<el-table-column
|
40
|
prop="waybill"
|
56
|
prop="waybill"
|
41
|
label="运单号"
|
57
|
label="运单号"
|
|
@@ -88,6 +104,7 @@ |
|
@@ -88,6 +104,7 @@ |
88
|
<template slot-scope="scope">
|
104
|
<template slot-scope="scope">
|
89
|
<el-button @click="handlePdf(scope.row)" type="text" size="small">下载PDF</el-button>
|
105
|
<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>
|
106
|
<el-button @click="handleExcel(scope.row)" type="text" size="small">下载EXCEL</el-button>
|
|
|
107
|
+ <el-button @click="handleDocx(scope.row)" type="text" size="small">下载DOCX</el-button>
|
91
|
</template>
|
108
|
</template>
|
92
|
</el-table-column>
|
109
|
</el-table-column>
|
93
|
</el-table>
|
110
|
</el-table>
|
|
@@ -108,7 +125,7 @@ |
|
@@ -108,7 +125,7 @@ |
108
|
</div>
|
125
|
</div>
|
109
|
</template>
|
126
|
</template>
|
110
|
<script>
|
127
|
<script>
|
111
|
- import {selectLists,extPdf,extExcel,importExcel} from "../../api/zhidan/zhidan";
|
128
|
+ import {selectLists,extPdf,extExcel,batchExtExcel,extDocx,importExcel,importPlanExcel} from "../../api/zhidan/zhidan";
|
112
|
|
129
|
|
113
|
export default {
|
130
|
export default {
|
114
|
data(){
|
131
|
data(){
|
|
@@ -152,6 +169,7 @@ |
|
@@ -152,6 +169,7 @@ |
152
|
value2:'',
|
169
|
value2:'',
|
153
|
tableData: [],
|
170
|
tableData: [],
|
154
|
total:0,
|
171
|
total:0,
|
|
|
172
|
+ selectedRows: []
|
155
|
}
|
173
|
}
|
156
|
},
|
174
|
},
|
157
|
mounted() {
|
175
|
mounted() {
|
|
@@ -187,6 +205,25 @@ |
|
@@ -187,6 +205,25 @@ |
187
|
onError(error); // 调用 onError 回调通知上传失败
|
205
|
onError(error); // 调用 onError 回调通知上传失败
|
188
|
})
|
206
|
})
|
189
|
},
|
207
|
},
|
|
|
208
|
+ // 导入计划表
|
|
|
209
|
+ importPlanExcel({file, onSuccess, onError}){
|
|
|
210
|
+ // 生成 FormData 对象
|
|
|
211
|
+ const formData = new FormData();
|
|
|
212
|
+ formData.append('file', file);
|
|
|
213
|
+ importPlanExcel(formData).then((response) => {
|
|
|
214
|
+ const res = response.data
|
|
|
215
|
+ if (res.code !== '200') {
|
|
|
216
|
+ return this.$message.error(res.msg);
|
|
|
217
|
+ }
|
|
|
218
|
+ this.$message.success(res.msg);
|
|
|
219
|
+ this.getList();
|
|
|
220
|
+ onSuccess(response.data); // 调用 onSuccess 回调通知上传成功
|
|
|
221
|
+ }).catch(error => {
|
|
|
222
|
+ // 关闭加载
|
|
|
223
|
+ this.$message.error(error.toString())
|
|
|
224
|
+ onError(error); // 调用 onError 回调通知上传失败
|
|
|
225
|
+ })
|
|
|
226
|
+ },
|
190
|
getList(){
|
227
|
getList(){
|
191
|
if(this.value2 !== null && this.value2 !== ""){
|
228
|
if(this.value2 !== null && this.value2 !== ""){
|
192
|
this.query.starttime=this.value2[0];
|
229
|
this.query.starttime=this.value2[0];
|
|
@@ -252,6 +289,68 @@ |
|
@@ -252,6 +289,68 @@ |
252
|
console.error('Error downloading Excel:', error);
|
289
|
console.error('Error downloading Excel:', error);
|
253
|
});
|
290
|
});
|
254
|
},
|
291
|
},
|
|
|
292
|
+ handleDocx(row){
|
|
|
293
|
+ extDocx({id: row.id}).then(response => {
|
|
|
294
|
+ // 创建一个 Blob 对象
|
|
|
295
|
+ const blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
|
|
|
296
|
+
|
|
|
297
|
+ // 创建一个隐藏的可下载链接
|
|
|
298
|
+ const link = document.createElement('a');
|
|
|
299
|
+ link.href = URL.createObjectURL(blob);
|
|
|
300
|
+ link.download = row.waybill + '.docx'; // 设置下载文件名
|
|
|
301
|
+
|
|
|
302
|
+ // 将链接添加到 DOM 中
|
|
|
303
|
+ document.body.appendChild(link);
|
|
|
304
|
+
|
|
|
305
|
+ // 触发下载
|
|
|
306
|
+ link.click();
|
|
|
307
|
+
|
|
|
308
|
+ // 移除链接
|
|
|
309
|
+ document.body.removeChild(link);
|
|
|
310
|
+ }).catch(error => {
|
|
|
311
|
+ console.error('Error downloading DOCX:', error);
|
|
|
312
|
+ });
|
|
|
313
|
+ },
|
|
|
314
|
+ batchExtExcel(){
|
|
|
315
|
+ if(this.selectedRows.length === 0){
|
|
|
316
|
+ this.$message.error('请选择需要批量导出的数据')
|
|
|
317
|
+ return
|
|
|
318
|
+ }
|
|
|
319
|
+
|
|
|
320
|
+ const ids = this.selectedRows.map(item => item.id)
|
|
|
321
|
+ const idsString = ids.join(',');
|
|
|
322
|
+ console.log(idsString)
|
|
|
323
|
+
|
|
|
324
|
+ batchExtExcel({ids: idsString}).then(response => {
|
|
|
325
|
+ if (!response || !response.data) {
|
|
|
326
|
+ console.error('Response data is empty or not a Blob.');
|
|
|
327
|
+ return;
|
|
|
328
|
+ }
|
|
|
329
|
+
|
|
|
330
|
+ const blob = new Blob([response.data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
|
|
|
331
|
+ const tempFile = URL.createObjectURL(blob);
|
|
|
332
|
+
|
|
|
333
|
+ fetch(tempFile)
|
|
|
334
|
+ .then(res => res.blob())
|
|
|
335
|
+ .then(blob => {
|
|
|
336
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
337
|
+ const link = document.createElement('a');
|
|
|
338
|
+ link.href = url;
|
|
|
339
|
+ link.setAttribute('download', 主单excel +'.xlsx');
|
|
|
340
|
+ document.body.appendChild(link);
|
|
|
341
|
+ link.click();
|
|
|
342
|
+ document.body.removeChild(link);
|
|
|
343
|
+ window.URL.revokeObjectURL(url);
|
|
|
344
|
+ })
|
|
|
345
|
+ .catch(error => {
|
|
|
346
|
+ console.error('Error creating temporary file:', error);
|
|
|
347
|
+ });
|
|
|
348
|
+
|
|
|
349
|
+ window.URL.revokeObjectURL(tempFile);
|
|
|
350
|
+ }).catch(error => {
|
|
|
351
|
+ console.error('Error downloading Excel:', error);
|
|
|
352
|
+ });
|
|
|
353
|
+ },
|
255
|
handleSizeChange(val) {
|
354
|
handleSizeChange(val) {
|
256
|
this.query.pageSize=val;
|
355
|
this.query.pageSize=val;
|
257
|
this.getList();
|
356
|
this.getList();
|
|
@@ -259,6 +358,10 @@ |
|
@@ -259,6 +358,10 @@ |
259
|
handleCurrentChange(val) {
|
358
|
handleCurrentChange(val) {
|
260
|
this.query.pageNum=val;
|
359
|
this.query.pageNum=val;
|
261
|
this.getList();
|
360
|
this.getList();
|
|
|
361
|
+ },
|
|
|
362
|
+ //多选
|
|
|
363
|
+ handleSelectionChange(selection) {
|
|
|
364
|
+ this.selectedRows = selection;
|
262
|
}
|
365
|
}
|
263
|
}
|
366
|
}
|
264
|
}
|
367
|
}
|