|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/models/get_deposit_model.dart';
|
|
|
|
import 'package:one_key/provider/feast_model.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../constant/state.dart';
|
|
|
|
import '../../../provider/user_model.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../utils/dialog_util.dart';
|
|
|
|
import '../../../utils/event_bus.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/page_exception.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../../widgets/system_app_bar.dart';
|
|
|
|
|
|
...
|
...
|
@@ -21,10 +28,42 @@ class FeastDepositTypePage extends StatefulWidget { |
|
|
|
}
|
|
|
|
|
|
|
|
class _FeastDepositTypePageState extends State<FeastDepositTypePage> {
|
|
|
|
FeastModel feastModel;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
Utils.changeStatusColor(color: MyColours.color_438E93);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_getDeposit();
|
|
|
|
// scrollController.jumpTo(scrollController.position.minScrollExtent);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取宴会分类
|
|
|
|
Future<bool> _getDeposit({bool isShowLoading = true}) async {
|
|
|
|
await feastModel.getDeposit(context, isShowLoading: isShowLoading);
|
|
|
|
}
|
|
|
|
|
|
|
|
_setDeposit(String dname, {String did}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
'dname': dname,
|
|
|
|
};
|
|
|
|
if (did != null) {
|
|
|
|
params['id'] = did;
|
|
|
|
}
|
|
|
|
bool success = await feastModel.setDeposit(context, params);
|
|
|
|
if (success) {
|
|
|
|
if (did != null) {
|
|
|
|
Utils.showToast('修改成功');
|
|
|
|
} else {
|
|
|
|
Utils.showToast('添加成功');
|
|
|
|
}
|
|
|
|
|
|
|
|
_getDeposit();
|
|
|
|
|
|
|
|
// _getWine(isShowLoading: true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildFeastTypeHeader() {
|
|
...
|
...
|
@@ -37,6 +76,7 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
lenghtLimit: false,
|
|
|
|
toast: '请输入类型名称', rCallback: (name) {
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
_setDeposit(name);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
text: '添加一项',
|
|
...
|
...
|
@@ -53,7 +93,7 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildFeastTypeItem(String title) {
|
|
|
|
Widget buildFeastTypeItem(GetDepositSunModel sunModel, int index) {
|
|
|
|
return Container(
|
|
|
|
height: h(48),
|
|
|
|
margin: EdgeInsets.only(top: w(12)),
|
|
...
|
...
|
@@ -64,7 +104,7 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
sunModel.dname,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: font(16), color: MyColours.color_E6000000),
|
|
|
|
),
|
|
...
|
...
|
@@ -74,10 +114,11 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
DialogUtil.textfeildAlertDialog(context,
|
|
|
|
title: '输入类型名称',
|
|
|
|
hintText: '请输入',
|
|
|
|
text: '原来的内容',
|
|
|
|
text: sunModel.dname,
|
|
|
|
lenghtLimit: true,
|
|
|
|
toast: '请输入类型名称', rCallback: (name) {
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
_setDeposit(name, did: sunModel.id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Text(
|
|
...
|
...
|
@@ -95,15 +136,20 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
DialogUtil.cupertinoAlertDialogFeast(context,
|
|
|
|
rTitle: '删除',
|
|
|
|
title: "是否确认删除",
|
|
|
|
content: "酒水定金", lCallback: () {
|
|
|
|
content: sunModel.dname, lCallback: () {
|
|
|
|
print("取消");
|
|
|
|
}, rCallback: () {
|
|
|
|
}, rCallback: () async {
|
|
|
|
print("确定");
|
|
|
|
// widget.deleteCallback(index);
|
|
|
|
Map<String, String> pramas = {'id': sunModel.id};
|
|
|
|
bool success = await feastModel.delDeposit(context, pramas);
|
|
|
|
if (success) {
|
|
|
|
Utils.showToast('删除成功');
|
|
|
|
_getDeposit(isShowLoading: true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
|
|
|
|
Utils.getImgPath('f_delete_red'),
|
|
|
|
width: w(32),
|
|
|
|
height: w(32),
|
|
|
|
)),
|
|
...
|
...
|
@@ -115,8 +161,12 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
feastModel = Provider.of<FeastModel>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
resizeToAvoidBottomInset: false,
|
|
|
|
|
|
|
|
/// 这里必须禁止重绘
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'定金类型',
|
|
|
|
needWhite: true,
|
|
...
|
...
|
@@ -144,12 +194,27 @@ class _FeastDepositTypePageState extends State<FeastDepositTypePage> { |
|
|
|
)
|
|
|
|
];
|
|
|
|
},
|
|
|
|
body: ListView.builder(
|
|
|
|
itemCount: 100,
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return buildFeastTypeItem('酒水定金');
|
|
|
|
}),
|
|
|
|
body: Consumer<FeastModel>(builder: (context, model, _) {
|
|
|
|
if (model.pageStateDeposit != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageStateDeposit,
|
|
|
|
callback: () {
|
|
|
|
_getDeposit();
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有定金类型哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: feastModel.depositData.length,
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
GetDepositSunModel sunModel = feastModel.depositData[index];
|
|
|
|
return buildFeastTypeItem(sunModel, index);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
...
|
...
|
|