couponsDetail.vue
7.12 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
<!-- 领用详情 -->
<template>
<div class="couponsDetail">
<d2-table ref="couponsDetailTable"
:has-num="false"
:base-data="baseData"
:sort-obj="sortObj"
:search-form="searchFormSearch"
:head-search-form="searchForm"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
@handleTableHeadChange="handleTableHeadChange">
<span slot="couponName"
slot-scope="scope">{{ scope.scope.couponName }}{{ scope.scope.customerCouponCode }}</span>
</d2-table>
</div>
</template>
<script>
import { getDetailList, getDistinctColum } from '@api/coupons'
import { Util, deepClone } from '@/common/util'
import { BaseData, inviteStatusList } from '@/common/constants.js'
import { mapActions } from 'vuex'
export default {
name: 'CouponsDetail',
data() {
return {
searchForm: {
usedFlagList: [],
employeeNameList: [],
sellerNameList: [],
couponTypeList: [],
inviteStatus: '',
carSeriesName: ''
},
searchFormSearch: {},
getListApi: getDetailList,
sortObj: {
createdDate: {
descending: 0,
ascending: 1
},
usedTime: {
ascending: 2,
descending: 3
}
},
tableParams: {
listName: 'list',
tableColumns: [{
label: '领用时间',
prop: 'createdDate',
sortable: 'custom',
width: '160px',
formatter: cellValue => {
return Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss')
}
}, {
label: '车主姓名',
prop: 'customerName'
}, {
label: '客户车型',
prop: 'carSeriesName',
width: '200px',
formatter: cellValue => {
let cartypeShow = ''
if (cellValue.customerInfo && cellValue.customerInfo.carBrand) {
cartypeShow = cellValue.customerInfo.carBrand + ' - ' + cellValue.customerInfo.carChildsBrandName + ' - ' + cellValue.customerInfo.carSeriesName
} else {
cartypeShow = '-'
}
return cartypeShow
}
}, {
label: '手机号',
prop: 'customerPhone',
width: '120px'
}, {
label: '预约状态',
prop: 'inviteStatus',
width: '100px',
formatter: (cellValue) => {
return this.baseData.inviteStatusList.find(item => item.confId === cellValue.inviteStatus)?.confValue
}
}, {
label: '礼券名称',
prop: 'couponName',
addHtml: 'couponName'
}, {
label: '类型',
parentProp: 'couponInfo',
prop: 'couponTypeName'
// optionConfig: {
// searchItemName: 'couponTypeList',
// optionId: 'goodsType',
// optionLabel: 'goodsTypeName'
// }
// optionList: []
}, {
label: '门店名称',
prop: 'merchantName',
formatter: cellValue => {
return cellValue.merchantCoupon.merchantName + ' - ' + cellValue.merchantCoupon.yqMerchantName
}
}, {
label: '发券人',
prop: 'employeeName'
// optionConfig: {
// searchItemName: 'employeeNameList',
// optionId: 'confId',
// optionLabel: 'confValue'
// }
// optionList: []
}, {
label: '核销状态',
prop: 'usedFlag',
width: '100px',
formatter: (cellValue) => {
return {
N: '待核销',
Y: '已核销'
}[cellValue.usedFlag]
}
// optionConfig: {
// searchItemName: 'usedFlagList',
// optionId: 'confId',
// optionLabel: 'confValue'
// }
// optionList: [{ confValue: '待核销', confId: 'N' }, { confValue: '已核销', confId: 'Y' }]
}, {
label: '核销人',
prop: 'sellerName'
// optionConfig: {
// searchItemName: 'sellerNameList',
// optionId: 'confId',
// optionLabel: 'confValue'
// }
// optionList: []
}, {
label: '核销时间',
prop: 'usedTime',
sortable: 'custom',
width: '160px',
formatter: cellValue => {
return cellValue.usedTime ? Util.dateFormate(cellValue.usedTime, 'YYYY-MM-DD HH:mm:ss') : ''
}
}]
},
// 基本数据
baseData: {
employeeNameList: [],
sellerNameList: [],
couponTypeList: [],
usedFlagList: [{ confValue: '待核销', confId: 'N' }, { confValue: '已核销', confId: 'Y' }],
inviteStatusList: inviteStatusList
}
}
},
props: {
parentSearchForm: {
type: Object,
default: () => { }
}
},
mounted() {
// this.getDistinctColumList(1, 'employeeNameList')
// this.getDistinctColumList(2, 'sellerNameList')
// this.getBaseData()
},
methods: {
...mapActions({
get: 'd2admin/base/get'
}),
async getBaseData() {
this.baseData.couponTypeList = deepClone(await this.get(BaseData.productType))
this.$nextTick()
},
// columType属性类型(1:发券人;2:转化人)
getDistinctColumList(columType, listName) {
getDistinctColum({ columType: columType, currentPage: 1, pageSize: 100 }).then(res => {
var tempArr = []
res.forEach(item => {
tempArr.push({
confId: item,
confValue: item
})
})
this.baseData[listName] = tempArr
// this.tableParams.tableColumns[this.findFormIdx(tableColumnsProp)].optionList = tempArr
})
},
// 找到在formList的位置,通过name来匹配
findFormIdx(prop) {
return this.tableParams.tableColumns.findIndex(item => item.prop === prop)
},
// 表格头部搜索-改变
handleTableHeadChange({ searchItemName, checkedList }) {
this.searchForm[searchItemName] = deepClone(checkedList)
this.keyDowmGetList()
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchFormSearch = {
...this.parentSearchForm,
startDate: this.parentSearchForm.useTime && this.parentSearchForm.useTime.length ? Util.dateFormate(this.parentSearchForm.useTime[0], 'YYYY-MM-DD HH:mm:ss') : '',
endDate: this.parentSearchForm.useTime && this.parentSearchForm.useTime.length ? Util.dateFormate(this.parentSearchForm.useTime[1], 'YYYY-MM-DD') + ' 23:59:59' : ''
// ...this.searchForm
}
delete this.searchFormSearch.useTime
resolve()
})
},
keyDowmGetList() {
this.$refs.couponsDetailTable.refreshTable(true, true)
}
}
}
</script>
<style scoped>
</style>