feat: inventory loading
This commit is contained in:
parent
74c9831ec7
commit
e1340ead5f
|
@ -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/models/inventory.model.dart';
|
||||||
import 'package:sk_base_mobile/util/debouncer.dart';
|
import 'package:sk_base_mobile/util/debouncer.dart';
|
||||||
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
||||||
|
import 'package:sk_base_mobile/widgets/empty.dart';
|
||||||
|
|
||||||
class InventorySearch extends StatelessWidget {
|
class InventorySearch extends StatelessWidget {
|
||||||
Function(InventoryModel)? onInventorySelected;
|
Function(InventoryModel)? onInventorySelected;
|
||||||
|
@ -103,7 +104,7 @@ class InventorySearch extends StatelessWidget {
|
||||||
],
|
],
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
controller.hasInventoryStatus.value = value!;
|
controller.hasInventoryStatus.value = value!;
|
||||||
controller.onRefresh();
|
controller.refreshController.requestRefresh();
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(
|
||||||
|
@ -124,112 +125,117 @@ class InventorySearch extends StatelessWidget {
|
||||||
controller: controller.refreshController,
|
controller: controller.refreshController,
|
||||||
onLoading: controller.onLoading,
|
onLoading: controller.onLoading,
|
||||||
onRefresh: controller.onRefresh,
|
onRefresh: controller.onRefresh,
|
||||||
child: Table(columnWidths: {
|
child: controller.inventories.isEmpty
|
||||||
0: FixedColumnWidth(100),
|
? Center(
|
||||||
1: FlexColumnWidth(2),
|
child: Empty(text: '暂无库存'),
|
||||||
2: MinColumnWidth(FixedColumnWidth(200), FixedColumnWidth(200)),
|
)
|
||||||
3: MinColumnWidth(FixedColumnWidth(100), FixedColumnWidth(100)),
|
: Table(columnWidths: {
|
||||||
4: MinColumnWidth(FixedColumnWidth(80), FixedColumnWidth(80)),
|
0: FixedColumnWidth(100),
|
||||||
}, children: [
|
1: FlexColumnWidth(2),
|
||||||
// table header
|
2: MinColumnWidth(FixedColumnWidth(200), FixedColumnWidth(200)),
|
||||||
TableRow(
|
3: MinColumnWidth(FixedColumnWidth(100), FixedColumnWidth(100)),
|
||||||
decoration: BoxDecoration(
|
4: MinColumnWidth(FixedColumnWidth(80), FixedColumnWidth(80)),
|
||||||
border:
|
}, children: [
|
||||||
Border(bottom: BorderSide(color: AppTheme.dividerColor))),
|
// table header
|
||||||
children: [
|
TableRow(
|
||||||
TableCell(
|
decoration: BoxDecoration(
|
||||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
border: Border(
|
||||||
child: Container(
|
bottom: BorderSide(color: AppTheme.dividerColor))),
|
||||||
alignment: Alignment.centerLeft,
|
children: [
|
||||||
height: ScreenAdaper.height(60),
|
TableCell(
|
||||||
child: Text(
|
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||||
'库存编号',
|
child: Container(
|
||||||
style: listTitleTextStyle,
|
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(
|
||||||
TableCell(
|
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||||
verticalAlignment: TableCellVerticalAlignment.middle,
|
child: Text(
|
||||||
child: Text(
|
'单价',
|
||||||
'产品名称',
|
style: listTitleTextStyle,
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
itemData: itemData),
|
TableCell(
|
||||||
buildTableCell(
|
verticalAlignment: TableCellVerticalAlignment.middle,
|
||||||
Column(
|
child: Text(
|
||||||
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,
|
textAlign: TextAlign.right,
|
||||||
style: textStyle),
|
style: listTitleTextStyle,
|
||||||
itemData: itemData,
|
),
|
||||||
alignment: Alignment.centerRight),
|
),
|
||||||
]);
|
]),
|
||||||
}).toList()
|
...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() {
|
Widget buildInventoryList1() {
|
||||||
|
|
|
@ -137,6 +137,7 @@ class DioService extends Get.GetxService {
|
||||||
response.data = response.data['data'];
|
response.data = response.data['data'];
|
||||||
// 分页数据处理
|
// 分页数据处理
|
||||||
if (response.data != null &&
|
if (response.data != null &&
|
||||||
|
response.data is Map &&
|
||||||
response.data['meta'] != null &&
|
response.data['meta'] != null &&
|
||||||
response.data['items'] != null) {
|
response.data['items'] != null) {
|
||||||
response.data = PaginationData.fromJson(response.data);
|
response.data = PaginationData.fromJson(response.data);
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Empty extends StatelessWidget {
|
||||||
Text(
|
Text(
|
||||||
text ?? '',
|
text ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: ScreenAdaper.sp(18)),
|
style: TextStyle(fontSize: ScreenAdaper.sp(30)),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue