Commit 1406fcaeee1e80115bb98dd2220fc3185bcfc2a7

Authored by wdn127929
1 parent e207a205

消费金额

... ... @@ -78,6 +78,7 @@ class NotebookDetail {
String abolition;
String tableinfo;
String pnum;
String actual_pum;
String rname;
String sex;
String phone;
... ... @@ -97,6 +98,7 @@ class NotebookDetail {
Cancel cancel;
Order order;
OrderInfo orderInfo;
String con_amount;
String get statuImgAssets {
switch (status) {
... ... @@ -214,7 +216,7 @@ class NotebookDetail {
@override
String toString() {
return 'NotebookDetail{id: $id, abolition: $abolition, tableinfo: $tableinfo, pnum: $pnum, rname: $rname, sex: $sex, phone: $phone, cusdem: $cusdem, cusman: $cusman, ddate: $ddate, is_set_ddate: $is_set_ddate, ddate_solt: $ddate_solt, status: $status, action: $action, type: $type, note_name: $note_name, channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel}';
return 'NotebookDetail{id: $id, con_amount:$con_amount,abolition: $abolition, tableinfo: $tableinfo,actual_pum:$actual_pum, pnum: $pnum, rname: $rname, sex: $sex, phone: $phone, cusdem: $cusdem, cusman: $cusman, ddate: $ddate, is_set_ddate: $is_set_ddate, ddate_solt: $ddate_solt, status: $status, action: $action, type: $type, note_name: $note_name, channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel}';
}
}
... ...
... ... @@ -13,6 +13,8 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) {
..tableinfo = json['tableinfo'] as String
..abolition = json['abolition'] as String
..pnum = json['pnum'] as String
..actual_pum = json['actual_pum'] as String
..con_amount = json['con_amount'] as String
..rname = json['rname'] as String
..sex = json['sex'] as String
..phone = json['phone'] as String
... ... @@ -52,6 +54,8 @@ Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) =>
'tableinfo': instance.tableinfo,
'abolition': instance.abolition,
'pnum': instance.pnum,
'con_amount':instance.con_amount,
'actual_pum':instance.actual_pum,
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
... ...
... ... @@ -108,5 +108,7 @@ class HttpUrl {
static const String add_table = "?service=App.Tables.AddTable"; // 添加商家桌位信息
static const String add_forward =
"?service=App.Activity.AddForward"; // 客户经理转发记录
static const String up_reserve_info =
"?service=App.Reserve.UpReserveInfo"; // 编辑订单附加信息
}
... ...
... ... @@ -13,6 +13,7 @@ import 'package:one_key/provider/notebook_detail_model.dart';
import 'package:one_key/provider/online_check_edit_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/NumLengthInputFormatter.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/route/navigator_util.dart';
... ... @@ -77,6 +78,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_initCancel();
_getReserveDetail();
... ... @@ -145,6 +147,20 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
"rid": widget.rid,
});
setState(() {
detailModel.selectNum = detailEntity.actual_pum;
detailModel.selectIndex = detailEntity.actual_pum != null
? personNumList.indexOf(detailEntity.actual_pum)
: null;
if (detailEntity.con_amount != null) {
detailModel.prestrTF = detailEntity.con_amount;
detailModel.numController.text = detailEntity.con_amount;
}
if (detailEntity.con_amount != null) {
detailModel.prestrTF = detailEntity.con_amount;
detailModel.strTF = detailEntity.con_amount;
detailModel.numController.text = detailEntity.con_amount;
}
cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
formatPhone = detailEntity.phone;
if (App.sp.getString("is_call_tel") != null &&
... ... @@ -219,6 +235,23 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
}
}
///编辑订单附加信息
Future<bool> _upReserveInfo({String actualPum, String conAmount}) async {
Map<String, dynamic> params = {
"rid": widget.rid,
};
if (actualPum != null) {
params['actual_pum'] = actualPum;
}
if (conAmount != null) {
params['con_amount'] = conAmount;
}
bool sucess = await detailModel.upReserveInfo(context, params);
if (sucess) {
Utils.showToast("修改成功!");
}
}
/// 取消预订, 变更预订按钮
Widget _cancelAndChangeBtn(GestureTapCallback onTap, String title,
{Color bgColor = MyColours.color_ffffff,
... ... @@ -542,11 +575,16 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
offstage: detailEntity.type == "0"
? false
: true,
child: TitleAndTextfield(
child: TitleAndBtn(
title: "用餐人数",
bookNum: detailEntity.pnum,
pnumlist: personNumList,
detailModel: model,
callback: () {
_upReserveInfo(
actualPum:
detailModel.selectNum);
},
),
),
Offstage(
... ... @@ -627,6 +665,15 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
),
),
)),
TitleAndTextfield(
title: "消费金额",
detailModel: detailModel,
callback: () {
_upReserveInfo(
conAmount:
detailModel.prestrTF);
},
),
RowMultiText(
"客户姓名", detailEntity.rnameStr),
InkWell(
... ... @@ -1192,13 +1239,19 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
}
}
class TitleAndTextfield extends StatelessWidget {
class TitleAndBtn extends StatelessWidget {
final String title;
final String bookNum;
final List<String> pnumlist;
final NotebookDetailModel detailModel;
const TitleAndTextfield(
{Key key, this.title, this.bookNum, this.pnumlist, this.detailModel})
final VoidCallback callback;
const TitleAndBtn(
{Key key,
this.title,
this.bookNum,
this.pnumlist,
this.detailModel,
this.callback})
: super(key: key);
@override
... ... @@ -1234,18 +1287,19 @@ class TitleAndTextfield extends StatelessWidget {
FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
DialogUtil.showSelectCusmanDialog(context, pnumlist, (value) {
if (value != null) {
detailModel.selectNum = value.first;
detailModel.selectIndex = value.first;
detailModel.selectNum = pnumlist[value.first];
detailModel.notifyListeners();
// setState(() {
// selectPnum = value.first;
// pnum = pnumlist[value.first];
// });
callback();
}
},
selecteds: detailModel.selectNum == null
selecteds: detailModel.selectIndex == null
? []
: [detailModel.selectNum])
: [detailModel.selectIndex])
.then((value) {});
},
child: Container(
... ... @@ -1277,54 +1331,122 @@ class TitleAndTextfield extends StatelessWidget {
]));
}
}
// Container(
// alignment: Alignment.center,
// // color: Colors.red,
// width: ScreenUtil().setWidth(114),
// height: ScreenUtil().setWidth(50),
// // padding: EdgeInsets.zero,
// child: TextField(
// controller: widget.model.numController,
// maxLines: 1,
// inputFormatters: [
// LengthLimitingTextInputFormatter(3),
// WhitelistingTextInputFormatter.digitsOnly
// ],
// //光标颜色
// cursorColor:
// MyColours.color_199095,
// //输入文本的样式
// style: TextStyle(
// fontSize: ScreenUtil().setSp(30),
// color: widget.isSelect
// ? Colors.white
// : MyColours.color_199095),
// // controller: _cancelController,
// focusNode: _cancelNode,
// textAlignVertical: TextAlignVertical.bottom,
// decoration: InputDecoration(
// // fillColor: Colors.lightGreenAccent,
// // filled: true,
// border: OutlineInputBorder(borderSide: BorderSide.none),
// hintText: "更多",
// hintStyle: TextStyle(
// color: widget.isSelect
// ? Colors.white
// : MyColours.color_199095,
// fontSize: ScreenUtil().setSp(30),
// ),
// // contentPadding: EdgeInsets.only(
// // bottom: ScreenUtil().setWidth(30)), //ios 17
// // border: InputBorder.none,
// ),
// onChanged: (value) {
class TitleAndTextfield extends StatelessWidget {
final String title;
final String bookNum;
final List<String> pnumlist;
final NotebookDetailModel detailModel;
final VoidCallback callback;
const TitleAndTextfield(
{Key key,
this.title,
this.bookNum,
this.pnumlist,
this.detailModel,
this.callback})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: MyColours.color_ffffff,
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(25)),
alignment: Alignment.center,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text(
title,
style: TextStyle(
color: MyColours.color_828282,
fontSize: ScreenUtil().setSp(30)),
),
),
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color: MyColours.color_199095))),
child: IntrinsicWidth(
child: TextField(
controller: detailModel.numController,
maxLines: 1,
// inputFormatters: [
// LengthLimitingTextInputFormatter(9),
// WhitelistingTextInputFormatter.digitsOnly
// ],
inputFormatters: [
NumLengthInputFormatter(
decimalLength: 2, integerLength: 6),
],
//光标颜色
cursorColor: MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095),
textAlign: TextAlign.right,
decoration: InputDecoration(
hintText: "修改",
hintStyle: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(30),
),
prefixIcon: detailModel.strTF != null &&
detailModel.strTF.trim().length > 0
? Text("¥",
style: TextStyle(color: MyColours.color_199095))
: SizedBox(), //添加内部左边图标
prefixIconConstraints: BoxConstraints(
//添加内部图标之后,图标和文字会有间距,实现这个方法,不用写任何参数即可解决
),
// },
// onEditingComplete: () {
// // _cancelNode.unfocus();
// contentPadding: EdgeInsets.only(
// bottom: ScreenUtil().setWidth(30)), //ios 17
border: InputBorder.none,
),
onChanged: (value) {
detailModel.strTF = value;
// },
// keyboardType: TextInputType.number,
// ),
// )
print(detailModel.numController.text);
detailModel.notifyListeners();
},
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
if (detailModel.prestrTF == null ||
detailModel.prestrTF == "") {
//修改之前无内容,不弹框
detailModel.prestrTF = detailModel.numController.text;
callback();
} else {
//修改之前有内容,则弹框
DialogUtil.cupertinoAlertDialog(context,
title: "是否修改",
content: "金额已修改,是否保存为新修改的金额",
lTitle: "不保存",
rTitle: "确认修改", lCallback: () {
print("取消");
detailModel.numController.text =
detailModel.prestrTF == null
? ""
: detailModel.prestrTF;
detailModel.strTF = detailModel.numController.text;
}, rCallback: () {
print("确定");
detailModel.prestrTF = detailModel.numController.text;
callback();
});
}
},
keyboardType: TextInputType.number,
)))
]));
}
}
... ...
... ... @@ -114,6 +114,8 @@ class LoginState extends State<LoginPage> with WidgetsBindingObserver {
super.didChangeDependencies();
}
//监听输入框,设置登录按钮状态
setActivate() {
if (_sellerCodeController.text.isNotEmpty &&
... ...
... ... @@ -14,7 +14,11 @@ import 'package:provider/provider.dart';
class NotebookDetailModel extends ChangeNotifier {
PageState pageState = PageState.Loading;
int selectNum;
String selectNum;
int selectIndex;
TextEditingController numController = TextEditingController();
String strTF;
String prestrTF;
///获取已预订订单
Future<NotebookDetail> getReserveDetail(
... ... @@ -134,4 +138,22 @@ class NotebookDetailModel extends ChangeNotifier {
Utils.showToast(baseResp.msg);
}
}
// 编辑订单附加信息
Future<bool> upReserveInfo(BuildContext context, Map<String, dynamic> params,
{ifPush = true, showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.up_reserve_info,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success && baseResp.data != null) {
return true;
} else {
Utils.showToast(baseResp.msg);
return false;
}
}
}
... ...
import 'package:flutter/services.dart';
class NumLengthInputFormatter extends TextInputFormatter {
int decimalLength;
int integerLength;
bool allowInputDecimal;
NumLengthInputFormatter({this.decimalLength = 2, this.integerLength = 8}) : super();
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
String value = newValue.text;
int selectionIndex = newValue.selection.end;
if (newValue.text.contains('.')) {
int pointIndex = newValue.text.indexOf('.');
String beforePoint = newValue.text.substring(0, pointIndex);
print('$beforePoint');
//小数点前内容大于integerLength
if (beforePoint.length > integerLength) {
value = oldValue.text;
selectionIndex = oldValue.selection.end;
} else
//小数点前内容小于等于integerLength
{
String afterPoint = newValue.text.substring(pointIndex + 1, newValue.text.length);
if (afterPoint.length > decimalLength) {
value = oldValue.text;
selectionIndex = oldValue.selection.end;
}
}
} else {
if (newValue.text.length > integerLength) {
value = oldValue.text;
selectionIndex = oldValue.selection.end;
}
}
return new TextEditingValue(
text: value,
selection: new TextSelection.collapsed(offset: selectionIndex),
);
}
}
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:ui';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
... ... @@ -1875,4 +1876,52 @@ class DialogUtil {
// default:
}
}
static Future cupertinoAlertDialog(BuildContext context,
{String title = "标题",
String content = "内容",
String lTitle = "取消",
String rTitle = "确定",
VoidCallback lCallback,
VoidCallback rCallback}) {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: Text(title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_353535)),
content: Text(content,
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_353535)),
actions: [
CupertinoDialogAction(
child: Text(lTitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_666666)),
onPressed: () {
Navigator.of(context).pop();
lCallback();
},
),
CupertinoDialogAction(
child: Text(rTitle,
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_199095)),
onPressed: () {
Navigator.of(context).pop();
rCallback();
},
),
],
insetAnimationDuration: Duration(seconds: 2),
);
},
);
}
}
... ...