263 lines
9.3 KiB
Dart
263 lines
9.3 KiB
Dart
|
|
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/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> {
|
|||
|
|
|
|||
|
|
final _vehicleTextController = TextEditingController(); // 载具号输入框
|
|||
|
|
final _goodsCodeController = TextEditingController(); // 条码输入框
|
|||
|
|
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: [
|
|||
|
|
TextButton(onPressed: (){}, style: const ButtonStyle(foregroundColor: WidgetStatePropertyAll(Colors.white)), child: const Text("清空"),)
|
|||
|
|
],
|
|||
|
|
),
|
|||
|
|
body: Center(
|
|||
|
|
child: Padding(padding: const EdgeInsets.only(top: 5, left: 10, right: 10),
|
|||
|
|
child: ListView(
|
|||
|
|
children: [
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "物料号:", hint: "请输入或扫描物料号",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnStepInputFormItem(
|
|||
|
|
title: "物料数量:",
|
|||
|
|
minLimit: 1,
|
|||
|
|
value: goodsNum,
|
|||
|
|
maxLimit: 9999,
|
|||
|
|
isRequire: true,
|
|||
|
|
canManualInput: true
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "单据号:", hint: "请输入或扫描单据号",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "单据类型:", hint: "请输入或扫描单据类型",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "客户名称:", hint: "请输入或扫描客户名称",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "物料描述:", hint: "请输入或扫描物料描述",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "重量:", hint: "仅支持数字(保留小数点四位)",
|
|||
|
|
isRequire: true,
|
|||
|
|
unit: "KG",
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "尺寸:", hint: "请输入或扫描尺寸",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
title: "备用1:", hint: "请输入",
|
|||
|
|
isRequire: true,
|
|||
|
|
),
|
|||
|
|
BrnTextInputFormItem(
|
|||
|
|
controller: _goodsCodeController,
|
|||
|
|
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: _goodsCodeController,
|
|||
|
|
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)
|
|||
|
|
],
|
|||
|
|
)),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// 解析条码
|
|||
|
|
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"));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// 码盘完成
|
|||
|
|
void wheelComplete() {
|
|||
|
|
if(stockInDataXuGong.isEmpty){
|
|||
|
|
DialogUtils.showWarningMessage(context, "警告", "您的码盘数据为空", btnLabel: "确定");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
String vehicleNo = "";
|
|||
|
|
int dataCount = stockInDataXuGong.length;
|
|||
|
|
DialogUtils.showConfirmMessage(context, "码盘完成", "载具:$vehicleNo 码盘 $dataCount 条数据,是否继续?", confirmBtn: "继续", confirm: () {
|
|||
|
|
int taskType = 1; // 1 表示进库,2 表示进站台
|
|||
|
|
BrnLoadingDialog.show(context, content: "正在请求入库");
|
|||
|
|
StockInApi.stockInComplete({
|
|||
|
|
"vehicleNo": vehicleNo,
|
|||
|
|
"inArea": taskType.toString(),
|
|||
|
|
"storageArea" : "",
|
|||
|
|
"goods": stockInDataXuGong
|
|||
|
|
}).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);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// 出一个空空箱
|
|||
|
|
getEmptyVehicle() {
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|