feat: mine page

This commit is contained in:
louis 2024-03-27 11:06:01 +08:00
parent e1340ead5f
commit 39a98530fd
26 changed files with 505 additions and 503 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 912 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -96,7 +96,7 @@ final theme = ThemeData(
iconTheme: const IconThemeData(color: Colors.black), iconTheme: const IconThemeData(color: Colors.black),
backgroundColor: AppTheme.primaryColor, backgroundColor: AppTheme.primaryColor,
titleTextStyle: TextStyle( titleTextStyle: TextStyle(
color: Colors.black, color: Colors.white,
fontSize: ScreenAdaper.sp(30), fontSize: ScreenAdaper.sp(30),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),

View File

@ -1,4 +1,5 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:sk_base_mobile/screens/inventory/inventory.dart';
import 'package:sk_base_mobile/screens/login/login.dart'; import 'package:sk_base_mobile/screens/login/login.dart';
import '../screens/landing/landing.dart'; import '../screens/landing/landing.dart';
@ -8,9 +9,11 @@ class RouteConfig {
static const String home = "/"; static const String home = "/";
static const String login = '/login'; static const String login = '/login';
static const String userinfo = '/userinfo'; static const String userinfo = '/userinfo';
static const String inventory = '/inventory';
static final List<GetPage> getPages = [ static final List<GetPage> getPages = [
GetPage(name: login, page: () => LoginScreen()), GetPage(name: login, page: () => LoginScreen()),
GetPage(name: home, page: () => LandingPage()), GetPage(name: home, page: () => LandingPage()),
GetPage(name: userinfo, page: () => UserInfoPage()), GetPage(name: userinfo, page: () => UserInfoPage()),
GetPage(name: inventory, page: () => InventoryPage()),
]; ];
} }

View File

@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:sk_base_mobile/config.dart'; import 'package:sk_base_mobile/config.dart';
import 'package:sk_base_mobile/screens/landing/landing.dart';
import 'package:sk_base_mobile/screens/login/login%20copy.dart';
import 'package:sk_base_mobile/services/storage.service.dart'; import 'package:sk_base_mobile/services/storage.service.dart';
import 'package:sk_base_mobile/app_theme.dart'; import 'package:sk_base_mobile/app_theme.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:sk_base_mobile/constants/bg_color.dart'; import 'package:sk_base_mobile/constants/bg_color.dart';
import 'package:sk_base_mobile/screens/inventory_inout/components/change_icon.dart'; import 'package:sk_base_mobile/screens/inventory_inout/components/change_icon.dart';
import 'package:sk_base_mobile/screens/inventory_inout/components/filter_btn.dart';
import 'package:sk_base_mobile/screens/inventory_inout/components/today_button.dart'; import 'package:sk_base_mobile/screens/inventory_inout/components/today_button.dart';
import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart'; import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart'; import 'package:sk_base_mobile/util/screen_adaper_util.dart';
@ -16,7 +17,7 @@ class ChangeButtonRow extends StatelessWidget {
horizontal: MediaQuery.sizeOf(context).width * 0.06), horizontal: MediaQuery.sizeOf(context).width * 0.06),
child: Row( child: Row(
children: [ children: [
const TodayButton(), TodayButton(),
const Spacer(), const Spacer(),
ClipOval( ClipOval(
child: InkWell( child: InkWell(

View File

@ -63,8 +63,7 @@ class CustomAppBar extends StatelessWidget {
initialDate: controller.endTime.value, initialDate: controller.endTime.value,
endDate: controller.endTime.value, endDate: controller.endTime.value,
onDateTimeChanged: (date) { onDateTimeChanged: (date) {
controller.endTime.value = DateTime.parse(date); controller.setEndTime(DateTime.parse(date));
controller.getData();
}, },
); );
}, },

View File

@ -0,0 +1,49 @@
// import 'package:flutter/foundation.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter/widgets.dart';
// import 'package:get/get.dart';
// import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
// import 'package:sk_base_mobile/util/screen_adaper_util.dart';
// class FilterBtn extends StatelessWidget {
// FilterBtn({super.key});
// final controller = Get.put<FilterBtnController>();
// @override
// Widget build(BuildContext context) {
// return Container(
// width: ScreenAdaper.width(150),
// constraints: BoxConstraints(minWidth: ScreenAdaper.width(150)),
// child: Obx(
// () => DropdownButtonFormField(
// value: controller.hasInventoryStatus.value,
// items: [
// DropdownMenuItem(
// child: Text('全部'),
// value: -1,
// ),
// DropdownMenuItem(
// child: const Text('入库'),
// value: 0,
// ),
// DropdownMenuItem(
// child: const Text('出库'),
// value: 1,
// ),
// ],
// onChanged: (value) {
// controller.hasInventoryStatus.value = value!;
// controller.refreshController.requestRefresh();
// },
// decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(
// vertical: ScreenAdaper.height(15),
// horizontal: ScreenAdaper.width(15)),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(ScreenAdaper.sp(15)),
// ),
// )),
// ));
// }
// }
// class FilterBtnController extends GetxController {}

View File

@ -6,15 +6,13 @@ import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controlle
import 'package:sk_base_mobile/util/util.dart'; import 'package:sk_base_mobile/util/util.dart';
class TodayButton extends StatelessWidget { class TodayButton extends StatelessWidget {
const TodayButton({super.key}); TodayButton({super.key});
final controller = Get.find<InventoryInoutController>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final controller = Get.find<InventoryInoutController>();
return InkWell( return InkWell(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(30)), borderRadius: BorderRadius.circular(ScreenAdaper.sp(30)),
onTap: () => controller.pageController.animateToPage(0, onTap: () => controller.setEndTime(DateTime.now()),
duration: const Duration(milliseconds: 300), curve: Curves.easeIn),
child: Container( child: Container(
height: ScreenAdaper.height(70), height: ScreenAdaper.height(70),
width: ScreenAdaper.width(200), width: ScreenAdaper.width(200),

View File

@ -41,7 +41,7 @@ class InventoryInoutController extends GetxController {
getData(); getData();
} }
/// /// picker
Future<void> showInOrOutPickerDialog() async { Future<void> showInOrOutPickerDialog() async {
showDialog( showDialog(
context: Get.overlayContext!, context: Get.overlayContext!,
@ -203,7 +203,7 @@ class InventoryInoutController extends GetxController {
); );
} }
/// /// dialog
Future showInventoryInoutCreateDialog(int inOrOut) async { Future showInventoryInoutCreateDialog(int inOrOut) async {
final isTablet = Responsive.isTablet(Get.context!); final isTablet = Responsive.isTablet(Get.context!);
return isTablet return isTablet
@ -242,11 +242,13 @@ class InventoryInoutController extends GetxController {
); );
} }
// dialog
Future showInventoryInoutInfoDialog(int id) async { Future showInventoryInoutInfoDialog(int id) async {
ModalUtil.showGeneralDialog( ModalUtil.showGeneralDialog(
width: ScreenAdaper.width(Get.width - 100), width: ScreenAdaper.width(Get.width - 100),
height: ScreenAdaper.height(Get.height - 100), height: ScreenAdaper.height(Get.height - 100),
content: InventoryInoutInfo(inventoryInoutId: id)) content: InventoryInoutInfo(inventoryInoutId: id),
offset: const Offset(0, -1))
.then((value) => {Get.delete<InventoryInouInfoController>()}); .then((value) => {Get.delete<InventoryInouInfoController>()});
} }
@ -279,6 +281,14 @@ class InventoryInoutController extends GetxController {
}); });
} }
setEndTime(DateTime newEndTime) async {
currentIndex.value = 0;
endTime.value = newEndTime;
pageController.jumpTo(0);
scrollController.jumpTo(0);
getData();
}
setIndex(int value) { setIndex(int value) {
pageController.animateToPage(value, pageController.animateToPage(value,
duration: const Duration(milliseconds: 300), curve: Curves.easeIn); duration: const Duration(milliseconds: 300), curve: Curves.easeIn);

View File

@ -34,118 +34,77 @@ class _MinePageState extends State<MinePage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _buildBody(); return Container(
color: AppTheme.nearlyWhite,
child: _buildBody(),
);
} }
Widget _buildBody() { Widget _buildBody() {
return Column(children: [ return Column(children: [
// Container( Container(
// height: ScreenAdaper.height(360), height: ScreenAdaper.height(300),
// width: ScreenAdaper.screenWidth(), decoration: const BoxDecoration(
// decoration: const BoxDecoration( image: DecorationImage(
// image: DecorationImage( fit: BoxFit.cover,
// fit: BoxFit.cover, image: AssetImage('assets/images/yeyazhijia_bg.jpg'))),
// image: AssetImage('assets/images/mine_bg.png'))),
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: ScreenAdaper.width(20),
// vertical: ScreenAdaper.height(20)),
// child: Column(children: [
// SizedBox(
// height: ScreenAdaper.height(30),
// ),
// Row(
// children: [
// const Spacer(),
// Container(
// height: ScreenAdaper.width(40),
// width: ScreenAdaper.width(40),
// padding: EdgeInsets.all(ScreenAdaper.width(2)),
// decoration: BoxDecoration( // decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(ScreenAdaper.sp(40)), // gradient: LinearGradient(
// color: const Color(0xFF000000).withOpacity(0.3)), // colors: [AppTheme.primaryColorLight, AppTheme.primaryColor])),
// child: const SizedBox(), child: Padding(
// ) padding: EdgeInsets.symmetric(
// ], horizontal: ScreenAdaper.width(20),
// ), vertical: ScreenAdaper.height(20)),
// SizedBox( child: Column(children: [
// height: ScreenAdaper.height(120), SizedBox(
// ), height: ScreenAdaper.height(80),
// Row( ),
// children: [ Row(
// Expanded( mainAxisAlignment: MainAxisAlignment.center,
// child: Column( children: [
// crossAxisAlignment: CrossAxisAlignment.start, Column(
// mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
// children: [ children: [
// Row( MyAvatarWidget(),
// crossAxisAlignment: CrossAxisAlignment.center, SizedBox(
// children: [ height: ScreenAdaper.height(10),
// Obx(() => Text( ),
// AuthStore.to.userInfo.value.nickname ?? '', Obx(
// style: TextStyle( () => Stack(
// fontSize: ScreenAdaper.sp(20), alignment: Alignment.center,
// fontWeight: FontWeight.w400), children: [
// )), Text(
// SizedBox( AuthStore.to.userInfo.value.nickname ?? '',
// width: ScreenAdaper.width(3), style: TextStyle(
// ), letterSpacing: ScreenAdaper.width(5),
// InkWell( fontSize: ScreenAdaper.sp(30),
// onTap: () { fontWeight: FontWeight.bold,
// Get.toNamed(RouteConfig.userinfo); foreground: Paint()
// }, ..style = PaintingStyle.stroke
// child: Image( ..strokeWidth = 2
// image: ..color = Colors.black),
// const AssetImage('assets/images/edit_icon.png'), ),
// height: ScreenAdaper.width(20), Text(
// ), AuthStore.to.userInfo.value.nickname ?? '',
// ) style: TextStyle(
// ], letterSpacing: ScreenAdaper.width(5),
// ), color: Colors.white,
// SizedBox( fontSize: ScreenAdaper.sp(30),
// height: ScreenAdaper.height(15), fontWeight: FontWeight.bold),
// ), ),
// Text(StorageService.to.getString(CacheKeys.deviceUUID) ?? ],
// ''), ),
// Row( )
// children: [ ],
// SizedBox( )
// width: ScreenAdaper.width(210), ],
// child: Text( )
// 'ID: ${AuthStore.to.userInfo.value.id}', ]),
// overflow: TextOverflow.ellipsis, ),
// maxLines: 2, ),
// style: TextStyle( SizedBox(
// fontSize: ScreenAdaper.sp(16), height: ScreenAdaper.height(50),
// color: Colors.grey[500]), ),
// ),
// ),
// InkWell(
// onTap: () {},
// child: Container(
// alignment: Alignment.topCenter,
// width: ScreenAdaper.width(50),
// height: ScreenAdaper.height(30),
// padding: EdgeInsets.symmetric(
// horizontal: ScreenAdaper.width(5)),
// decoration: BoxDecoration(
// color: const Color(0xFF454545),
// borderRadius: BorderRadius.circular(5)),
// child: Text('copy',
// style: TextStyle(
// color: AppTheme.white,
// fontSize: ScreenAdaper.sp(16)))),
// )
// ],
// )
// ],
// )),
// MyAvatarWidget()
// ],
// )
// ]),
// ),
// ),
Expanded(child: MineSettingsPage()) Expanded(child: MineSettingsPage())
// Expanded( // Expanded(
// child: DefaultTabController( // child: DefaultTabController(

View File

@ -14,58 +14,65 @@ class MineSettingsPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: ScreenAdaper.width(15)), padding: EdgeInsets.symmetric(horizontal: ScreenAdaper.width(15)),
child: ListView.separated( child: SingleChildScrollView(
separatorBuilder: (_, index) => const Divider( child: Column(
color: Color(0xFFCCCCCC),
),
itemBuilder: ((_, index) => _buildSettingsItem(
index,
)),
itemCount: 4),
);
}
Widget _buildSettingsItem(int index) {
switch (index) {
// auto translate
case 0:
return Container(
padding: EdgeInsets.symmetric(vertical: ScreenAdaper.width(10)),
child: Row(
children: [],
));
case 1:
return InkWell(
onTap: () async {
await AuthStore.to.deleteAccount();
},
child: Container(
padding: EdgeInsets.symmetric(vertical: ScreenAdaper.width(10)),
child: Row(
children: [ children: [
Text( Container(
'Delete acount', decoration: BoxDecoration(
style: TextStyle(fontSize: ScreenAdaper.sp(18)), border: Border.all(),
), borderRadius: BorderRadius.circular(15),
], color: AppTheme.nearlyWhite),
))); width: ScreenAdaper.width(400),
case 2: padding:
return InkWell( EdgeInsets.symmetric(vertical: ScreenAdaper.width(10)),
child: InkWell(
onTap: () async { onTap: () async {
await AuthStore.to.logout(force: true); await AuthStore.to.logout(force: true);
}, },
child: Container( child: Container(
padding: EdgeInsets.symmetric(vertical: ScreenAdaper.width(10)), padding: EdgeInsets.symmetric(
horizontal: ScreenAdaper.width(20),
vertical: ScreenAdaper.width(20)),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text( Text(
'Logout', '退出登录',
style: TextStyle(fontSize: ScreenAdaper.sp(18)), style: TextStyle(
fontSize: ScreenAdaper.sp(20),
fontWeight: FontWeight.w600),
), ),
], ],
))); ))))
default: ],
return SizedBox(); ),
} ));
} }
// Widget _buildSettingsItem(int index) {
// switch (index) {
// // auto translate
// case 0:
// return;
// case 1:
// return InkWell(
// onTap: () async {
// await AuthStore.to.deleteAccount();
// },
// child: Container(
// padding: EdgeInsets.symmetric(vertical: ScreenAdaper.width(10)),
// child: Row(
// children: [
// Text(
// 'Delete acount',
// style: TextStyle(fontSize: ScreenAdaper.sp(18)),
// ),
// ],
// )));
// case 2:
// return I;
// default:
// return SizedBox();
// }
// }
} }

