|
@@ -1,11 +1,10 @@
|
1
|
1
|
import 'package:flutter/material.dart';
|
2
|
|
-import 'package:flutter_easyrefresh/easy_refresh.dart';
|
3
|
2
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
4
|
3
|
import 'package:get/get.dart';
|
5
|
4
|
import 'package:worker_client/models/entities/Order.dart';
|
6
|
5
|
import 'package:worker_client/services/order.dart';
|
7
|
6
|
import 'package:worker_client/widgets/MyCard/index.dart';
|
8
|
|
-import 'package:worker_client/widgets/NullCard.dart';
|
|
7
|
+import 'package:worker_client/widgets/RefreshMoreList.dart';
|
9
|
8
|
import 'package:worker_client/widgets/layout/BasicPage.dart';
|
10
|
9
|
|
11
|
10
|
class Order extends BasicPage {
|
|
@@ -23,64 +22,11 @@ class Order extends BasicPage {
|
23
|
22
|
];
|
24
|
23
|
final currentIndex = Rx<int>(0);
|
25
|
24
|
|
26
|
|
- //测试上拉加载更多
|
27
|
|
- EasyRefreshController _controller = EasyRefreshController();
|
28
|
|
- var pageIndex = 1;
|
29
|
|
- var count = 10;
|
30
|
|
- int maxSum = 0;
|
31
|
|
- final params = Rx<Map<String, dynamic>>({'pageNum': 1, 'workStatus': 1});
|
32
|
|
- final newOrderList = Rx<List<OrderModel>>([]);
|
33
|
|
- void getNewData() {
|
34
|
|
- Map<String, dynamic> map = {...params.value};
|
35
|
|
- pageIndex = 1;
|
36
|
|
- map['pageNum'] = pageIndex;
|
37
|
|
- map['workStatus'] = currentIndex.value;
|
38
|
|
- if (map['workStatus'] == 2) {
|
39
|
|
- map['workStatus'] = 3;
|
40
|
|
- }
|
41
|
|
- map['q'] = q.value;
|
42
|
|
- params(map);
|
43
|
|
- getOrderList(params.value).then((value) {
|
44
|
|
- maxSum = value['total'];
|
45
|
|
-
|
46
|
|
- List<OrderModel> list = [];
|
47
|
|
- value['records'].forEach((item) {
|
48
|
|
- list.add(OrderModel.fromJson(item));
|
49
|
|
- });
|
50
|
|
- orderList(list);
|
51
|
|
- newOrderList(list);
|
52
|
|
- });
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- void getMoreData() {
|
56
|
|
- Map<String, dynamic> map = {...params.value};
|
57
|
|
- pageIndex++;
|
58
|
|
- map['pageNum'] = pageIndex;
|
59
|
|
- map['workStatus'] = currentIndex.value;
|
60
|
|
- if (map['workStatus'] == 2) {
|
61
|
|
- map['workStatus'] = 3;
|
62
|
|
- }
|
63
|
|
- map['q'] = q.value;
|
64
|
|
- params(map);
|
65
|
|
- getOrderList(params.value).then((value) {
|
66
|
|
- maxSum = value['total'];
|
67
|
|
- List<OrderModel> list = [];
|
68
|
|
- List<OrderModel> Newlist = [];
|
69
|
|
- value['records'].forEach((item) {
|
70
|
|
- list.add(OrderModel.fromJson(item));
|
71
|
|
- });
|
72
|
|
- newOrderList.value.addAll(list);
|
73
|
|
- Newlist.addAll(newOrderList.value);
|
74
|
|
- orderList(Newlist);
|
75
|
|
- });
|
76
|
|
- }
|
77
|
|
-
|
78
|
|
- int _count = 0;
|
|
25
|
+ final params = Rx<Map<String, dynamic>>({'workStatus': 0});
|
79
|
26
|
|
80
|
27
|
@override
|
81
|
28
|
void beforeShow() {
|
82
|
29
|
super.beforeShow();
|
83
|
|
- getNewData();
|
84
|
30
|
}
|
85
|
31
|
|
86
|
32
|
List<OrderModel> GetList(value) {
|
|
@@ -93,6 +39,7 @@ class Order extends BasicPage {
|
93
|
39
|
Get.toNamed('/orderDetail', arguments: {'id': item.orderId});
|
94
|
40
|
}
|
95
|
41
|
|
|
42
|
+ late Function Refresh;
|
96
|
43
|
@override
|
97
|
44
|
Widget builder(BuildContext context) {
|
98
|
45
|
return Container(
|
|
@@ -130,7 +77,9 @@ class Order extends BasicPage {
|
130
|
77
|
),
|
131
|
78
|
onChanged: (e) {
|
132
|
79
|
q(e);
|
133
|
|
- getNewData();
|
|
80
|
+ Map<String, dynamic> myParams = {...params.value, 'q': q};
|
|
81
|
+ params(myParams);
|
|
82
|
+ Refresh();
|
134
|
83
|
},
|
135
|
84
|
),
|
136
|
85
|
),
|
|
@@ -138,110 +87,90 @@ class Order extends BasicPage {
|
138
|
87
|
),
|
139
|
88
|
),
|
140
|
89
|
Container(
|
141
|
|
- width: 345.w,
|
142
|
|
- decoration: BoxDecoration(
|
143
|
|
- color: Colors.white,
|
144
|
|
- boxShadow: [
|
145
|
|
- BoxShadow(
|
146
|
|
- color: const Color(0x14000000),
|
147
|
|
- offset: Offset(0, 1.w),
|
148
|
|
- blurRadius: 0)
|
149
|
|
- ],
|
150
|
|
- border: Border(
|
151
|
|
- top: BorderSide.none,
|
152
|
|
- bottom:
|
153
|
|
- BorderSide(width: 1.w, color: const Color(0x14000000)),
|
154
|
|
- left: BorderSide.none,
|
155
|
|
- right: BorderSide.none, // 右边不设置边框
|
156
|
|
- ),
|
|
90
|
+ width: 345.w,
|
|
91
|
+ decoration: BoxDecoration(
|
|
92
|
+ color: Colors.white,
|
|
93
|
+ boxShadow: [
|
|
94
|
+ BoxShadow(
|
|
95
|
+ color: const Color(0x14000000),
|
|
96
|
+ offset: Offset(0, 1.w),
|
|
97
|
+ blurRadius: 0)
|
|
98
|
+ ],
|
|
99
|
+ border: Border(
|
|
100
|
+ top: BorderSide.none,
|
|
101
|
+ bottom: BorderSide(width: 1.w, color: const Color(0x14000000)),
|
|
102
|
+ left: BorderSide.none,
|
|
103
|
+ right: BorderSide.none, // 右边不设置边框
|
157
|
104
|
),
|
158
|
|
- child: Obx(() => Row(
|
159
|
|
- children: tabValues.map((e) {
|
160
|
|
- int index = tabValues.indexOf(e);
|
161
|
|
- return Expanded(
|
162
|
|
- flex: 1,
|
163
|
|
- child: GestureDetector(
|
164
|
|
- onTap: () {
|
165
|
|
- currentIndex(index);
|
166
|
|
- getNewData();
|
167
|
|
- },
|
168
|
|
- child: SizedBox(
|
169
|
|
- height: 44.h,
|
170
|
|
- child: Stack(
|
171
|
|
- alignment: Alignment.center,
|
172
|
|
- children: [
|
173
|
|
- Text(
|
174
|
|
- e,
|
175
|
|
- textAlign: TextAlign.center,
|
176
|
|
- style: TextStyle(
|
|
105
|
+ ),
|
|
106
|
+ child: Obx(
|
|
107
|
+ () => Row(
|
|
108
|
+ children: tabValues.map(
|
|
109
|
+ (e) {
|
|
110
|
+ int index = tabValues.indexOf(e);
|
|
111
|
+ return Expanded(
|
|
112
|
+ flex: 1,
|
|
113
|
+ child: GestureDetector(
|
|
114
|
+ onTap: () {
|
|
115
|
+ currentIndex(index);
|
|
116
|
+ Map<String, dynamic> map = {
|
|
117
|
+ ...params.value,
|
|
118
|
+ 'workStatus': currentIndex.value
|
|
119
|
+ };
|
|
120
|
+ if (map['workStatus'] == 2) {
|
|
121
|
+ map['workStatus'] = 3;
|
|
122
|
+ }
|
|
123
|
+ params(map);
|
|
124
|
+ Refresh();
|
|
125
|
+ },
|
|
126
|
+ child: SizedBox(
|
|
127
|
+ height: 44.h,
|
|
128
|
+ child: Stack(
|
|
129
|
+ alignment: Alignment.center,
|
|
130
|
+ children: [
|
|
131
|
+ Text(
|
|
132
|
+ e,
|
|
133
|
+ textAlign: TextAlign.center,
|
|
134
|
+ style: TextStyle(
|
|
135
|
+ color: currentIndex.value == index
|
|
136
|
+ ? const Color(0xFF06b03b)
|
|
137
|
+ : const Color(0xFF999999),
|
|
138
|
+ fontSize: 16.sp,
|
|
139
|
+ fontWeight: currentIndex.value == index
|
|
140
|
+ ? FontWeight.w800
|
|
141
|
+ : FontWeight.w500),
|
|
142
|
+ ),
|
|
143
|
+ Positioned(
|
|
144
|
+ bottom: 0,
|
|
145
|
+ child: Container(
|
|
146
|
+ width: 48.h,
|
|
147
|
+ height: 3.w,
|
|
148
|
+ decoration: BoxDecoration(
|
177
|
149
|
color: currentIndex.value == index
|
178
|
150
|
? const Color(0xFF06b03b)
|
179
|
|
- : const Color(0xFF999999),
|
180
|
|
- fontSize: 16.sp,
|
181
|
|
- fontWeight: currentIndex.value == index
|
182
|
|
- ? FontWeight.w800
|
183
|
|
- : FontWeight.w500),
|
|
151
|
+ : Colors.white),
|
184
|
152
|
),
|
185
|
|
- Positioned(
|
186
|
|
- bottom: 0,
|
187
|
|
- child: Container(
|
188
|
|
- width: 48.h,
|
189
|
|
- height: 3.w,
|
190
|
|
- decoration: BoxDecoration(
|
191
|
|
- color: currentIndex.value == index
|
192
|
|
- ? const Color(0xFF06b03b)
|
193
|
|
- : Colors.white),
|
194
|
|
- ))
|
195
|
|
- ],
|
196
|
|
- ),
|
|
153
|
+ ),
|
|
154
|
+ ],
|
197
|
155
|
),
|
198
|
156
|
),
|
199
|
|
- );
|
200
|
|
- }).toList(),
|
201
|
|
- ))),
|
|
157
|
+ ),
|
|
158
|
+ );
|
|
159
|
+ },
|
|
160
|
+ ).toList(),
|
|
161
|
+ ),
|
|
162
|
+ ),
|
|
163
|
+ ),
|
202
|
164
|
Expanded(
|
203
|
165
|
flex: 1,
|
204
|
|
- child: Obx(() => orderList.value.isNotEmpty
|
205
|
|
- ? EasyRefresh(
|
206
|
|
- controller: _controller,
|
207
|
|
- header: ClassicalHeader(
|
208
|
|
- infoText: '',
|
209
|
|
- refreshedText: '刷新完成',
|
210
|
|
- refreshText: '刷新中....',
|
211
|
|
- refreshingText: '刷新中....',
|
212
|
|
- refreshReadyText: '刷新完毕',
|
213
|
|
- noMoreText: '',
|
214
|
|
- textColor: const Color(0xff666666),
|
215
|
|
- ),
|
216
|
|
- footer: ClassicalFooter(
|
217
|
|
- infoText: '',
|
218
|
|
- loadText: '上拉加载更多',
|
219
|
|
- loadingText: '加载中....',
|
220
|
|
- loadReadyText: '释放加载',
|
221
|
|
- noMoreText: '暂无更多',
|
222
|
|
- enableInfiniteLoad: false,
|
223
|
|
- textColor: const Color(0xff666666),
|
224
|
|
- ),
|
225
|
|
- // firstRefresh: true,//是否首次刷新
|
226
|
|
- onRefresh: () async {
|
227
|
|
- await Future.delayed(const Duration(seconds: 1), () {
|
228
|
|
- // print("下拉刷新-----");
|
229
|
|
- getNewData();
|
230
|
|
- _count = orderList.value.length;
|
231
|
|
- // print("最新条数" + _count.toString());
|
232
|
|
- _controller.resetLoadState();
|
233
|
|
- });
|
234
|
|
- },
|
235
|
|
- onLoad: () async {
|
236
|
|
- await Future.delayed(const Duration(seconds: 1), () {
|
237
|
|
- // print("上拉加载-----");
|
238
|
|
- getMoreData();
|
239
|
|
- _count = orderList.value.length;
|
240
|
|
- // print("加载更多条数" + _count.toString());
|
241
|
|
- _controller.finishLoad(noMore: _count >= maxSum);
|
242
|
|
- });
|
243
|
|
- },
|
244
|
|
- child: Column(
|
|
166
|
+ child: RefreshMoreList(
|
|
167
|
+ pPrams: params,
|
|
168
|
+ cardText: '暂无农机',
|
|
169
|
+ fetch: getOrderList,
|
|
170
|
+ builder: (
|
|
171
|
+ {required BuildContext context, required Function toggle}) {
|
|
172
|
+ Refresh = toggle;
|
|
173
|
+ return Obx(() => Column(
|
245
|
174
|
children: orderList.value
|
246
|
175
|
.map(
|
247
|
176
|
(item) => MyCard(
|
|
@@ -250,15 +179,17 @@ class Order extends BasicPage {
|
250
|
179
|
detail: false,
|
251
|
180
|
onClick: () {},
|
252
|
181
|
goDetail: () {
|
253
|
|
- // goDetail(item);
|
|
182
|
+ goDetail(item);
|
254
|
183
|
},
|
255
|
184
|
buttomText: item.status == 0 ? '开始作业' : '完成作业',
|
256
|
185
|
),
|
257
|
186
|
)
|
258
|
187
|
.toList(),
|
259
|
|
- ),
|
260
|
|
- )
|
261
|
|
- : const NullCard(text:'暂无订单'),
|
|
188
|
+ ));
|
|
189
|
+ },
|
|
190
|
+ useState: (state) {
|
|
191
|
+ orderList(GetList(state));
|
|
192
|
+ },
|
262
|
193
|
),
|
263
|
194
|
),
|
264
|
195
|
],
|