PreferencePage.vue
14.2 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
<template>
<!--查询栏-->
<m-pagination-query-render :fields="pagination.filterFields" :form="pagination.queryForm"
@onSearch="handlePageReload" @onReset="handleReset" :simpleFieldNum="4">
<template #cityCodeName="{ record }">
<a-cascader v-model:value="carProvinceCity" :options="areaData" @change="handleChangeCity"
placeholder="请选择省/市" />
</template>
</m-pagination-query-render>
<div class="table-download">
<div class="selectedList">已选 {{ selectIds.length }} 项</div>
<div class="selectedBut">
<a-button type="primary" @click="modalVisible = true, excelValue = '1'" :disabled="exporting">
导出
</a-button>
</div>
</div>
<a-table :columns="columns" :data-source="pagination.content" :loading="loading" :bordered="false"
@change="pageRefresh" @resizeColumn="this.$filters.tableResizeColumn" size="small" :pagination="pageState"
:row-key="record => record.id" :scroll="{ y: 'calc(100vh - 288px)' }"
:row-selection="{ selectedRowKeys: selectIds, onChange: onSelectChange, type: 'checkbox', preserveSelectedRowKeys: true, }">
<template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
<m-filter-text-render :pagination="pagination" :column="column" :confirm="confirm"></m-filter-text-render>
<m-filter-checkbox-group-render :pagination="pagination" :column="column"
:confirm="confirm"></m-filter-checkbox-group-render>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'operationAction'">
<router-link
:to="{ path: '/finance/preference/view', query: { preferenceId: record.id, action: 'VIEW' } }">
<a-button type="link" size="small">详情</a-button>
</router-link>
<router-link
:to="{ path: '/finance/preference/edit', query: { preferenceId: record.id, action: 'EDIT' } }">
<a-button type="link" size="small">编辑</a-button>
</router-link>
</template>
<template v-if="column.key === 'businessModel'">
{{ record.businessModel == '1' ? '批发' : record.businessModel == '2' ? '零售' : '--' }}
</template>
<template v-if="column.key === 'cityName'">
{{ record.provinceName }}-{{ record.cityName }}
</template>
<template v-if="column.key === 'vehicleCondition'">
<PageMultipleTag :listValue="'vehicleConditionList'" :tagValue="record.vehicleCondition" />
</template>
<template v-if="column.key === 'vehicleAge'">
<PageMultipleTag :listValue="'vehicleAgeList'" :tagValue="record.vehicleAge" />
</template>
<template v-if="column.key === 'vehicleFuelType'">
<PageMultipleTag :listValue="'vehicleFuelTypeList'" :tagValue="record.vehicleFuelType" />
</template>
<template v-if="column.key === 'vehicleType'">
<PageMultipleTag :listValue="'vehicleTypeList'" :tagValue="record.vehicleType" />
</template>
<template v-if="column.key === 'brandList'">
<PageMultipleTag :listValue="record.brandList || []" :tagValue="record.brandList" />
</template>
<template v-if="column.key === 'status'">
<div v-if="record.status == '1'" class="tag1">已完成</div>
<div v-else class="tag2">未完成</div>
</template>
</template>
</a-table>
<a-modal :visible="modalVisible" @ok="handleVisibleOk" @cancel="modalVisible = false" title="导出范围" width="420px">
<div>
<div class="visible-title">请选择导出范围 <span class="validate">*</span> </div>
<a-select v-model:value="excelValue" style="width: 100%" placeholder="请选择导出范围">
<a-select-option value="1">导出全部</a-select-option>
<a-select-option value="2">导出当前勾选的结果</a-select-option>
</a-select>
</div>
</a-modal>
</template>
<script lang="ts">
import { Component } from 'vue-facing-decorator';
import { EyeFilled } from "@ant-design/icons-vue";
import { PaginationComponent } from "autumn-vue/lib/core/page/PaginationComponent";
import { Deposit } from "lib/src/entity/finance/entity/Deposit";
import { message, TableColumnsType } from "ant-design-vue";
import { Operator, Order, Pagination } from "autumn-vue/lib/core/page/Pagination";
import { PreferenceController } from "@/api/PreferenceController";
import { ExportUtil } from "@/common/ExportUtil";
import { Security } from "@/store";
import PageMultipleTag from "@/views/finance/preference/PageMultipleTag.vue";
import { returnPreferenceList } from "@/views/finance/preference/listData";
import { convertToTree } from "@/common/chinaarea";
import { DefaultOptionType } from "ant-design-vue/es/vc-cascader/Cascader";
@Component({
components: { EyeFilled, PageMultipleTag }
})
export default class PreferencePage extends PaginationComponent<Deposit> {
areaData: DefaultOptionType[] = [];
carProvinceCity = ''
selectedRowKeys = [];
selectIds: number[] = [];
selectedItems = [];
exporting = false;
modalVisible = false;
excelValue = '1';
businessModelList = [
{ label: '全部', value: '' },
{ label: '批发', value: '1' },
{ label: '零售', value: '2' }
]
researchStatusList = [
{ label: '未完成', value: '0' },
{ label: '已完成', value: '1' },
]
brands = [];
@Security.Getter hasPrivilege;
/**
* 表格列配置
*/
columns: TableColumnsType = [
{
title: '序号', key: 'index', width: 70, align: 'center', sorter: false,
customRender: ({ index }) => {
return (this.getPagination().pageIndex - 1) * this.getPagination().pageSize + index + 1;
},
},
{ title: '车商ID', dataIndex: 'accountId', key: 'accountId', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '车商手机号', dataIndex: 'mobile', key: 'mobile', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '车商昵称', dataIndex: 'nickName', key: 'nickName', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '实名姓名', dataIndex: 'accountName', key: 'accountName', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '经营模式', dataIndex: 'businessModel', key: 'businessModel', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '注册地区', dataIndex: 'cityName', key: 'cityName', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '偏好车况', dataIndex: 'vehicleCondition', key: 'vehicleCondition', align: 'center', width: 224, resizable: true, ellipsis: true, sorter: false },
{ title: '偏好车龄', dataIndex: 'vehicleAge', key: 'vehicleAge', align: 'center', width: 224, resizable: true, ellipsis: true, sorter: false },
{ title: '燃油类型', dataIndex: 'vehicleFuelType', key: 'vehicleFuelType', align: 'center', width: 224, resizable: true, ellipsis: true, sorter: false },
{ title: '收车车型', dataIndex: 'vehicleType', key: 'vehicleType', align: 'center', width: 224, resizable: true, ellipsis: true, sorter: false },
{ title: '品牌偏好', dataIndex: 'brandList', key: 'brandList', align: 'center', width: 224, resizable: true, ellipsis: true, sorter: false },
{ title: '调研状态', dataIndex: 'status', key: 'status', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: true },
{ title: '编辑人', dataIndex: 'updatedBy', key: 'updatedBy', align: 'center', width: 160, resizable: true, ellipsis: true, sorter: false },
{ title: '操作', dataIndex: 'operationAction', key: 'operationAction', width: 120, align: 'center', fixed: 'right' },
];
getPagination(): Pagination<Deposit> {
return this.pagination;
}
/**
* 初始化配置
*/
created(): void {
this.init(this.axios, PreferenceController.PAGE_PREFERENCE);
this.buildQueryForm({
key: [null, { label: '车商信息', field: 'key', placeholder: '请输入用户ID/手机号/昵称', operator: Operator.like }],
cityCode: [null, {
name: 'cityCodeName', label: '注册地区', field: 'cityCode', type: 'slot', placeholder: '请选择省/市', operator: Operator.eq
}],
businessModel: ['', {
label: '经营模式', field: 'businessModel', type: 'select', placeholder: '请选择经营模式', optionItems: this.businessModelList, operator: Operator.eq
}],
vehicleCondition: [[], {
label: '偏好车况', field: 'vehicleCondition', type: 'select', mode: 'multiple', allowClear: true, optionItems: returnPreferenceList('vehicleConditionList'), operator: Operator.eq
}],
vehicleAge: [[], {
label: '偏好车龄', field: 'vehicleAge', type: 'select', mode: 'multiple', allowClear: true, optionItems: returnPreferenceList('vehicleAgeList'), operator: Operator.eq
}],
vehicleFuelType: [[], {
label: '燃油类型', field: 'vehicleFuelType', type: 'select', mode: 'multiple', allowClear: true, optionItems: returnPreferenceList('vehicleFuelTypeList'), operator: Operator.eq
}],
vehicleType: [[], {
label: '收车车型', field: 'vehicleType', type: 'select', mode: 'multiple', allowClear: true, optionItems: returnPreferenceList('vehicleTypeList'), operator: Operator.eq
}],
brandName: [null, { label: '品牌偏好', field: 'brandName', placeholder: '请输入品牌名称', operator: Operator.like }],
status: [null, {
label: '调研状态', field: 'status', type: 'select', allowClear: true, optionItems: this.researchStatusList, operator: Operator.eq
}],
createTime: [null, { label: '更新时间', field: 'updateTime', operator: Operator.dateBetween, type: 'date-range' }],
});
this.pagination.setDefaultSort('createTime', Order.desc);
this.pageLoad();
this.areaData = convertToTree(false);
}
//区域数据发生变化
handleChangeCity(value: string[], e: any) {
let code = ''
if (e && e.length > 0) {
const cityObj = e[e.length - 1];
code = cityObj.value || '';
}
this.pagination.queryForm.cityCode = code;
}
handlePageReload() {
this.selectIds = [];
this.selectedItems = [];
this.pageReload();
}
//重置查询条件
handleReset() {
this.carProvinceCity = '';
this.pagination.queryForm.businessModel = '';
this.selectIds = [];
this.selectedItems = [];
this.pageReset();
}
handleVisibleOk() {
this.modalVisible = false;
this.downloadExcel();
}
downloadExcel(): void {
this.exporting = true;
let paramsData = {
...this.pagination.requestParams,
}
if (this.excelValue == '2') {
if (!this.selectIds.length) {
message.error('请选择需要导出的数据');
this.exporting = false;
return false
} else {
if (!paramsData.filters) {
paramsData.filters = []
}
paramsData.filters.push({ field: "id", logic: "and", operator: "in", value: this.selectIds, })
}
}
PreferenceController.exportPreference(this.axios, paramsData, { responseType: 'blob' }).then(response => {
message.success('导出任务已创建,请在下载中心查看');
ExportUtil.downloadExcelFile(response.data, '收车偏好列表' + this.getNewTime());
}).catch(error => {
console.error('Error downloading Word file:', error);
}).finally(() => {
this.exporting = false;
});
}
getNewTime() {
//获取当前年月日时分秒
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const monthStr = month < 10 ? '0' + month : month;
const day = date.getDate();
const dayStr = day < 10 ? '0' + day : day;
const hour = date.getHours();
const minute = date.getMinutes();
const minuteStr = minute < 10 ? '0' + minute : minute;
return `${year}-${monthStr}-${dayStr}-${hour}-${minuteStr}`
}
onSelectChange(selectedRowKeys: number[], selectedRows: []): void {
this.selectIds = selectedRowKeys;
this.selectedItems = selectedRows;
}
}
</script>
<style scoped lang="less">
:deep(.ant-form-item-control) {
min-width: 120px;
}
.table-download {
width: 100%;
height: 32px;
margin-bottom: 12px;
}
.selectedList {
float: left;
height: 32px;
line-height: 32px;
color: #777c85;
font-size: 14px;
font-weight: 400;
}
.selectedBut {
float: right;
}
.tag1 {
width: 52px;
height: 24px;
border-radius: 3px;
border: 1px solid #e8f8f2;
background: #e8f8f2;
color: #00ad74;
font-size: 12px;
font-weight: 400;
text-align: center;
line-height: 24px;
margin: 0 auto;
}
.tag2 {
width: 52px;
height: 24px;
border: 1px solid #f0f2f5;
border-radius: 3px;
background: #f0f2f5;
color: #777c85;
font-size: 12px;
font-weight: 400;
text-align: center;
line-height: 24px;
margin: 0 auto;
}
.visible-title {
width: 100%;
height: 32px;
line-height: 32px;
color: #777C85FF;
}
.validate {
color: #ee3040;
font-size: 16px;
padding-left: 2px;
}
</style>