2025-02-23 20:39:20 +08:00
|
|
|
|
import 'dart:convert';
|
2025-02-19 18:52:05 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2025-02-23 20:39:20 +08:00
|
|
|
|
import 'package:logger/logger.dart';
|
|
|
|
|
|
import 'package:wms_app/api_client/monitor.dart';
|
2025-02-19 18:52:05 +08:00
|
|
|
|
import 'package:wms_app/page/stockIn/stock_in_normal.dart';
|
|
|
|
|
|
import '../../common/user/login_user.dart';
|
2025-02-23 20:39:20 +08:00
|
|
|
|
import '../../utils/dialogUtils.dart';
|
2025-02-19 18:52:05 +08:00
|
|
|
|
import '/common/colorCom.dart';
|
|
|
|
|
|
import 'package:bruno/bruno.dart';
|
|
|
|
|
|
import 'package:wms_app/page/stockIn/stock_in_empty.dart';
|
2025-02-20 13:23:50 +08:00
|
|
|
|
import 'package:wms_app/page/stockIn/stock_in_buy.dart';
|
2025-02-20 13:48:18 +08:00
|
|
|
|
import 'package:wms_app/page/stockOut/stock_out_empty.dart';
|
2025-02-20 14:10:16 +08:00
|
|
|
|
import 'package:wms_app/page/stock/check.dart';
|
2025-02-19 18:52:05 +08:00
|
|
|
|
import 'package:wms_app/page/pick/pick.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class Home extends StatefulWidget {
|
|
|
|
|
|
const Home({super.key});
|
2025-02-23 20:39:20 +08:00
|
|
|
|
|
2025-02-19 18:52:05 +08:00
|
|
|
|
@override
|
|
|
|
|
|
State<Home> createState() => _HomePageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
class _HomePageState extends State<Home> {
|
2025-02-23 20:39:20 +08:00
|
|
|
|
var logger = Logger(
|
|
|
|
|
|
printer: PrettyPrinter(),
|
|
|
|
|
|
);
|
2025-02-19 18:52:05 +08:00
|
|
|
|
List<BrnDoughnutDataItem> stockChartsData = []; // 库存占用情况
|
2025-02-23 20:39:20 +08:00
|
|
|
|
int available = 0, all = 0;
|
2025-02-19 18:52:05 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
|
iconTheme: const IconThemeData(color: Colors.white),
|
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
|
backgroundColor: ColorCommon.colorScheme,
|
|
|
|
|
|
title: const Text("WMS移动终端(徐工料箱库)",
|
|
|
|
|
|
style: TextStyle(color: Colors.white)),
|
|
|
|
|
|
actions: [
|
|
|
|
|
|
IconButton(onPressed: refreshData, icon: const Icon(Icons.refresh))
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
drawer: Drawer(
|
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
|
child: ListView(
|
|
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
|
|
children: [
|
|
|
|
|
|
UserAccountsDrawerHeader(
|
|
|
|
|
|
accountName: Text(LoginUser.userName),
|
|
|
|
|
|
accountEmail: const Text("欢迎使用WMS移动终端"),
|
|
|
|
|
|
decoration: BoxDecoration(color: ColorCommon.colorScheme)),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("空料箱入库"),
|
|
|
|
|
|
trailing: const Icon(Icons.grain),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const StockInEmpty()));
|
|
|
|
|
|
}),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("货位信息码盘"),
|
|
|
|
|
|
trailing: const Icon(Icons.add_box),
|
2025-02-23 20:39:20 +08:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const StockInNormal()));
|
|
|
|
|
|
}),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("采购有货入库"),
|
|
|
|
|
|
trailing: const Icon(Icons.add_box),
|
2025-02-23 20:39:20 +08:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const StockInBuy()));
|
|
|
|
|
|
}),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("其他物料入库"),
|
|
|
|
|
|
trailing: const Icon(Icons.add_box),
|
2025-02-23 20:39:20 +08:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const StockInNormal()));
|
|
|
|
|
|
}),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("生产配盘入库"),
|
|
|
|
|
|
trailing: const Icon(Icons.add_box),
|
|
|
|
|
|
onTap: () {}),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("呼叫空托"),
|
|
|
|
|
|
trailing: const Icon(Icons.ac_unit),
|
2025-02-23 20:39:20 +08:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const StockOutEmpty()));
|
|
|
|
|
|
}),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("出库拣货"),
|
|
|
|
|
|
trailing: const Icon(Icons.back_hand),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(context,
|
|
|
|
|
|
MaterialPageRoute(builder: (context) => const Pick()));
|
|
|
|
|
|
}),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
title: const Text("物料盘点"),
|
|
|
|
|
|
trailing: const Icon(Icons.checklist),
|
2025-02-23 20:39:20 +08:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => const InventoryCheckPage()));
|
|
|
|
|
|
}),
|
2025-02-19 18:52:05 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
body: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(top: 10, left: 20, right: 20),
|
|
|
|
|
|
child: ListView(children: [
|
|
|
|
|
|
const Text("库存占用情况:"),
|
|
|
|
|
|
Row(children: [
|
|
|
|
|
|
Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
BrnDoughnutChart(
|
|
|
|
|
|
padding: const EdgeInsets.all(50),
|
|
|
|
|
|
width: 150,
|
|
|
|
|
|
height: 150,
|
|
|
|
|
|
data: stockChartsData,
|
|
|
|
|
|
showTitleWhenSelected: false),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Column(children: [
|
|
|
|
|
|
DoughnutChartLegend(
|
|
|
|
|
|
data: stockChartsData,
|
|
|
|
|
|
legendStyle: BrnDoughnutChartLegendStyle.list),
|
|
|
|
|
|
])
|
|
|
|
|
|
])
|
|
|
|
|
|
])));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-23 20:39:20 +08:00
|
|
|
|
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); // 隐藏加载动画
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-19 18:52:05 +08:00
|
|
|
|
/// 刷新界面数据
|
2025-02-23 20:39:20 +08:00
|
|
|
|
refreshData() {
|
|
|
|
|
|
count();
|
|
|
|
|
|
}
|
2025-02-19 18:52:05 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
2025-02-23 20:39:20 +08:00
|
|
|
|
count(); // 在初始化时调用count方法,加载数据并显示缓冲动画
|
2025-02-19 18:52:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-23 20:39:20 +08:00
|
|
|
|
|