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
<template>
<div class="sms">
<el-form ref="searchFrom" inline :model="searchFrom" label-width="100px">
<el-form-item label="交易订单号">
<el-input v-model="searchFrom.order_id"></el-input>
</el-form-item>
<el-form-item label="购买人">
<el-input v-model="searchFrom.nickname"></el-input>
</el-form-item>
<el-form-item label="购买人ID">
<el-input v-model="searchFrom.user_id"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input v-model="searchFrom.mobile"></el-input>
</el-form-item>
<el-form-item label="绑定状态">
<el-select v-model="searchFrom.user_buy" placeholder="请选择" @change="getList" clearable>
<el-option v-for="item in useTypeList" :key="item.user_buy" :label="item.value" :value="item.user_buy">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="商品名称">
<el-select v-model="searchFrom.goods_id" placeholder="请选择" @change="getList" clearable>
<el-option v-for="(data,index) in goodList" :key="index" :label="data | filterGoods" :value="data.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="老师">
<el-select v-model="searchFrom.teacher_id" placeholder="请选择" @change="getList" clearable filterable>
<el-option v-for="(data,index) in teacherList" :key="index" :label="data.name" :value="data.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList">搜索</el-button>
<el-button type="primary" plain @click="exportTable(list)">导出</el-button>
<el-button type="success" plain @click="classListOption()">当前同步进度</el-button>
</el-form-item>
</el-form>
<el-table :data="list" style="width: 100%">
<el-table-column prop="order_id" label="订单号">
</el-table-column>
<el-table-column prop="nickname" label="购买人">
<template slot-scope="scope">
<div v-if='scope.row.user_id !== 0' style="display: flex">
<img class="avatar" :src="scope.row.avatar" />
<div>{{scope.row.nickname}}<br>(ID:{{scope.row.user_id}})</div>
</div>
<div v-if='scope.row.user_id === 0'>
暂未绑定用户
</div>
</template>
</el-table-column>
<el-table-column prop="goods_name" label="商品名称">
</el-table-column>
<el-table-column prop="receiver_name" label="姓名">
</el-table-column>
<el-table-column prop="receiver_phone" label="手机号">
</el-table-column>
<el-table-column label="收货地址">
<template slot-scope="scope">
{{scope.row.receiver_province}} {{scope.row.receiver_city}} {{scope.row.receiver_area}} {{scope.row.receiver_address}}
</template>
</el-table-column>
<el-table-column prop="teacher_name" label="班级老师">
</el-table-column>
<el-table-column prop="create_time" label="创建时间" sortable>
</el-table-column>
<el-table-column prop="pay_time" label="支付时间" sortable>
</el-table-column>
<el-table-column prop="desc" label="备注">
</el-table-column>
<el-table-column label="操作" v-if="!$store.state.readonly" width="220">
<template slot-scope="scope">
<el-button @click="editNote(scope.row.id, scope.row.desc)" size="mini" plain type="primary">编辑备注</el-button>
</template>
</el-table-column>
</el-table>
<page :nowPage="nowPage" :total="total" @pageChange="onPageChange" @sizeChange="onSizeChange" />
<el-dialog :title="classObj.title" :visible.sync="classObj.show" center width="800px">
<div style="margin:10px;color: #888888">
最新同步时间:{{last_pull_time}}
</div>
<el-table :data="classList" >
<el-table-column prop="teacher_name" label="班级老师">
</el-table-column>
<el-table-column prop="num" label="预计入班人数">
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
</span>
</el-dialog>
</div>
</template>
<script>
import page from "../framework/page";
import {
getyunjiApi,
getGoodsListApi,
exportExcelApi,
getTeacherListApi,
orderDescApi
} from "../../service/api";
import { GOODSTYPE } from "../../util/wordbook";
export default {
name: "smsRecord",
components: {
page,
},
data() {
return {
nowPage: 1,
total: 0,
limit: 10,
useTypeList: [
{
user_buy: 0,
value: "未绑定"
},
{
user_buy: 1,
value: "已绑定"
}
],
searchFrom: {
goods_id: "",
mobile: "",
order_id: "",
teacher_id: "",
user_id:"",
nickname:"",
},
list: [],
teacherList: [],
goodList: [],
classObj:{
show: false,
title: "当前同步进度",
order_id: 0,
teacher_id: 0
},
classList:[],
last_pull_time:"无",
};
},
filters: {
filterStatus: function(value) {
let msg = "";
if (value === 0) {
msg = "未绑定";
} else {
msg = "已绑定";
}
return msg;
},
filterGoods(val) {
return (
"[" +
GOODSTYPE[val.goods_type] +
"]" +
"[" +
val.current_price / 100 +
"元]" +
val.name
);
}
},
mounted() {
this.getList();
this.getGoodsOption();
this.getTeacherList();
},
methods: {
onPageChange(val) {
this.nowPage = val;
this.getList();
},
getTeacherList() {
let json = {
page: 1,
limit: 200
};
getTeacherListApi(json).then(res => {
this.teacherList = res.list;
});
},
onSizeChange(val) {
this.nowPage = 1;
this.limit = val;
this.getList();
},
getList() {
let json = {
limit: this.limit,
page: this.nowPage
};
if (this.searchFrom.mobile) {
json.mobile = this.searchFrom.mobile;
}
if (this.searchFrom.nickname) {
json.nickname = this.searchFrom.nickname;
}
if (this.searchFrom.user_id) {
json.user_id = this.searchFrom.user_id;
}
if (this.searchFrom.teacher_id) {
json.teacher_id = this.searchFrom.teacher_id;
}
if (this.searchFrom.goods_name) {
json.goods_name = this.searchFrom.goods_name;
}
if (this.searchFrom.user_buy || this.searchFrom.user_buy == 0) {
json.user_buy = this.searchFrom.user_buy;
}
if (this.searchFrom.order_id) {
json.order_id = this.searchFrom.order_id;
}
if (this.searchFrom.goods_id) {
json.goods_id = this.searchFrom.goods_id;
}
getyunjiApi(json).then(res => {
this.total = res.total;
this.list = res.list ? res.list : [];
});
},
getGoodsOption() {
let json = {
page: 1,
limit: 100
};
getGoodsListApi(json).then(res => {
this.goodList = res.list;
});
},
editNote(id, desc) {
this.$prompt("", "编辑备注", {
confirmButtonText: "确定",
cancelButtonText: "取消",
inputType: "textarea",
inputValue: desc || ""
}).then(({ value }) => {
this.$confirm("确定保存?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
orderDescApi({ desc: value }, id).then(res => {
this.$message({
type: "success",
message: "编辑备注成功"
});
this.getList();
});
});
});
},
exportTable(data) {
if (data.length > 0) {
let json = {};
if (this.searchFrom.order_id) {
json.order_id = this.searchFrom.order_id;
}
if (this.searchFrom.user_buy || this.searchFrom.user_buy == 0) {
json.user_buy = this.searchFrom.user_buy;
}
if (this.searchFrom.mobile) {
json.mobile = this.searchFrom.mobile;
}
if (this.searchFrom.nickname) {
json.nickname = this.searchFrom.nickname;
}
if (this.searchFrom.user_id) {
json.user_id = this.searchFrom.user_id;
}
if (this.searchFrom.goods_id) {
json.goods_id = this.searchFrom.goods_id;
}
if (this.searchFrom.teacher_id) {
json.teacher_id = this.searchFrom.teacher_id;
}
exportExcelApi(`api/admin/yunji/order/export`, json);
}
},
classListOption() {
this.classObj.show=true;
getyunjiApi({ page: 1,limit: 200}).then(res => {
this.classList=res.teacher;
if(res.last_pull_time){
this.last_pull_time=res.last_pull_time;
}
});
}
}
};
</script>
<style scoped>
.sms {
padding: 20px 0;
}
.avatar {
width: 50px;
min-width: 50px;
margin-right: 10px;
height: 50px;
border-radius: 50%;
}
</style>
<style>
.userInfo > div {
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
}
</style>