Browse Source

新建商品页面,商品设置套餐数据交互对接完成;

新建商品页面-多规格-设置商品规格数据数据对接未完成;
设置套餐页面数据传至-新建商品页面数据交互对接完成;
wr_2023_new_business
wurong 1 year ago
parent
commit
a5432bac6e
  1. 9
      lib/business_system/goods/add_goods/add_goods_page.dart
  2. 31
      lib/business_system/goods/add_goods/set_goods_specs.dart
  3. 161
      lib/business_system/goods/add_goods/set_meal.dart
  4. 1
      lib/retrofit/data/set_specs_meal_list.dart

9
lib/business_system/goods/add_goods/add_goods_page.dart

@ -52,6 +52,7 @@ class _AddGoodsPage extends State<AddGoodsPage> {
bool isAttrStyle = false;
bool isKeyBoardShow = false;
FocusNode _focusNode = FocusNode();
List<dynamic> mealDetails = [];
@override
void initState() {
@ -365,7 +366,13 @@ class _AddGoodsPage extends State<AddGoodsPage> {
behavior: HitTestBehavior.opaque,
onTap:(){
Navigator.of(context).pushNamed(
'/router/set_meal',arguments:{"storeId":widget.arguments["storeId"]});
'/router/set_meal',arguments:{"storeId":widget.arguments["storeId"],"mealDetails":mealDetails}).then((value){
if (value != null){
mealDetails.clear();
mealDetails.addAll(value);
setState((){});
}
});
},
child: Padding(padding: EdgeInsets.symmetric(horizontal: 16.w,vertical:16.h),
child: Column(

31
lib/business_system/goods/add_goods/set_goods_specs.dart

@ -254,7 +254,36 @@ class _SetGoodsSpecs extends State<SetGoodsSpecs> {
alignment: Alignment.bottomCenter,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
onTap: () {
bool flag = false;
String tipText = "";
specs.forEach((element) {
if (element.specsNameController.text
.trim() ==
"") {
flag = true;
tipText = "规格名称未输入,请先输入规格名称";
return;
} else if (element
.specsValues.length ==
0) {
flag = true;
tipText = "未添加规格值,请先添加规格值";
return;
}
});
if (flag) {
SmartDialog.show(
clickBgDismissTemp: false,
widget: SettlementTips(
() {},
text: tipText,
color: Color(0xFF30415B),
));
} else {
// Navigator.of(context).pop();
}
},
child: Container(
color: Colors.white,
width: double.infinity,

161
lib/business_system/goods/add_goods/set_meal.dart

@ -1,9 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../generated/l10n.dart';
import '../../../retrofit/business_api.dart';
import '../../../retrofit/data/set_specs_meal_list.dart';
import '../../../utils/font_weight.dart';
import '../../../view_widget/border_text.dart';
import '../../../view_widget/round_button.dart';
import '../../../view_widget/settlement_tips_dialog.dart';
class SetMeal extends StatefulWidget {
final Map<String, dynamic> arguments;
@ -39,6 +44,15 @@ class _SetMeal extends State<SetMeal> {
}
});
});
List<dynamic> mealDetails = widget?.arguments["mealDetails"] ??[];
mealDetails.forEach((element) {
var tempValue = SetSpecsMealList();
tempValue.groupsNameController.text = element["groupsName"];
tempValue.groupsTotal = element["groupsTotal"];
tempValue.optionalNum = element["optionalNum"];
tempValue.goodsMeal = element["goodsDetail"];
specsMeal.add(tempValue);
});
}
///
@ -65,6 +79,56 @@ class _SetMeal extends State<SetMeal> {
brightness: Brightness.dark,
action: GestureDetector(
onTap: () {
bool flag = false;
String tipText = "";
int index = 0;
List<dynamic> mealDetail = [];
if (specsMeal.length != 0) {
specsMeal.forEach((element) {
index += 1;
if (element.groupsNameController.text.trim() == "") {
flag = true;
tipText = "分组$index未填写分组名";
return;
} else if (element.goodsMeal.length == 0 ||
element.goodsMeal.length != element.groupsTotal) {
flag = true;
tipText =
"分组${element.groupsNameController.text}已选商品数量与设定分组总数不符,请修改";
return;
} else if (element.optionalNum > element.groupsTotal) {
flag = true;
tipText =
"分组${element.groupsNameController.text}可选数量不可大于分组总数";
return;
}
mealDetail.add({
"groupsName":element.groupsNameController.text,
"groupsTotal":element.groupsTotal,
"optionalNum":element.optionalNum,
"goodsDetail":element.goodsMeal
});
});
if (flag) {
SmartDialog.show(
clickBgDismissTemp: false,
widget: SettlementTips(
() {},
text: tipText,
color: Color(0xFF30415B),
));
} else {
Navigator.of(context).pop(mealDetail);
}
} else {
SmartDialog.show(
clickBgDismissTemp: false,
widget: SettlementTips(
() {},
text: "请添加设置分组后再点击确实按钮",
color: Color(0xFF30415B),
));
}
},
child: Text(
"确定",
@ -95,9 +159,9 @@ class _SetMeal extends State<SetMeal> {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {});
FocusScope.of(context).unfocus();
},
child: specsValueText(position));
child: mealText(position));
},
),
GestureDetector(
@ -141,8 +205,8 @@ class _SetMeal extends State<SetMeal> {
));
}
///
Widget specsValueText(index) {
///
Widget mealText(index) {
return Column(
children: [
Container(
@ -158,7 +222,7 @@ class _SetMeal extends State<SetMeal> {
children: [
Expanded(
child: Text(
"分组1",
"分组${index + 1}",
style: TextStyle(
color: Color(0xD9000000),
fontSize: 14.sp,
@ -364,9 +428,7 @@ class _SetMeal extends State<SetMeal> {
Spacer(),
GestureDetector(
onTap: () {
setState(() {
specsMeal.removeAt(index);
});
deleteGroupsDialog(index);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
@ -412,7 +474,7 @@ class _SetMeal extends State<SetMeal> {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: specsInfoItem(index, position),
child: addGoodsItem(index, position),
);
},
)
@ -420,8 +482,85 @@ class _SetMeal extends State<SetMeal> {
);
}
///
Widget specsInfoItem(specsIndex, index) {
///
deleteGroupsDialog(index) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Container(
width: MediaQuery.of(context).size.width - 84,
height: 139.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"此操作将直接删除当前分组, 是否继续?",
style: TextStyle(
color: Color(0xFFF4524D),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
SizedBox(
height: 35.h,
),
Row(
children: [
Expanded(
child: InkWell(
child: BorderText(
text: S.of(context).quxiao,
textColor: Color(0xFF30415B),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
borderColor: Color(0xFF30415B),
radius: 4,
padding: EdgeInsets.all(12),
borderWidth: 1,
),
onTap: () {
Navigator.of(context).pop();
},
),
flex: 1,
),
SizedBox(
width: 16.w,
),
Expanded(
child: InkWell(
child: RoundButton(
text: S.of(context).queren,
textColor: Colors.white,
radius: 4,
padding: EdgeInsets.all(12),
backgroup: Color(0xFF30415B),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
onTap: () {
setState((){
Navigator.of(context).pop();
specsMeal.removeAt(index);
});
},
),
flex: 1,
),
],
)
],
),
),
);
},
);
}
///Item
Widget addGoodsItem(specsIndex, index) {
return Container(
color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 12.h),

1
lib/retrofit/data/set_specs_meal_list.dart

@ -15,7 +15,6 @@ class SetSpecsMealList {
_goodsMeal = value;
}
num get groupsTotal => _groupsTotal;
set groupsTotal(num value) {

Loading…
Cancel
Save