113 lines
3.7 KiB
Dart
113 lines
3.7 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:bruno/bruno.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:wms_app/api_client/dto/empty_Vehicle_in_request.dart';
|
|
import 'package:wms_app/api_client/stock_in.dart';
|
|
import '/common/colorCom.dart';
|
|
import 'package:wms_app/utils/dialogUtils.dart';
|
|
|
|
class StockInEmpty extends StatefulWidget {
|
|
const StockInEmpty({super.key});
|
|
@override
|
|
State<StockInEmpty> createState() => _StockInEmptyPageState();
|
|
}
|
|
|
|
/// 空托入库界面
|
|
class _StockInEmptyPageState extends State<StockInEmpty> {
|
|
final _vehicleTextController = TextEditingController(); // 载具号输入框
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
iconTheme: const IconThemeData(color: Colors.white),
|
|
leading: IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
icon: const Icon(Icons.arrow_back)),
|
|
centerTitle: true,
|
|
backgroundColor: ColorCommon.colorScheme,
|
|
title: const Text(
|
|
"空料箱入库",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 5, left: 10, right: 10),
|
|
child: ListView(
|
|
children: [
|
|
BrnTextInputFormItem(
|
|
controller: _vehicleTextController,
|
|
title: "料箱号:",
|
|
hint: "需要入库的料箱号",
|
|
isRequire: true,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 5),
|
|
child: ElevatedButton(
|
|
onPressed: emptyIn,
|
|
style: ButtonStyle(
|
|
backgroundColor:
|
|
WidgetStateProperty.all(ColorCommon.colorScheme),
|
|
),
|
|
child: const Text("空载具入库", style: TextStyle(color: Colors.white))
|
|
)
|
|
)
|
|
],
|
|
)
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 空托入库方法
|
|
void emptyIn() {
|
|
String vehicleNo = _vehicleTextController.text.trim();
|
|
if (vehicleNo == "") {
|
|
DialogUtils.showWarningMessage(context, "请先填写容器号", "", btnLabel: "返回填写");
|
|
return;
|
|
}
|
|
BrnLoadingDialog.show(context,
|
|
content: "请稍后...", barrierDismissible: false);
|
|
// var emptyVehicleInReq = EmptyVehicleInReq(vehicleNo: vehicleNo).toJsonString();
|
|
StockInApi.emptyVehicleIn(vehicleNo).then((response) {
|
|
if (response["code"] != 200) {
|
|
var thisContext = context;
|
|
if (thisContext.mounted) {
|
|
DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败", btnLabel: "我知道了");
|
|
}
|
|
return;
|
|
}
|
|
final data = Map<String, dynamic>.from(jsonDecode(response["data"]));
|
|
if (data["code"] == 200) {
|
|
// 请求成功
|
|
var thisContext = context;
|
|
if (thisContext.mounted) {
|
|
DialogUtils.showSuccessMessage(thisContext, "成功", "", btnLabel: "我知道了");
|
|
_vehicleTextController.clear();
|
|
}
|
|
return;
|
|
}
|
|
var thisContext = context;
|
|
if (thisContext.mounted) {
|
|
DialogUtils.showWarningMessage(thisContext, "警告", "服务器返回失败:${data["message"]}", btnLabel: "我知道了");
|
|
}
|
|
return;
|
|
}).catchError((err) {
|
|
var thisContext = context;
|
|
if (thisContext.mounted) {
|
|
DialogUtils.showErrorMessage(thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()}", btnLabel: "我知道了");
|
|
}
|
|
return;
|
|
}).whenComplete(() {
|
|
var thisContext = context;
|
|
if (thisContext.mounted) {
|
|
BrnLoadingDialog.dismiss(thisContext);
|
|
}
|
|
});
|
|
}
|
|
}
|