|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/guest_info_model.dart';
|
|
|
|
import 'package:one_key/provider/customer_provider.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
...
|
...
|
@@ -7,6 +8,7 @@ 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/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
...
|
...
|
@@ -14,7 +16,10 @@ import 'package:provider/provider.dart'; |
|
|
|
|
|
|
|
class FestivalEditPage extends StatefulWidget {
|
|
|
|
final Guest guest;
|
|
|
|
FestivalEditPage({Key key, this.guest}) : super(key: key);
|
|
|
|
final String idstr;
|
|
|
|
final String phone;
|
|
|
|
FestivalEditPage({Key key, this.guest, this.idstr, this.phone})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_FestivalEditPageState createState() => _FestivalEditPageState();
|
|
...
|
...
|
@@ -23,18 +28,36 @@ class FestivalEditPage extends StatefulWidget { |
|
|
|
class _FestivalEditPageState extends State<FestivalEditPage> {
|
|
|
|
CustomerProvider customerProvider;
|
|
|
|
|
|
|
|
_setGuestInfo(String cday) async {
|
|
|
|
Map<String, String> params = {"id": widget.guest.id, 'c_day': cday};
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
_getGuestInfoCday();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getGuestInfoCday() async {
|
|
|
|
Map<String, String> params = {"id": widget.idstr, 'phone': widget.phone};
|
|
|
|
await customerProvider.getGuestInfoCday(context, params);
|
|
|
|
// await customerProvider.searchData(customerProvider.controller.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sucess =
|
|
|
|
await customerProvider.setGuestInfo(context, params, showLoading: true);
|
|
|
|
_setGuestInfocDay(String id, String cday) async {
|
|
|
|
Map<String, String> params = {"gid": widget.guest.id, 'content': cday};
|
|
|
|
if (id != '') {
|
|
|
|
params["id"] = id;
|
|
|
|
}
|
|
|
|
bool sucess = await customerProvider.setGuestInfocDay(context, params,
|
|
|
|
showLoading: true);
|
|
|
|
if (sucess) {
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
//刷新当前页
|
|
|
|
_getGuestInfoCday();
|
|
|
|
// 刷新
|
|
|
|
bus.emit('refresh_guest_info');
|
|
|
|
bus.emit('refresh_guest_list');
|
|
|
|
// Navigator.pop(context);
|
|
|
|
//刷新当前页? 还没做???????
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -55,44 +78,102 @@ class _FestivalEditPageState extends State<FestivalEditPage> { |
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
vertical: ScreenUtil().setWidth(40)),
|
|
|
|
child: Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: 10,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
DialogUtil.festivalAlertDialog(context, 'ggg', 520,
|
|
|
|
rCallback: (name) {
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(20),
|
|
|
|
vertical: ScreenUtil().setWidth(20)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
'本人生日:12月18日(公历)',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(26),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
)),
|
|
|
|
HEmptyView(10),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('c_edit'),
|
|
|
|
width: ScreenUtil().setWidth(40),
|
|
|
|
// height: ScreenUtil().setWidth(10),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
Expanded(child:
|
|
|
|
Consumer<CustomerProvider>(builder: (context, model, _) {
|
|
|
|
if (model.pageStateGuestInfoCday != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageStateGuestInfoCday,
|
|
|
|
callback: () {
|
|
|
|
model.pageStateGuestInfoCday = PageState.Loading;
|
|
|
|
model.notifyListeners();
|
|
|
|
_getGuestInfoCday();
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有纪念日哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: model.cday.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
String str = model.cday[index].content;
|
|
|
|
// str += '${name}:';
|
|
|
|
// if (yearStr != '' &&
|
|
|
|
// yearStr != null &&
|
|
|
|
// yearStr != '选填') {
|
|
|
|
// str += '${yearStr}年';
|
|
|
|
// }
|
|
|
|
// str += '${monthStr}月';
|
|
|
|
// str += '${dayStr}日';
|
|
|
|
// str += '(${gongli ? '公历' : '农历'})';
|
|
|
|
String yearStr = '选填';
|
|
|
|
String monthStr = '';
|
|
|
|
String dayStr = '';
|
|
|
|
bool gongli = true;
|
|
|
|
String content = str.substring(0, str.indexOf(':'));
|
|
|
|
if (str.contains('年')) {
|
|
|
|
yearStr = str.substring(
|
|
|
|
str.indexOf(':') + 1, str.indexOf('年'));
|
|
|
|
}
|
|
|
|
if (str.contains('月')) {
|
|
|
|
if (str.contains('年')) {
|
|
|
|
monthStr = str.substring(
|
|
|
|
str.indexOf('年') + 1, str.indexOf('月'));
|
|
|
|
} else {
|
|
|
|
monthStr = str.substring(
|
|
|
|
str.indexOf(':') + 1, str.indexOf('月'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (str.contains('日')) {
|
|
|
|
dayStr = str.substring(
|
|
|
|
str.indexOf('月') + 1, str.indexOf('日'));
|
|
|
|
}
|
|
|
|
if (str.contains('农历')) {
|
|
|
|
gongli = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogUtil.festivalAlertDialog(
|
|
|
|
context, content, 520, rCallback: (name) {
|
|
|
|
print(name);
|
|
|
|
_setGuestInfocDay(model.cday[index].id, name);
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
},
|
|
|
|
yearStr: yearStr,
|
|
|
|
monthStr: monthStr,
|
|
|
|
dayStr: dayStr,
|
|
|
|
gongli: gongli);
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(20),
|
|
|
|
vertical: ScreenUtil().setWidth(20)),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
model.cday[index].content,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(26),
|
|
|
|
color: MyColours.color_333333),
|
|
|
|
)),
|
|
|
|
HEmptyView(10),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('c_edit'),
|
|
|
|
width: ScreenUtil().setWidth(40),
|
|
|
|
// height: ScreenUtil().setWidth(10),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})),
|
|
|
|
RoundButton(
|
|
|
|
text: '新增',
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
...
|
...
|
@@ -105,12 +186,14 @@ class _FestivalEditPageState extends State<FestivalEditPage> { |
|
|
|
DialogUtil.festivalAlertDialog(context, '', 520,
|
|
|
|
rCallback: (name) {
|
|
|
|
print(name);
|
|
|
|
_setGuestInfo(name);
|
|
|
|
_setGuestInfocDay('', name);
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
VEmptyView(30)
|
|
|
|
])));
|
|
|
|
// }
|
|
|
|
// }));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|