handle_online_page.dart
23.3 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/manager.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/provider/notebook_detail_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/need_item.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/row_multi_text.dart';
import 'package:one_key/widgets/table_item.dart';
import 'package:one_key/models/table.dart' as t;
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:one_key/utils/event_bus.dart';
import '../../app.dart';
class HandleOnlinePage extends StatefulWidget {
final String rid;
final String mid;
final bool fromNotify;
HandleOnlinePage(this.rid, this.mid, {this.fromNotify = false});
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new HandleOnlinePageState();
}
}
class HandleOnlinePageState extends State<HandleOnlinePage> {
NotebookDetailModel detailModel;
NotebookDetail detailEntity;
String cusmanText = "";
List<Manager> managers = []; //客户经理
Manager manager = Manager();
bool isCallTel = false;
String formatPhone = ""; //格式客户号码
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getOrderListData();
});
}
/// 获取当前预订订单详情
_getOrderListData() async {
detailEntity = await detailModel.getReserveDetail(context, {
"rid": widget.rid,
});
setState(() {
//未处理
cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
formatPhone = detailEntity.phone;
if (App.sp.getString("is_call_tel") != null &&
App.sp.getString("is_call_tel") == "1") {
isCallTel = true;
} else {
isCallTel = false;
if (detailEntity.phone.isNotEmpty &&
detailEntity.phone.length == 11 &&
(detailEntity.status == "0" || detailEntity.status == "6")) {
formatPhone = detailEntity.phone.substring(0, 3) +
"****" +
detailEntity.phone.substring(7);
}
}
});
if (detailEntity.status != "0") {
//已处理
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goNotebookDetailPage(context, detailEntity.id,
fromNotify: widget.fromNotify, replace: true);
});
setMessageStatus();
} else {
managers = await detailModel.getManagers(context);
}
}
//设置当前客户经理
_setCurrManager() {
manager = managers.firstWhere((manager) => manager.userName == cusmanText,
orElse: () => Manager());
if (manager.id == null || manager.id.toString().isEmpty) return;
Map<String, String> params = {
"rid": detailEntity.id,
"cusman_id": manager.id.toString(),
"cusman": manager.userName
};
detailModel.setReserveCusmnan(context, params);
}
//拒绝订单弹框
_showRefuseDialog() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("确定拒绝订单吗?\n拒绝后无法联系客户"),
titleTextStyle: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(32)),
content: Text("如果包间类型订满,请及时停用"),
contentTextStyle: TextStyle(
color: MyColours.color_828282,
fontSize: ScreenUtil().setSp(28)),
actions: <Widget>[
FlatButton(
child: Text(
"拒绝订单",
style: TextStyle(fontSize: ScreenUtil().setSp(32)),
),
onPressed: () {
Navigator.of(context).pop();
setReserveStatus("6");
},
),
FlatButton(
child: Text(
"去安排",
style: TextStyle(fontSize: ScreenUtil().setSp(32)),
),
onPressed: () async {
Navigator.of(context).pop();
Map temp = await NavigatorUtil.goSelectTablePage(
context,
widget.rid,
int.parse(detailEntity.ddate) * 1000,
detailEntity.ddate_solt);
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
},
)
],
);
});
}
//处理在线预订
setReserveStatus(String status, {String tid = ""}) async {
bus.emit("remove_untreated_message", widget.mid);
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> causeMap = {
"uid": userModel.user.openid,
"uname": userModel.user.account,
"desc": "",
};
Map<String, String> params = {
"rid": widget.rid,
"status": status, //5安排包间 6 拒绝订单
"tid": tid,
"mid": widget.mid,
"cause": json.encode(causeMap)
};
bool success =
await detailModel.setReserveStatus(context, params, showLoading: true);
if (success != null && success) {
bus.emit("refresh_book_list");
}
}
//处理在线预订
setMessageStatus() {
bus.emit("remove_untreated_message", widget.mid);
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"id": widget.mid,
"status": "is_handle"
};
detailModel.setMessageStatus(context, params);
}
@override
Widget build(BuildContext context) {
detailModel = Provider.of<NotebookDetailModel>(context, listen: true);
return Scaffold(
body: SafeArea(
child: WillPopScope(
child: Column(
children: <Widget>[
MyAppBar(
"在线预订详情",
showBack: true,
callback: () {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
} else {
Navigator.of(context).pop();
}
},
),
Expanded(child: Consumer<NotebookDetailModel>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
_getOrderListData();
},
emptyMsg: "暂时没有预订列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Expanded(
child: DefaultTextStyle(
style: TextStyle(decoration: TextDecoration.none),
child: Container(
color: MyColours.color_ffffff,
child: Column(
children: <Widget>[
Expanded(
child: SingleChildScrollView(
child: Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(43)),
child: Column(
children: <Widget>[
RowMultiText(
"用餐时段", detailEntity.ddateMd),
Stack(
alignment: Alignment.center,
children: <Widget>[
Column(
children: <Widget>[
RowMultiText("用餐时间",
detailEntity.ddateHm),
Offstage(
offstage:
detailEntity.type == "0"
? false
: true,
child: RowMultiText("用餐人数",
detailEntity.pnum),
)
],
),
Image.asset(
detailEntity.statuImgAssets,
width:
ScreenUtil().setWidth(100),
height:
ScreenUtil().setWidth(30),
)
],
),
RowMultiText(
"包间需求",
(detailEntity.demands.length
.toString() +
"个") ??
""),
Align(
alignment: Alignment.centerRight,
child: Offstage(
offstage: detailEntity
.demands.length >
0
? false
: true,
child: Container(
height: ScreenUtil()
.setHeight(210),
child: ListView.builder(
itemBuilder:
(BuildContext contxt,
int index) {
return NeedItem(
detailEntity
.demands[index]);
},
itemCount: detailEntity
.demands.length,
shrinkWrap: true,
scrollDirection:
Axis.horizontal,
),
),
)),
RowMultiText(
"客户姓名", detailEntity.rnameStr),
RowMultiText("客户电话", formatPhone),
RowMultiText("备注信息",
detailEntity.cusdem ?? ""),
MyDivider(double.infinity,
ScreenUtil().setHeight(1)),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
height: ScreenUtil().setHeight(80),
alignment: Alignment.center,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: Text(
"客户经理",
style: TextStyle(
color: MyColours
.color_828282,
fontSize: ScreenUtil()
.setSp(30)),
),
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () async {
List<String> list = [];
for (Manager manager
in managers) {
list.add(manager
.roleUserName);
}
DialogUtil
.showSelectCusmanDialog(
context, list,
(value) {
if (value != null) {
setState(() {
cusmanText =
managers[value
.first]
.userName;
});
_setCurrManager();
}
}).then((value) {});
},
child: Text(
cusmanText,
style: TextStyle(
color: MyColours
.color_353535,
fontSize: ScreenUtil()
.setSp(30),
decoration:
TextDecoration
.underline,
),
),
),
)
],
),
),
],
)),
),
),
Container(
margin: EdgeInsets.only(
top: ScreenUtil().setHeight(30),
bottom: ScreenUtil().setHeight(30)),
child: Column(
children: <Widget>[
CommonButton(
content: "安排包间",
width: 669,
height: 84,
fontSize: 34,
onPress: () async {
Map map = await NavigatorUtil
.goSelectTablePage(
context,
widget.rid,
int.parse(detailEntity.ddate) *
1000,
detailEntity.ddate_solt);
if (map != null && map['tid'] != null) {
setReserveStatus("5",
tid: map['tid']);
}
},
),
VEmptyView(20),
Container(
width: ScreenUtil().setWidth(669),
height: ScreenUtil().setWidth(84),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10)),
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: GestureDetector(
child: Center(
child: Text(
"拒绝订单",
style: TextStyle(
color:
MyColours.color_199095,
fontSize:
ScreenUtil().setSp(34)),
),
),
onTap: () {
_showRefuseDialog();
},
)),
Offstage(
offstage: !isCallTel,
child: SizedBox(
width: ScreenUtil().setWidth(335),
height: ScreenUtil().setWidth(84),
child: Row(
children: [
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setHeight(52),
color:
MyColours.color_199095,
),
Expanded(
child: GestureDetector(
child: Center(
child: Text(
"联系顾客",
style: TextStyle(
color: MyColours
.color_199095,
fontSize:
ScreenUtil()
.setSp(34)),
),
),
onTap: () {
if (detailEntity.phone !=
null &&
detailEntity.phone
.isNotEmpty) {
Utils.goPhone(
detailEntity.phone);
} else {
Utils.showToast(
"没有客户电话!");
}
},
)),
],
),
),
)
],
),
)
],
),
)
],
))),
);
}
},
))
],
),
onWillPop: () async {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
return true;
}
Navigator.of(context).pop();
return true;
},
)));
}
}