index.vue
3.96 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
<template>
<div class="system-container">
<div class="container">
<h1>有效试驾(日报)</h1>
<div class="m-b-md">用于展示日运营数据并支持下载Excel文件</div>
<search-form
class="searchTop border-shadow"
:formModel="searchForm"
:formList="reportFormList"
>
<span
class="inline-b"
slot="form-slot"
>
<el-button
type="primary"
:size="btn_size"
icon="el-icon-search"
:id="reportTableParams.btnId"
>搜索</el-button>
<el-button
type="primary"
:size="btn_size"
icon="el-icon-refresh"
@click="refresh"
>重置</el-button>
</span>
</search-form>
<h3>
有效试驾信息
<el-button
class="pull-right"
type="primary"
:size="btn_size"
@click="btnClick('export')"
>导出Excel</el-button>
</h3>
<basic-table
ref="reportTable"
:tableParams="reportTableParams"
:beforeSearchFn="beforeSearchFn"
:searchForm="searchDataForm"
:getListApi="getListApi"
:hasNum="false"
>
</basic-table>
</div>
</div>
</template>
<script>
import { REPORT_API } from '@/config/config'
import store from '@/store'
import { getList, getYears } from 'services/report'
export default {
data() {
const _this = this
return {
searchDataForm: {},
searchForm: {},
reportFormList: [
{
type: 'input',
inputType: 'text',
prop: 'keywords',
placeholder: '特约店编码|店名称',
},
{
type: 'singleDate',
dateType: 'month',
prop: 'date',
placeholder: '请选择年月',
pickerOptions: {
disabledDate(time) {
return time.getTime() < new Date(_this.date).getTime()
}
}
}
],
reportTableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '特约店编码',
prop: 'shopCode'
}, {
label: '特约店名称',
prop: 'shopName'
}, {
label: '车型',
prop: 'vehicleTypeName'
}, {
label: '车架号VIN码',
prop: 'vin',
width: 120
}, {
label: '时间',
prop: 'statDate'
}
]
},
getListApi: getList,
date: ''
}
},
mounted() {
getYears({}).then(res => {
console.log(res.data[0])
this.date = `${res.data[0]}-01-01`
})
for (let i = 1; i <= 31; i++) {
this.reportTableParams.tableColumns.push({
label: `${i}日`,
prop: `dayNum${i}`
})
if (i == 31) {
this.reportTableParams.tableColumns.push({
label: '总计',
prop: 'summation'
})
}
}
},
methods: {
refresh() {
this.searchForm = {}
this.searchDataForm = {}
this.$refs.reportTable.refreshTable()
},
beforeSearchFn() {
return new Promise((resolve, reject) => {
console.log(this.searchForm.date)
if (this.searchForm.date) {
this.searchDataForm.year = this.searchForm.date.split('-')[0]
this.searchDataForm.month = this.searchForm.date.split('-')[1]
} else {
this.searchDataForm.year = ''
this.searchDataForm.month = ''
}
this.searchDataForm.keywords = this.searchForm.keywords
resolve()
})
},
btnClick(type, scope) {
this.$Common.exportExcel({
url: `${store.state.baseURL}${REPORT_API.REPORT_EXPORT}`,
method: 'GET',
data: this.searchDataForm,
fileName: '导出报表Excel'
})
}
},
}
</script>
<style>
</style>