fix carton
This commit is contained in:
@@ -98,10 +98,16 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_selectedCartonType = _carton.cartonType;
|
||||
_cargoTypes = List.from(_carton.cargoTypes);
|
||||
_isNew = false;
|
||||
_user = User(fcsID: _carton.fcsID, name: _carton.userName);
|
||||
consignee =
|
||||
User(fcsID: _carton.receiverFCSID, name: _carton.receiverName);
|
||||
sender = User(fcsID: _carton.senderID, name: _carton.senderName);
|
||||
_user = User(
|
||||
id: _carton.userID, fcsID: _carton.fcsID, name: _carton.userName);
|
||||
consignee = User(
|
||||
id: _carton.receiverID,
|
||||
fcsID: _carton.receiverFCSID,
|
||||
name: _carton.receiverName);
|
||||
sender = User(
|
||||
id: _carton.senderID,
|
||||
fcsID: _carton.senderID,
|
||||
name: _carton.senderName);
|
||||
_selectedMixBoxType = _carton.mixBoxType ?? "";
|
||||
this._mixCartons =
|
||||
_carton.mixCartons == null ? [] : List.from(_carton.mixCartons);
|
||||
@@ -268,13 +274,12 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
_isNew
|
||||
? IconButton(
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () =>
|
||||
searchUser(context, callbackUserSelect: (u) {
|
||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
this._user = u;
|
||||
_loadPackages();
|
||||
});
|
||||
}))
|
||||
}, popPage: true))
|
||||
: Container(),
|
||||
],
|
||||
));
|
||||
@@ -356,6 +361,36 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
),
|
||||
);
|
||||
|
||||
final mixTypeDisplayBox = Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: LocalText(
|
||||
context,
|
||||
"box.mix_type",
|
||||
color: primaryColor,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
)),
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
Icons.check,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
Text(_selectedMixBoxType ?? "")
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
final mixcartonTitleBox = Container(
|
||||
child: LocalTitle(
|
||||
textKey: "box.mix_caton_title",
|
||||
@@ -427,7 +462,7 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
);
|
||||
|
||||
final createMixCarton = LocalButton(
|
||||
textKey: _isNew ? "box.mix_carton_btn" : "box.cargo.save.btn",
|
||||
textKey: _isNew ? "box.mix_carton_btn" : "btn.save",
|
||||
callBack: _creatMixCarton,
|
||||
);
|
||||
|
||||
@@ -441,11 +476,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
this.consignee = u;
|
||||
});
|
||||
})),
|
||||
}, popPage: true)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -475,11 +510,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search, color: primaryColor),
|
||||
onPressed: () => searchUser(context, callbackUserSelect: (u) {
|
||||
onPressed: () => searchUser(context, onUserSelect: (u) {
|
||||
setState(() {
|
||||
this.sender = u;
|
||||
});
|
||||
})),
|
||||
}, popPage: true)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -537,7 +572,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
cartonTypeBox,
|
||||
LocalTitle(textKey: "box.shipment_info"),
|
||||
_isNew ? fcsShipmentsBox : shipmentBox,
|
||||
isMixBox ? mixTypeBox : Container(),
|
||||
isMixBox
|
||||
? _isNew
|
||||
? mixTypeBox
|
||||
: mixTypeDisplayBox
|
||||
: Container(),
|
||||
...(isMixBox
|
||||
? [
|
||||
mixcartonTitleBox,
|
||||
@@ -647,8 +686,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Carton _c = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
PackageCartonEditor(carton: c.value, isNew: false)),
|
||||
builder: (context) => PackageCartonEditor(
|
||||
carton: c.value,
|
||||
isNew: false,
|
||||
consignee: _user,
|
||||
)),
|
||||
);
|
||||
if (_c == null) return;
|
||||
cartons.removeWhere((item) => item.id == _c.id);
|
||||
@@ -826,8 +868,11 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
Carton _c = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
PackageCartonEditor(carton: carton, isNew: _isNew)),
|
||||
builder: (context) => PackageCartonEditor(
|
||||
carton: carton,
|
||||
isNew: _isNew,
|
||||
consignee: _user,
|
||||
)),
|
||||
);
|
||||
if (_c == null) return;
|
||||
var cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
@@ -882,9 +927,9 @@ class _CartonEditorState extends State<CartonEditor> {
|
||||
CartonModel cartonModel =
|
||||
Provider.of<CartonModel>(context, listen: false);
|
||||
if (_isNew) {
|
||||
await cartonModel.createMixCarton(carton);
|
||||
await cartonModel.createCarton(carton);
|
||||
} else {
|
||||
await cartonModel.updateMixCarton(carton);
|
||||
await cartonModel.updateCarton(carton);
|
||||
}
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
|
||||
@@ -51,7 +51,6 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
double volumetricRatio = 0;
|
||||
double shipmentWeight = 0;
|
||||
String selectMixBoxType;
|
||||
List<Carton> _mixCartons = [];
|
||||
|
||||
bool isMixBox;
|
||||
bool isFromShipments;
|
||||
@@ -76,6 +75,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
|
||||
_updateBoxData();
|
||||
_loadPackages();
|
||||
_loadMixCartons();
|
||||
}
|
||||
|
||||
_updateBoxData() {
|
||||
@@ -93,7 +93,6 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
isEdiable = (isFromPackages || isMixBox || isFromCartons) &&
|
||||
_box.status == carton_packed_status;
|
||||
selectMixBoxType = _box.mixBoxType ?? "";
|
||||
_mixCartons = _box.mixCartons == null ? [] : _box.mixCartons;
|
||||
getCartonSize();
|
||||
}
|
||||
|
||||
@@ -132,6 +131,20 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
});
|
||||
}
|
||||
|
||||
_loadMixCartons() async {
|
||||
if (_box.cartonType != carton_mix_box) return;
|
||||
CartonModel cartonModel = Provider.of<CartonModel>(context, listen: false);
|
||||
List<Carton> catons = [];
|
||||
for (var id in _box.mixCartonIDs) {
|
||||
Carton c = await cartonModel.getCarton(id);
|
||||
catons.add(c);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_box.mixCartons = catons;
|
||||
});
|
||||
}
|
||||
|
||||
_calShipmentWeight() {
|
||||
double l = double.parse(_lengthController.text, (s) => 0);
|
||||
double w = double.parse(_widthController.text, (s) => 0);
|
||||
@@ -356,7 +369,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
isMixBox ? mixTypeBox : Container(),
|
||||
isMixBox ? LocalTitle(textKey: "box.mix_caton_title") : Container(),
|
||||
isMixBox
|
||||
? Column(children: _getCartons(context, this._mixCartons))
|
||||
? Column(children: _getCartons(context, _box.mixCartons))
|
||||
: Container(),
|
||||
isFromPackages || isSmallBag
|
||||
? CartonPackageTable(
|
||||
@@ -397,6 +410,7 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
}
|
||||
|
||||
_gotoEditor() async {
|
||||
widget.box.mixCartons=_box.mixCartons;
|
||||
bool updated = await Navigator.push<bool>(
|
||||
context,
|
||||
CupertinoPageRoute(builder: (context) => CartonEditor(box: widget.box)),
|
||||
@@ -406,9 +420,10 @@ class _CartonInfoState extends State<CartonInfo> {
|
||||
var c = await cartonModel.getCarton(widget.box.id);
|
||||
setState(() {
|
||||
_box = c;
|
||||
_loadPackages();
|
||||
_loadMixCartons();
|
||||
_updateBoxData();
|
||||
});
|
||||
_loadPackages();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class CartonModel extends BaseModel {
|
||||
|
||||
List<String> cartonTypes = [
|
||||
carton_from_packages,
|
||||
carton_from_cargos,
|
||||
// carton_from_cargos,
|
||||
carton_mix_box
|
||||
];
|
||||
List<String> mixBoxTypes = [mix_delivery, mix_pickup];
|
||||
@@ -262,11 +262,4 @@ class CartonModel extends BaseModel {
|
||||
return Services.instance.cartonService.searchCarton(term);
|
||||
}
|
||||
|
||||
Future<Carton> createMixCarton(Carton carton) {
|
||||
// return Services.instance.cartonService.createCarton(carton);
|
||||
}
|
||||
|
||||
Future<void> updateMixCarton(Carton carton) {
|
||||
// return Services.instance.cartonService.updateCarton(carton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/carton_size.dart';
|
||||
import 'package:fcs/domain/entities/package.dart';
|
||||
import 'package:fcs/domain/entities/user.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/carton_size/carton_size_list.dart';
|
||||
@@ -30,7 +31,8 @@ import 'model/carton_model.dart';
|
||||
class PackageCartonEditor extends StatefulWidget {
|
||||
final Carton carton;
|
||||
final bool isNew;
|
||||
PackageCartonEditor({this.carton, this.isNew});
|
||||
final User consignee;
|
||||
PackageCartonEditor({this.carton, this.isNew, this.consignee});
|
||||
|
||||
@override
|
||||
_PackageCartonEditorState createState() => _PackageCartonEditorState();
|
||||
@@ -199,8 +201,10 @@ class _PackageCartonEditorState extends State<PackageCartonEditor> {
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => DeliveryAddressSelection(
|
||||
deliveryAddress: _deliveryAddress,
|
||||
deliveryAddresses: this._deliveryAddresses)),
|
||||
deliveryAddress: _deliveryAddress,
|
||||
deliveryAddresses: this._deliveryAddresses,
|
||||
user: widget.consignee,
|
||||
)),
|
||||
);
|
||||
if (d == null) return;
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user