|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
|
2
|
import 'package:easy_refresh/easy_refresh.dart';
|
2
|
3
|
import 'package:flutter/material.dart';
|
3
|
4
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
@@ -6,13 +7,16 @@ import 'package:lszlgl/base/base_vm.dart';
|
6
|
7
|
import 'package:lszlgl/config/colors.dart';
|
7
|
8
|
import 'package:lszlgl/model/rsp/sample_task_rsp.dart';
|
8
|
9
|
import 'package:lszlgl/network/my_api.dart';
|
|
10
|
+import 'package:lszlgl/page/print/print_page.dart';
|
9
|
11
|
import 'package:lszlgl/page/sample_task/sample_list_vm.dart';
|
10
|
12
|
import 'package:lszlgl/page/sample_task/sample_task_list_tab_page.dart';
|
11
|
13
|
import 'package:lszlgl/service/dict_service.dart';
|
|
14
|
+import 'package:lszlgl/service/print_service.dart';
|
12
|
15
|
import 'package:lszlgl/utils/date_time_utils.dart';
|
13
|
16
|
import 'package:lszlgl/utils/inject.dart';
|
14
|
17
|
import 'package:lszlgl/widget/button.dart';
|
15
|
18
|
import 'package:lszlgl/widget/page_widget.dart';
|
|
19
|
+import 'package:lszlgl/widget/print_checkbox_widget.dart';
|
16
|
20
|
|
17
|
21
|
import '../../main.dart';
|
18
|
22
|
import 'reap_sample_detail/reap_sample_task_page.dart';
|
|
@@ -36,6 +40,7 @@ class SampleTaskListPage extends StatefulWidget {
|
36
|
40
|
class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
37
|
41
|
with AutomaticKeepAliveClientMixin {
|
38
|
42
|
late SampleListVM vm;
|
|
43
|
+ List<num> selectList = [];
|
39
|
44
|
|
40
|
45
|
/// 详情
|
41
|
46
|
void startTaskDetail(bool detail, SampleTaskItem data, {num? deliveryStatus}) async {
|
|
@@ -43,7 +48,8 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
43
|
48
|
switch (widget.type) {
|
44
|
49
|
case StepType.reap:
|
45
|
50
|
success = await MyRouter.startReapSampleTask(
|
46
|
|
- args: ReapSampleTaskPageArgs(detail: detail, id: data.id,deliveryStatus: deliveryStatus));
|
|
51
|
+ args: ReapSampleTaskPageArgs(
|
|
52
|
+ detail: detail, id: data.id, deliveryStatus: deliveryStatus));
|
47
|
53
|
break;
|
48
|
54
|
case StepType.stock:
|
49
|
55
|
success = await MyRouter.startStockSampleTask(
|
|
@@ -101,7 +107,12 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
101
|
107
|
@override
|
102
|
108
|
Widget build(BuildContext context) {
|
103
|
109
|
super.build(context);
|
104
|
|
- return buildBody();
|
|
110
|
+ return Stack(
|
|
111
|
+ children: [
|
|
112
|
+ buildBody(),
|
|
113
|
+ buildPrintBtn(),
|
|
114
|
+ ],
|
|
115
|
+ );
|
105
|
116
|
// Container(
|
106
|
117
|
// margin: const EdgeInsets.symmetric(horizontal: 8),
|
107
|
118
|
// clipBehavior: Clip.hardEdge,
|
|
@@ -114,6 +125,82 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
114
|
125
|
// );
|
115
|
126
|
}
|
116
|
127
|
|
|
128
|
+ // 批量打印前 获取数据
|
|
129
|
+ getPrintData() async{
|
|
130
|
+ if(selectList.isEmpty){
|
|
131
|
+ MyNavigator.showToast('请选择打印数据');
|
|
132
|
+ return;
|
|
133
|
+ }
|
|
134
|
+
|
|
135
|
+ MyNavigator.showLoading(msg: '数据处理中...');
|
|
136
|
+ var dataList = await Future.wait(selectList.map((id) => MyApi.get().sampleTaskDetailSgjc(id)));
|
|
137
|
+ List<SampleTaskItem?> data = dataList.map((e) => e.data).toList();
|
|
138
|
+ if(data.isEmpty){
|
|
139
|
+ MyNavigator.dismissLoading();
|
|
140
|
+ MyNavigator.showToast('打印数据获取有误');
|
|
141
|
+ return;
|
|
142
|
+ }
|
|
143
|
+ // List<Uint8List?> imgList = await Future.wait(data.map((item)=>imageToBytes(item!.ewmfilePictureList!.first.url!)));
|
|
144
|
+ List<PrintPageArgs> printList = [];
|
|
145
|
+ for(int i = 0; i < data.length; i++){
|
|
146
|
+ List<String> textList = PrintService.getPrintTextListWithSampleTaskItem(data[i]);
|
|
147
|
+ PrintPageArgs arg = PrintPageArgs(
|
|
148
|
+ urlCode:'${MyApi.globalUrl}/admin-api/zj/code-sampling-task-details-sgjc/getSamplingTaskDetails?id=${data[i]!.id}' ,
|
|
149
|
+ numCode: data[i]!.ewmfilePictureList!.first.name,
|
|
150
|
+ textList: textList,
|
|
151
|
+ );
|
|
152
|
+ printList.add(arg);
|
|
153
|
+ }
|
|
154
|
+ MyNavigator.dismissLoading();
|
|
155
|
+
|
|
156
|
+ var args = PrintPageArgs(printList: printList);
|
|
157
|
+ await MyRouter.startPrint(args);
|
|
158
|
+
|
|
159
|
+ }
|
|
160
|
+
|
|
161
|
+ // 通过地址获取图片内容
|
|
162
|
+ // Future<Uint8List?> imageToBytes(String imageUrl) async {
|
|
163
|
+ // try{
|
|
164
|
+ // var response = await Dio().get(
|
|
165
|
+ // imageUrl,
|
|
166
|
+ // options: Options(responseType: ResponseType.bytes)
|
|
167
|
+ // );
|
|
168
|
+ // return Uint8List.fromList(response.data);
|
|
169
|
+ // } catch(e){
|
|
170
|
+ // logger.d(e);
|
|
171
|
+ // return null;
|
|
172
|
+ // }
|
|
173
|
+ // }
|
|
174
|
+
|
|
175
|
+ Widget buildPrintBtn() {
|
|
176
|
+ if (widget.type == StepType.reap && widget.tabIndex == 2) {
|
|
177
|
+ return ValueListenableBuilder(
|
|
178
|
+ valueListenable: vm.showPrintBtn,
|
|
179
|
+ builder: (context, show, child) {
|
|
180
|
+ if (show) {
|
|
181
|
+ return child!;
|
|
182
|
+ } else {
|
|
183
|
+ return const SizedBox.shrink();
|
|
184
|
+ }
|
|
185
|
+ },
|
|
186
|
+ child: Positioned(
|
|
187
|
+ bottom: 0,
|
|
188
|
+ left: 8,
|
|
189
|
+ right: 8,
|
|
190
|
+ child: MyButton(
|
|
191
|
+ '打 印',
|
|
192
|
+ radius: 8,
|
|
193
|
+ gradient: const LinearGradient(colors: [Color(0xFF3BD2E5), Color(0xFF247AF8)]),
|
|
194
|
+ onTap: () {
|
|
195
|
+ getPrintData();
|
|
196
|
+ },
|
|
197
|
+ )),
|
|
198
|
+ );
|
|
199
|
+ } else {
|
|
200
|
+ return const SizedBox.shrink();
|
|
201
|
+ }
|
|
202
|
+ }
|
|
203
|
+
|
117
|
204
|
Widget buildBody() {
|
118
|
205
|
return EasyRefresh.builder(
|
119
|
206
|
controller: vm.ctrlList[widget.tabIndex],
|
|
@@ -161,7 +248,6 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
161
|
248
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
162
|
249
|
),
|
163
|
250
|
child: Stack(
|
164
|
|
- alignment: Alignment.topRight,
|
165
|
251
|
children: [
|
166
|
252
|
Column(
|
167
|
253
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
@@ -177,12 +263,42 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
177
|
263
|
],
|
178
|
264
|
),
|
179
|
265
|
buildState(item.getDeliveryStatusText()),
|
|
266
|
+ buildSelectBtn(item),
|
180
|
267
|
],
|
181
|
268
|
),
|
182
|
269
|
),
|
183
|
270
|
);
|
184
|
271
|
}
|
185
|
272
|
|
|
273
|
+ buildSelectBtn(SampleTaskItem item){
|
|
274
|
+ if(widget.type == StepType.reap && item.deliveryStatus==2){
|
|
275
|
+ return ValueListenableBuilder(valueListenable: vm.showPrintBtn, builder: (_,show,__){
|
|
276
|
+ if(show){
|
|
277
|
+ return Positioned(
|
|
278
|
+ right: 0,
|
|
279
|
+ top: 60,
|
|
280
|
+ child: PrintCheckboxWidget(
|
|
281
|
+ list: selectList,
|
|
282
|
+ itemId: item.id!,
|
|
283
|
+ onChanged: (bool isSelect){
|
|
284
|
+ item.isSelect = isSelect;
|
|
285
|
+ if(isSelect){
|
|
286
|
+ selectList.add(item.id!);
|
|
287
|
+ }else{
|
|
288
|
+ selectList.remove(item.id!);
|
|
289
|
+ }
|
|
290
|
+ },
|
|
291
|
+ ),
|
|
292
|
+ );
|
|
293
|
+ }else{
|
|
294
|
+ return const SizedBox.shrink();
|
|
295
|
+ }
|
|
296
|
+ });
|
|
297
|
+ }else{
|
|
298
|
+ return const SizedBox.shrink();
|
|
299
|
+ }
|
|
300
|
+ }
|
|
301
|
+
|
186
|
302
|
Widget buildTop() {
|
187
|
303
|
return Row(
|
188
|
304
|
children: [
|
|
@@ -208,12 +324,16 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
208
|
324
|
img = imgQYStateOn;
|
209
|
325
|
color = const Color(0xFFDEA70A);
|
210
|
326
|
}
|
211
|
|
- return Container(
|
212
|
|
- padding: const EdgeInsets.fromLTRB(40, 4, 20, 16),
|
213
|
|
- decoration: BoxDecoration(image: DecorationImage(image: AssetImage(img), fit: BoxFit.fill)),
|
214
|
|
- child: Text(
|
215
|
|
- state,
|
216
|
|
- style: TextStyle(color: color, fontSize: 15),
|
|
327
|
+ return Positioned(
|
|
328
|
+ top: 0,
|
|
329
|
+ right: 0,
|
|
330
|
+ child: Container(
|
|
331
|
+ padding: const EdgeInsets.fromLTRB(40, 4, 20, 16),
|
|
332
|
+ decoration: BoxDecoration(image: DecorationImage(image: AssetImage(img), fit: BoxFit.fill)),
|
|
333
|
+ child: Text(
|
|
334
|
+ state,
|
|
335
|
+ style: TextStyle(color: color, fontSize: 15),
|
|
336
|
+ ),
|
217
|
337
|
),
|
218
|
338
|
);
|
219
|
339
|
}
|
|
@@ -320,7 +440,7 @@ class _SampleTaskListPageState extends BaseLifecycleState<SampleTaskListPage>
|
320
|
440
|
} else {
|
321
|
441
|
button = MyButton(
|
322
|
442
|
'修改信息',
|
323
|
|
- onTap: () => startTaskDetail(false, item,deliveryStatus: item.deliveryStatus),
|
|
443
|
+ onTap: () => startTaskDetail(false, item, deliveryStatus: item.deliveryStatus),
|
324
|
444
|
fountSize: 13,
|
325
|
445
|
radius: 6,
|
326
|
446
|
alignment: null,
|