2025-02-19 18:52:05 +08:00
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:bruno/bruno.dart';
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2025-02-23 16:19:27 +08:00
|
|
|
|
import 'package:uuid/uuid.dart';
|
2025-02-19 18:52:05 +08:00
|
|
|
|
import 'package:wms_app/api_client/stock_in.dart';
|
|
|
|
|
|
import 'package:wms_app/api_client/stock_out.dart';
|
|
|
|
|
|
import 'package:wms_app/component/card/stock_in_card_xugong.dart';
|
|
|
|
|
|
import 'package:wms_app/model/bo/stock_in_data_xugong.dart';
|
|
|
|
|
|
import '../../common/colorCom.dart';
|
|
|
|
|
|
import '../../utils/dialogUtils.dart';
|
|
|
|
|
|
import '../../utils/stringUtils.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class StockInNormal extends StatefulWidget {
|
|
|
|
|
|
const StockInNormal({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<StockInNormal> createState() => _StockInNormalState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 通用普通码盘界面
|
|
|
|
|
|
class _StockInNormalState extends State<StockInNormal> {
|
2025-02-23 16:19:27 +08:00
|
|
|
|
Uuid uuidGen = Uuid();
|
2025-02-19 18:52:05 +08:00
|
|
|
|
|
|
|
|
|
|
final _vehicleTextController = TextEditingController(); // 载具号输入框
|
|
|
|
|
|
final _goodsCodeController = TextEditingController(); // 条码输入框
|
2025-02-23 16:19:27 +08:00
|
|
|
|
final _goodsNumController = BrnStepsController();
|
|
|
|
|
|
final _orderNoController = TextEditingController();
|
|
|
|
|
|
final _orderTypeController = TextEditingController();
|
|
|
|
|
|
final _customerIdController = TextEditingController();
|
|
|
|
|
|
final _goodsDescController = TextEditingController();
|
|
|
|
|
|
final _weightController = TextEditingController();
|
|
|
|
|
|
final _sizeController = TextEditingController();
|
|
|
|
|
|
final _containerNoController = TextEditingController();
|
|
|
|
|
|
final _spare1Controller = TextEditingController();
|
|
|
|
|
|
final _spare2Controller = TextEditingController();
|
|
|
|
|
|
|
2025-02-19 18:52:05 +08:00
|
|
|
|
int goodsNum = 1; // 物料数量
|
|
|
|
|
|
|
|
|
|
|
|
List<StockInDataXuGong> stockInDataXuGong = [];
|
|
|
|
|
|
|
|
|
|
|
|
@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),
|
|
|
|
|
|
),
|
|
|
|
|
|
actions: [
|
2025-02-23 16:19:27 +08:00
|
|
|
|
TextButton(onPressed: () {},
|
|
|
|
|
|
style: const ButtonStyle(
|
|
|
|
|
|
foregroundColor: WidgetStatePropertyAll(Colors.white)),
|
|
|
|
|
|
child: const Text("清空"),)
|
2025-02-19 18:52:05 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
body: Center(
|
2025-02-23 16:19:27 +08:00
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(top: 5, left: 10, right: 10),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
child: ListView(
|
2025-02-23 16:19:27 +08:00
|
|
|
|
children: [
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _goodsCodeController,
|
|
|
|
|
|
title: "物料号:", hint: "请输入或扫描物料号",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnStepInputFormItem(
|
|
|
|
|
|
title: "物料数量:",
|
|
|
|
|
|
minLimit: 1,
|
|
|
|
|
|
value: goodsNum,
|
|
|
|
|
|
maxLimit: 9999,
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
canManualInput: true
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _orderNoController,
|
|
|
|
|
|
title: "单据号:", hint: "请输入或扫描单据号",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _orderTypeController,
|
|
|
|
|
|
title: "单据类型:", hint: "请输入或扫描单据类型",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _customerIdController,
|
|
|
|
|
|
title: "客户名称:", hint: "请输入或扫描客户名称",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _goodsDescController,
|
|
|
|
|
|
title: "物料描述:", hint: "请输入或扫描物料描述",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _weightController,
|
|
|
|
|
|
title: "重量:",
|
|
|
|
|
|
hint: "仅支持数字(保留小数点四位)",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
unit: "KG",
|
2025-02-19 18:52:05 +08:00
|
|
|
|
),
|
2025-02-23 16:19:27 +08:00
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _sizeController,
|
|
|
|
|
|
title: "尺寸:", hint: "请输入或扫描尺寸",
|
|
|
|
|
|
isRequire: true,
|
2025-02-19 18:52:05 +08:00
|
|
|
|
),
|
2025-02-23 16:19:27 +08:00
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _spare1Controller,
|
|
|
|
|
|
title: "备用1:", hint: "请输入",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _spare2Controller,
|
|
|
|
|
|
title: "备用2:", hint: "请输入",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
|
onPressed: resolveCode,
|
|
|
|
|
|
style: ButtonStyle(
|
|
|
|
|
|
backgroundColor: WidgetStateProperty.all(
|
|
|
|
|
|
ColorCommon.colorScheme),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
"添加物料",
|
|
|
|
|
|
style: TextStyle(color: Colors.white))
|
|
|
|
|
|
),
|
|
|
|
|
|
BrnTextInputFormItem(
|
|
|
|
|
|
controller: _containerNoController,
|
|
|
|
|
|
title: "容器号:", hint: "",
|
|
|
|
|
|
isRequire: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
Padding(padding: const EdgeInsets.only(top: 0),
|
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
|
onPressed: wheelComplete,
|
|
|
|
|
|
style: ButtonStyle(
|
|
|
|
|
|
backgroundColor: WidgetStateProperty.all(
|
|
|
|
|
|
ColorCommon.colorScheme),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: const Text(
|
|
|
|
|
|
"码盘完成",
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: Colors.white
|
|
|
|
|
|
))
|
|
|
|
|
|
)),
|
|
|
|
|
|
const Padding(padding: EdgeInsets.only(top: 10, bottom: 10),
|
|
|
|
|
|
child: Text("添加在载具的物料:"),
|
|
|
|
|
|
),
|
|
|
|
|
|
StockInCardXuGong(stockInDataXuGong: stockInDataXuGong)
|
|
|
|
|
|
],
|
2025-02-19 18:52:05 +08:00
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 解析条码
|
|
|
|
|
|
void resolveCode() {
|
|
|
|
|
|
setState(() {
|
2025-02-23 16:19:27 +08:00
|
|
|
|
stockInDataXuGong.add(StockInDataXuGong(
|
|
|
|
|
|
customerName: "yuqili",
|
|
|
|
|
|
containerNo: "0",
|
|
|
|
|
|
weight: 10,
|
|
|
|
|
|
size: "55",
|
|
|
|
|
|
listId: uuidGen.v4(),
|
|
|
|
|
|
goodsCode: "555",
|
|
|
|
|
|
unit: "支",
|
|
|
|
|
|
status: 0,
|
|
|
|
|
|
storageType: 0,
|
|
|
|
|
|
createPerson: "system",
|
|
|
|
|
|
remark: "test",
|
|
|
|
|
|
orderType: _orderTypeController.text,
|
|
|
|
|
|
goodsNum: goodsNum,
|
|
|
|
|
|
orderId: _orderNoController.text,
|
|
|
|
|
|
vehicleNo: "0",
|
|
|
|
|
|
goodsId: _goodsCodeController.text,
|
|
|
|
|
|
goodsDesc: _goodsDescController.text,
|
|
|
|
|
|
customerId: _customerIdController.text,
|
|
|
|
|
|
recordId: uuidGen.v4(),
|
|
|
|
|
|
createTime: DateTime.now(),
|
|
|
|
|
|
updateTime: DateTime.now(),
|
|
|
|
|
|
spare1: _spare1Controller.text,
|
|
|
|
|
|
spare2: _spare2Controller.text));
|
2025-02-19 18:52:05 +08:00
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 码盘完成
|
|
|
|
|
|
void wheelComplete() {
|
2025-02-23 16:19:27 +08:00
|
|
|
|
if (stockInDataXuGong.isEmpty) {
|
|
|
|
|
|
DialogUtils.showWarningMessage(
|
|
|
|
|
|
context, "警告", "您的码盘数据为空", btnLabel: "确定");
|
2025-02-19 18:52:05 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-23 16:19:27 +08:00
|
|
|
|
String vehicleNo = "1";
|
2025-02-19 18:52:05 +08:00
|
|
|
|
int dataCount = stockInDataXuGong.length;
|
2025-02-23 16:19:27 +08:00
|
|
|
|
DialogUtils.showConfirmMessage(
|
|
|
|
|
|
context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?",
|
|
|
|
|
|
confirmBtn: "继续", confirm: () {
|
2025-02-19 18:52:05 +08:00
|
|
|
|
int taskType = 1; // 1 表示进库,2 表示进站台
|
|
|
|
|
|
BrnLoadingDialog.show(context, content: "正在请求入库");
|
2025-02-23 16:19:27 +08:00
|
|
|
|
StockInApi.stockInComplete(stockInDataXuGong).then((response) {
|
2025-02-19 18:52:05 +08:00
|
|
|
|
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) {
|
|
|
|
|
|
// 请求成功
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
_vehicleTextController.clear();
|
|
|
|
|
|
stockInDataXuGong = [];
|
|
|
|
|
|
});
|
|
|
|
|
|
var thisContext = context;
|
|
|
|
|
|
if (thisContext.mounted) {
|
|
|
|
|
|
DialogUtils.showSuccessMessage(
|
|
|
|
|
|
thisContext, "码盘成功", "", btnLabel: "我知道了");
|
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 出一个空空箱
|
|
|
|
|
|
getEmptyVehicle() {
|
2025-02-23 16:19:27 +08:00
|
|
|
|
DialogUtils.showConfirmMessage(
|
|
|
|
|
|
context, "空载具出库", "出一个空载具?", confirmBtn: "出一个",
|
|
|
|
|
|
confirm: () {
|
|
|
|
|
|
BrnLoadingDialog.show(context, content: "正在请求,请稍后");
|
|
|
|
|
|
StockOutApi.getEmptyVehicle().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) {
|
|
|
|
|
|
// 请求成功
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
_vehicleTextController.clear();
|
|
|
|
|
|
stockInDataXuGong = [];
|
|
|
|
|
|
});
|
|
|
|
|
|
var thisContext = context;
|
|
|
|
|
|
if (thisContext.mounted) {
|
|
|
|
|
|
DialogUtils.showSuccessMessage(
|
|
|
|
|
|
thisContext, "请求成功", "", btnLabel: "我知道了");
|
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
2025-02-19 18:52:05 +08:00
|
|
|
|
});
|
2025-02-23 16:19:27 +08:00
|
|
|
|
});
|
2025-02-19 18:52:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|