update cartion editor

This commit is contained in:
tzw
2024-02-09 17:40:51 +06:30
parent edf89935a0
commit 95b07c22bb
6 changed files with 55 additions and 33 deletions

View File

@@ -36,8 +36,9 @@ class Carton {
String? mixCartonNumber;
String? cartonSizeID;
String? cartonSizeName;
String? deliveryType;
String? cartonSizeType;
String? cartonStandardSize;
double cartonWeight;
String? billTo;
bool isSelected;
@@ -51,7 +52,6 @@ class Carton {
String? remark;
DateTime? arrivedDate;
String? cartonNumber;
String? deliveryCarton;
List<String> packageIDs;
List<Package> packages;
@@ -163,8 +163,7 @@ class Carton {
this.cartonSizeID,
this.cartonSizeName,
this.cartonSizeType,
this.cartonStandardSize,
this.deliveryCarton,
this.deliveryType,
this.mixBoxType,
this.mixCartons = const [],
this.mixCartonIDs = const [],

View File

@@ -17,6 +17,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../domain/entities/carton_size.dart';
import '../widgets/local_button.dart';
import 'carton_package_editor.dart';
import 'mix_carton/mix_carton_editor.dart';
@@ -42,6 +43,7 @@ class _CartonInfoState extends State<CartonInfo> {
List<Package> _packages = [];
double totalWeight = 0.0;
double totalSurchargeCount = 0.0;
CartonSize? standardSize;
@override
void initState() {
@@ -51,13 +53,14 @@ class _CartonInfoState extends State<CartonInfo> {
}
_init() async {
_carton.billTo = billToSender;
_carton.cartonSizeType=standardCarton;
_carton.billTo = billToConsignee;
_carton.cartonSizeType = customCarton;
_carton.cartonType = carton_from_packages;
multiImgController.setImageUrls = _carton.photos;
_cargoTypes = _carton.cargoTypes.where((e) => !e.isCutomDuty).toList();
_surchareItems = _carton.cargoTypes.where((e) => e.isCutomDuty).toList();
if (_carton.cartonType == carton_from_packages) {
_carton.deliveryType = delivery_caton;
_packages = await context
.read<PackageModel>()
.getPackagesByIds(_carton.packageIDs);
@@ -81,7 +84,11 @@ class _CartonInfoState extends State<CartonInfo> {
@override
Widget build(BuildContext context) {
String? boxDimension = _carton.cartonSizeType == standardCarton
? "${standardSize?.name} - ${standardSize?.length.toInt()}”x${standardSize?.width.toInt()}”x${standardSize?.height.toInt()}"
: _carton.cartonSizeType == customCarton
? "${_carton.length.toInt()}”x${_carton.width.toInt()}”x${_carton.height.toInt()}"
: null;
final cartonTypeBox = DisplayText(
text: _carton.cartonNumber,
@@ -90,8 +97,10 @@ class _CartonInfoState extends State<CartonInfo> {
final cartonQrBox = DisplayText(iconData: AntDesign.qrcode);
final cartonSubTypeBox = DisplayText(
text: _carton.cartonType==carton_from_packages ? "Carton for packages":"Mix carton",
subText:Text( "${_carton.cartonStandardSize}"),
text: _carton.cartonType == carton_from_packages
? "Carton for packages"
: "Mix carton",
subText: boxDimension == null ? null : Text("$boxDimension"),
labelTextKey: "box.carton.type",
);
@@ -101,7 +110,7 @@ class _CartonInfoState extends State<CartonInfo> {
);
final deliveryBox = DisplayText(
text: _carton.deliveryCarton,
text: _carton.deliveryType,
labelTextKey: "box.delivery_type",
);
@@ -183,7 +192,6 @@ class _CartonInfoState extends State<CartonInfo> {
style: TextStyle(color: Colors.black54, fontSize: 15)))
],
),
//),
Container(
child: Padding(
padding: const EdgeInsets.only(right: 100),
@@ -346,20 +354,21 @@ class _CartonInfoState extends State<CartonInfo> {
child: cartonQrBox,
),
]),
Row(children: [Flexible(child: cartonSubTypeBox),],),
Row(
children: [
Flexible(child: cartonSubTypeBox),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: shipmentBox),
_mixCartons.isEmpty
?
Flexible(child: deliveryBox):const SizedBox(),
? Flexible(child: deliveryBox)
: const SizedBox(),
],
),
_mixCartons.isEmpty
?
userRowBox:
const SizedBox(),
_mixCartons.isEmpty ? userRowBox : const SizedBox(),
_packages.isEmpty
? const SizedBox()
: Padding(

View File

@@ -16,6 +16,7 @@ import '../../domain/entities/package.dart';
import '../../domain/entities/user.dart';
import '../fcs_shipment/model/fcs_shipment_model.dart';
import '../main/util.dart';
import '../package/model/package_model.dart';
import '../widgets/local_text.dart';
import '../widgets/progress.dart';
import '../widgets/step_widget.dart';
@@ -70,6 +71,7 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
}
_init() async {
context.read<PackageSelectionModel>().clearSelection();
_sender = User(
name: widget.carton.senderName,
fcsID: widget.carton.senderFCSID,
@@ -81,18 +83,23 @@ class _CartonPackageEditorState extends State<CartonPackageEditor> {
fcsID: widget.carton.fcsID);
_billToValue = widget.carton.billTo ?? billToSender;
_selectedDeliveryType = delivery_caton;
_cartonSizeType = customCarton;
_selectedDeliveryType = widget.carton.deliveryType ?? delivery_caton;
_cartonSizeType = widget.carton.cartonSizeType ?? customCarton;
_length = widget.carton.length;
_width = widget.carton.width;
_height = widget.carton.height;
_cargoTypes = widget.carton.cargoTypes.where((e) => !e.isCutomDuty).toList();
_surchareItems = widget.carton.cargoTypes.where((e) => e.isCutomDuty).toList();
var s = await context
.read<FcsShipmentModel>()
.getFcsShipment(widget.carton.fcsShipmentID ?? "");
_shipment = s;
context.read<PackageSelectionModel>().clearSelection();
_packages = await context
.read<PackageModel>()
.getPackagesByIds(widget.carton.packageIDs);
if (mounted) {
setState(() {});
}

View File

@@ -144,4 +144,5 @@ class CartonSelectionModel extends BaseModel {
cartons.clear();
query = "";
}
}

View File

@@ -102,6 +102,10 @@ class PackageSelectionModel extends BaseModel {
}
}
addSelectedPackage(List<Package> list){
selectedPackageList = list;
}
Future<void> _refresh(
{required String shipmentId,
required String senderId,

View File

@@ -60,6 +60,8 @@ class _PackageSelectionWidgetState extends State<PackageSelectionWidget> {
consigneeId: widget.consignee.id!,
senderId: widget.sender.id!);
searchModel.addSelectedPackage(widget.packages);
_controller.text = searchModel.query;
_query = searchModel.query;
if (mounted) {