add countAvailable flutter

This commit is contained in:
李宇奇 2025-02-23 20:39:20 +08:00
parent a719927536
commit 910670c0cd
5 changed files with 333 additions and 159 deletions

View File

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

View File

@ -0,0 +1,25 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'baseDio.dart';
import 'package:logger/logger.dart';
class MonitorApi {
static var logger = Logger(
printer: PrettyPrinter(),
);
static Future<dynamic> countAvailable({int timeOut = 5000}) async {
final response =
await BaseDio.instance().get<String>("/app/location/count",
options: Options(
responseType: ResponseType.json,
sendTimeout: Duration(milliseconds: timeOut),
receiveTimeout: Duration(milliseconds: timeOut),
));
logger.e("yuqili $response");
return {"code": response.statusCode, "data": response.data};
}
}

View File

@ -1,6 +1,10 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:wms_app/api_client/monitor.dart';
import 'package:wms_app/page/stockIn/stock_in_normal.dart'; import 'package:wms_app/page/stockIn/stock_in_normal.dart';
import '../../common/user/login_user.dart'; import '../../common/user/login_user.dart';
import '../../utils/dialogUtils.dart';
import '/common/colorCom.dart'; import '/common/colorCom.dart';
import 'package:bruno/bruno.dart'; import 'package:bruno/bruno.dart';
import 'package:wms_app/page/stockIn/stock_in_empty.dart'; import 'package:wms_app/page/stockIn/stock_in_empty.dart';
@ -11,12 +15,16 @@ import 'package:wms_app/page/pick/pick.dart';
class Home extends StatefulWidget { class Home extends StatefulWidget {
const Home({super.key}); const Home({super.key});
@override @override
State<Home> createState() => _HomePageState(); State<Home> createState() => _HomePageState();
} }
class _HomePageState extends State<Home> { class _HomePageState extends State<Home> {
var logger = Logger(
printer: PrettyPrinter(),
);
List<BrnDoughnutDataItem> stockChartsData = []; // List<BrnDoughnutDataItem> stockChartsData = []; //
int available = 0, all = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -52,15 +60,30 @@ class _HomePageState extends State<Home> {
ListTile( ListTile(
title: const Text("货位信息码盘"), title: const Text("货位信息码盘"),
trailing: const Icon(Icons.add_box), trailing: const Icon(Icons.add_box),
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const StockInNormal()));}), onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const StockInNormal()));
}),
ListTile( ListTile(
title: const Text("采购有货入库"), title: const Text("采购有货入库"),
trailing: const Icon(Icons.add_box), trailing: const Icon(Icons.add_box),
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const StockInBuy()));}), onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const StockInBuy()));
}),
ListTile( ListTile(
title: const Text("其他物料入库"), title: const Text("其他物料入库"),
trailing: const Icon(Icons.add_box), trailing: const Icon(Icons.add_box),
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const StockInNormal()));}), onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const StockInNormal()));
}),
ListTile( ListTile(
title: const Text("生产配盘入库"), title: const Text("生产配盘入库"),
trailing: const Icon(Icons.add_box), trailing: const Icon(Icons.add_box),
@ -68,7 +91,12 @@ class _HomePageState extends State<Home> {
ListTile( ListTile(
title: const Text("呼叫空托"), title: const Text("呼叫空托"),
trailing: const Icon(Icons.ac_unit), trailing: const Icon(Icons.ac_unit),
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const StockOutEmpty()));}), onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const StockOutEmpty()));
}),
ListTile( ListTile(
title: const Text("出库拣货"), title: const Text("出库拣货"),
trailing: const Icon(Icons.back_hand), trailing: const Icon(Icons.back_hand),
@ -79,7 +107,12 @@ class _HomePageState extends State<Home> {
ListTile( ListTile(
title: const Text("物料盘点"), title: const Text("物料盘点"),
trailing: const Icon(Icons.checklist), trailing: const Icon(Icons.checklist),
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const InventoryCheckPage()));}), onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const InventoryCheckPage()));
}),
], ],
), ),
), ),
@ -107,17 +140,49 @@ class _HomePageState extends State<Home> {
]))); ])));
} }
count() async {
BrnLoadingDialog.show(context); //
MonitorApi.countAvailable().then((response) {
if (response["code"] != 200) {
DialogUtils.showWarningMessage(context, "警告", "服务器请求失败",
btnLabel: "我知道了");
return;
}
final data = jsonDecode(response["data"]);
if (response["code"] == 200) {
setState(() {
available = data["data"]["available_count"];
all = data["data"]["total_count"];
stockChartsData = [
BrnDoughnutDataItem(value: available * 1.0, title: "空闲", color: Colors.green),
BrnDoughnutDataItem(value: (all - available) * 1.0, title: "占用", color: Colors.orange)
];
});
DialogUtils.showSuccessMessage(context, "计数成功", "", btnLabel: "我知道了");
} else {
DialogUtils.showWarningMessage(
context, "警告", "服务器返回失败:${response["message"]}",
btnLabel: "我知道了");
}
}).catchError((err) {
DialogUtils.showErrorMessage(
context, "请求发生错误", "请求服务器发生错误:${err.toString()}",
btnLabel: "我知道了");
}).whenComplete(() {
BrnLoadingDialog.dismiss(context); //
});
}
/// ///
refreshData() {} refreshData() {
count();
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
setState(() { count(); // count方法
stockChartsData = [
BrnDoughnutDataItem(value: 40, title: "空闲", color: Colors.green),
BrnDoughnutDataItem(value: 60, title: "占用", color: Colors.orange)
];
});
} }
} }

