Browse Source

新建商品-设置多规格商品详情数据交互完成;

编辑多规格详情数据更改;
设置商品规格页面数据传值处理;
wr_2023_new_business
wurong 1 year ago
parent
commit
bfc6c59c52
  1. 173
      lib/business_system/goods/add_goods/add_goods_page.dart
  2. 8
      lib/business_system/goods/add_goods/edit_specs_detail.dart
  3. 22
      lib/business_system/goods/add_goods/set_goods_specs.dart
  4. 88
      lib/business_system/goods/on_sale/batch_shelf.dart

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

@ -53,6 +53,7 @@ class _AddGoodsPage extends State<AddGoodsPage> {
bool isKeyBoardShow = false;
FocusNode _focusNode = FocusNode();
List<dynamic> mealDetails = [];
List<dynamic> goodsSpecsDetails = [];
@override
void initState() {
@ -83,13 +84,11 @@ class _AddGoodsPage extends State<AddGoodsPage> {
_onRefresh() async {
EasyLoading.show(
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
await queryProductGroupList();
await queryCategorize();
EasyLoading.dismiss();
if (mounted)
setState(() {});
if (mounted) setState(() {});
}
///
@ -128,7 +127,8 @@ class _AddGoodsPage extends State<AddGoodsPage> {
tenant: BusinessInstance.instance.businessTenant,
storeId: widget.arguments["storeId"]);
}
BaseData<List<GoodsCategoryList>> baseData = await businessService.findCategoryListByDepth().catchError((error) {});
BaseData<List<GoodsCategoryList>> baseData =
await businessService.findCategoryListByDepth().catchError((error) {});
if (baseData != null && baseData.isSuccess) {
goodsCategoryList = baseData.data;
}
@ -153,7 +153,8 @@ class _AddGoodsPage extends State<AddGoodsPage> {
"groupId": "1693436138259218432", //id
"imgs": [
{
"imgPath": "https://pos.upload.lotus-wallet.com/1195/2023/10/1ba87000-d940-49e5-a6ca-f15623d5f841.jpg"
"imgPath":
"https://pos.upload.lotus-wallet.com/1195/2023/10/1ba87000-d940-49e5-a6ca-f15623d5f841.jpg"
}
], //
"needLogistics": isLogistics == true ? 1 : 0, //1- 0-
@ -166,20 +167,31 @@ class _AddGoodsPage extends State<AddGoodsPage> {
"attrName": "", //,app新增商品用不到""
"needImg": 0, //,app新增商品用不到0
"attrValueList": [
{"attrValue": "商品规格",//
{
"attrValue": "商品规格", //
"attrValueCode": "", //,app新增商品用不到""
}]//
}
] //
}
], //
"skuList": [
{
"applyPrice": "234",//
"skuAttrCodeDTOList": [{"attrCode": "", "attrValueCode": ""}],//sku对应的规格编码,app新增商品用不到
"skuPrice": "123",//
"packagingFee": "789",//
"skuStock": "666",//
"weight": "222"//
}],//sku列表
"applyPrice": "234",
//
"skuAttrCodeDTOList": [
{"attrCode": "", "attrValueCode": ""}
],
//sku对应的规格编码,app新增商品用不到
"skuPrice": "123",
//
"packagingFee": "789",
//
"skuStock": "666",
//
"weight": "222"
//
}
], //sku列表
"status": isGround == true ? 1 : 0 //1- 0-
}).catchError((error) {
networkError = AppUtils.dioErrorTypeToString(error.type);
@ -252,14 +264,16 @@ class _AddGoodsPage extends State<AddGoodsPage> {
onTap: () {
officialCategory();
},
child:textSelectItem("官方分类",categoryName == "" ? "请选择":categoryName),
child: textSelectItem(
"官方分类", categoryName == "" ? "请选择" : categoryName),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
goodsGroup();
},
child:textSelectItem("商品分组",groupName == "" ? "请选择":groupName)),
child: textSelectItem(
"商品分组", groupName == "" ? "请选择" : groupName)),
],
),
),
@ -269,7 +283,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
margin: EdgeInsets.only(top: 12.h),
child: Column(
children: [
Padding(padding: EdgeInsets.only(top: 18.h,left: 16.w,right: 16.w),
Padding(
padding:
EdgeInsets.only(top: 18.h, left: 16.w, right: 16.w),
child: Row(
children: [
Padding(
@ -290,7 +306,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
});
},
child: Image.asset(
isAttrStyle == true ? "assets/image/reservation_switch.webp":"assets/image/reservation_unswitch.webp",
isAttrStyle == true
? "assets/image/reservation_switch.webp"
: "assets/image/reservation_unswitch.webp",
width: 44.w,
height: 24.h,
),
@ -301,24 +319,38 @@ class _AddGoodsPage extends State<AddGoodsPage> {
width: double.infinity,
height: 1.w,
color: Color(0x14000000),
margin: EdgeInsets.only(top: 16.h,left: 16.w,right: 16.w),
margin:
EdgeInsets.only(top: 16.h, left: 16.w, right: 16.w),
),
isAttrStyle == true ? GestureDetector(
isAttrStyle == true
? GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/set_goods_specs');
'/router/set_goods_specs',
arguments: {
"goodsSpecsDetails": goodsSpecsDetails
}).then((value) {
if (value != null) {
goodsSpecsDetails.clear();
goodsSpecsDetails.addAll(value);
setState(() {});
}
});
},
child: Container(
padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 16.h),
padding: EdgeInsets.only(
left: 16.w, right: 16.w, top: 16.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(child:Text(
Expanded(
child: Text(
"商品规格",
style: TextStyle(
color: Color(0xFF0D0D0D),
@ -350,7 +382,8 @@ class _AddGoodsPage extends State<AddGoodsPage> {
],
),
),
): textItem("商品规格", skuController, "请输入商品规格"),
)
: textItem("商品规格", skuController, "请输入商品规格"),
if (isAttrStyle == false)
textItem("商品重量", heftController, "请输入商品重量"),
if (isAttrStyle == false)
@ -365,8 +398,10 @@ class _AddGoodsPage extends State<AddGoodsPage> {
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed(
'/router/set_meal',arguments:{"storeId":widget.arguments["storeId"],"mealDetails":mealDetails}).then((value){
Navigator.of(context).pushNamed('/router/set_meal',
arguments: {
"mealDetails": mealDetails
}).then((value) {
if (value != null) {
mealDetails.clear();
mealDetails.addAll(value);
@ -374,7 +409,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
}
});
},
child: Padding(padding: EdgeInsets.symmetric(horizontal: 16.w,vertical:16.h),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16.w, vertical: 16.h),
child: Column(
children: [
Row(
@ -413,21 +450,21 @@ class _AddGoodsPage extends State<AddGoodsPage> {
width: double.infinity,
),
],
),),
),
),
),
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 16.h),
margin: EdgeInsets.only(top: 111.h, bottom: 34.h,left:16.w,right:16.w),
margin: EdgeInsets.only(
top: 111.h, bottom: 34.h, left: 16.w, right: 16.w),
decoration: BoxDecoration(
color: Color(0xFF30415B),
borderRadius: BorderRadius.circular(27),
),
alignment: Alignment.center,
child: Text(
S
.of(context)
.baocun,
S.of(context).baocun,
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
@ -608,7 +645,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
});
},
child: Image.asset(
isLogistics == true ? "assets/image/reservation_switch.webp":"assets/image/reservation_unswitch.webp",
isLogistics == true
? "assets/image/reservation_switch.webp"
: "assets/image/reservation_unswitch.webp",
width: 44.w,
height: 24.h,
),
@ -637,7 +676,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
});
},
child: Image.asset(
isGround == true ? "assets/image/reservation_switch.webp":"assets/image/reservation_unswitch.webp",
isGround == true
? "assets/image/reservation_switch.webp"
: "assets/image/reservation_unswitch.webp",
width: 44.w,
height: 24.h,
),
@ -676,14 +717,17 @@ class _AddGoodsPage extends State<AddGoodsPage> {
});
},
child: Image.asset(
isOversold == true ? "assets/image/reservation_switch.webp":"assets/image/reservation_unswitch.webp",
isOversold == true
? "assets/image/reservation_switch.webp"
: "assets/image/reservation_unswitch.webp",
width: 44.w,
height: 24.h,
),
),
],
),
), Expanded(
),
Expanded(
child: Row(
children: [
Padding(
@ -704,7 +748,9 @@ class _AddGoodsPage extends State<AddGoodsPage> {
});
},
child: Image.asset(
isSetMeal == true ? "assets/image/reservation_switch.webp":"assets/image/reservation_unswitch.webp",
isSetMeal == true
? "assets/image/reservation_switch.webp"
: "assets/image/reservation_unswitch.webp",
width: 44.w,
height: 24.h,
),
@ -961,7 +1007,8 @@ class _AddGoodsPage extends State<AddGoodsPage> {
),
],
),
Expanded(child:ListView.builder(
Expanded(
child: ListView.builder(
padding: EdgeInsets.zero,
itemCount: goodsCategoryList?.length ?? 0,
scrollDirection: Axis.vertical,
@ -974,21 +1021,24 @@ class _AddGoodsPage extends State<AddGoodsPage> {
categoryIndex = position;
});
},
child: categoryItem(goodsCategoryList[position],position),
child:
categoryItem(goodsCategoryList[position], position),
);
},
)),
GestureDetector(
onTap: () {
setState(() {
categoryName = goodsCategoryList[categoryIndex].categoryName;
categoryName =
goodsCategoryList[categoryIndex].categoryName;
Navigator.of(context).pop();
});
},
child: Container(
width: double.infinity,
alignment: Alignment.center,
margin: EdgeInsets.symmetric(vertical:25.h,horizontal:16.w),
margin: EdgeInsets.symmetric(
vertical: 25.h, horizontal: 16.w),
padding: EdgeInsets.symmetric(vertical: 16.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(27),
@ -1026,17 +1076,13 @@ class _AddGoodsPage extends State<AddGoodsPage> {
: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4.w),
border: Border.all(
color: categoryIndex == index
? Color(0xFF30415B)
: Colors.white,
color:
categoryIndex == index ? Color(0xFF30415B) : Colors.white,
width: categoryIndex == index ? 1.w : 0,
),
),
padding: EdgeInsets.only(
top: 16.h,
bottom: 16.h,
left: 16.w,
right: 17.w),
top: 16.h, bottom: 16.h, left: 16.w, right: 17.w),
child: Text(
goodsCategoryList?.categoryName ?? "",
style: TextStyle(
@ -1118,7 +1164,8 @@ class _AddGoodsPage extends State<AddGoodsPage> {
),
],
),
Expanded(child:ListView.builder(
Expanded(
child: ListView.builder(
padding: EdgeInsets.zero,
itemCount: productGroupList?.records?.length ?? 0,
scrollDirection: Axis.vertical,
@ -1131,21 +1178,25 @@ class _AddGoodsPage extends State<AddGoodsPage> {
groupIndex = position;
});
},
child: groupItem(productGroupList.records[position],position),
child: groupItem(
productGroupList.records[position], position),
);
},
)),
GestureDetector(
onTap: () {
setState(() {
groupName = productGroupList?.records[groupIndex]?.groupName ?? "";
groupName =
productGroupList?.records[groupIndex]?.groupName ??
"";
Navigator.of(context).pop();
});
},
child: Container(
width: double.infinity,
alignment: Alignment.center,
margin: EdgeInsets.symmetric(vertical:25.h,horizontal:16.w),
margin: EdgeInsets.symmetric(
vertical: 25.h, horizontal: 16.w),
padding: EdgeInsets.symmetric(vertical: 16.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(27),
@ -1178,22 +1229,16 @@ class _AddGoodsPage extends State<AddGoodsPage> {
height: 52.h,
width: double.infinity,
decoration: BoxDecoration(
color: groupIndex == index
? Color(0xFFEFF5FF)
: Color(0xFFF7F7F7),
color:
groupIndex == index ? Color(0xFFEFF5FF) : Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4.w),
border: Border.all(
color: groupIndex == index
? Color(0xFF30415B)
: Colors.white,
color: groupIndex == index ? Color(0xFF30415B) : Colors.white,
width: groupIndex == index ? 1.w : 0,
),
),
padding: EdgeInsets.only(
top: 16.h,
bottom: 16.h,
left: 16.w,
right: 17.w),
top: 16.h, bottom: 16.h, left: 16.w, right: 17.w),
child: Text(
records?.groupName ?? "",
style: TextStyle(

8
lib/business_system/goods/add_goods/edit_specs_detail.dart

@ -125,10 +125,10 @@ class _EditSpecsDetail extends State<EditSpecsDetail> {
specsDetail.add({
"skuName": element.specsDetailName,
"goodPrice": element.goodPriceController.text,
"originalPrice": element.originalPriceController.text,
"packagingFee": element.packagingFeeController.text,
"specsWeight": element.specsWeightController.text,
"skuStock": element.skuStockController.text
"originalPrice": element.originalPriceController.text == "" ? "0" :element.originalPriceController.text,
"packagingFee": element.packagingFeeController.text == "" ? "0" :element.packagingFeeController.text,
"specsWeight": element.specsWeightController.text == "" ? "0" :element.specsWeightController.text,
"skuStock": element.skuStockController.text == "" ? "0" :element.skuStockController.text
});
});
if (flag) {

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

@ -3,7 +3,6 @@ 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 '../../../retrofit/business_api.dart';
import '../../../retrofit/data/edit_specs_detail_list.dart';
import '../../../retrofit/data/set_specs_list.dart';
import '../../../utils/font_weight.dart';
import '../../../view_widget/settlement_tips_dialog.dart';
@ -43,6 +42,14 @@ class _SetGoodsSpecs extends State<SetGoodsSpecs> {
}
});
});
List<dynamic> goodsSpecsDetails = widget?.arguments["goodsSpecsDetails"] ??[];
goodsSpecsDetails.forEach((element) {
var tempValue = SetSpecsList();
tempValue.specsNameController.text = element["specsName"];
tempValue.specsValues = element["specsValue"];
specsDetails.addAll(element["valueDetail"]);
specs.add(tempValue);
});
}
///
@ -257,6 +264,7 @@ class _SetGoodsSpecs extends State<SetGoodsSpecs> {
onTap: () {
bool flag = false;
String tipText = "";
List<dynamic> goodsSpecsDetail = [];
specs.forEach((element) {
if (element.specsNameController.text
.trim() ==
@ -270,7 +278,16 @@ class _SetGoodsSpecs extends State<SetGoodsSpecs> {
flag = true;
tipText = "未添加规格值,请先添加规格值";
return;
}else if(specsDetails.length == 0){
flag = true;
tipText = "请设置规格明细";
return;
}
goodsSpecsDetail.add({
"specsName": element.specsNameController.text,
"specsValue":element.specsValues,
"valueDetail":specsDetails
});
});
if (flag) {
SmartDialog.show(
@ -281,7 +298,8 @@ class _SetGoodsSpecs extends State<SetGoodsSpecs> {
color: Color(0xFF30415B),
));
} else {
// Navigator.of(context).pop();
print(goodsSpecsDetail);
Navigator.of(context).pop(goodsSpecsDetail);
}
},
child: Container(

88
lib/business_system/goods/on_sale/batch_shelf.dart

@ -27,6 +27,7 @@ class BatchShelf extends StatefulWidget {
final Map<String, dynamic> arguments;
BatchShelf({this.arguments});
@override
State<StatefulWidget> createState() {
return _BatchShelf();
@ -66,13 +67,17 @@ class _BatchShelf extends State<BatchShelf> {
status: S.current.zhengzaijiazai,
maskType: EasyLoadingMaskType.black);
SharedPreferences.getInstance().then((value) {
businessService = BusinessApiService(Dio(),
businessService = BusinessApiService(
Dio(),
context: context,
token: BusinessInstance.instance.businessToken,
tenant: BusinessInstance.instance.businessTenant,
storeId: widget.arguments["storeId"],);
storeId: widget.arguments["storeId"],
);
queryProductGroupList();
queryGoodsList(groupIndex != -1 ? productGroupList.records[groupIndex].id : "", isSing: false);
queryGoodsList(
groupIndex != -1 ? productGroupList.records[groupIndex].id : "",
isSing: false);
});
}
@ -97,8 +102,7 @@ class _BatchShelf extends State<BatchShelf> {
"order": "ascending",
"size": 100,
"sort": "sort"
}).catchError((error) {
});
}).catchError((error) {});
if (!mounted) return;
if (baseData != null && baseData.isSuccess) {
productGroupList = baseData.data;
@ -169,16 +173,17 @@ class _BatchShelf extends State<BatchShelf> {
if (baseData != null && baseData.isSuccess) {
_pageIndex = 1;
adminProductVoList.clear();
await queryGoodsList(groupIndex == -1
await queryGoodsList(
groupIndex == -1
? ""
: productGroupList?.records[groupIndex]?.id ?? "", isSing: false);
: productGroupList?.records[groupIndex]?.id ?? "",
isSing: false);
setState(() {});
SmartDialog.showToast("商品下架成功", alignment: Alignment.center);
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
finally{
} finally {
EasyLoading.dismiss();
}
}
@ -198,21 +203,18 @@ class _BatchShelf extends State<BatchShelf> {
onTap: () {
List<Map<String, String>> goodsMeal = [];
if (titleName == "批量下架") {
if (productIds.length != 0)
productIds.clear();
if (productIds.length != 0) productIds.clear();
adminProductVoList.forEach((element) {
if (element.isSelect) productIds.add(element.id);
});
if (productIds.length == 0) {
SmartDialog.showToast("请选择要下架的商品",
alignment: Alignment.center);
SmartDialog.showToast("请选择要下架的商品", alignment: Alignment.center);
return;
} else {
showGoodsStateDialog();
}
} else {
if(goodsMeal.length != 0)
goodsMeal.clear();
if (goodsMeal.length != 0) goodsMeal.clear();
adminProductVoList.forEach((element) {
if (element.isSelect)
goodsMeal.add({
@ -222,8 +224,7 @@ class _BatchShelf extends State<BatchShelf> {
});
Navigator.of(context).pop(goodsMeal);
if (goodsMeal.length == 0) {
SmartDialog.showToast("请选择要增加的商品",
alignment: Alignment.center);
SmartDialog.showToast("请选择要增加的商品", alignment: Alignment.center);
return;
}
}
@ -241,7 +242,9 @@ class _BatchShelf extends State<BatchShelf> {
),
),
),
body: networkStatus == -1 ? noNetwork() : Row(
body: networkStatus == -1
? noNetwork()
: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -270,11 +273,12 @@ class _BatchShelf extends State<BatchShelf> {
groupIndex = position;
_pageIndex = 1;
adminProductVoList.clear();
queryGoodsList(productGroupList?.records[position].id,);
queryGoodsList(
productGroupList?.records[position].id,
);
},
child: shelfLeftItem(
productGroupList.records[position],
position),
productGroupList.records[position], position),
);
},
),
@ -320,8 +324,7 @@ class _BatchShelf extends State<BatchShelf> {
: ((adminProductVoList == null ||
adminProductVoList.length == 0)
? NoDataView(
src:
"assets/image/bs_no data_logo.webp",
src: "assets/image/bs_no data_logo.webp",
isShowBtn: false,
text: "该分组暂无添加商品",
fontSize: 16.sp,
@ -334,7 +337,8 @@ class _BatchShelf extends State<BatchShelf> {
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return shelfGoodsItem(adminProductVoList[position]);
return shelfGoodsItem(
adminProductVoList[position]);
},
)))),
),
@ -458,11 +462,15 @@ class _BatchShelf extends State<BatchShelf> {
fit: BoxFit.cover,
radius: BorderRadius.circular(4),
),
SizedBox(width:12.w,),
Expanded(child:Column(
SizedBox(
width: 12.w,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding:EdgeInsets.only(top: 2.h),
Padding(
padding: EdgeInsets.only(top: 2.h),
child: Text(
adminProductVoList?.productName ?? "",
maxLines: 1,
@ -483,8 +491,11 @@ class _BatchShelf extends State<BatchShelf> {
color: Color(0xFFA29E9E),
),
),
SizedBox(width: 8.w,),
Expanded(child: Text(
SizedBox(
width: 8.w,
),
Expanded(
child: Text(
"销量${adminProductVoList?.sellCount ?? 0}",
style: TextStyle(
fontSize: 10.sp,
@ -496,7 +507,8 @@ class _BatchShelf extends State<BatchShelf> {
value: adminProductVoList.isSelect,
onChanged: (a) {
setState(() {
adminProductVoList.isSelect = !adminProductVoList.isSelect;
adminProductVoList.isSelect =
!adminProductVoList.isSelect;
});
},
shape: RoundedRectangleBorder(
@ -507,10 +519,13 @@ class _BatchShelf extends State<BatchShelf> {
),
],
),
SizedBox(height:7.h,),
SizedBox(
height: 7.h,
),
Row(
children: [
Expanded(child:Text.rich(
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
@ -537,9 +552,9 @@ class _BatchShelf extends State<BatchShelf> {
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
if(adminProductVoList.goodsNumber <= 1)
return;
adminProductVoList?.goodsNumber = adminProductVoList.goodsNumber - 1;
if (adminProductVoList.goodsNumber <= 1) return;
adminProductVoList?.goodsNumber =
adminProductVoList.goodsNumber - 1;
});
},
child: Container(
@ -563,7 +578,8 @@ class _BatchShelf extends State<BatchShelf> {
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
adminProductVoList.goodsNumber = adminProductVoList.goodsNumber + 1;
adminProductVoList.goodsNumber =
adminProductVoList.goodsNumber + 1;
});
},
child: Container(

Loading…
Cancel
Save