add stock_in_buy
This commit is contained in:
parent
dbb752f2a5
commit
f5f9a34c7a
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ColorCommon {
|
||||
static Color colorScheme = const Color(0xfffdbe5f); // 主题色
|
||||
static Color colorScheme = const Color.fromARGB(255, 100, 95, 253); // 主题色
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
/// 入库码盘数据
|
||||
class StockInDataXuGong {
|
||||
|
||||
/// 物料号
|
||||
String goodsId = "";
|
||||
|
||||
|
|
@ -25,6 +24,9 @@ class StockInDataXuGong {
|
|||
/// 尺寸
|
||||
String size = "";
|
||||
|
||||
/// 容器号
|
||||
String containerNo = "";
|
||||
|
||||
/// 备用1
|
||||
String spare1 = "";
|
||||
|
||||
|
|
@ -42,8 +44,6 @@ class StockInDataXuGong {
|
|||
required this.size,
|
||||
required this.spare1,
|
||||
required this.spare2,
|
||||
required this.containerNo,
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import '../../common/user/login_user.dart';
|
|||
import '/common/colorCom.dart';
|
||||
import 'package:bruno/bruno.dart';
|
||||
import 'package:wms_app/page/stockIn/stock_in_empty.dart';
|
||||
import 'package:wms_app/page/stockIn/stock_in_buy.dart';
|
||||
import 'package:wms_app/page/pick/pick.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
|
|
@ -53,7 +54,7 @@ class _HomePageState extends State<Home> {
|
|||
ListTile(
|
||||
title: const Text("采购有货入库"),
|
||||
trailing: const Icon(Icons.add_box),
|
||||
onTap: () {}),
|
||||
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const StockInBuy()));}),
|
||||
ListTile(
|
||||
title: const Text("其他物料入库"),
|
||||
trailing: const Icon(Icons.add_box),
|
||||
|
|
|
|||
281
lib/page/stockIn/stock_in_buy.dart
Normal file
281
lib/page/stockIn/stock_in_buy.dart
Normal file
|
|
@ -0,0 +1,281 @@
|
|||
import 'dart:convert';
|
||||
import 'package:bruno/bruno.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wms_app/api_client/stock_in.dart';
|
||||
import 'package:wms_app/model/bo/stock_in_data_xugong.dart';
|
||||
import '../../common/colorCom.dart';
|
||||
import '../../utils/dialogUtils.dart';
|
||||
|
||||
class StockInBuy extends StatefulWidget {
|
||||
const StockInBuy({super.key});
|
||||
|
||||
@override
|
||||
State<StockInBuy> createState() => _StockInBuyState();
|
||||
}
|
||||
|
||||
class _StockInBuyState extends State<StockInBuy> {
|
||||
List<StockInDataXuGong> stockInDataXuGong = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchOrderData();
|
||||
}
|
||||
|
||||
void _fetchOrderData() {
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
String orderNo = "order123";
|
||||
_fetchGoodsData(orderNo);
|
||||
});
|
||||
}
|
||||
|
||||
void _fetchGoodsData(String orderNo) {
|
||||
Future.delayed(Duration(seconds: 1), () {
|
||||
setState(() {
|
||||
stockInDataXuGong = [
|
||||
StockInDataXuGong(
|
||||
goodsId: "001",
|
||||
goodsNum: 5,
|
||||
orderNo: orderNo,
|
||||
orderType: "订购",
|
||||
customerName: "Customer A",
|
||||
goodsDesc: "Material 1 Description",
|
||||
weight: 20.0,
|
||||
size: "Small",
|
||||
spare1: "Spare1A",
|
||||
spare2: "Spare2A",
|
||||
containerNo: "Container123"),
|
||||
StockInDataXuGong(
|
||||
goodsId: "002",
|
||||
goodsNum: 10,
|
||||
orderNo: orderNo,
|
||||
orderType: "订购",
|
||||
customerName: "Customer B",
|
||||
goodsDesc: "Material 2 Description",
|
||||
weight: 15.5,
|
||||
size: "Medium",
|
||||
spare1: "Spare1B",
|
||||
spare2: "Spare2B",
|
||||
containerNo: "Container456"),
|
||||
];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@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: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: stockInDataXuGong.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = stockInDataXuGong[index];
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: ListTile(
|
||||
onTap: () => _editGood(item),
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(child: Text("物料号: ${item.goodsId}")),
|
||||
Expanded(child: Text("数量: ${item.goodsNum}")),
|
||||
Expanded(child: Text("描述: ${item.goodsDesc}")),
|
||||
Expanded(child: Text("重量: ${item.weight} KG")),
|
||||
Expanded(child: Text("尺寸: ${item.size}")),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
_addMaterial(item);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
_editGood(item);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: ElevatedButton(
|
||||
onPressed: _completeStockIn,
|
||||
child: const Text("码盘完成"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _editGood(StockInDataXuGong item) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EditGoodPage(item: item, onSave: _updateGood),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateGood(StockInDataXuGong updatedItem) {
|
||||
setState(() {
|
||||
final index =
|
||||
stockInDataXuGong.indexWhere((e) => e.goodsId == updatedItem.goodsId);
|
||||
if (index != -1) {
|
||||
stockInDataXuGong[index] = updatedItem;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _addMaterial(StockInDataXuGong item) {
|
||||
DialogUtils.showSuccessMessage(context, "添加物料成功", "", btnLabel: "我知道了");
|
||||
}
|
||||
|
||||
void _completeStockIn() {
|
||||
if (stockInDataXuGong.isEmpty) {
|
||||
DialogUtils.showWarningMessage(context, "警告", "您的码盘数据为空", btnLabel: "确定");
|
||||
return;
|
||||
}
|
||||
DialogUtils.showConfirmMessage(context, "码盘完成", "是否完成入库?", confirmBtn: "完成",
|
||||
confirm: () {
|
||||
BrnLoadingDialog.show(context, content: "正在请求入库");
|
||||
StockInApi.stockInComplete({
|
||||
"vehicleNo":
|
||||
"",
|
||||
"inArea": "1",
|
||||
"storageArea": "",
|
||||
"goods": stockInDataXuGong,
|
||||
}).then((response) {
|
||||
if (response["code"] != 200) {
|
||||
DialogUtils.showWarningMessage(context, "警告", "服务器请求失败",
|
||||
btnLabel: "我知道了");
|
||||
return;
|
||||
}
|
||||
final data = Map<String, dynamic>.from(jsonDecode(response["data"]));
|
||||
if (data["code"] == 200) {
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class EditGoodPage extends StatefulWidget {
|
||||
final StockInDataXuGong item;
|
||||
final Function(StockInDataXuGong) onSave;
|
||||
|
||||
const EditGoodPage({super.key, required this.item, required this.onSave});
|
||||
|
||||
@override
|
||||
_EditGoodPageState createState() => _EditGoodPageState();
|
||||
}
|
||||
|
||||
class _EditGoodPageState extends State<EditGoodPage> {
|
||||
late StockInDataXuGong _editedItem;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_editedItem = widget.item;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("编辑物料"),
|
||||
backgroundColor: ColorCommon.colorScheme,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildEditableField("物料号", _editedItem.goodsId,
|
||||
(value) => _editedItem.goodsId = value),
|
||||
_buildEditableField("数量", _editedItem.goodsNum.toString(),
|
||||
(value) => _editedItem.goodsNum = double.tryParse(value) ?? 0),
|
||||
_buildEditableField("单据号", _editedItem.orderNo,
|
||||
(value) => _editedItem.orderNo = value),
|
||||
_buildEditableField("单据类型", _editedItem.orderType,
|
||||
(value) => _editedItem.orderType = value),
|
||||
_buildEditableField("客户名称", _editedItem.customerName,
|
||||
(value) => _editedItem.customerName = value),
|
||||
_buildEditableField("描述", _editedItem.goodsDesc,
|
||||
(value) => _editedItem.goodsDesc = value),
|
||||
_buildEditableField("重量", _editedItem.weight.toString(),
|
||||
(value) => _editedItem.weight = double.tryParse(value) ?? 0.0),
|
||||
_buildEditableField(
|
||||
"尺寸", _editedItem.size, (value) => _editedItem.size = value),
|
||||
_buildEditableField("备用1", _editedItem.spare1,
|
||||
(value) => _editedItem.spare1 = value),
|
||||
_buildEditableField("备用2", _editedItem.spare2,
|
||||
(value) => _editedItem.spare2 = value),
|
||||
_buildEditableField("容器号", _editedItem.containerNo,
|
||||
(value) => _editedItem.containerNo = value),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
widget.onSave(_editedItem);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("保存修改"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEditableField(
|
||||
String title, String initialValue, Function(String) onChanged) {
|
||||
TextEditingController controller =
|
||||
TextEditingController(text: initialValue);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: title),
|
||||
onChanged: onChanged,
|
||||
keyboardType: TextInputType.text,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ class _StockInNormalState extends State<StockInNormal> {
|
|||
/// 解析条码
|
||||
void resolveCode() {
|
||||
setState(() {
|
||||
stockInDataXuGong.add(StockInDataXuGong(goodsId: "00", goodsNum: 1, orderNo: "orderNo", orderType: "orderType", customerName: "customerName", goodsDesc: "goodsDesc", weight: 11, size: "siz", spare1: "spare1", spare2: "spare2"));
|
||||
stockInDataXuGong.add(StockInDataXuGong(goodsId: "00", goodsNum: 1, orderNo: "orderNo", orderType: "orderType", customerName: "customerName", goodsDesc: "goodsDesc", weight: 11, size: "siz", containerNo: "containerNo", spare1: "spare1", spare2: "spare2"));
|
||||
});
|
||||
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user