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) {
|
||||
|
||||
Reference in New Issue
Block a user