Commit 77364708bfc8b73c4a6addbb49acb35ca05ec2df

Authored by weixin_45529955
1 parent ade6f527

优惠券管理员和店长可以编辑发放人

... ... @@ -223,6 +223,10 @@ class Constant {
'设置服务人员': [
'管理员',
'店长',
],
'优惠券详情-编辑发放人': [
'管理员',
'店长',
]
};
}
... ...
... ... @@ -11,6 +11,7 @@ import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_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/round_button.dart';
... ... @@ -43,6 +44,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
late CouponProvider couponProvider;
PageState pageState = PageState.Loading;
String? managerName = '';
String nickNameShow = '编辑';
@override
void initState() {
... ... @@ -58,6 +60,15 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
// setState(() {});
// }
});
bus.on("refresh_coupon_detail", (arg) {
_getActivityByIdRefresh();
});
}
@override
void dispose() {
bus.off("refresh_coupon_detail");
super.dispose();
}
_getCustomerActivityBaseinfo() async {
... ... @@ -69,7 +80,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
};
bool success =
await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
await _baseIndoProvider.getCustomerActivityBaseinfo(context, params,isShowLoading: false);
if (success) {
managerName = _baseIndoProvider.baseInfoSunModel!.name;
}
... ... @@ -81,14 +92,24 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
.getActivityById(context, {'id': widget.idstr}, isShowLoading: false);
if (success) {
pageState = PageState.Success;
nickNameShow = couponProvider.couponSunModel?.nickNameShow ?? '编辑';
} else {
pageState = PageState.ConnectivityError;
}
setState(() {});
}
_getActivityByIdRefresh() async {
bool success = await couponProvider
.getActivityById(context, {'id': widget.idstr}, isShowLoading: true);
if (success) {
nickNameShow = couponProvider.couponSunModel?.nickNameShow ?? '编辑';
}
setState(() {});
}
///时间选择
Widget _select(String title, String hintText, GestureTapCallback onTap) {
Widget _select(String title, String hintText, GestureTapCallback onTap,{bool canEdit = false}) {
return InkWell(
onTap: onTap,
child: Container(
... ... @@ -108,20 +129,21 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
),
),
HEmptyView(20),
Spacer(),
Text(hintText,
style: TextStyle(
color: hintText == '点击选择'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
)),
// Spacer(),
Expanded(
child: Text(hintText,
style: TextStyle(
color: hintText == '点击选择'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
))),
HEmptyView(20),
Image.asset(
Utils.getImgPath('arrow_right_new'),
Utils.getImgPath(canEdit ? 'enter_store_arrow_r':'arrow_right_new'),
width: ScreenUtil().setWidth(20),
),
HEmptyView(32),
// HEmptyView(32),
],
),
),
... ... @@ -778,10 +800,28 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'谁可以发放',
couponProvider
.couponSunModel!.nickNameShow!),
Utils.getAuthority(context, '优惠券详情-编辑发放人')
? _select('谁可以发放', nickNameShow,canEdit: true,
() async {
Map? temp = await NavigatorUtil
.goCouponToPersonnalPage(
context,
couponProvider
.couponSunModel
?.uidList ??
'',
id: widget.idstr ?? '',
needSave: true);
// if (temp != null &&
// temp['object'] != null) {
// uids = temp['object'];
// }
})
: _item(
'谁可以发放',
couponProvider.couponSunModel!
.nickNameShow!),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
... ...
... ... @@ -1466,7 +1466,7 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
widget.isMine
? SizedBox()
: _select('谁可以发放', '编辑', () async {
Map temp = await NavigatorUtil
dynamic temp = await NavigatorUtil
.goCouponToPersonnalPage(
context, uids);
if (temp != null &&
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/personnel_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
... ... @@ -15,7 +16,14 @@ import 'package:provider/provider.dart';
class CouponToPersonnalPage extends StatefulWidget {
final String? uids;
final bool onlyShow;
CouponToPersonnalPage({Key? key, this.uids, this.onlyShow = false})
final bool needSave;
final String id;
CouponToPersonnalPage(
{Key? key,
this.uids,
this.onlyShow = false,
this.needSave = false,
this.id = ''})
: super(key: key);
@override
... ... @@ -26,6 +34,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
late PersonnelProvider personnelProvider;
ScrollController _scrollController = ScrollController();
List<String> titleList = [];
late CouponProvider couponProvider;
@override
void initState() {
... ... @@ -178,6 +187,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
... ... @@ -775,8 +785,29 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
uids = uids.substring(0, uids.length - 1);
}
Map temp = {'object': uids};
Navigator.of(context).pop(temp);
if (widget.needSave) {
//接口保存发放人信息uids
Map<String, String?> params = {
"id": widget.id,
"uid_list": uids,
};
bool isSuccess = await couponProvider.setCustomerActivity(
context, params,
isShowLoading: true);
print(isSuccess);
if(isSuccess){
Utils.showToast('保存成功');
bus.emit('refresh_coupon_detail');
Navigator.of(context).pop();
}
// 提交接口修改,成功后刷新前一个页面的数据 bus.emit 并返回前一个页面
} else {
Map temp = {'object': uids};
Navigator.of(context).pop(temp);
}
}),
VEmptyView(30)
]));
... ...
... ... @@ -1093,9 +1093,9 @@ class NavigatorUtil {
///优惠券----可发放员工
static Future<dynamic> goCouponToPersonnalPage(
BuildContext context, String? uids,
{replace = false, bool onlyShow = false}) {
{replace = false,bool needSave = false, bool onlyShow = false,String id = ''}) {
return _navigateTo(context,
"${Routes.coupon_to_personnel_page}?uids=$uids&onlyShow=$onlyShow",
"${Routes.coupon_to_personnel_page}?uids=$uids&onlyShow=$onlyShow&needSave=$needSave&id=$id",
replace: replace);
}
... ...
... ... @@ -2076,9 +2076,14 @@ var couponToPersonnelPageHandle = new Handler(
bool onlyShow =
FluroConvertUtils.string2bool(params["onlyShow"]!.first as String);
String id = params["id"]!.first as String;
bool needSave = FluroConvertUtils.string2bool(params["needSave"]!.first as String);
return ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child: CouponToPersonnalPage(uids: uids, onlyShow: onlyShow));
child: CouponToPersonnalPage(uids: uids, onlyShow: onlyShow,needSave:needSave,id:id));
});
///宴会----宴会看板
... ...