index.vue
13.4 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<!-- 下载报表 - 列表 -->
<template>
<div>
<!-- class="order-detail" -->
<d2-container>
<!-- <div class="offline-account"> -->
<template #header>
<div class="header"
style="padding: 10px 20px">
<d2-search ref="showSearch"
class="show-search"
:form-data="showFormData"
:label-width="labelWidth"
:search-form="searchForm" />
<div class="up-btns">
<el-button size="small"
type="primary"
@click="handleSearch">
查询
</el-button>
<el-button size="small"
@click="handleReset">
重置
</el-button>
</div>
</div>
</template>
<!-- </d2-container>
<d2-container> -->
<div class="d2-container-content">
<d2-table-header>
<auth-button category="Button" />
</d2-table-header>
<d2-table ref="recordTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchFormSearch"
:table-params="tableParams">
<template #pushNumHtml="scope">
<div>
<template v-if="scope.scope.push_num === '-'">
{{ scope.scope.push_num }}
</template>
<template v-else>
<el-button type="text"
@click="handlePushRecord(scope.scope)">
{{ scope.scope.push_num }}
</el-button>
</template>
</div>
</template>
<template #auth-button="scope">
<div v-if="scope.scope.status != -1">
<!-- <auth-button :data="scope.scope" /> -->
<!-- 下载 -->
<span style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9063001']" />
</span>
<!-- 重新生成 -->
<span v-if="scope.scope.report_type !== '驻店人员能力定级'" style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9063002']" />
</span>
<!-- 自定义周期:门店产值及个人成交排名 / BI数据分析表 / 无日报门店产值表 -->
<span v-if="isCustomPeriodReportType(scope.scope.report_type)"
style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9063003']" />
</span>
<!-- 导入更新 -->
<span v-if="scope.scope.report_type.includes('园区店毛利报表')"
style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9063004']" />
</span>
<!-- 推送 -->
<span v-if="scope.scope.report_type.includes('园区店毛利报表')"
style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9063005']" />
</span>
</div>
<div v-else>
<span class="list-span">正在生成中</span>
</div>
</template>
</d2-table>
</div>
<!-- 选择报表周期及下载 -->
<DateChooseDialog v-if="dateVisible"
:params-obj="recordInfo"
:visible.sync="dateVisible"
@dialogClose="closeDateDialog" />
<!-- 推送记录 -->
<PushRecordDialog v-if="pushVisible"
:params-obj="recordInfo"
:visible.sync="pushVisible"
@dialogClose="closePushDialog" />
<!-- 导入更新 -->
<d2-file-import-dialog title="导入"
:is-visible="fileVisible"
@closeDialog="handleImport"
@confirmDialog="handleConfirmImport" />
<el-dialog title="提示"
width="30%"
:close-on-click-modal="false"
:show-close="false"
:visible.sync="dialogVisible">
<div v-if="updateStatus === ''"
class="dialog-content">
<div>
<img src="./images/loadingGIF.gif">
</div>
<div class="dialog-tips-big">
正在处理中
</div>
<div class="dialog-tips-small">
说明:系统正在加急导入中,请耐心等待;导入过程中,请不要退出当前操作,否则将导致本次提交无效。
</div>
</div>
<div v-else-if="updateStatus && failNum == 0"
class="dialog-content">
<div class="dialog-tips-big">
处理成功,可返回列表查看
</div>
</div>
<div v-else-if="updateStatus && failNum > 0"
class="dialog-content">
<div class="dialog-tips-big">
{{ errMsg }}
</div>
</div>
<template #footer>
<span class="dialog-footer">
<!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
<el-button v-if="updateStatus"
type="primary"
@click="gotoList">
确定
</el-button>
</span>
</template>
</el-dialog>
</d2-container>
</div>
</template>
<script>
import {
importExcel,
pushMessageAndExcle,
queryAllExcel,
rebuild,
reportExport_download,
} from "@api/downloadReportManage";
import {
downloadReportManage_businessType,
downloadReportManage_reportType,
} from "@/common/constants.js";
import { deepClone, Util } from "@/common/util";
import dateChooseDialog from "./components/dateChooseDialog";
import pushRecordDialog from "./components/pushRecordDialog";
export default {
name: "DownloadReportList",
components: {
DateChooseDialog: dateChooseDialog,
PushRecordDialog: pushRecordDialog,
},
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
labelWidth: "100px",
searchForm: {
filename: "",
business_type: "",
report_type: "",
key: "",
},
searchFormSearch: {},
showFormData: [
{
label: "文件标题",
name: "filename",
type: "input",
maxlength: "50",
isClear: true,
},
{
label: "报表类型",
name: "report_type",
type: "select",
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "downloadReportManage_reportType",
},
{
label: "业务类型",
name: "business_type",
type: "select",
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "downloadReportManage_businessType",
},
],
getListApi: queryAllExcel,
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
// tableOption: { width: '200px' },
tableOption: true,
tableColumns: [
{
label: "文件标题",
prop: "filename",
width: "400px",
},
{
label: "报表类型",
prop: "report_type",
},
{
label: "业务类型",
prop: "business_type",
},
{
label: "统计周期",
prop: "statperiod",
},
{
label: "创建时间",
prop: "created_date",
},
{
label: "推送次数",
addHtml: "pushNumHtml",
},
],
},
baseData: {
downloadReportManage_reportType: deepClone(
downloadReportManage_reportType,
),
downloadReportManage_businessType: deepClone(
downloadReportManage_businessType,
),
},
dateVisible: false,
recordInfo: {},
fileVisible: false,
dialogVisible: false,
updateStatus: "",
updatePercentage: 0,
succNum: 0,
failNum: 0,
errMsg: "",
pushVisible: false,
};
},
computed: {
// ...mapState({
// dowloadList: (state) => state.d2admin.user.dowloadList
// })
},
mounted() {
this.getBaseData();
},
methods: {
// ...mapActions({
// get: 'd2admin/base/get',
// close: 'd2admin/page/close'
// }),
// ...mapActions('d2admin/user', ['actionSetDownloadList']),
/**
* 是否展示「自定义周期」按钮(与 common/constants.js downloadReportManage_reportType 中报表名称一致)
*/
isCustomPeriodReportType(reportType) {
if (!reportType || typeof reportType !== "string") {
return false;
}
const keywords = [
"门店产值及个人成交排名",
"BI数据分析表",
"无日报门店产值表",
];
return keywords.some(k => reportType.includes(k));
},
async getBaseData() {
this.getOptionsList();
},
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = deepClone(this.searchForm);
resolve();
});
},
getOptionsList() {
this.showFormData.forEach((item, index) => {
if (item.type === "select") {
if (
this.baseData[item.optionsName].length
&& this.baseData[item.optionsName][0][
this.showFormData[index].optionLabel
] !== "全部"
) {
const temp = {};
temp[this.showFormData[index].optionId] = "";
temp[this.showFormData[index].optionLabel] = "全部";
this.baseData[item.optionsName].unshift(temp);
}
this.$set(
this.showFormData[index],
"optionList",
this.baseData[item.optionsName],
);
}
});
},
handleSearch() {
this.$refs.recordTable.refreshTable(false, true);
},
handleReset() {
this.searchForm = {
filename: "",
business_type: "",
report_type: "",
};
this.$refs.recordTable.refreshTable(false, true);
},
// 下载
handleDownload(row) {
reportExport_download({ key: row.key }).then((result) => {
console.log(result, "result");
result && this.downLoadFile(result.list[0].url);
});
},
/**
* url下载文件
*
*/
downLoadFile(url) {
const Temp = document.createElement("a");
// url = url + `${url.includes('?') ? '&' : '?'}` + "timestamp=" + new Date().getTime()
Temp.href = url;
document.body.append(Temp);
Temp.click();
document.body.removeChild(Temp);
},
// 重新生成
handleGenerate(row) {
this.$confirm(
// "系统将自动按照对应的报表及统计时间重新生成,生成过程中不可下载,请耐心等待。是否确认重新生成?",
"将基于 T-1 天(YYYY-MM-DD)重新生成报表,是否继续?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false,
},
)
.then(() => {
rebuild({ key: row.key }).then((res) => {
this.notice.okTips();
this.$refs.recordTable.refreshTable();
});
})
.catch((err) => {
console.log(err);
});
},
// 自定义周期
handleCustomize(row) {
this.recordInfo = row;
this.dateVisible = !this.dateVisible;
},
closeDateDialog() {
this.dateVisible = !this.dateVisible;
// this.$refs.recordTable.refreshTable(false, true)
},
handleImport(row) {
this.recordInfo = row;
this.fileVisible = !this.fileVisible;
},
handleConfirmImport({ fileName, fileData }) {
this.dialogVisible = true;
const formData = new FormData();
formData.append("file", fileData);
formData.append("key", this.recordInfo.key);
for (const [key, value] of formData.entries()) {
console.log(key, value);
}
importExcel(formData).then((res) => {
console.log(res, "res");
this.updateStatus = true;
if (res.errId == "-7") {
this.failNum = 1;
this.errMsg = res.message;
}
});
},
gotoList() {
this.fileVisible = !this.fileVisible;
this.dialogVisible = !this.dialogVisible;
this.$refs.recordTable.refreshTable();
},
// 推送
handlePush(row) {
this.$confirm(
"系统将自动按照推送当前报表至相关的负责人及群聊中,是否确认推送?",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false,
},
)
.then(() => {
let params = {
accountName: this.userInfo.loginAccount.userName,
key: row.key,
};
pushMessageAndExcle(params).then((res) => {
this.notice.okTips();
this.$refs.recordTable.refreshTable();
});
})
.catch((err) => {
console.log(err);
});
},
handlePushRecord(row) {
this.recordInfo = row;
this.pushVisible = !this.pushVisible;
},
closePushDialog() {
this.pushVisible = !this.pushVisible;
},
},
};
</script>
<style lang="scss" scoped>
.count-txt {
font-weight: 700;
color: #2a58ad;
margin: 0 2px;
}
.leftSpan {
display: inline-block;
box-sizing: border-box;
margin-right: 10px;
}
.list-span {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14px;
color: #999999;
}
.dialog-content {
text-align: center;
.dialog-tips-big {
font-size: 16px;
color: #333333;
margin-bottom: 20px;
}
.dialog-tips-small {
font-size: 12px;
color: #666666;
}
.iconSize {
width: 20px;
height: 20px;
}
}
</style>
<style lang="scss">
.downloadReportManage {
.el-table__header-wrapper .el-checkbox {
display: none;
}
.el-table__body-wrapper .el-checkbox {
display: none;
}
}
</style>