add 批量删除

hmxc
张萌 4 years ago
parent 7920bc36fc
commit 0b78e30878

@ -127,6 +127,9 @@ class _Manager {
///
String get getQRcode => '/user/articleOut/getQRCode';
///app
String get articleOutDelete => '/user/articleOut/falseDelete';
}
class _Community {

@ -1,4 +1,7 @@
// Flutter imports:
import 'package:akuCommunity/pages/manager_func.dart';
import 'package:akuCommunity/widget/buttons/bottom_button.dart';
import 'package:akuCommunity/widget/buttons/radio_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -25,10 +28,51 @@ class GoodsDetoPage extends StatefulWidget {
class _GoodsDetoPageState extends State<GoodsDetoPage> {
EasyRefreshController _refreshController = EasyRefreshController();
List<int> _select = [];
bool _isEdit = false;
bool _canSkew(int state) {
switch (state) {
case 1:
case 2:
case 3:
return false;
case 4:
case 5:
case 6:
case 7:
return true;
default:
return true;
}
}
Widget _buildPositioned(GoodsOutModel model) {
return AnimatedPositioned(
bottom: 0,
top: 0,
left: (_canSkew(4) && _isEdit) ? 80.w : 0.w,
duration: Duration(milliseconds: 300),
width: 750.w,
child: GoodsInfoCard(
model: model,
),
);
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '物品出户',
actions: [
IconButton(
icon: _isEdit
? '完成'.text.black.size(28.sp).make()
: '编辑'.text.black.size(28.sp).make(),
onPressed: () {
_isEdit = !_isEdit;
setState(() {});
})
],
body: Padding(
padding: EdgeInsets.only(bottom: 98.w),
child: BeeListView(
@ -42,23 +86,49 @@ class _GoodsDetoPageState extends State<GoodsDetoPage> {
builder: (items) {
return ListView.builder(
itemBuilder: (context, index) {
return GoodsInfoCard(
model: items[index],
);
return Stack(children: [
GestureDetector(
onTap: () {
if (_select.contains(items[index].id)) {
_select.remove(items[index].id);
} else
_select.add(items[index].id);
setState(() {});
},
child: Container(
padding: EdgeInsets.symmetric(
vertical: 50.w, horizontal: 32.w),
alignment: Alignment.topLeft,
constraints: BoxConstraints(
minHeight: 631.w + 96.w, minWidth: 686.w),
child: BeeRadio(
value: items[index].id, groupValues: _select),
),
),
_buildPositioned(items[index]),
]);
},
itemCount: items.length,
);
},
),
),
bottomNavi: MaterialButton(
color: kPrimaryColor,
padding: EdgeInsets.only(top:26.w ,bottom: MediaQuery.of(context).padding.bottom+26.w),
child: '新增'.text.black.size(32.sp).bold.make(),
onPressed: () {
bottomNavi: BottomButton(
onPressed: _isEdit
? _select.isEmpty
? null
: () async {
await ManagerFunc.articleOutDelete(_select);
_select.clear();
_refreshController.callRefresh();
}
: () {
DetoCreatePage().to();
},),
},
child: _isEdit
? '删除'.text.size(32.sp).bold.make()
: '新增'.text.size(32.sp).bold.make(),
),
);
}
}

@ -19,7 +19,7 @@ class GoodsInfoCard extends StatelessWidget {
Widget _builTile(String title, String text) {
return Container(
padding: EdgeInsets.only(top: 8.w),
// padding: EdgeInsets.only(top: 8.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [

@ -81,6 +81,7 @@ class GoodsInfoCardButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.6),
borderRadius: BorderRadius.only(

@ -138,4 +138,13 @@ class ManagerFunc {
);
return ArticleQRModel.fromJson(response.data);
}
static Future<BaseModel> articleOutDelete(List<int> ids) async {
BaseModel baseModel = await NetUtil().post(
API.manager.articleOutDelete,
params: {'ids': ids},
showMessage: true,
);
return baseModel;
}
}

@ -84,7 +84,7 @@ class _FixedSubmitPageState extends State<FixedSubmitPage> {
Widget _buildCard(FixedSubmitModel model) {
return AnimatedPositioned(
top: 0,
left: (_canSkew(4) && _isEdit) ? 55.w : 0,
left: (_canSkew(model.status) && _isEdit) ? 55.w : 0,
bottom: 0,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,

@ -26,7 +26,8 @@ class _FixedCheckBoxState extends State<FixedCheckBox> {
});
widget.onChanged(_isSelected);
},
child: Container(
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
alignment: Alignment.center,
width: 40.w,
height: 40.w,
@ -36,7 +37,8 @@ class _FixedCheckBoxState extends State<FixedCheckBox> {
width: 3.w, color: _isSelected ? kPrimaryColor : kDarkSubColor),
color: Colors.transparent,
),
child: Container(
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
width: 24.w,
height: 24.w,
decoration: BoxDecoration(

@ -24,14 +24,10 @@ class BottomButton extends StatelessWidget {
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: DefaultTextStyle(
disabledColor: Colors.white.withOpacity(0.5),
disabledTextColor: ktextSubColor.withOpacity(0.8),
textColor: ktextPrimary,
child: child,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 32.sp,
),
),
onPressed: onPressed,
color: kPrimaryColor,
height: 98.w,

Loading…
Cancel
Save