View File

@ -125,25 +125,32 @@ class InventorySearch extends StatelessWidget {
controller: controller.refreshController, controller: controller.refreshController,
onLoading: controller.onLoading, onLoading: controller.onLoading,
onRefresh: controller.onRefresh, onRefresh: controller.onRefresh,
child: controller.inventories.isEmpty child: controller.refreshController.isLoading
? SizedBox()
: controller.inventories.isEmpty
? Center( ? Center(
child: Empty(text: '暂无库存'), child: Empty(text: '暂无库存'),
) )
: Table(columnWidths: { : Table(columnWidths: {
0: FixedColumnWidth(100), 0: FixedColumnWidth(100),
1: FlexColumnWidth(2), 1: FlexColumnWidth(2),
2: MinColumnWidth(FixedColumnWidth(200), FixedColumnWidth(200)), 2: MinColumnWidth(
3: MinColumnWidth(FixedColumnWidth(100), FixedColumnWidth(100)), FixedColumnWidth(200), FixedColumnWidth(200)),
4: MinColumnWidth(FixedColumnWidth(80), FixedColumnWidth(80)), 3: MinColumnWidth(
FixedColumnWidth(100), FixedColumnWidth(100)),
4: MinColumnWidth(
FixedColumnWidth(80), FixedColumnWidth(80)),
}, children: [ }, children: [
// table header // table header
TableRow( TableRow(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: BorderSide(color: AppTheme.dividerColor))), bottom:
BorderSide(color: AppTheme.dividerColor))),
children: [ children: [
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment:
TableCellVerticalAlignment.middle,
child: Container( child: Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
height: ScreenAdaper.height(60), height: ScreenAdaper.height(60),
@ -153,27 +160,31 @@ class InventorySearch extends StatelessWidget {
), ),
)), )),
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment:
TableCellVerticalAlignment.middle,
child: Text( child: Text(
'产品名称', '产品名称',
style: listTitleTextStyle, style: listTitleTextStyle,
)), )),
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment:
TableCellVerticalAlignment.middle,
child: Text( child: Text(
'规格', '规格',
style: listTitleTextStyle, style: listTitleTextStyle,
), ),
), ),
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment:
TableCellVerticalAlignment.middle,
child: Text( child: Text(
'单价', '单价',
style: listTitleTextStyle, style: listTitleTextStyle,
), ),
), ),
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment:
TableCellVerticalAlignment.middle,
child: Text( child: Text(
'数量', '数量',
textAlign: TextAlign.right, textAlign: TextAlign.right,
@ -185,8 +196,8 @@ class InventorySearch extends StatelessWidget {
return TableRow( return TableRow(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
bottom: bottom: BorderSide(
BorderSide(color: AppTheme.dividerColor))), color: AppTheme.dividerColor))),
children: [ children: [
buildTableCell( buildTableCell(
Text( Text(
@ -214,7 +225,9 @@ class InventorySearch extends StatelessWidget {
itemData: itemData), itemData: itemData),
// //
buildTableCell( buildTableCell(
Text(itemData.product?.productSpecification ?? '', Text(
itemData.product?.productSpecification ??
'',
style: textStyle), style: textStyle),
itemData: itemData), itemData: itemData),
// //
@ -238,107 +251,6 @@ class InventorySearch extends StatelessWidget {
]))); ])));
} }
Widget buildInventoryList1() {
final textStyle = TextStyle(fontSize: ScreenAdaper.sp(22));
return Obx(
() => SmartRefresher(
enablePullDown: true,
enablePullUp: true,
controller: controller.refreshController,
onLoading: controller.onLoading,
onRefresh: controller.onRefresh,
child: ListView.separated(
itemCount: controller.inventories.length,
separatorBuilder: (context, index) => const Divider(
height: 1,
color: AppTheme.dividerColor,
),
itemBuilder: (context, index) {
final itemData = controller.inventories[index];
return InkWell(
onTap: () {
if (onInventorySelected != null)
onInventorySelected!(itemData);
},
child: Container(
padding:
EdgeInsets.symmetric(vertical: ScreenAdaper.height(10)),
child: Row(
children: [
Container(
//
constraints:
BoxConstraints(minWidth: ScreenAdaper.width(100)),
child: Text(
itemData.inventoryNumber!,
style: textStyle,
),
),
SizedBox(
width: ScreenAdaper.width(10),
),
Expanded(
flex: 8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${itemData.product?.name}',
style: textStyle,
),
Text(
'${itemData.product?.company?.name}',
style: TextStyle(
fontSize: ScreenAdaper.sp(15),
color: AppTheme.grey),
)
],
)),
SizedBox(
width: ScreenAdaper.width(10),
),
//
Expanded(
child: Container(
constraints:
BoxConstraints(minWidth: ScreenAdaper.width(100)),
child: Text(
itemData.product?.productSpecification ?? '',
style: textStyle),
)),
SizedBox(
width: ScreenAdaper.width(10),
),
//
Container(
constraints:
BoxConstraints(minWidth: ScreenAdaper.width(100)),
child: Text(
'${double.parse('${itemData.unitPrice}')}${double.parse('${itemData.unitPrice}')}${double.parse('${itemData.unitPrice}')}${double.parse('${itemData.unitPrice}')}',
style: textStyle),
),
SizedBox(
width: ScreenAdaper.width(10),
),
//
Expanded(
child: Container(
alignment: Alignment.centerRight,
constraints:
BoxConstraints(minWidth: ScreenAdaper.width(80)),
child: Text(
'${itemData.quantity}${itemData.quantity}${itemData.product?.unit?.label ?? ''}',
style: textStyle),
))
],
),
),
);
}),
),
);
}
Widget buildTableCell(Widget child, Widget buildTableCell(Widget child,
{required InventoryModel itemData, AlignmentGeometry? alignment}) { {required InventoryModel itemData, AlignmentGeometry? alignment}) {
return TableCell( return TableCell(

View File

@ -358,10 +358,12 @@ class NewInventoryInout extends StatelessWidget {
vertical: ScreenAdaper.height(20), vertical: ScreenAdaper.height(20),
horizontal: ScreenAdaper.width(20)), horizontal: ScreenAdaper.width(20)),
alignment: Alignment.center, alignment: Alignment.center,
child: Row(children: [
Expanded(
child: Column( child: Column(
children: [ children: [
Text( Text(
'*请拍照上传照片', '*产品照片',
style: TextStyle( style: TextStyle(
fontSize: ScreenAdaper.sp(25), fontSize: ScreenAdaper.sp(25),
color: AppTheme.secondPrimaryColor), color: AppTheme.secondPrimaryColor),
@ -375,20 +377,50 @@ class NewInventoryInout extends StatelessWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
...controller.uploadImgFilesPath ...controller.uploadProductImgFilesPath
.map((String path) => builderImagePreview(path)) .map((String path) =>
builderImagePreview(path, 'product'))
.toList(), .toList(),
buildImageUploader() buildImageUploader('product')
], ],
), ),
)), )),
], ],
)),
Expanded(
child: Column(
children: [
Text(
'*经办人自拍',
style: TextStyle(
fontSize: ScreenAdaper.sp(25),
color: AppTheme.secondPrimaryColor),
), ),
SizedBox(
height: ScreenAdaper.height(10),
),
Obx(() => SingleChildScrollView(
controller: controller.uploadScrollController,
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
...controller.uploadAgentImgFilesPath
.map((String path) =>
builderImagePreview(path, 'agent'))
.toList(),
buildImageUploader('agent')
],
),
)),
],
))
]),
); );
} }
/// Item /// Item
Widget builderImagePreview(String path) { Widget builderImagePreview(String path, String type) {
return Stack( return Stack(
children: [ children: [
Container( Container(
@ -417,7 +449,11 @@ class NewInventoryInout extends StatelessWidget {
right: ScreenAdaper.width(5), right: ScreenAdaper.width(5),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
controller.uploadImgFilesPath.remove(path); if (type == 'agent') {
controller.uploadAgentImgFilesPath.remove(path);
} else {
controller.uploadProductImgFilesPath.remove(path);
}
}, },
child: Icon( child: Icon(
Icons.close, Icons.close,
@ -442,10 +478,10 @@ class NewInventoryInout extends StatelessWidget {
} }
// //
Widget buildImageUploader() { Widget buildImageUploader(String type) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
controller.photoPicker(); controller.photoPicker(type);
}, },
child: Container( child: Container(
margin: EdgeInsets.symmetric(horizontal: ScreenAdaper.width(5)), margin: EdgeInsets.symmetric(horizontal: ScreenAdaper.width(5)),

View File

@ -43,7 +43,9 @@ class NewInventoryInoutController extends GetxController {
final agentTextController = TextEditingController(); final agentTextController = TextEditingController();
final remarkTextController = TextEditingController(); final remarkTextController = TextEditingController();
final positionTextController = TextEditingController(); final positionTextController = TextEditingController();
final uploadImgFilesPath = <String>[].obs; final uploadProductImgFilesPath = <String>[].obs;
final uploadAgentImgFilesPath = <String>[].obs;
// final uploadImgFilesPath = <String>[].obs
final uploadScrollController = ScrollController(); final uploadScrollController = ScrollController();
Map<String, dynamic> payload = {}; Map<String, dynamic> payload = {};
NewInventoryInoutController({this.inOrOut}); NewInventoryInoutController({this.inOrOut});
@ -114,37 +116,49 @@ class NewInventoryInoutController extends GetxController {
/// ///
Future<void> create() async { Future<void> create() async {
if (payload['projectId'] == null) { if (payload['projectId'] == null) {
SnackBarUtil().info( SnackBarUtil().error(
'项目不能为空', '项目不能为空',
); );
return; return;
} }
if (payload['productId'] == null) { if (payload['productId'] == null) {
SnackBarUtil().info( SnackBarUtil().error(
'产品不能为空', '产品不能为空',
); );
return; return;
} }
if (payload['time'] == null) { if (payload['time'] == null) {
SnackBarUtil().info( SnackBarUtil().error(
'时间不能为空', '时间不能为空',
); );
return; return;
} }
payload['quantity'] = quantityTextController.text; payload['quantity'] = quantityTextController.text;
if (payload['quantity'].isEmpty || payload['quantity'] == '0') { if (payload['quantity'].isEmpty || payload['quantity'] == '0') {
SnackBarUtil().info( SnackBarUtil().error(
'数量必须大于1', '数量必须大于1',
); );
return; return;
} }
payload['agent'] = agentTextController.text; payload['agent'] = agentTextController.text;
if (payload['agent'].isEmpty) { if (payload['agent'].isEmpty) {
SnackBarUtil().info( SnackBarUtil().error(
'经办人不能为空', '经办人不能为空',
); );
return; return;
} }
if (uploadProductImgFilesPath.isEmpty) {
SnackBarUtil().error(
'请上传产品照片',
);
return;
}
if (uploadAgentImgFilesPath.isEmpty) {
SnackBarUtil().error(
'请上传经办人照片',
);
return;
}
if (unitPriceTextController.text.isEmpty) { if (unitPriceTextController.text.isEmpty) {
payload.remove('unitPrice'); payload.remove('unitPrice');
} else { } else {
@ -163,7 +177,10 @@ class NewInventoryInoutController extends GetxController {
try { try {
// final recordId = res.data as int; // final recordId = res.data as int;
// //
final uploadRes = await Future.wait(uploadImgFilesPath final uploadRes = await Future.wait([
...uploadProductImgFilesPath,
...uploadAgentImgFilesPath
]
.map((filePath) => MediaUtil().uploadImg(File(filePath), .map((filePath) => MediaUtil().uploadImg(File(filePath),
bussinessModule: StorageBussinessModuleEnum.MaterialsInOut, bussinessModule: StorageBussinessModuleEnum.MaterialsInOut,
bussinessRecordId: null)) bussinessRecordId: null))
@ -189,10 +206,15 @@ class NewInventoryInoutController extends GetxController {
} }
} }
Future<void> photoPicker() async { Future<void> photoPicker(String type) async {
XFile? pickedFile = await MediaUtil().getImageFromCamera(); XFile? pickedFile =
await MediaUtil().getImageFromCamera(isFront: type == 'agent');
if (pickedFile != null) { if (pickedFile != null) {
uploadImgFilesPath.add(pickedFile.path); if (type == 'product') {
uploadProductImgFilesPath.add(pickedFile.path);
} else {
uploadAgentImgFilesPath.add(pickedFile.path);
}
Future.delayed(const Duration(milliseconds: 100), () { Future.delayed(const Duration(milliseconds: 100), () {
// //
uploadScrollController.animateTo( uploadScrollController.animateTo(
@ -283,17 +305,17 @@ class NewInventoryInoutController extends GetxController {
insertTask(BuildContext context) { insertTask(BuildContext context) {
if (label.value.text.toString().isEmpty) { if (label.value.text.toString().isEmpty) {
SnackBarUtil().warning( // SnackBarUtil().error(
'Warning', // 'Warning',
message: 'Enter valid label', // message: 'Enter valid label',
); // );
return; // return;
} }
if (category.value.text.toString().isEmpty) { if (category.value.text.toString().isEmpty) {
SnackBarUtil().warning( // SnackBarUtil().error(
'Warning', // 'Warning',
message: 'Enter Correct Category', // message: 'Enter Correct Category',
); // );
return; return;
} }
if (selectedDate.isEmpty) { if (selectedDate.isEmpty) {

View File

@ -1,49 +1,29 @@
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart'; import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/constants/router.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/util/snack_bar.util.dart';
class WorkBenchModel { class WorkBenchModel {
final String title; final String title;
final String icon;
final String route; final String route;
WorkBenchModel( WorkBenchModel({required this.title, required this.route});
{required this.title, required this.icon, required this.route});
} }
class WorkBenchPage extends StatelessWidget { class WorkBenchPage extends StatelessWidget {
WorkBenchPage({super.key}); WorkBenchPage({super.key});
List<WorkBenchModel> works = [ List<WorkBenchModel> works = [
WorkBenchModel( WorkBenchModel(title: '库存', route: '/inventory'),
title: '产品管理', WorkBenchModel(title: '产品', route: '/product'),
icon: 'assets/images/product_manage.png', WorkBenchModel(title: '合同', route: '/contract'),
route: '/product'), WorkBenchModel(title: '人事', route: '/personnel'),
WorkBenchModel( WorkBenchModel(title: '公车', route: '/finance'),
title: '库存管理', WorkBenchModel(title: '任务', route: '/task_manage'),
icon: 'assets/images/inventory_manage.png', WorkBenchModel(title: '报表', route: '/report'),
route: '/inventory'),
WorkBenchModel(
title: '合同管理',
icon: 'assets/images/contract_manage.png',
route: '/contract'),
WorkBenchModel(
title: '人事管理',
icon: 'assets/images/hr_manage.png',
route: '/personnel'),
WorkBenchModel(
title: '公车管理',
icon: 'assets/images/vehicle_usage.png',
route: '/finance'),
WorkBenchModel(
title: '任务管理',
icon: 'assets/images/task_manage.png',
route: '/task_manage'),
WorkBenchModel(
title: '报表管理',
icon: 'assets/images/report_manage.png',
route: '/report'),
]; ];
@override @override
@ -78,15 +58,36 @@ class WorkBenchPage extends StatelessWidget {
} }
Widget buildCard(int index) { Widget buildCard(int index) {
return Card( return InkWell(
onTap: () {
final route = RouteConfig.getPages
.map((e) => e.name)
.firstWhereOrNull((name) => name == works[index].route);
if (route != null) {
Get.toNamed(works[index].route);
} else {
SnackBarUtil().info('功能待开发。');
}
},
child: Container(
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
shadowColor: AppTheme.black, decoration: BoxDecoration(
elevation: 10.0, borderRadius: BorderRadius.circular(10),
shape: RoundedRectangleBorder( gradient: LinearGradient(
borderRadius: BorderRadius.circular(ScreenAdaper.width(20))), begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
boxShadow: [
BoxShadow(
color: AppTheme.black.withOpacity(0.5),
offset: Offset(0, 0),
blurRadius: 5,
spreadRadius: 2)
],
),
child: Stack( child: Stack(
children: [ children: [
Image.asset(works[index].icon), // Image.asset(works[index].icon),
Center( Center(
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
@ -95,7 +96,7 @@ class WorkBenchPage extends StatelessWidget {
works[index].title, works[index].title,
style: TextStyle( style: TextStyle(
letterSpacing: ScreenAdaper.width(5), letterSpacing: ScreenAdaper.width(5),
fontSize: ScreenAdaper.sp(30), fontSize: ScreenAdaper.sp(40),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
foreground: Paint() foreground: Paint()
..style = PaintingStyle.stroke ..style = PaintingStyle.stroke
@ -107,13 +108,13 @@ class WorkBenchPage extends StatelessWidget {
style: TextStyle( style: TextStyle(
letterSpacing: ScreenAdaper.width(5), letterSpacing: ScreenAdaper.width(5),
color: Colors.white, color: Colors.white,
fontSize: ScreenAdaper.sp(30), fontSize: ScreenAdaper.sp(40),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
], ],
), ),
) )
], ],
)); )));
} }
} }

View File

@ -14,7 +14,7 @@ class DioService extends Get.GetxService {
static DioService get to => Get.Get.find(); static DioService get to => Get.Get.find();
static Dio get dio => _dio; static Dio get dio => _dio;
static late Dio _dio; static late Dio _dio;
List<String> whiteList = [Urls.login, Urls.uploadAttachemnt]; List<String> whiteList = [Urls.login];
BaseOptions dioBaseOptions = BaseOptions( BaseOptions dioBaseOptions = BaseOptions(
connectTimeout: const Duration(seconds: 20), connectTimeout: const Duration(seconds: 20),
baseUrl: '${GloablConfig.BASE_URL}', baseUrl: '${GloablConfig.BASE_URL}',

View File

@ -10,15 +10,19 @@ import 'package:sk_base_mobile/services/service.dart';
class MediaUtil { class MediaUtil {
// //
Future<XFile?> getImageFromCamera({double? maxWidth}) async { Future<XFile?> getImageFromCamera(
{double? maxWidth, bool isFront = false}) async {
XFile? pickedFile; XFile? pickedFile;
try { try {
if (AppInfoService.to.isCameraing.value) { if (AppInfoService.to.isCameraing.value) {
return null; return null;
} }
AppInfoService.to.isCameraing.value = true; AppInfoService.to.isCameraing.value = true;
pickedFile = await ImagePicker() pickedFile = await ImagePicker().pickImage(
.pickImage(source: ImageSource.camera, maxWidth: maxWidth ?? 2000); source: ImageSource.camera,
maxWidth: maxWidth ?? 2000,
preferredCameraDevice:
isFront ? CameraDevice.front : CameraDevice.rear);
AppInfoService.to.isCameraing.value = false; AppInfoService.to.isCameraing.value = false;
} catch (e) { } catch (e) {
AppInfoService.to.isCameraing.value = false; AppInfoService.to.isCameraing.value = false;

View File

@ -68,7 +68,10 @@ class ModalUtil {
); );
static Future<void> showGeneralDialog( static Future<void> showGeneralDialog(
{required Widget content, double? width, double? height}) { {required Widget content,
double? width,
double? height,
Offset? offset}) {
return Get.generalDialog( return Get.generalDialog(
barrierLabel: "productPicker", barrierLabel: "productPicker",
barrierDismissible: true, barrierDismissible: true,
@ -86,7 +89,7 @@ class ModalUtil {
}, },
transitionBuilder: (_, anim, __, child) { transitionBuilder: (_, anim, __, child) {
Tween<Offset> tween; Tween<Offset> tween;
tween = Tween(begin: const Offset(0, 1), end: Offset.zero); tween = Tween(begin: offset ?? const Offset(0, 1), end: Offset.zero);
return SlideTransition( return SlideTransition(
position: tween.animate( position: tween.animate(
CurvedAnimation(parent: anim, curve: Curves.easeInOut), CurvedAnimation(parent: anim, curve: Curves.easeInOut),

View File

@ -29,8 +29,8 @@ class MyAvatarWidget extends StatelessWidget {
border: Border.all( border: Border.all(
color: AppTheme.white, width: ScreenAdaper.sp(2)), color: AppTheme.white, width: ScreenAdaper.sp(2)),
borderRadius: BorderRadius.circular(50)), borderRadius: BorderRadius.circular(50)),
height: ScreenAdaper.width(90), height: ScreenAdaper.width(120),
width: ScreenAdaper.width(90), width: ScreenAdaper.width(120),
child: const SizedBox(), child: const SizedBox(),
)), )),
Positioned( Positioned(
@ -42,7 +42,7 @@ class MyAvatarWidget extends StatelessWidget {
}, },
child: Image( child: Image(
height: ScreenAdaper.width(40), height: ScreenAdaper.width(40),
image: const AssetImage('assets/images/photo_icon.png'), image: const AssetImage('assets/images/company_logo.png'),
))) )))
], ],
); );