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
<template>
<div>
<el-table
:data="tableData"
border
style="width: 100%">
<el-table-column type="expand">
<template slot-scope="props">
<el-form label-position="left" class="demo-table-expand">
<el-row>
<el-col :span="10">
<el-form-item label="客户信息:">
<span>ID:{{props.row.user_id}} {{props.row.username}} {{props.row.mobile}}</span>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="班主任:">
<span>{{ props.row.teacher_name }}</span>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="来源:">
<span> {{props.row.invite_username}}<br>{{props.row.invite_mobile}}</span>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注:">
<span>{{ props.row.desc }}</span>
</el-form-item>
<el-form-item label="收货地址:">
<div>
{{props.row.receive_name}}
{{props.row.receive_mobile}}
{{props.row.province_name}}{{props.row.city}}{{props.row.area}}{{props.row.address}}
</div>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column
prop="out_trade_no"
label="订单号"
>
</el-table-column>
<el-table-column
prop="product_title"
label="商品名称">
</el-table-column>
<el-table-column
:min-width="'150px'"
prop="course_title"
label="课程名称"
>
<template slot-scope="scope">
<router-link :to="{name:'ClassList', params: { courseId: scope.row.courses_id }, query: { courseName: scope.row.course_title}}" >
{{scope.row.course_title}} <br>【{{scope.row.instructor}}】<br>
{{scope.row|courseTypeFilter}}
</router-link>
</template>
</el-table-column>
<el-table-column
label="价格(元)"
>
<template slot-scope="scope">
{{scope.row.money|moneytFilter}}
</template>
</el-table-column>
<el-table-column label="推荐收益(元)">
<template slot-scope="scope">
{{parseInt(scope.row.revenue_fixed, 10) / 100}}
</template>
</el-table-column>
<el-table-column
prop="created_at"
label="订单创建时间"
>
</el-table-column>
<el-table-column
prop="pay_at"
label="购买时间"
>
</el-table-column>
<el-table-column
label="付款状态">
<template slot-scope="scope">
{{scope.row.is_pay|payMentFilter}}
</template>
</el-table-column>
<el-table-column
label="操作"
min-width="80"
>
<template slot-scope="scope">
<el-popover
placement="top"
width="280">
<div style="text-align: center">
<el-button
v-if="scope.row.is_pay == 1"
@click="onRefund(scope.row.pay_id, scope.row.money)"
type="warning"
plain
size="mini">
退款
</el-button>
<el-button
@click="editComment(scope.row.pay_id, scope.row.desc)"
type="warning"
plain
size="mini">
编辑备注
</el-button>
<el-button
@click="editAddress(scope.row)"
plain
type="warning"
size="mini">
编辑收货地址
</el-button>
</div>
<el-button slot="reference" size="mini" type="text" >操作</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<address-dialog v-if="dialogObj.show" :dialogObj="dialogObj" @reflash="onUpdateAddress"></address-dialog>
<refund-dialog :dialogObj="refundDialogObj" @reflash="onAfterRefund" @changeShow="changeShow"></refund-dialog>
<page :nowPage="nowPage" :total="total"/>
</div>
</template>
<script>
import {getOrderListApi,editOrderDescApi} from "../../service/api";
import page from '../framework/page'
import addressDialog from './dialog'
import refundDialog from './refundDialog'
import AddressArray from '../framework/address-picker/addr'
export default {
name: 'index',
data(){
return {
nowPage: 1,
total: 0,
tableData: [
{
"pay_id": 269,
"out_trade_no": "sing_pay_6333_1535597840440458",
"user_id": 6333,
"user_address_id": 185,
"product_id": 1,
"invite_type": 0,
"invite_user_id": 0,
"money": 1,
"desc": "系统备注:付款成功,但未找到ID为0的课程或它的课程类型不匹配(下单类型:1)",
"revenue_fixed": 0,
"is_pay": 0,
"pay_at": "2018-08-30 10:57:25",
"teacher_id": 0,
"created_at": "2018-08-30 10:57:21",
"username": "青山",
"mobile": "18616964357",
"course_title": null,
"instructor": null,
"courses_id": null,
"type": 1,
"duration": 12,
"product_title": "1499元一年课 ",
"teacher_name": null,
"receive_name": "江姐",
"receive_mobile": "13424673456",
"province_name": "广东",
"province_id": null,
"city": "深圳",
"city_id": null,
"area": "福田区",
"area_id": null,
"address": " 我"
},
{
"pay_id": 267,
"out_trade_no": "sing_pay_6281_1533889878982223",
"user_id": 6295,
"user_address_id": 168,
"product_id": 4,
"invite_type": 0,
"invite_user_id": 6300,
"money": 1,
"desc": "",
"revenue_fixed": 6000,
"is_pay": 1,
"pay_at": null,
"teacher_id": 0,
"created_at": "2018-08-10 16:31:18",
"username": null,
"mobile": null,
"course_title": "30天高效英语启蒙主题训练营",
"instructor": "8月20日开课",
"courses_id": 65,
"type": 1,
"duration": 1,
"product_title": "30天高效英语启蒙主题训练营(买课赠实物教具礼盒)",
"teacher_name": null,
"receive_name": "www",
"receive_mobile": "16766467976",
"province_name": "广东",
"province_id": null,
"city": "深圳",
"city_id": null,
"area": "福田区",
"area_id": null,
"address": "6164466"
}
],
dialogObj: {
show: false
},
refundDialogObj: {
show: false,
id: '',
money: 0
}
}
},
methods: {
editComment(id, desc) {
this.$prompt('编辑备注', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValue: desc
}).then(({ value }) => {
editOrderDescApi(id,'refund',{desc: value}).then(res=>{
if( res.data.result === 'success' ){
this.$message({
type: 'success',
message: '编辑备注成功'
});
}else{
this.$message.error( res.data.message );
}
});
}).catch(() => {
this.$message({
type: 'info',
message: '取消编辑备注'
});
});
},
getOrderList(){
getOrderListApi().then((res)=>{
})
},
changeShow(data){
this.refundDialogObj.show=data
},
onRefund(id, money){
console.log('onRefund', id, money)
this.refundDialogObj.id= id;
this.refundDialogObj.money= money;
this.refundDialogObj.show = true;
},
onAfterRefund(){
},
onUpdateAddress(){
this.dialogObj.show = false;
this.getOrderList();
},
editAddress(row){
if(!row.province_name){
this.dialogObj.province = ''
this.dialogObj.city = ''
this.dialogObj.district = ''
} else {
let provinceObj = AddressArray.filter((item) => {
return item.label === row.province_name
})
if(provinceObj && provinceObj.length > 0){
this.dialogObj.province = row.province_id ? row.province_id : provinceObj[0].value
if(!row.city){
this.dialogObj.city = ''
} else {
let cityObj = provinceObj[0].children.filter((city) => {
return city.label === row.city
})
this.dialogObj.city = row.city_id ? row.city_id : cityObj[0].value
if(!row.area){
this.dialogObj.district = ''
}else {
let districtObj = cityObj[0].children.filter((district) => {
return district.label === row.area
})
this.dialogObj.district = row.area_id ? row.area_id : districtObj[0].value
}
}
} else {
this.dialogObj.province = ''
this.dialogObj.district = ''
this.dialogObj.city = ''
}
}
this.dialogObj.detail = row.address
this.dialogObj.user_id = row.user_id
this.dialogObj.pay_id = row.pay_id
this.dialogObj.receive_mobile = row.receive_mobile
this.dialogObj.receive_name = row.receive_name
this.dialogObj.province_name = row.province_name
this.dialogObj.city_name = row.city
this.dialogObj.district_name = row.area
this.dialogObj.show=true;
}
},
components: {
addressDialog,
refundDialog,
page
},
mounted(){
this.getOrderList();
},
filters:{
payMentFilter(val){
return val=='1'?'已付款':'未付款'
},
courseTypeFilter(val){
return val.type=='1'?`正式课(${val.duration}个月)`:`试听课(${val.duration}天)`
},
moneytFilter(val){
return val = val / 100
}
}
}
</script>
<style scoped>
</style>