Commit db9226adc2434b9fb9b986f987723bd09421a48a

Authored by wdn127929
1 parent 7833194f

桌位管理部分

... ... @@ -446,8 +446,8 @@ class DioUtil {
static BaseOptions getDefOptions() {
BaseOptions options = new BaseOptions();
options.contentType = Headers.formUrlEncodedContentType;
options.connectTimeout = 1000 * 10; //默认10s
options.receiveTimeout = 10000 * 10; //默认10s
options.connectTimeout = 1000 * 300; //默认30s
options.receiveTimeout = 1000 * 300; //默认30s
return options;
}
}
... ...
... ... @@ -224,5 +224,13 @@ class HttpUrl {
"?service=App.GuestManage.SendMarketingMsgByMid"; // 催促未完成任务经理发消息
static const String get_table_type =
"?service=App.Tables.GetTabletype"; // 获取桌子类型列表
static const String set_table_by_id =
"?service=App.Tables.SetTableById"; // 修改桌位信息
static const String del_seller_tables =
"?service=App.Tables.DelSellerTables"; // 商户端删除桌位
static const String set_table_region_by_id =
"?service=App.Tables.SetTableRegionById"; // 修改商家桌位区域
static const String del_table_region =
"?service=App.Tables.DelTableRegion"; // 删除区域同时删除区域下面的桌位
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/provider/my_table_manage_home_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
/*
**** 区域管理
*/
class MyAreaManagePage extends StatefulWidget {
MyAreaManagePage({Key key}) : super(key: key);
@override
_MyAreaManagePageState createState() => _MyAreaManagePageState();
}
class _MyAreaManagePageState extends State<MyAreaManagePage> {
MyTableManageHomeModel tableManagerModel;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
tableManagerModel.initTime(context);
// EventBus().on("refresh_tablemanager", (arg) {
// //订座-完成预订 刷新管理桌位
// tableManagerModel.getReserveList(context,
// needLoading: false, needKeep: true);
// print(tableManagerModel);
// });
// EventBus().on("refresh_tablePhoto", (arg) {
// ///刷新图片显示
// _refreshTablePhoto();
// });
});
}
@override
Widget build(BuildContext context) {
tableManagerModel =
Provider.of<MyTableManageHomeModel>(context, listen: true);
return Scaffold(
resizeToAvoidBottomInset: false, //输入框抵住键盘
appBar: SystemAppBar(
"区域管理",
showLeading: true,
onTap: () {
Navigator.pop(context);
},
),
backgroundColor: MyColours.color_ffffff,
body: SafeArea(child:
Consumer<MyTableManageHomeModel>(builder: (context, model, child) {
return model.pageState != PageState.Success
? Expanded(
child: ExceptionPage(
pageState: model.pageState,
callback: () {
// if (tableManagerModel.tableOuterList.isEmpty) {
// tableManagerModel.getTableList(context);
// } else {
// tableManagerModel.getReserveList(context);
// }
},
emptyMsg: "暂时没有区域数据哦",
emptyImg: "table_manage_empty",
showMsg: "加载中,请稍后...",
))
: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32),
vertical: ScreenUtil().setWidth(54)),
itemCount: tableManagerModel.areas.length,
shrinkWrap: true,
// scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext contxt, int index) {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(16),
vertical: ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: InkWell(
onTap: () async {
//修改区域弹框
await DialogUtil
.openTableManageCreateAreaDialog(
context,
title: '修改区域',
content: tableManagerModel
.areas[index]
.name, onTap: (value) async {
print(value);
//添加区域
bool success = await tableManagerModel
.setTableRegionById(
context,
value,
tableManagerModel
.areas[index].rid);
print(success);
if (success) {
Utils.showToast('修改成功!');
tableManagerModel.currentArea = value;
await tableManagerModel
.refreshTable(context);
EventBus().emit("refresh_table_area");
// await tableManagerModel
// .getTableList(context,
// needLoading: false);
// tableManagerModel.initData();
// setState(() {
// updateMenu();
// });
// _scrollToIndex(widget
// .tableManagerModel
// .areas
// .length);
}
});
},
child: Text(
tableManagerModel.areas[index].name,
style: TextStyle(
color: MyColours.color_000000,
fontSize: ScreenUtil().setSp(32))))),
InkWell(
onTap: () {
DialogUtil.cupertinoAlertDialog(context,
title: "",
content: "是否确定删除该区域",
lTitle: "取消",
rTitle: "确认删除",
isBold: true,
isBoldContent: true,
rColor: MyColours.color_E34D59,
lCallback: () {
print("取消");
}, rCallback: () async {
bool success =
await tableManagerModel.delTableRegion(
context,
tableManagerModel.areas[index].rid);
print(success);
if (success) {
Utils.showToast('删除成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
await tableManagerModel
.refreshTable(context);
EventBus().emit("refresh_table_area");
}
});
},
child: Text('删除',
style: TextStyle(
color: MyColours.color_438E93,
decoration: TextDecoration.underline,
fontSize: ScreenUtil().setSp(32))))
],
),
);
});
})));
}
}
... ...
... ... @@ -84,10 +84,9 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
// needLoading: false, needKeep: true);
// print(tableManagerModel);
// });
// EventBus().on("refresh_tablePhoto", (arg) {
// ///刷新图片显示
// _refreshTablePhoto();
// });
EventBus().on("refresh_table_area", (arg) {
tableManagerModel.refreshTable(context);
});
});
}
... ... @@ -95,7 +94,7 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
void dispose() {
// TODO: implement dispose
super.dispose();
// EventBus().off("refresh_tablemanager");
EventBus().off("refresh_table_area");
// EventBus().off("refresh_tablePhoto");
}
... ... @@ -162,13 +161,15 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
child: InkWell(
onTap: () async {
List<String> tableTypeS = [];
for (int i = 0; i < tableManagerModel.tableTypeList.length; i++) {
for (int i = 0;
i < tableManagerModel.tableTypeList.length;
i++) {
tableTypeS.add(tableManagerModel.tableTypeList[i].name);
}
//添加桌位弹框
await DialogUtil.openMyTableManageCreateTableDialog(
context, tableTypeS, personNumList,
context, tableTypeS, personNumList,
onTap: (Map<String, String> value) async {
print(value);
// 'areaname':
... ... @@ -178,24 +179,53 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
// 'pnumMax': pnumMax
//添加桌位 接口参数带整合???
// 以下是旧的不去,明天添加桌位接口
// 'bjtype': baojianList[
// currentBaojianIndex],
// 'name': controller.text,
// 'pnumMin': pnumMin,
// 'pnumMax': pnumMax,
// 'mulcreate':
// mulCreate.toString(),
// 'tablenum':
// _norNumController.text
String rid;
for (Area item in tableManagerModel.areas) {
if (item.name == value['areaname']) {
if (item.name == tableManagerModel.currentArea) {
rid = item.rid;
}
}
Map<String, String> params = {
'rid': rid,
'name': value['name'],
};
if (value['pnumMin'] != '') {
params['pnum'] = value['pnumMin'];
String tid;
for (int i = 0;
i < tableManagerModel.tableTypeList.length;
i++) {
if (value['bjtype'] ==
tableManagerModel.tableTypeList[i].name) {
tid = tableManagerModel.tableTypeList[i].id;
}
}
if (value['pnumMax'] != '') {
params['most_pnum'] = value['pnumMax'];
if (value['mulcreate'] == 'true') {
//批量创建
params['tablenum'] = value['tablenum'];
params['pnum'] = '10';
params['most_pnum'] = '10';
// params['name'] = 'lll';
} else {
//单个创建
params['name'] = value['name'];
if (value['pnumMin'] != '') {
params['pnum'] = value['pnumMin'];
}
if (value['pnumMax'] != '') {
params['most_pnum'] = value['pnumMax'];
}
}
bool success =
await tableManagerModel.addTable(context, params);
bool success = await tableManagerModel
.addTable(context, params, tid: tid);
print(success);
if (success) {
Utils.showToast('添加成功!');
... ... @@ -251,29 +281,127 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
builder: (context, table, _) {
return ManageTableItem(table,
canMulSelected: tableManagerModel.tableOuterList[i].isSelect,
onSelected: (table) {
onSelected: (table) async {
if (tableManagerModel.tableOuterList[i].isSelect) {
//多选
setState(() {
table.selected = !(table.selected ?? false);
});
if (table.selected) {
tableManagerModel.tableOuterList[i].selectTables.add(table);
} else {
tableManagerModel.tableOuterList[i].selectTables
.removeWhere((t) => t.id == table.id);
}
} else {
for (t.Table item
in tableManagerModel.tableOuterList[i].list) {
item.selected = false;
// for (t.Table item
// in tableManagerModel.tableOuterList[i].list) {
// item.selected = false;
// }
// tableManagerModel.tableOuterList[i].selectTables = [];
// //单选
// setState(() {
// table.selected = true;
// });
//修改桌位
print(table);
List<String> tableTypeS = [];
for (int i = 0;
i < tableManagerModel.tableTypeList.length;
i++) {
tableTypeS.add(tableManagerModel.tableTypeList[i].name);
}
tableManagerModel.tableOuterList[i].selectTables = [];
//单选
setState(() {
table.selected = true;
await DialogUtil.openMyTableManageModifyTableDialog(
context, tableTypeS, personNumList,
name: table.name,
tidStr: table.tidStr,
pnumMin: table.table_pnum ?? '',
pnumMax: table.most_pnum ?? '',
onTapDel: (Map<String, String> value) async {
Map<String, String> params = {
'sid': Provider.of<UserModel>(context, listen: false)
.user
.sellerid,
'tid': table.id
};
bool success = await tableManagerModel.delSellerTables(
context, params);
print(success);
if (success) {
Utils.showToast('删除成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
await tableManagerModel.refreshTable(context);
}
}, onTap: (Map<String, String> value) async {
// String rid;
// for (Area item in tableManagerModel.areas) {
// if (item.name == tableManagerModel.currentArea) {
// rid = item.rid;
// }
// }
// Map<String, String> params = {
// 'rid': rid,
// };
String tid;
for (int i = 0;
i < tableManagerModel.tableTypeList.length;
i++) {
if (value['bjtype'] ==
tableManagerModel.tableTypeList[i].name) {
tid = tableManagerModel.tableTypeList[i].id;
}
}
Map<String, String> params = {
'id': table.id,
'name': value['name'],
'tid': tid
};
if (value['pnumMin'] != '') {
params['table_pnum'] = value['pnumMin'];
}
if (value['pnumMax'] != '') {
params['most_pnum'] = value['pnumMax'];
}
bool success =
await tableManagerModel.setTableById(context, params);
print(success);
if (success) {
Utils.showToast('修改成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
await tableManagerModel.refreshTable(context);
}
});
}
if (table.selected) {
tableManagerModel.tableOuterList[i].selectTables.add(table);
} else {
tableManagerModel.tableOuterList[i].selectTables
.removeWhere((t) => t.id == table.id);
}
});
},
);
... ... @@ -488,6 +616,10 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
.selectNumber]
.isSelect) {
//区域管理页面跳转
NavigatorUtil
.goMyAreaManagerHomePage(
context);
}
},
child: Container(
... ... @@ -901,12 +1033,34 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
MainAxisAlignment.spaceBetween,
children: [
CommonButton(
content: "修改名称",
width: 200,
height: 72,
fontSize: 32,
onPress: () async {},
),
content: "修改名称",
width: 200,
height: 72,
fontSize: 32,
onPress: () async {
DialogUtil
.openMyTableManageModifyTableNameDialog(
context,
onTap: (Map<String, String>
value) async {
Map<String, String> params = {
'name': value['name'],
};
bool success =
await tableManagerModel
.setTableById(
context, params);
print(success);
if (success) {
Utils.showToast('修改成功!');
await tableManagerModel
.refreshTable(context);
}
},
);
}),
CommonButton(
content: "修改人数",
width: 200,
... ... @@ -930,7 +1084,73 @@ class MyTableManagerHomePageState extends State<MyTableManagerHomePage> {
height: 72,
fontSize: 32,
state: -3,
onPress: () async {},
onPress: () async {
if (tableManagerModel
.tableOuterList[
tableManagerModel.selectNumber]
.selectTables
.length ==
0) {
Utils.showToast('请选择桌位');
return;
}
String tids = '';
for (t.Table item in tableManagerModel
.tableOuterList[
tableManagerModel.selectNumber]
.selectTables) {
tids += '${item.id},';
}
if (tids.endsWith(',')) {
tids = tids.substring(0, tids.length - 1);
}
DialogUtil.cupertinoAlertDialog(context,
title: "",
content:
"是否确定删除${tids.split(',').length}个桌位",
lTitle: "取消",
rTitle: "确认删除",
isBold: true,
isBoldContent: true,
rColor: MyColours.color_E34D59,
lCallback: () {
print("取消");
}, rCallback: () async {
print("确定");
Map<String, String> params = {
'sid': Provider.of<UserModel>(context,
listen: false)
.user
.sellerid,
'tid': tids
};
bool success = await tableManagerModel
.delSellerTables(context, params);
print(success);
if (success) {
Utils.showToast('删除成功!');
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value;
// tableOuter.list = [];
// tableManagerModel.tableOuterList.add(tableOuter);
// tableManagerModel.initData();
// Timer(
// Duration(milliseconds: 500),
// () => _areaController.jumpTo(
// _areaController.position.maxScrollExtent));
// await tableManagerModel
// .getTableList(context);
// await tableManagerModel
// .initData();
await tableManagerModel
.refreshTable(context);
}
});
},
),
VEmptyView(32),
],
... ...
... ... @@ -249,6 +249,90 @@ class MyTableManageHomeModel with ChangeNotifier {
return false;
}
///修改商家桌位区域
Future<bool> setTableRegionById(
BuildContext context, String name, String areaid) async {
Map<String, String> params = {
"sellerid": userModel.user.sellerid,
"name": name,
"id": areaid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_table_region_by_id,
data: params, showLoading: true)
.catchError((error) {
print(error.toString());
// if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.responseData['data'] != null &&
baseResp.responseData['data'].length > 0) {
return true;
} else {
Utils.showToast(baseResp.msg ?? '修改区域失败!');
}
} else {
Utils.showToast(baseResp.msg ?? '修改区域失败!');
}
return false;
}
///删除区域同时删除区域下面的桌位
Future<bool> delTableRegion(BuildContext context, String areaid) async {
Map<String, String> params = {
"sellerid": userModel.user.sellerid,
"regionid": areaid
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_table_region,
data: params, showLoading: true)
.catchError((error) {
print(error.toString());
// if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.responseData['data'] != null &&
baseResp.responseData['data'] > 0) {
return true;
} else {
Utils.showToast(baseResp.msg ?? '删除区域失败!');
}
} else {
Utils.showToast(baseResp.msg ?? '删除区域失败!');
}
return false;
}
//获取区域数据
Future<List<AreaSunModel>> getRegionBySellerid(BuildContext context) async {
Map<String, String> params = {"sellerid": userModel.user.sellerid};
... ... @@ -286,10 +370,10 @@ class MyTableManageHomeModel with ChangeNotifier {
}
//添加商家桌位
Future<bool> addTable(
BuildContext context, Map<String, String> params) async {
Future<bool> addTable(BuildContext context, Map<String, String> params,
{tid: '2'}) async {
params["sellerid"] = userModel.user.sellerid;
params["tid"] = '2';
params["tid"] = tid;
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.add_table,
data: params, showLoading: true)
... ... @@ -325,6 +409,82 @@ class MyTableManageHomeModel with ChangeNotifier {
return false;
}
//修改桌位信息
Future<bool> setTableById(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_table_by_id,
data: params, showLoading: true)
.catchError((error) {
print(error.toString());
// if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.responseData['data'] != null &&
baseResp.responseData['data']['id'] == 1) {
return true;
} else {
Utils.showToast(baseResp.msg ?? '修改桌位失败!');
}
} else {
Utils.showToast(baseResp.msg ?? '修改桌位失败!');
}
return false;
}
//商户端删除桌位
Future<bool> delSellerTables(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.del_seller_tables,
data: params, showLoading: true)
.catchError((error) {
print(error.toString());
// if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
// }
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.responseData['data'] != null &&
(baseResp.responseData['data'] > 0)) {
return true;
} else {
Utils.showToast(baseResp.msg ?? '删除桌位失败!');
}
} else {
Utils.showToast(baseResp.msg ?? '删除桌位失败!');
}
return false;
}
refreshTable(context) async {
List temp = await getTableList(context, needLoading: false);
// if (temp.length > 0) {
... ...
... ... @@ -18,6 +18,7 @@ import 'package:one_key/models/statics_model.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/my_table_manage_home_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/routes.dart';
import 'package:one_key/utils/fluro_convert_utils.dart';
... ... @@ -796,4 +797,13 @@ class NavigatorUtil {
return _navigateTo(context, "${Routes.my_table_manager_home_page}",
replace: replace);
}
///我的----区域管理
static Future<dynamic> goMyAreaManagerHomePage(
BuildContext context, {
replace = false,
}) {
return _navigateTo(context, "${Routes.my_area_manage_page}?",
replace: replace);
}
}
... ...
... ... @@ -95,6 +95,7 @@ import 'package:one_key/pages/my/sms_manager.dart';
import 'package:one_key/pages/my/sms_recharge_page.dart';
import 'package:one_key/pages/my/store_base_info_page.dart';
import 'package:one_key/pages/my/store_type_fill_manage_page.dart';
import 'package:one_key/pages/my/table_manage/my_areas_manage_page.dart';
import 'package:one_key/pages/my/table_manage/my_table_manage_home_page.dart';
import 'package:one_key/pages/notebook/statistics_page.dart';
import 'package:one_key/pages/notebook/statistics_sms_page.dart';
... ... @@ -1231,3 +1232,17 @@ var myTableManagerHomePageHandle = new Handler(
child: MyTableManagerHomePage(),
);
});
///我的---区域管理
var myAreaManagePageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// Guest guest = Guest.fromJson(json
// .decode(FluroConvertUtils.fluroCnParamsDecode(params["guest"].first)));
// UserHistoryEntity userHistoryEntity = UserHistoryEntity.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(
// params["userHistoryEntity"].first)));
return ChangeNotifierProvider<MyTableManageHomeModel>(
create: (_) => MyTableManageHomeModel(),
child: MyAreaManagePage(),
);
});
... ...
... ... @@ -107,6 +107,9 @@ class Routes {
static String table_manager_page = "/table_manager_page"; //客情再次预订跳转的桌位预订页面
static String account_login_page = "/account_login_page"; //账号登录页面
static String my_table_manager_home_page = "/my_table_manager_home_page"; //我的---桌位管理
static String my_area_manage_page = "/my_area_manage_page"; //我的---区域管理
... ... @@ -219,6 +222,7 @@ class Routes {
router.define(table_manager_page, handler: tableManagerPageHandle);
router.define(account_login_page, handler: accountLoginPageHandle);
router.define(my_table_manager_home_page, handler: myTableManagerHomePageHandle);
router.define(my_area_manage_page, handler: myAreaManagePageHandle);
}
... ...
... ... @@ -282,9 +282,12 @@ class DialogUtil {
// }
static Future openTableManageCreateAreaDialog(BuildContext context,
{CustomCallBack onTap}) async {
{CustomCallBack onTap,
String title = '添加区域',
String content = ''}) async {
TextEditingController controller = TextEditingController();
bool isRed = true;
controller.text = content;
bool isRed = content != '' ? false : true;
final action = await showDialog(
context: context,
barrierDismissible: false,
... ... @@ -311,7 +314,7 @@ class DialogUtil {
Container(
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('添加区域',
child: Text(title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(34),
... ... @@ -756,13 +759,15 @@ class DialogUtil {
TextEditingController controller = TextEditingController();
TextEditingController _norNumController = TextEditingController();
_norNumController.text = '10';
FocusNode _norNumFocusNode = FocusNode();
bool showBaojian = true;
bool showPnumMin = true;
bool showPnumMax = true;
String pnumMin = '';
String pnumMax = '';
int currentBaojianIndex = 0;
int currentBaojianIndex =
baojianList.indexWhere((element) => element == '包间') ?? 0;
String baojian = baojianList[currentBaojianIndex];
bool mulCreate = false;
// StateSetter globalState;
... ... @@ -789,7 +794,7 @@ class DialogUtil {
// globalState = state;
return Container(
margin: EdgeInsets.only(top: ScreenUtil().setWidth(300)),
margin: EdgeInsets.only(top: ScreenUtil().setWidth(300)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(50)),
// height: ScreenUtil().setWidth(326 * 2) +
... ... @@ -880,7 +885,8 @@ class DialogUtil {
'填写个数',
_norNumController,
_norNumFocusNode,
'人'))
'个',
state))
: Container(
margin: EdgeInsets.symmetric(
horizontal:
... ... @@ -1122,13 +1128,28 @@ class DialogUtil {
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor: controller.text == ''
textColor: (!mulCreate &&
controller.text ==
'') ||
(mulCreate &&
_norNumController.text
.trim() ==
'')
? MyColours.color_999999
: MyColours.color_438E93,
fontSize: 34,
onPressed: () {
if (controller.text.trim() ==
'') {
if (mulCreate &&
_norNumController.text
.trim()
.length ==
0) {
Utils.showToast('请输入数量!');
return;
}
if (!mulCreate &&
controller.text.trim() ==
'') {
Utils.showToast('请输入桌位名称!');
return;
}
... ... @@ -1140,11 +1161,15 @@ class DialogUtil {
// pnumMax
onTap({
'areaname': baojianList[
'bjtype': baojianList[
currentBaojianIndex],
'name': controller.text,
'pnumMin': pnumMin,
'pnumMax': pnumMax
'pnumMax': pnumMax,
'mulcreate':
mulCreate.toString(),
'tablenum':
_norNumController.text
});
Navigator.pop(context);
}),
... ... @@ -1204,6 +1229,674 @@ class DialogUtil {
});
}
static Future openMyTableManageModifyTableDialog(
BuildContext context, List<String> baojianList, List<String> pnum,
{String name,
String tidStr,
String pnumMin = '',
String pnumMax = '',
CustomCallBackMap onTap,
CustomCallBackMap onTapDel}) async {
TextEditingController controller = TextEditingController();
controller.text = name;
// TextEditingController _norNumController = TextEditingController();
// _norNumController.text = '10';
// FocusNode _norNumFocusNode = FocusNode();
bool showBaojian = true;
bool showPnumMin = true;
bool showPnumMax = true;
int currentBaojianIndex = tidStr == null
? 0
: baojianList.indexWhere((element) => element == tidStr) ?? 0;
String baojian = baojianList[currentBaojianIndex];
// StateSetter globalState;
// //输入框焦点
// focusNode.addListener(() {
// if (!focusNode.hasFocus) {
// // print('失去焦点');
// } else {
// // print('得到焦点');
// globalState(() {
// showPnumMin = true;
// showPnumMax = true;
// showArea = true;
// });
// }
// });
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Center(child: StatefulBuilder(builder: (context, state) {
// globalState = state;
return Container(
margin: EdgeInsets.only(top: ScreenUtil().setWidth(300)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(50)),
// height: ScreenUtil().setWidth(326 * 2) +
// ScreenUtil().setWidth(250 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Stack(children: [
Column(
children: [
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(
ScreenUtil().setWidth(10)))), //设置圆角
child: Stack(
overflow: Overflow.visible,
children: [
Container(
child: Column(
children: [
VEmptyView(64),
Container(
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(44)),
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('修改桌位',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_333333)),
),
VEmptyView(60),
Container(
margin: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(48 * 2),
// margin: EdgeInsets.symmetric(
// horizontal:
// ScreenUtil().setWidth(40)),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
HEmptyView(20),
Expanded(
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize:
ScreenUtil().setSp(32),
color:
MyColours.color_515151),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(
40)), //设置文字内容与边框距离
// enabledBorder: UnderlineInputBorder(
// borderSide: BorderSide(
// color: MyColours.color_efefef),
// ),
// focusedBorder: UnderlineInputBorder(
// borderSide: BorderSide(
// color: MyColours.color_efefef,
// width: ScreenUtil().setWidth(2)),
// ),
// prefixText: '*',
// prefixStyle: TextStyle(
// fontSize: ScreenUtil().setSp(32),
// color: MyColours.color_E95750),
border: OutlineInputBorder(
borderSide:
BorderSide.none),
hintText: '桌位名称',
hintStyle: TextStyle(
color: MyColours.color_BFC4D4,
fontSize:
ScreenUtil().setSp(32),
),
),
onChanged: (value) {
state(() {});
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
)
],
),
),
VEmptyView(32),
InkWell(
onTap: () {
state(() {
showPnumMax = true;
showPnumMin = true;
showBaojian = !showBaojian;
});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(30 * 2),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
HEmptyView(32),
Text(
'桌位类型',
style: TextStyle(
fontSize:
ScreenUtil().setSp(32),
color:
MyColours.color_000000),
),
Spacer(),
// Stack(
// overflow: Overflow.visible,
// children: [
Text(
baojian,
style: TextStyle(
color:
MyColours.color_515151,
fontSize:
ScreenUtil().setSp(32)),
),
HEmptyView(12),
Image.asset(
Utils.getImgPath(
'table_manage_arrow_down'),
width: ScreenUtil()
.setWidth(40)),
HEmptyView(32),
],
),
)),
Container(
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(60)),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(44),
right: ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(30 * 2),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
HEmptyView(32),
Text(
'人数',
style: TextStyle(
fontSize:
ScreenUtil().setSp(32),
color: MyColours.color_000000),
),
Spacer(),
// Stack(
// overflow: Overflow.visible,
// children: [
btnChooseTableManagePnum(
pnumMin,
'min',
ScreenUtil().setWidth(54 * 2),
(value) {
state(() {
showBaojian = true;
showPnumMax = true;
showPnumMin = !showPnumMin;
});
}),
HEmptyView(40),
Text(
'至',
style: TextStyle(
fontSize:
ScreenUtil().setSp(32),
color: MyColours.color_000000),
),
HEmptyView(40),
btnChooseTableManagePnum(
pnumMax,
'max',
ScreenUtil().setWidth(54 * 2),
(value) {
state(() {
showBaojian = true;
showPnumMin = true;
showPnumMax = !showPnumMax;
});
}),
HEmptyView(32),
],
),
),
VEmptyView(60),
RoundButton(
text: '删除桌位',
width: ScreenUtil().setWidth(88 * 2),
height: ScreenUtil().setWidth(36 * 2),
radius: ScreenUtil().setWidth(10),
gradientStart: MyColours.color_E34D59,
gradientEnd: MyColours.color_E34D59,
textColor: MyColours.color_ffffff,
isBold: false,
fontSize: 28,
onPressed: () {
DialogUtil.cupertinoAlertDialog(
context,
title: "",
content: "是否确定删除1个桌位",
lTitle: "取消",
rTitle: "确认删除",
isBold: true,
isBoldContent: true,
rColor: MyColours.color_E34D59,
lCallback: () {
print("取消");
}, rCallback: () {
print("确定");
onTapDel({
'bjtype': baojianList[
currentBaojianIndex],
'name': controller.text,
'pnumMin': pnumMin,
'pnumMax': pnumMax,
});
Navigator.pop(context);
});
}),
VEmptyView(52),
MyDivider(double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: '取消',
width: (ScreenUtil.screenWidthDp -
ScreenUtil()
.setWidth(110) *
2) /
2,
height:
ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor: MyColours.color_000000,
isBold: false,
fontSize: 34,
onPressed: () {
Navigator.pop(context);
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '确定',
width: (ScreenUtil.screenWidthDp -
ScreenUtil()
.setWidth(110) *
2) /
2,
height:
ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor: controller.text == ''
? MyColours.color_999999
: MyColours.color_438E93,
fontSize: 34,
onPressed: () {
if (controller.text.trim() ==
'') {
Utils.showToast('请输入桌位名称!');
return;
}
// 当前选中区域
// areas[currentAreaIndex]
//最低人数
// pnumMin
//最高人数
// pnumMax
onTap({
'bjtype': baojianList[
currentBaojianIndex],
'name': controller.text,
'pnumMin': pnumMin,
'pnumMax': pnumMax,
});
Navigator.pop(context);
}),
])
],
),
),
Positioned(
left: ScreenUtil().setWidth(100 * 2),
top: ScreenUtil().setWidth(65 * 2),
child: Offstage(
offstage: showBaojian,
child: tableManageSelectWidget(
baojianList, 210, (index) {
state(() {
showBaojian = !showBaojian;
currentBaojianIndex = index;
baojian =
baojianList[currentBaojianIndex];
});
}),
)),
],
)),
],
),
Positioned(
left: ScreenUtil().setWidth(0),
top: ScreenUtil().setWidth(90 * 2),
child: Offstage(
offstage: showPnumMin,
child: Material(
color: Colors.transparent,
child: selectWidget(pnum, (index) {
state(() {
showPnumMin = !showPnumMin;
pnumMin = pnum[index];
});
}),
))),
Positioned(
left: ScreenUtil().setWidth(106 * 2),
top: ScreenUtil().setWidth(90 * 2),
child: Material(
color: Colors.transparent,
child: Offstage(
offstage: showPnumMax,
child: selectWidget(pnum, (index) {
state(() {
showPnumMax = !showPnumMax;
pnumMax = pnum[index];
});
}),
))),
]));
}));
});
}
///批量改名
static Future openMyTableManageModifyTableNameDialog(
BuildContext context, {
CustomCallBackMap onTap,
}) async {
TextEditingController controller = TextEditingController();
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Center(child: StatefulBuilder(builder: (context, state) {
// globalState = state;
return Container(
margin: EdgeInsets.only(top: ScreenUtil().setWidth(300)),
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(50)),
// height: ScreenUtil().setWidth(326 * 2) +
// ScreenUtil().setWidth(250 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Stack(children: [
Column(
children: [
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(
ScreenUtil().setWidth(10)))), //设置圆角
child: Stack(
overflow: Overflow.visible,
children: [
Container(
child: Column(
children: [
VEmptyView(64),
Container(
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(44)),
// height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('批量改名',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_333333)),
),
VEmptyView(60),
Container(
margin: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(44)),
height: ScreenUtil().setWidth(48 * 2),
// margin: EdgeInsets.symmetric(
// horizontal:
// ScreenUtil().setWidth(40)),
decoration: BoxDecoration(
color: MyColours.color_f3f3f3,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
HEmptyView(20),
Expanded(
child: TextField(
controller: controller,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize:
ScreenUtil().setSp(32),
color:
MyColours.color_515151),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
bottom: ScreenUtil()
.setWidth(
40)), //设置文字内容与边框距离
// enabledBorder: UnderlineInputBorder(
// borderSide: BorderSide(
// color: MyColours.color_efefef),
// ),
// focusedBorder: UnderlineInputBorder(
// borderSide: BorderSide(
// color: MyColours.color_efefef,
// width: ScreenUtil().setWidth(2)),
// ),
// prefixText: '*',
// prefixStyle: TextStyle(
// fontSize: ScreenUtil().setSp(32),
// color: MyColours.color_E95750),
border: OutlineInputBorder(
borderSide:
BorderSide.none),
hintText: '桌位名称',
hintStyle: TextStyle(
color: MyColours.color_BFC4D4,
fontSize:
ScreenUtil().setSp(32),
),
),
onChanged: (value) {
state(() {});
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.text,
),
)
],
),
),
VEmptyView(26),
Row(
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Image.asset(
(true
? 'mine_radio_sel'
: 'mine_radio_nor'),
width:
ScreenUtil().setWidth(34)),
Text(
'跳过4',
style: TextStyle(
color: MyColours.color_515151,
fontSize:
ScreenUtil().setSp(32)),
)
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Image.asset(
(true
? 'mine_radio_sel'
: 'mine_radio_nor'),
width:
ScreenUtil().setWidth(34)),
Text(
'跳过7',
style: TextStyle(
color: MyColours.color_515151,
fontSize:
ScreenUtil().setSp(32)),
)
],
),
],
),
MyDivider(double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: '取消',
width: (ScreenUtil.screenWidthDp -
ScreenUtil()
.setWidth(110) *
2) /
2,
height:
ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor: MyColours.color_000000,
isBold: false,
fontSize: 34,
onPressed: () {
Navigator.pop(context);
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: '确定',
width: (ScreenUtil.screenWidthDp -
ScreenUtil()
.setWidth(110) *
2) /
2,
height:
ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor: controller.text == ''
? MyColours.color_999999
: MyColours.color_438E93,
fontSize: 34,
onPressed: () {
if (controller.text.trim() ==
'') {
Utils.showToast('请输入桌位名称!');
return;
}
// 当前选中区域
// areas[currentAreaIndex]
//最低人数
// pnumMin
//最高人数
// pnumMax
onTap({
'name': controller.text,
});
Navigator.pop(context);
}),
])
],
),
),
],
)),
],
),
]));
}));
});
}
///输入框
static Widget textfield(
BuildContext context,
... ... @@ -1212,6 +1905,7 @@ class DialogUtil {
TextEditingController editingController,
FocusNode focusNode,
String subTitle,
state,
{bool needStar = false,
TextInputType inputType = TextInputType.number}) {
return Container(
... ... @@ -1277,7 +1971,9 @@ class DialogUtil {
),
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
onChanged: (value) {
state(() {});
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
... ... @@ -3242,6 +3938,9 @@ class DialogUtil {
String content = "内容",
String lTitle = "取消",
String rTitle = "确定",
Color rColor = MyColours.color_199095,
bool isBold = false,
bool isBoldContent = false,
VoidCallback lCallback,
VoidCallback rCallback}) {
showCupertinoDialog(
... ... @@ -3257,6 +3956,8 @@ class DialogUtil {
: SizedBox(),
content: Text(content,
style: TextStyle(
fontWeight:
isBoldContent ? FontWeight.bold : FontWeight.normal,
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_353535)),
actions: [
... ... @@ -3273,8 +3974,9 @@ class DialogUtil {
CupertinoDialogAction(
child: Text(rTitle,
style: TextStyle(
fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_199095)),
color: rColor)),
onPressed: () {
Navigator.of(context).pop();
rCallback();
... ...