import 'package:flutter/cupertino.dart';
|
import 'package:flutter/material.dart';
|
import 'package:get/get.dart';
|
import 'package:zy_wms_pda/api/api_service.dart';
|
import 'package:zy_wms_pda/pages/inbound/mat_detls_page.dart';
|
|
import '../../common/bottom_bar.dart';
|
import '../../common/empty_count.dart';
|
import '../../widgets/buttons/custom_elevated_button.dart';
|
import 'mat_card.dart';
|
|
class InboundPage extends StatefulWidget {
|
const InboundPage({super.key});
|
|
@override
|
State<InboundPage> createState() => _InboundPageState();
|
}
|
|
class _InboundPageState extends State<InboundPage> {
|
/// 输入框焦点
|
FocusNode barcodeFocus = FocusNode();
|
TextEditingController _barCodeController = TextEditingController();
|
|
late List<Map<String, dynamic>> items = [];
|
int maxLen = 8;
|
|
void _reset() {
|
setState(() {
|
items = [];
|
});
|
}
|
|
@override
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
appBar: AppBar(
|
title: Text('组托'),
|
),
|
body: Padding(
|
padding: EdgeInsets.all(16),
|
child: ListView(
|
children: [
|
Container(
|
padding: EdgeInsets.all(8),
|
decoration: BoxDecoration(
|
color: Colors.white, borderRadius: BorderRadius.circular(10)),
|
child: Column(
|
children: [
|
TextField(
|
controller: _barCodeController,
|
focusNode: barcodeFocus,
|
onTapOutside: (e) => {barcodeFocus.unfocus()},
|
decoration: InputDecoration(labelText: '托盘码',counterText: '${_barCodeController.text.length}/$maxLen'),
|
onChanged: (text) {
|
setState(() {
|
if (text.length > maxLen) {
|
_barCodeController.clear(); // 清空文本
|
} else {
|
_barCodeController.text = text;
|
}
|
});
|
},
|
),
|
],
|
),
|
),
|
Container(
|
padding: EdgeInsets.all(8),
|
margin: EdgeInsets.only(left: 0, top: 8, right: 0, bottom: 8),
|
decoration: BoxDecoration(
|
color: Colors.white, borderRadius: BorderRadius.circular(10)),
|
// child: Text('物料明细', style: TextStyle(fontSize: 18)),
|
child: Row(
|
// direction: Axis.horizontal,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
Text('物料明细', style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold,fontFamily: 'PingFang SC')),
|
CEBtn(title: '编辑', type: Type.second, onPressed: () async {
|
var result = await Get.to(() => MatDetlsPage(data: items));
|
if (result!= null) {
|
setState(() {
|
items = result;
|
});
|
}
|
}),
|
],
|
),
|
),
|
ListItems(items),
|
],
|
),
|
),
|
bottomNavigationBar: BottomBar(
|
children: [
|
CEBtn(title: '重置', type: Type.cancel, onPressed: _reset),
|
CEBtn(title: '组托', type: Type.second, onPressed: () {
|
var result = ApiService.mobileComb(_barCodeController.text,items);
|
print('result:$result');
|
}),
|
],
|
),
|
);
|
}
|
}
|
|
/// 物料列表
|
Widget ListItems(List<Map<String, dynamic>> items) {
|
return Container(
|
child: Column(
|
children: items.isEmpty
|
? [
|
EmptyCount()
|
]
|
: List.generate(items.length, (index) {
|
var item = items[index];
|
return MatCard(
|
item: item,
|
isEdit: false,
|
);
|
}),
|
),
|
);
|
}
|