feat: inventory loading

This commit is contained in:
louis 2024-03-26 17:10:14 +08:00
parent 74c9831ec7
commit e1340ead5f
3 changed files with 112 additions and 105 deletions

View File

@ -10,6 +10,7 @@ import 'package:sk_base_mobile/models/index.dart';
import 'package:sk_base_mobile/models/inventory.model.dart';
import 'package:sk_base_mobile/util/debouncer.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
import 'package:sk_base_mobile/widgets/empty.dart';
class InventorySearch extends StatelessWidget {
Function(InventoryModel)? onInventorySelected;
@ -103,7 +104,7 @@ class InventorySearch extends StatelessWidget {
],
onChanged: (value) {
controller.hasInventoryStatus.value = value!;
controller.onRefresh();
controller.refreshController.requestRefresh();
},
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
@ -124,112 +125,117 @@ class InventorySearch extends StatelessWidget {
controller: controller.refreshController,
onLoading: controller.onLoading,
onRefresh: controller.onRefresh,
child: Table(columnWidths: {
0: FixedColumnWidth(100),
1: FlexColumnWidth(2),
2: MinColumnWidth(FixedColumnWidth(200), FixedColumnWidth(200)),
3: MinColumnWidth(FixedColumnWidth(100), FixedColumnWidth(100)),
4: MinColumnWidth(FixedColumnWidth(80), FixedColumnWidth(80)),
}, children: [
// table header
TableRow(
decoration: BoxDecoration(
border:
Border(bottom: BorderSide(color: AppTheme.dividerColor))),
children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Container(
alignment: Alignment.centerLeft,
height: ScreenAdaper.height(60),
child: Text(
'库存编号',
style: listTitleTextStyle,
child: controller.inventories.isEmpty
? Center(
child: Empty(text: '暂无库存'),
)
: Table(columnWidths: {
0: FixedColumnWidth(100),
1: FlexColumnWidth(2),
2: MinColumnWidth(FixedColumnWidth(200), FixedColumnWidth(200)),
3: MinColumnWidth(FixedColumnWidth(100), FixedColumnWidth(100)),
4: MinColumnWidth(FixedColumnWidth(80), FixedColumnWidth(80)),
}, children: [
// table header
TableRow(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: AppTheme.dividerColor))),
children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Container(
alignment: Alignment.centerLeft,
height: ScreenAdaper.height(60),
child: Text(
'库存编号',
style: listTitleTextStyle,
),
)),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'产品名称',
style: listTitleTextStyle,
)),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'规格',
style: listTitleTextStyle,
),
),
)),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'产品名称',
style: listTitleTextStyle,
)),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'规格',
style: listTitleTextStyle,
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'单价',
style: listTitleTextStyle,
),
),
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'数量',
textAlign: TextAlign.right,
style: listTitleTextStyle,
),
),
]),
...controller.inventories.map((itemData) {
return TableRow(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: AppTheme.dividerColor))),
children: [
buildTableCell(
Text(
itemData.inventoryNumber!,
style: textStyle,
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'单价',
style: listTitleTextStyle,
),
),
itemData: itemData),
buildTableCell(
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${itemData.product?.name}',
style: textStyle,
),
Text(
'${itemData.product?.company?.name}',
style: TextStyle(
fontSize: ScreenAdaper.sp(15),
color: AppTheme.grey),
)
],
),
itemData: itemData),
//
buildTableCell(
Text(itemData.product?.productSpecification ?? '',
style: textStyle),
itemData: itemData),
//
buildTableCell(
Text(
'${double.parse('${itemData.unitPrice}')}',
style: textStyle,
),
itemData: itemData),
//
buildTableCell(
Text(
'${itemData.quantity}${itemData.product?.unit?.label ?? ''}',
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(
'数量',
textAlign: TextAlign.right,
style: textStyle),
itemData: itemData,
alignment: Alignment.centerRight),
]);
}).toList()
])));
style: listTitleTextStyle,
),
),
]),
...controller.inventories.map((itemData) {
return TableRow(
decoration: BoxDecoration(
border: Border(
bottom:
BorderSide(color: AppTheme.dividerColor))),
children: [
buildTableCell(
Text(
itemData.inventoryNumber!,
style: textStyle,
),
itemData: itemData),
buildTableCell(
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${itemData.product?.name}',
style: textStyle,
),
Text(
'${itemData.product?.company?.name}',
style: TextStyle(
fontSize: ScreenAdaper.sp(15),
color: AppTheme.grey),
)
],
),
itemData: itemData),
//
buildTableCell(
Text(itemData.product?.productSpecification ?? '',
style: textStyle),
itemData: itemData),
//
buildTableCell(
Text(
'${double.parse('${itemData.unitPrice}')}',
style: textStyle,
),
itemData: itemData),
//
buildTableCell(
Text(
'${itemData.quantity}${itemData.product?.unit?.label ?? ''}',
textAlign: TextAlign.right,
style: textStyle),
itemData: itemData,
alignment: Alignment.centerRight),
]);
}).toList()
])));
}
Widget buildInventoryList1() {

View File

@ -137,6 +137,7 @@ class DioService extends Get.GetxService {
response.data = response.data['data'];
//
if (response.data != null &&
response.data is Map &&
response.data['meta'] != null &&
response.data['items'] != null) {
response.data = PaginationData.fromJson(response.data);

View File

@ -17,7 +17,7 @@ class Empty extends StatelessWidget {
Text(
text ?? '',
textAlign: TextAlign.center,
style: TextStyle(fontSize: ScreenAdaper.sp(18)),
style: TextStyle(fontSize: ScreenAdaper.sp(30)),
),
]),
);