clean shit

This commit is contained in:
李宇奇 2025-02-24 15:52:03 +08:00
parent 910670c0cd
commit 5194d953ed
9 changed files with 288 additions and 361 deletions

View File

@ -6,8 +6,8 @@ class BaseDio {
static Dio instance() { static Dio instance() {
if (!initializeComplete) { if (!initializeComplete) {
final options = BaseOptions( final options = BaseOptions(
// baseUrl: 'http://10.0.2.2:9990', baseUrl: 'http://10.0.2.2:9990',
baseUrl: 'http://192.168.1.3:9990', // baseUrl: 'http://192.168.1.3:9990',
connectTimeout: const Duration(seconds: 10), connectTimeout: const Duration(seconds: 10),
receiveTimeout: const Duration(seconds: 5), receiveTimeout: const Duration(seconds: 5),
); );

View File

@ -21,8 +21,8 @@ class StockInApi {
/// ///
static Future<dynamic> emptyVehicleIn(String vehicleNo, static Future<dynamic> emptyVehicleIn(String vehicleNo,
{int timeOut = 5000}) async { {int timeOut = 5000}) async {
final response = final response = await BaseDio.instance()
await BaseDio.instance().post<String>("/system/storage/addEmpty?vehicleNo=$vehicleNo", .post<String>("/system/storage/addEmpty?vehicleNo=$vehicleNo",
options: Options( options: Options(
responseType: ResponseType.json, responseType: ResponseType.json,
sendTimeout: Duration(milliseconds: timeOut), sendTimeout: Duration(milliseconds: timeOut),
@ -32,13 +32,19 @@ class StockInApi {
} }
/// ///
static Future<dynamic> stockInComplete(List<StockInDataXuGong> stockInDataXuGong, static Future<dynamic> stockInComplete(
List<StockInDataXuGong> stockInDataXuGong, String vehicleNo,
{int timeOut = 5000}) async { {int timeOut = 5000}) async {
logger.e("yuqili $stockInDataXuGong"); logger.e("yuqili $stockInDataXuGong");
final stockInDataJson = stockInDataXuGong.map((item) => item.toJson()).toList(); final stockInDataJson =
final response = await BaseDio.instance() stockInDataXuGong.map((item) => item.toJson()).toList();
.post<String>("/system/storage/addOtherList", final request = {
data: jsonEncode(stockInDataJson), "data": stockInDataJson,
"vehicleNo": vehicleNo
};
final response =
await BaseDio.instance().post<String>("/system/storage/addOtherList",
data: jsonEncode(request),
options: Options( options: Options(
responseType: ResponseType.json, responseType: ResponseType.json,
sendTimeout: Duration(milliseconds: timeOut), sendTimeout: Duration(milliseconds: timeOut),

View File

@ -47,6 +47,7 @@ class StockOutApi {
"goodsDesc": "empty", "goodsDesc": "empty",
"spare1": uuidGen.v1(), "spare1": uuidGen.v1(),
"spare2": uuidGen.v1(), "spare2": uuidGen.v1(),
"orderStatus": 1,
}), }),
options: Options( options: Options(
responseType: ResponseType.json, responseType: ResponseType.json,

View File

@ -47,7 +47,7 @@ class _StockInCardXuGongState extends State<StockInCardXuGong> {
}); });
} }
), ),
BrnRichGridInfo('单据号:', item.orderId), BrnRichGridInfo('单据号:', item.listId),
BrnRichGridInfo('单据类型:', item.orderType), BrnRichGridInfo('单据类型:', item.orderType),
BrnRichGridInfo('客户名称:', item.customerName), BrnRichGridInfo('客户名称:', item.customerName),
BrnRichGridInfo('物料描述:', item.goodsDesc), BrnRichGridInfo('物料描述:', item.goodsDesc),

View File

@ -1,127 +1,71 @@
import 'package:intl/intl.dart';
class StockInDataXuGong { class StockInDataXuGong {
String recordId = "";
String listId = "";
String orderType = ""; //
String customerId = "";
String orderId = "test"; //
String vehicleNo = "";
String goodsId = ""; // String goodsId = ""; //
int goodsNum = 0; // int goodsNum = 0; //
String goodsCode = "";
String goodsDesc = ""; // String listId = ""; //
String unit = "";
String spare1 = ""; // 1 int orderType = 0; //
String spare2 = ""; // 2
int status = 0;
int storageType = 0;
String createPerson = "empty";
String remark = "test";
DateTime createTime = DateTime.now();
DateTime updateTime = DateTime.now();
double weight = 0; //
String customerName = ""; // String customerName = ""; //
String size = ""; //
String containerNo = ""; // String goodsDesc = ""; //
double weight = 0; //
int size = 0; //
String unit = ""; //
String spare1 = ""; // 1
String spare2 = ""; // 2
StockInDataXuGong({ StockInDataXuGong({
required this.recordId,
required this.goodsId, required this.goodsId,
required this.goodsNum, required this.goodsNum,
required this.orderId,
required this.orderType, required this.orderType,
required this.goodsDesc, required this.goodsDesc,
required this.weight, required this.weight,
required this.size, required this.size,
required this.customerName, required this.customerName,
required this.containerNo,
required this.spare1, required this.spare1,
required this.spare2, required this.spare2,
required this.vehicleNo,
required this.customerId,
required this.goodsCode,
required this.listId, required this.listId,
required this.unit, required this.unit,
required this.status,
required this.storageType,
required this.createPerson,
required this.remark,
required this.createTime,
required this.updateTime,
}); });
// Updated fromJson method // Updated fromJson method
factory StockInDataXuGong.fromJson(Map<String, dynamic> json) { factory StockInDataXuGong.fromJson(Map<String, dynamic> json) {
return StockInDataXuGong( return StockInDataXuGong(
containerNo: json["containerNo"] ?? "0",
customerName: json["customerName"] ?? "", customerName: json["customerName"] ?? "",
listId: json["listId"] ?? "", listId: json["listId"] ?? "",
customerId: json["customerId"] ?? "",
recordId: json["recordId"] ?? "",
goodsId: json["goodsId"] ?? "", goodsId: json["goodsId"] ?? "",
//
vehicleNo: json["vehicleNo"] ?? "",
//
goodsNum: json["goodsNum"] ?? 10.0, goodsNum: json["goodsNum"] ?? 10.0,
// orderType: json["orderType"] ?? 0,
orderId: json["orderId"] ?? "",
//
orderType: json["orderType"] ?? "",
//
goodsCode: json["goodsCode"] ?? "",
// customerName: json["customerName"] ?? "", //
goodsDesc: json["goodsDesc"] ?? "", goodsDesc: json["goodsDesc"] ?? "",
//
// weight: json["weight"]?.toDouble() ?? 0.0, //
// size: json["size"] ?? "", //
// containerNo: json["containerNo"] ?? "",
//
spare1: json["spare1"] ?? "", spare1: json["spare1"] ?? "",
// 1
spare2: json["spare2"] ?? "", spare2: json["spare2"] ?? "",
// 2
unit: json["unit"] ?? "",
status: json["status"] ?? 0,
storageType: json["storageType"] ?? 0,
createPerson: json["createPerson"] ?? "",
remark: json["remark"] ?? "",
createTime: json["createTime"] ?? DateTime.now(),
updateTime: json["updateTime"] ?? DateTime.now(),
weight: json["weight"] ?? 10.0, weight: json["weight"] ?? 10.0,
size: json["size"] ?? "50", size: json["size"] ?? "50",
unit: json["unit"] ?? "",
); );
} }
// toJson // toJson
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
String formattedCreateDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(createTime);
String formattedUpdateDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(updateTime);
return { return {
"recordId": recordId,
"listId": listId, "listId": listId,
"orderType": orderType, "orderType": orderType,
"customerId": customerId,
"orderId": orderId,
"vehicleNo": vehicleNo,
"goodsId": goodsId, "goodsId": goodsId,
"goodsNum": goodsNum, "goodsNum": goodsNum,
"goodsCode": goodsCode,
"goodsDesc": goodsDesc, "goodsDesc": goodsDesc,
"unit": unit,
"spare1": spare1, "spare1": spare1,
"spare2": spare2, "spare2": spare2,
"status": status,
"storageType": storageType,
"createPerson": createPerson,
"remark": remark,
"createTime": formattedCreateDate,
"updateTime": formattedUpdateDate,
"weight": weight, "weight": weight,
"customerName": customerName, "customerName": customerName,
"size": size, "size": size,
"containerNo": containerNo, "unit": unit,
}; };
} }
} }

View File

@ -26,55 +26,31 @@ class _InventoryCheckPageState extends State<InventoryCheckPage> {
// Filtering the data // Filtering the data
filteredItems = [ filteredItems = [
StockInDataXuGong( StockInDataXuGong(
recordId: "0001", unit: "test",
vehicleNo: "11", listId: "1111",
customerId: "111", goodsId: "001",
createTime: DateTime.now(), goodsNum: 5,
updateTime: DateTime.now(), orderType: 1,
goodsCode: "00001", customerName: "Customer A",
listId: "1111", goodsDesc: "Material 1 Description",
unit: "", weight: 20.0,
status: 1, size: 10,
storageType: 1, spare1: "Spare1A",
createPerson: "system", spare2: "Spare2A",
remark: "test", ),
goodsId: "001",
goodsNum: 5,
orderId: "order123",
orderType: "订购",
customerName: "Customer A",
goodsDesc: "Material 1 Description",
weight: 20.0,
size: "Small",
spare1: "Spare1A",
spare2: "Spare2A",
containerNo: "Container123"),
StockInDataXuGong( StockInDataXuGong(
recordId: "0001", unit: "test",
vehicleNo: "11", listId: "1111",
customerId: "111", goodsId: "002",
createTime: DateTime.now(), goodsNum: 10,
updateTime: DateTime.now(), orderType: 1,
goodsCode: "00001", customerName: "Customer B",
listId: "1111", goodsDesc: "Material 2 Description",
unit: "", weight: 15.5,
status: 1, size: 10,
storageType: 1, spare1: "Spare1B",
createPerson: "system", spare2: "Spare2B",
remark: "test", ),
goodsId: "002",
goodsNum: 10,
orderId: "order456",
orderType: "订购",
customerName: "Customer B",
goodsDesc: "Material 2 Description",
weight: 15.5,
size: "Medium",
spare1: "Spare1B",
spare2: "Spare2B",
containerNo: "Container456"),
]; ];
}); });
}); });
@ -113,7 +89,8 @@ class _InventoryCheckPageState extends State<InventoryCheckPage> {
} }
void _completeInventoryCheck() { void _completeInventoryCheck() {
DialogUtils.showSuccessMessage(context, "盘点完成", "所有物料已完成盘点", btnLabel: "我知道了"); DialogUtils.showSuccessMessage(context, "盘点完成", "所有物料已完成盘点",
btnLabel: "我知道了");
} }
@override @override
@ -240,10 +217,8 @@ class _EditGoodPageState extends State<EditGoodPage> {
(value) => _editedItem.goodsId = value), (value) => _editedItem.goodsId = value),
_buildEditableField("数量", _editedItem.goodsNum.toString(), _buildEditableField("数量", _editedItem.goodsNum.toString(),
(value) => _editedItem.goodsNum = int.tryParse(value) ?? 0), (value) => _editedItem.goodsNum = int.tryParse(value) ?? 0),
_buildEditableField("单据号", _editedItem.orderId, _buildEditableField("单据类型", _editedItem.orderType.toString(),
(value) => _editedItem.orderId = value), (value) => _editedItem.orderType = int.parse(value)),
_buildEditableField("单据类型", _editedItem.orderType,
(value) => _editedItem.orderType = value),
_buildEditableField("客户名称", _editedItem.customerName, _buildEditableField("客户名称", _editedItem.customerName,
(value) => _editedItem.customerName = value), (value) => _editedItem.customerName = value),
_buildEditableField("描述", _editedItem.goodsDesc, _buildEditableField("描述", _editedItem.goodsDesc,
@ -251,7 +226,7 @@ class _EditGoodPageState extends State<EditGoodPage> {
_buildEditableField("重量", _editedItem.weight.toString(), _buildEditableField("重量", _editedItem.weight.toString(),
(value) => _editedItem.weight = double.tryParse(value) ?? 0.0), (value) => _editedItem.weight = double.tryParse(value) ?? 0.0),
_buildEditableField( _buildEditableField(
"尺寸", _editedItem.size, (value) => _editedItem.size = value), "尺寸", _editedItem.size.toString(), (value) => _editedItem.size = int.parse(value)),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
widget.onSave(_editedItem); widget.onSave(_editedItem);

View File

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:bruno/bruno.dart'; import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wms_app/api_client/stock_in.dart'; import 'package:wms_app/api_client/stock_in.dart';
import 'package:wms_app/model/bo/stock_in_data_xugong.dart';
import 'package:wms_app/utils/stringUtils.dart'; import 'package:wms_app/utils/stringUtils.dart';
import '/common/colorCom.dart'; import '/common/colorCom.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart';
@ -19,7 +20,7 @@ class StockInWheelEBS extends StatefulWidget {
class _StockInWheelEBSPageState extends State<StockInWheelEBS> { class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
final _vehicleTextController = TextEditingController(); // final _vehicleTextController = TextEditingController(); //
final _goodsCodeController = TextEditingController(); // final _goodsCodeController = TextEditingController(); //
List<dynamic> packageData = []; // List<StockInDataXuGong> packageData = []; //
int packageDataId = 0; // int packageDataId = 0; //
@override @override
@ -258,21 +259,34 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
final item = data["data"] as dynamic; final item = data["data"] as dynamic;
setState(() { setState(() {
packageDataId++; packageDataId++;
packageData.add({ // packageData.add({
"id": packageDataId.toString(), // "id": packageDataId.toString(),
"segment1": codeData[0], // "segment1": codeData[0],
"itemId": codeData[1], // "itemId": codeData[1],
"batch": codeData[2], // "batch": codeData[2],
"quantity": codeData[3], // "quantity": codeData[3],
"weight": codeData[4], // "weight": codeData[4],
"productData": codeData[5], // "productData": codeData[5],
"sendOrderId": sendOrderId, // // "sendOrderId": sendOrderId, //
"goodsName": item["itemDesc"].toString(), // "goodsName": item["itemDesc"].toString(),
"unit": item["purUomCode"].toString(), // "unit": item["purUomCode"].toString(),
"poHeaderId": item["poHeaderId"].toString(), // "poHeaderId": item["poHeaderId"].toString(),
"poLineId": item["poLineId"].toString(), // "poLineId": item["poLineId"].toString(),
"lineLocationId": item["lineLocationId"].toString(), // "lineLocationId": item["lineLocationId"].toString(),
}); // });
packageData.add(StockInDataXuGong(
goodsId: goodsId,
goodsNum: packageDataId,
listId: sendOrderId,
unit: "test",
orderType: 1,
customerName: "system",
goodsDesc: item["itemDesc"].toString(),
weight: double.parse(codeData[4]),
size: 10,
spare1: "test",
spare2: "test",
));
_goodsCodeController.clear(); _goodsCodeController.clear();
}); });
return; return;
@ -302,11 +316,11 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
/// ///
void delete(dynamic) { void delete(dynamic) {
setState(() { // setState(() {
packageData.removeWhere((r) { // packageData.removeWhere((r) {
return r["id"] == dynamic["id"]; // return r["id"] == dynamic["id"];
}); // });
}); // });
if (packageData.isEmpty) { if (packageData.isEmpty) {
packageDataId = 0; packageDataId = 0;
} }
@ -320,10 +334,10 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
DialogUtils.showWarningMessage(context, "警告", "该文本框仅支持数字"); DialogUtils.showWarningMessage(context, "警告", "该文本框仅支持数字");
return; return;
} }
setState(() { // setState(() {
packageData.where((w) => w["id"] == dynamic["id"]).first["quantity"] = // packageData.where((w) => w["id"] == dynamic["id"]).first["quantity"] =
value; // value;
}); // });
}); });
} }
@ -365,7 +379,8 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
confirmBtn: "继续", confirm: () { confirmBtn: "继续", confirm: () {
int taskType = 1; // 1 2 int taskType = 1; // 1 2
BrnLoadingDialog.show(context, content: "正在请求入库"); BrnLoadingDialog.show(context, content: "正在请求入库");
StockInApi.stockInComplete(packageData).then((response) { StockInApi.stockInComplete(packageData, vehicleNo)
.then((response) {
if (response["code"] != 200) { if (response["code"] != 200) {
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {

View File

@ -9,6 +9,11 @@ import '../../utils/dialogUtils.dart';
import 'package:logger/logger.dart'; import 'package:logger/logger.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
Logger logger = Logger(
printer: PrettyPrinter(),
);
const Uuid uuidGen = Uuid();
class StockInBuy extends StatefulWidget { class StockInBuy extends StatefulWidget {
const StockInBuy({super.key}); const StockInBuy({super.key});
@ -18,10 +23,6 @@ class StockInBuy extends StatefulWidget {
class _StockInBuyState extends State<StockInBuy> { class _StockInBuyState extends State<StockInBuy> {
List<StockInDataXuGong> stockInDataXuGong = []; List<StockInDataXuGong> stockInDataXuGong = [];
static var logger = Logger(
printer: PrettyPrinter(),
);
static var uuidGen = Uuid();
@override @override
void initState() { void initState() {
@ -40,7 +41,8 @@ class _StockInBuyState extends State<StockInBuy> {
if (response["code"] != 200) { if (response["code"] != 200) {
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败", btnLabel: "我知道了"); DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败",
btnLabel: "我知道了");
} }
return; return;
} }
@ -49,7 +51,8 @@ class _StockInBuyState extends State<StockInBuy> {
logger.e("yuqili2 $data"); logger.e("yuqili2 $data");
final List<dynamic> res = data["rows"]; final List<dynamic> res = data["rows"];
stockInDataXuGong = res.map((item) => StockInDataXuGong.fromJson(item)).toList(); stockInDataXuGong =
res.map((item) => StockInDataXuGong.fromJson(item)).toList();
} }
@override @override
@ -96,8 +99,10 @@ class _StockInBuyState extends State<StockInBuy> {
children: [ children: [
Expanded(child: Text("物料号: ${item.goodsId}")), Expanded(child: Text("物料号: ${item.goodsId}")),
Expanded(child: Text("数量: ${item.goodsNum}")), Expanded(child: Text("数量: ${item.goodsNum}")),
Expanded(child: Text("描述: ${item.goodsDesc}")), Expanded(
Expanded(child: Text("重量: ${item.weight} KG")), child: Text("描述: ${item.goodsDesc}")),
Expanded(
child: Text("重量: ${item.weight} KG")),
Expanded(child: Text("尺寸: ${item.size}")), Expanded(child: Text("尺寸: ${item.size}")),
IconButton( IconButton(
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
@ -144,7 +149,8 @@ class _StockInBuyState extends State<StockInBuy> {
if (updatedItem != null) { if (updatedItem != null) {
setState(() { setState(() {
final index = stockInDataXuGong.indexWhere((e) => e.goodsId == item.goodsId); final index =
stockInDataXuGong.indexWhere((e) => e.goodsId == item.goodsId);
if (index != -1) { if (index != -1) {
stockInDataXuGong[index] = updatedItem; // stockInDataXuGong[index] = updatedItem; //
} }
@ -152,8 +158,6 @@ class _StockInBuyState extends State<StockInBuy> {
} }
} }
void _addMaterial(StockInDataXuGong item) { void _addMaterial(StockInDataXuGong item) {
StockInApi.addStockIn(item).then((response) { StockInApi.addStockIn(item).then((response) {
logger.e("yuqili $response"); logger.e("yuqili $response");
@ -167,8 +171,7 @@ class _StockInBuyState extends State<StockInBuy> {
} }
final data = Map<String, dynamic>.from(jsonDecode(response["data"])); final data = Map<String, dynamic>.from(jsonDecode(response["data"]));
if (data["code"] == 200) { if (data["code"] == 200) {
DialogUtils.showSuccessMessage(context, "成功", "添加入库", DialogUtils.showSuccessMessage(context, "成功", "添加入库", btnLabel: "我知道了");
btnLabel: "我知道了");
return; return;
} }
}).catchError((err) { }).catchError((err) {
@ -189,34 +192,39 @@ class _StockInBuyState extends State<StockInBuy> {
} }
DialogUtils.showConfirmMessage(context, "码盘完成", "是否完成入库?", confirmBtn: "完成", DialogUtils.showConfirmMessage(context, "码盘完成", "是否完成入库?", confirmBtn: "完成",
confirm: () { confirm: () {
BrnLoadingDialog.show(context, content: "正在请求入库"); BrnLoadingDialog.show(context, content: "正在请求入库");
StockInApi.addCompleted(uuidGen.v4()).then((response) { StockInApi.addCompleted(uuidGen.v4()).then((response) {
logger.e("yuqili $response"); logger.e("yuqili $response");
if (response["code"] != 200) { if (response["code"] != 200) {
DialogUtils.showWarningMessage(context, "警告", "服务器请求失败", btnLabel: "我知道了"); DialogUtils.showWarningMessage(context, "警告", "服务器请求失败",
return; btnLabel: "我知道了");
} return;
final data = Map<String, dynamic>.from(jsonDecode(response["data"])); }
if (data["code"] == 200) { final data = Map<String, dynamic>.from(jsonDecode(response["data"]));
setState(() { if (data["code"] == 200) {
stockInDataXuGong.clear(); setState(() {
}); stockInDataXuGong.clear();
DialogUtils.showSuccessMessage(context, "码盘成功", "", btnLabel: "我知道了");
} else {
DialogUtils.showWarningMessage(
context, "警告", "服务器返回失败:${data["message"]}", btnLabel: "我知道了");
}
}).catchError((err) {
DialogUtils.showErrorMessage(context, "请求发生错误", "请求服务器发生错误:${err.toString()}", btnLabel: "我知道了");
}).whenComplete(() {
BrnLoadingDialog.dismiss(context);
}); });
}); DialogUtils.showSuccessMessage(context, "码盘成功", "", btnLabel: "我知道了");
} else {
DialogUtils.showWarningMessage(
context, "警告", "服务器返回失败:${data["message"]}",
btnLabel: "我知道了");
}
}).catchError((err) {
DialogUtils.showErrorMessage(
context, "请求发生错误", "请求服务器发生错误:${err.toString()}",
btnLabel: "我知道了");
}).whenComplete(() {
BrnLoadingDialog.dismiss(context);
});
});
} }
} }
class EditStockInPage extends StatefulWidget { class EditStockInPage extends StatefulWidget {
final StockInDataXuGong item; final StockInDataXuGong item;
const EditStockInPage({super.key, required this.item}); const EditStockInPage({super.key, required this.item});
@override @override
@ -234,10 +242,12 @@ class _EditStockInPageState extends State<EditStockInPage> {
void initState() { void initState() {
super.initState(); super.initState();
goodsIdController = TextEditingController(text: widget.item.goodsId); goodsIdController = TextEditingController(text: widget.item.goodsId);
goodsNumController = TextEditingController(text: widget.item.goodsNum.toString()); goodsNumController =
TextEditingController(text: widget.item.goodsNum.toString());
goodsDescController = TextEditingController(text: widget.item.goodsDesc); goodsDescController = TextEditingController(text: widget.item.goodsDesc);
weightController = TextEditingController(text: widget.item.weight.toString()); weightController =
sizeController = TextEditingController(text: widget.item.size); TextEditingController(text: widget.item.weight.toString());
sizeController = TextEditingController(text: widget.item.size.toString());
} }
@override @override
@ -251,39 +261,25 @@ class _EditStockInPageState extends State<EditStockInPage> {
} }
void _saveEdits() { void _saveEdits() {
// Create the updated item String listId = uuidGen.v4();
StockInDataXuGong updatedItem = StockInDataXuGong( StockInDataXuGong updatedItem = StockInDataXuGong(
recordId: "0001", listId: listId,
vehicleNo: "11",
customerId: "111",
createTime: DateTime.now(),
updateTime: DateTime.now(),
goodsCode: "00001",
listId: "1111",
unit: "",
status: 1,
storageType: 1,
createPerson: "system",
remark: "test",
goodsId: goodsIdController.text, goodsId: goodsIdController.text,
goodsNum: int.parse(goodsNumController.text), goodsNum: int.parse(goodsNumController.text),
orderId: widget.item.orderId, // Retain the original value orderType: widget.item.orderType,
orderType: widget.item.orderType, // Retain the original value customerName: widget.item.customerName,
customerName: widget.item.customerName, // Retain the original value
goodsDesc: goodsDescController.text, goodsDesc: goodsDescController.text,
weight: double.parse(weightController.text), weight: double.parse(weightController.text),
size: sizeController.text, size: int.parse(sizeController.text),
spare1: widget.item.spare1, // Retain the original value unit: widget.item.unit,
spare2: widget.item.spare2, // Retain the original value spare1: widget.item.spare1,
containerNo: widget.item.containerNo, // Retain the original value spare2: widget.item.spare2,
); );
// Pass the updated item back to the previous page // Pass the updated item back to the previous page
Navigator.of(context).pop(updatedItem); Navigator.of(context).pop(updatedItem);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -319,15 +315,8 @@ class _EditStockInPageState extends State<EditStockInPage> {
controller: sizeController, controller: sizeController,
decoration: const InputDecoration(labelText: '尺寸'), decoration: const InputDecoration(labelText: '尺寸'),
), ),
// Non-editable fields styled to look like editable ones but greyed out
TextField( TextField(
controller: TextEditingController(text: widget.item.orderId), controller: TextEditingController(text: widget.item.orderType.toString()),
decoration: const InputDecoration(labelText: "单据号"),
enabled: false,
style: TextStyle(color: Colors.grey),
),
TextField(
controller: TextEditingController(text: widget.item.orderType),
decoration: const InputDecoration(labelText: "单据类型"), decoration: const InputDecoration(labelText: "单据类型"),
enabled: false, enabled: false,
style: TextStyle(color: Colors.grey), style: TextStyle(color: Colors.grey),
@ -338,12 +327,6 @@ class _EditStockInPageState extends State<EditStockInPage> {
enabled: false, enabled: false,
style: TextStyle(color: Colors.grey), style: TextStyle(color: Colors.grey),
), ),
TextField(
controller: TextEditingController(text: widget.item.containerNo),
decoration: const InputDecoration(labelText: "容器号"),
enabled: false,
style: TextStyle(color: Colors.grey),
),
TextField( TextField(
controller: TextEditingController(text: widget.item.spare1), controller: TextEditingController(text: widget.item.spare1),
decoration: const InputDecoration(labelText: "备用1"), decoration: const InputDecoration(labelText: "备用1"),
@ -369,5 +352,3 @@ class _EditStockInPageState extends State<EditStockInPage> {
); );
} }
} }

View File

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi';
import 'package:bruno/bruno.dart'; import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -25,13 +26,13 @@ class _StockInNormalState extends State<StockInNormal> {
final _vehicleTextController = TextEditingController(); // final _vehicleTextController = TextEditingController(); //
final _goodsCodeController = TextEditingController(); // final _goodsCodeController = TextEditingController(); //
final _goodsNumController = BrnStepsController(); final _goodsNumController = BrnStepsController();
final _orderNoController = TextEditingController(); final _listIdController = TextEditingController();
final _orderTypeController = TextEditingController(); final _orderTypeController = TextEditingController();
final _customerIdController = TextEditingController(); final _customerNameController = TextEditingController();
final _goodsDescController = TextEditingController(); final _goodsDescController = TextEditingController();
final _goodsUnitController = TextEditingController();
final _weightController = TextEditingController(); final _weightController = TextEditingController();
final _sizeController = TextEditingController(); final _sizeController = TextEditingController();
final _containerNoController = TextEditingController();
final _spare1Controller = TextEditingController(); final _spare1Controller = TextEditingController();
final _spare2Controller = TextEditingController(); final _spare2Controller = TextEditingController();
@ -44,9 +45,11 @@ class _StockInNormalState extends State<StockInNormal> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
iconTheme: const IconThemeData(color: Colors.white), iconTheme: const IconThemeData(color: Colors.white),
leading: IconButton(onPressed: () { leading: IconButton(
Navigator.of(context).pop(); onPressed: () {
}, icon: const Icon(Icons.arrow_back)), Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back)),
centerTitle: true, centerTitle: true,
backgroundColor: ColorCommon.colorScheme, backgroundColor: ColorCommon.colorScheme,
title: const Text( title: const Text(
@ -54,10 +57,12 @@ class _StockInNormalState extends State<StockInNormal> {
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
actions: [ actions: [
TextButton(onPressed: () {}, TextButton(
onPressed: () {},
style: const ButtonStyle( style: const ButtonStyle(
foregroundColor: WidgetStatePropertyAll(Colors.white)), foregroundColor: WidgetStatePropertyAll(Colors.white)),
child: const Text("清空"),) child: const Text("清空"),
)
], ],
), ),
body: Center( body: Center(
@ -67,7 +72,8 @@ class _StockInNormalState extends State<StockInNormal> {
children: [ children: [
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _goodsCodeController, controller: _goodsCodeController,
title: "物料号:", hint: "请输入或扫描物料号", title: "物料号:",
hint: "请输入或扫描物料号",
isRequire: true, isRequire: true,
), ),
BrnStepInputFormItem( BrnStepInputFormItem(
@ -76,26 +82,40 @@ class _StockInNormalState extends State<StockInNormal> {
value: goodsNum, value: goodsNum,
maxLimit: 9999, maxLimit: 9999,
isRequire: true, isRequire: true,
canManualInput: true canManualInput: true,
), onChanged: (newValue, _) {
setState(() {
goodsNum = newValue;
});
}),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _orderNoController, controller: _listIdController,
title: "单据号:", hint: "请输入或扫描单据号", title: "单据号:",
hint: "请输入或扫描单据号",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _orderTypeController, controller: _orderTypeController,
title: "单据类型:", hint: "请输入或扫描单据类型", title: "单据类型:",
hint: "请输入或扫描单据类型",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _customerIdController, controller: _customerNameController,
title: "客户名称:", hint: "请输入或扫描客户名称", title: "客户名称:",
hint: "请输入或扫描客户名称",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _goodsDescController, controller: _goodsDescController,
title: "物料描述:", hint: "请输入或扫描物料描述", title: "物料描述:",
hint: "请输入或扫描物料描述",
isRequire: true,
),
BrnTextInputFormItem(
controller: _goodsUnitController,
title: "物料单位:",
hint: "请输入物料单位",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
@ -107,48 +127,48 @@ class _StockInNormalState extends State<StockInNormal> {
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _sizeController, controller: _sizeController,
title: "尺寸:", hint: "请输入或扫描尺寸", title: "尺寸:",
hint: "请输入或扫描尺寸",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _spare1Controller, controller: _spare1Controller,
title: "备用1", hint: "请输入", title: "备用1",
hint: "请输入",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _spare2Controller, controller: _spare2Controller,
title: "备用2", hint: "请输入", title: "备用2",
hint: "请输入",
isRequire: true, isRequire: true,
), ),
ElevatedButton( ElevatedButton(
onPressed: resolveCode, onPressed: resolveCode,
style: ButtonStyle( style: ButtonStyle(
backgroundColor: WidgetStateProperty.all( backgroundColor:
ColorCommon.colorScheme), WidgetStateProperty.all(ColorCommon.colorScheme),
), ),
child: const Text( child: const Text("添加物料",
"添加物料", style: TextStyle(color: Colors.white))),
style: TextStyle(color: Colors.white))
),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _containerNoController, controller: _vehicleTextController,
title: "容器号:", hint: "", title: "容器号:",
hint: "",
isRequire: true, isRequire: true,
), ),
Padding(padding: const EdgeInsets.only(top: 0), Padding(
padding: const EdgeInsets.only(top: 0),
child: ElevatedButton( child: ElevatedButton(
onPressed: wheelComplete, onPressed: wheelComplete,
style: ButtonStyle( style: ButtonStyle(
backgroundColor: WidgetStateProperty.all( backgroundColor:
ColorCommon.colorScheme), WidgetStateProperty.all(ColorCommon.colorScheme),
), ),
child: const Text( child: const Text("码盘完成",
"码盘完成", style: TextStyle(color: Colors.white)))),
style: TextStyle( const Padding(
color: Colors.white padding: EdgeInsets.only(top: 10, bottom: 10),
))
)),
const Padding(padding: EdgeInsets.only(top: 10, bottom: 10),
child: Text("添加在载具的物料:"), child: Text("添加在载具的物料:"),
), ),
StockInCardXuGong(stockInDataXuGong: stockInDataXuGong) StockInCardXuGong(stockInDataXuGong: stockInDataXuGong)
@ -162,54 +182,41 @@ class _StockInNormalState extends State<StockInNormal> {
void resolveCode() { void resolveCode() {
setState(() { setState(() {
stockInDataXuGong.add(StockInDataXuGong( stockInDataXuGong.add(StockInDataXuGong(
customerName: "yuqili", customerName: _customerNameController.text,
containerNo: "0", weight: double.parse(_weightController.text),
weight: 10, size: int.parse(_sizeController.text),
size: "55", unit: _goodsUnitController.text,
listId: uuidGen.v4(), listId: _listIdController.text,
goodsCode: "555", orderType: int.parse(_orderTypeController.text),
unit: "",
status: 0,
storageType: 0,
createPerson: "system",
remark: "test",
orderType: _orderTypeController.text,
goodsNum: goodsNum, goodsNum: goodsNum,
orderId: _orderNoController.text,
vehicleNo: "0",
goodsId: _goodsCodeController.text, goodsId: _goodsCodeController.text,
goodsDesc: _goodsDescController.text, goodsDesc: _goodsDescController.text,
customerId: _customerIdController.text,
recordId: uuidGen.v4(),
createTime: DateTime.now(),
updateTime: DateTime.now(),
spare1: _spare1Controller.text, spare1: _spare1Controller.text,
spare2: _spare2Controller.text)); spare2: _spare2Controller.text));
}); });
return; return;
} }
/// ///
void wheelComplete() { void wheelComplete() {
if (stockInDataXuGong.isEmpty) { if (stockInDataXuGong.isEmpty) {
DialogUtils.showWarningMessage( DialogUtils.showWarningMessage(context, "警告", "您的码盘数据为空", btnLabel: "确定");
context, "警告", "您的码盘数据为空", btnLabel: "确定");
return; return;
} }
String vehicleNo = "1"; String vehicleNo = _vehicleTextController.text;
int dataCount = stockInDataXuGong.length; int dataCount = stockInDataXuGong.length;
DialogUtils.showConfirmMessage( DialogUtils.showConfirmMessage(
context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?", context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?",
confirmBtn: "继续", confirm: () { confirmBtn: "继续", confirm: () {
int taskType = 1; // 1 2 int taskType = 1; // 1 2
BrnLoadingDialog.show(context, content: "正在请求入库"); BrnLoadingDialog.show(context, content: "正在请求入库");
StockInApi.stockInComplete(stockInDataXuGong).then((response) { StockInApi.stockInComplete(stockInDataXuGong, vehicleNo)
.then((response) {
if (response["code"] != 200) { if (response["code"] != 200) {
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showWarningMessage( DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败",
thisContext, "警告", "服务器请求失败", btnLabel: "我知道了"); btnLabel: "我知道了");
} }
return; return;
} }
@ -222,8 +229,8 @@ class _StockInNormalState extends State<StockInNormal> {
}); });
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showSuccessMessage( DialogUtils.showSuccessMessage(thisContext, "码盘成功", "",
thisContext, "码盘成功", "", btnLabel: "我知道了"); btnLabel: "我知道了");
} }
return; return;
} }
@ -237,8 +244,9 @@ class _StockInNormalState extends State<StockInNormal> {
}).catchError((err) { }).catchError((err) {
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showErrorMessage(thisContext, "请求发生错误", DialogUtils.showErrorMessage(
"请求服务器发生错误:${err.toString()}", btnLabel: "我知道了"); thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()}",
btnLabel: "我知道了");
} }
return; return;
}).whenComplete(() { }).whenComplete(() {
@ -252,56 +260,53 @@ class _StockInNormalState extends State<StockInNormal> {
/// ///
getEmptyVehicle() { getEmptyVehicle() {
DialogUtils.showConfirmMessage( DialogUtils.showConfirmMessage(context, "空载具出库", "出一个空载具?",
context, "空载具出库", "出一个空载具?", confirmBtn: "出一个", confirmBtn: "出一个", confirm: () {
confirm: () { BrnLoadingDialog.show(context, content: "正在请求,请稍后");
BrnLoadingDialog.show(context, content: "正在请求,请稍后"); StockOutApi.getEmptyVehicle().then((response) {
StockOutApi.getEmptyVehicle().then((response) { if (response["code"] != 200) {
if (response["code"] != 200) { var thisContext = context;
var thisContext = context; if (thisContext.mounted) {
if (thisContext.mounted) { DialogUtils.showWarningMessage(thisContext, "警告", "服务器请求失败",
DialogUtils.showWarningMessage( btnLabel: "我知道了");
thisContext, "警告", "服务器请求失败", }
btnLabel: "我知道了"); return;
} }
return; final data = Map<String, dynamic>.from(jsonDecode(response["data"]));
} if (data["code"] == 200) {
final data = Map<String, dynamic>.from( //
jsonDecode(response["data"])); setState(() {
if (data["code"] == 200) { _vehicleTextController.clear();
// stockInDataXuGong = [];
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);
}
}); });
}); 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);
}
});
});
} }
}
}