View File

@ -10,13 +10,13 @@ import 'package:wms_app/utils/dialogUtils.dart';
class StockInWheelEBS extends StatefulWidget { class StockInWheelEBS extends StatefulWidget {
const StockInWheelEBS({super.key}); const StockInWheelEBS({super.key});
@override @override
State<StockInWheelEBS> createState() => _StockInWheelEBSPageState(); State<StockInWheelEBS> createState() => _StockInWheelEBSPageState();
} }
/// EBS码盘入库 /// EBS码盘入库
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<dynamic> packageData = []; //
@ -31,12 +31,12 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
iconTheme: const IconThemeData( iconTheme: const IconThemeData(color: Colors.white),
color: Colors.white leading: IconButton(
), onPressed: () {
leading: IconButton(onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, icon: const Icon(Icons.arrow_back)), },
icon: const Icon(Icons.arrow_back)),
centerTitle: true, centerTitle: true,
backgroundColor: ColorCommon.colorScheme, backgroundColor: ColorCommon.colorScheme,
title: const Text( title: const Text(
@ -45,49 +45,50 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
), ),
), ),
body: Center( body: Center(
child: Padding(padding: const EdgeInsets.only(top: 5, left: 10, right: 10), child: Padding(
padding: const EdgeInsets.only(top: 5, left: 10, right: 10),
child: ListView( child: ListView(
children: [ children: [
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _vehicleTextController, controller: _vehicleTextController,
title: "载具号:", hint: "请扫描或输入", title: "载具号:",
hint: "请扫描或输入",
isRequire: true, isRequire: true,
), ),
BrnTextInputFormItem( BrnTextInputFormItem(
controller: _goodsCodeController, controller: _goodsCodeController,
title: "条码:", hint: "请扫描物料二维码", title: "条码:",
hint: "请扫描物料二维码",
isRequire: true, isRequire: true,
), ),
Padding(padding: const EdgeInsets.only( Padding(
top: 5 padding: const EdgeInsets.only(top: 5),
), child: ElevatedButton( child: ElevatedButton(
onPressed: resolveCode, onPressed: resolveCode,
style: ButtonStyle( style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(ColorCommon.colorScheme), backgroundColor:
WidgetStateProperty.all(ColorCommon.colorScheme),
), ),
child: const Text( child: const Text("添加物料",
"添加物料", style: TextStyle(color: Colors.white)))),
style: TextStyle( Padding(
color: Colors.white 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(ColorCommon.colorScheme), backgroundColor:
WidgetStateProperty.all(ColorCommon.colorScheme),
), ),
child: const Text("码盘完成", child: const Text("码盘完成",
style: TextStyle( style: TextStyle(color: Colors.white)))),
color: Colors.white const Padding(
)) padding: EdgeInsets.only(top: 10, bottom: 10),
)),
const Padding(padding: EdgeInsets.only(top: 10, bottom: 10),
child: Text("已码物料:"), child: Text("已码物料:"),
), ),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: const Color(0x4D0C0C05), width: 0.3),// border border: Border.all(
color: const Color(0x4D0C0C05), width: 0.3), // border
borderRadius: BorderRadius.circular((5)), // borderRadius: BorderRadius.circular((5)), //
), ),
child: TDTable( child: TDTable(
@ -102,23 +103,100 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
align: TDTableColAlign.center, align: TDTableColAlign.center,
cellBuilder: (BuildContext context) { cellBuilder: (BuildContext context) {
return const SizedBox( return const SizedBox(
child: Icon(TDIcons.delete, color: Colors.redAccent, size: 10), child: Icon(TDIcons.delete,
color: Colors.redAccent, size: 10),
); );
}, },
), ),
TDTableCol(title: '序号', colKey: 'id', align: TDTableColAlign.center, width: 80), TDTableCol(
TDTableCol(title: '采购单号', colKey: 'segment1', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), title: '序号',
TDTableCol(title: '物料号', colKey: 'itemId', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), colKey: 'id',
TDTableCol(title: '批次号', colKey: 'batch', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), align: TDTableColAlign.center,
TDTableCol(title: '数量', colKey: 'quantity', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), width: 80),
TDTableCol(title: '重量', colKey: 'weight', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), TDTableCol(
TDTableCol(title: '生产日期', colKey: 'productData', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), title: '采购单号',
TDTableCol(title: '送货单号', colKey: 'sendOrderId', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), colKey: 'segment1',
TDTableCol(title: '物料描述', colKey: 'goodsName', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), align: TDTableColAlign.center,
TDTableCol(title: '单位', colKey: 'unit', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), ellipsis: true,
TDTableCol(title: '订单头主键', colKey: 'poHeaderId', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), ellipsisTitle: true,
TDTableCol(title: '订单行主键', colKey: 'poLineId', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), width: 100),
TDTableCol(title: '发运行主键', colKey: 'lineLocationId', align: TDTableColAlign.center, ellipsis: true, ellipsisTitle: true, width: 100), TDTableCol(
title: '物料号',
colKey: 'itemId',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '批次号',
colKey: 'batch',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '数量',
colKey: 'quantity',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '重量',
colKey: 'weight',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '生产日期',
colKey: 'productData',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '送货单号',
colKey: 'sendOrderId',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '物料描述',
colKey: 'goodsName',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '单位',
colKey: 'unit',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '订单头主键',
colKey: 'poHeaderId',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '订单行主键',
colKey: 'poLineId',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
TDTableCol(
title: '发运行主键',
colKey: 'lineLocationId',
align: TDTableColAlign.center,
ellipsis: true,
ellipsisTitle: true,
width: 100),
], ],
data: packageData, data: packageData,
onCellTap: (index, dynamic, cell) { onCellTap: (index, dynamic, cell) {
@ -133,11 +211,13 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
/// ///
void clickLine(index, dynamic, cell) { void clickLine(index, dynamic, cell) {
if(cell.colKey == "action") { // if (cell.colKey == "action") {
//
delete(dynamic); delete(dynamic);
return; return;
} }
if(cell.colKey == "quantity") { // if (cell.colKey == "quantity") {
//
modifyNumber(index, dynamic); modifyNumber(index, dynamic);
return; return;
} }
@ -168,7 +248,8 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
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;
} }
@ -198,13 +279,17 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
} }
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showWarningMessage(thisContext, "数据异常", "服务器返回错误:${data["message"]} ", btnLabel: "我知道了"); DialogUtils.showWarningMessage(
thisContext, "数据异常", "服务器返回错误:${data["message"]} ",
btnLabel: "我知道了");
} }
return; return;
}).catchError((err) { }).catchError((err) {
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showErrorMessage(thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()} ", btnLabel: "我知道了"); DialogUtils.showErrorMessage(
thisContext, "请求发生错误", "请求服务器发生错误:${err.toString()} ",
btnLabel: "我知道了");
} }
return; return;
}).whenComplete(() { }).whenComplete(() {
@ -229,13 +314,15 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
/// ///
void modifyNumber(index, dynamic) { void modifyNumber(index, dynamic) {
DialogUtils.showInputMessage(context, "请输入要修改的数量", message: "仅支持数字", confirm: (value) { DialogUtils.showInputMessage(context, "请输入要修改的数量", message: "仅支持数字",
confirm: (value) {
if (!StringUtils.isNumber(value)) { if (!StringUtils.isNumber(value)) {
DialogUtils.showWarningMessage(context, "警告", "该文本框仅支持数字"); DialogUtils.showWarningMessage(context, "警告", "该文本框仅支持数字");
return; return;
} }
setState(() { setState(() {
packageData.where((w)=>w["id"] == dynamic["id"]).first["quantity"] = value; packageData.where((w) => w["id"] == dynamic["id"]).first["quantity"] =
value;
}); });
}); });
} }
@ -255,7 +342,8 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
message.add({"label": "单位:", "msg": tableRow["unit"].toString()}); message.add({"label": "单位:", "msg": tableRow["unit"].toString()});
message.add({"label": "订单头主键:", "msg": tableRow["poHeaderId"].toString()}); message.add({"label": "订单头主键:", "msg": tableRow["poHeaderId"].toString()});
message.add({"label": "订单行主键:", "msg": tableRow["poLineId"].toString()}); message.add({"label": "订单行主键:", "msg": tableRow["poLineId"].toString()});
message.add({"label":"发运行主键:", "msg":tableRow["lineLocationId"].toString()}); message
.add({"label": "发运行主键:", "msg": tableRow["lineLocationId"].toString()});
DialogUtils.showMessageList(context, "数据详情", message, btnLabel: "我知道了"); DialogUtils.showMessageList(context, "数据详情", message, btnLabel: "我知道了");
} }
@ -267,25 +355,22 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
} }
String vehicleNo = _vehicleTextController.text; String vehicleNo = _vehicleTextController.text;
if (StringUtils.isEmpty(vehicleNo)) { if (StringUtils.isEmpty(vehicleNo)) {
DialogUtils.showWarningMessage(context, "警告", "请先扫描载具号", btnLabel: "返回填写"); DialogUtils.showWarningMessage(context, "警告", "请先扫描载具号",
btnLabel: "返回填写");
return; return;
} }
int dataCount = packageData.length; int dataCount = packageData.length;
DialogUtils.showConfirmMessage(context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?", confirmBtn: "继续", confirm: () DialogUtils.showConfirmMessage(
{ context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?",
confirmBtn: "继续", confirm: () {
int taskType = 1; // 1 2 int taskType = 1; // 1 2
BrnLoadingDialog.show(context, content: "正在请求入库"); BrnLoadingDialog.show(context, content: "正在请求入库");
StockInApi.stockInComplete({ StockInApi.stockInComplete(packageData).then((response) {
"vehicleNo": vehicleNo,
"inArea": taskType.toString(),
"storageArea" : "",
"goods": packageData
}).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;
} }
@ -298,8 +383,8 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
}); });
var thisContext = context; var thisContext = context;
if (thisContext.mounted) { if (thisContext.mounted) {
DialogUtils.showSuccessMessage( DialogUtils.showSuccessMessage(thisContext, "码盘成功", "",
thisContext, "码盘成功", "", btnLabel: "我知道了"); btnLabel: "我知道了");
} }
return; return;
} }
@ -313,8 +398,9 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
}).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(() {
@ -325,5 +411,4 @@ class _StockInWheelEBSPageState extends State<StockInWheelEBS> {
}); });
}); });
} }
} }

View File

@ -281,7 +281,7 @@ packages:
source: hosted source: hosted
version: "0.2.1+1" version: "0.2.1+1"
intl: intl:
dependency: transitive dependency: "direct main"
description: description:
name: intl name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"