Commit 77364708bfc8b73c4a6addbb49acb35ca05ec2df

Authored by weixin_45529955
1 parent ade6f527

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

@@ -223,6 +223,10 @@ class Constant { @@ -223,6 +223,10 @@ class Constant {
223 '设置服务人员': [ 223 '设置服务人员': [
224 '管理员', 224 '管理员',
225 '店长', 225 '店长',
  226 + ],
  227 + '优惠券详情-编辑发放人': [
  228 + '管理员',
  229 + '店长',
226 ] 230 ]
227 }; 231 };
228 } 232 }
@@ -11,6 +11,7 @@ import 'package:one_key/provider/user_model.dart'; @@ -11,6 +11,7 @@ import 'package:one_key/provider/user_model.dart';
11 import 'package:one_key/res/colors.dart'; 11 import 'package:one_key/res/colors.dart';
12 12
13 import 'package:one_key/route/navigator_util.dart'; 13 import 'package:one_key/route/navigator_util.dart';
  14 +import 'package:one_key/utils/event_bus.dart';
14 import 'package:one_key/utils/utils.dart'; 15 import 'package:one_key/utils/utils.dart';
15 import 'package:one_key/widgets/h_empty_view.dart'; 16 import 'package:one_key/widgets/h_empty_view.dart';
16 import 'package:one_key/widgets/round_button.dart'; 17 import 'package:one_key/widgets/round_button.dart';
@@ -43,6 +44,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -43,6 +44,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
43 late CouponProvider couponProvider; 44 late CouponProvider couponProvider;
44 PageState pageState = PageState.Loading; 45 PageState pageState = PageState.Loading;
45 String? managerName = ''; 46 String? managerName = '';
  47 + String nickNameShow = '编辑';
46 48
47 @override 49 @override
48 void initState() { 50 void initState() {
@@ -58,6 +60,15 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -58,6 +60,15 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
58 // setState(() {}); 60 // setState(() {});
59 // } 61 // }
60 }); 62 });
  63 + bus.on("refresh_coupon_detail", (arg) {
  64 + _getActivityByIdRefresh();
  65 + });
  66 + }
  67 +
  68 + @override
  69 + void dispose() {
  70 + bus.off("refresh_coupon_detail");
  71 + super.dispose();
61 } 72 }
62 73
63 _getCustomerActivityBaseinfo() async { 74 _getCustomerActivityBaseinfo() async {
@@ -69,7 +80,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -69,7 +80,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
69 }; 80 };
70 81
71 bool success = 82 bool success =
72 - await _baseIndoProvider.getCustomerActivityBaseinfo(context, params); 83 + await _baseIndoProvider.getCustomerActivityBaseinfo(context, params,isShowLoading: false);
73 if (success) { 84 if (success) {
74 managerName = _baseIndoProvider.baseInfoSunModel!.name; 85 managerName = _baseIndoProvider.baseInfoSunModel!.name;
75 } 86 }
@@ -81,14 +92,24 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -81,14 +92,24 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
81 .getActivityById(context, {'id': widget.idstr}, isShowLoading: false); 92 .getActivityById(context, {'id': widget.idstr}, isShowLoading: false);
82 if (success) { 93 if (success) {
83 pageState = PageState.Success; 94 pageState = PageState.Success;
  95 + nickNameShow = couponProvider.couponSunModel?.nickNameShow ?? '编辑';
84 } else { 96 } else {
85 pageState = PageState.ConnectivityError; 97 pageState = PageState.ConnectivityError;
86 } 98 }
87 setState(() {}); 99 setState(() {});
88 } 100 }
89 101
  102 + _getActivityByIdRefresh() async {
  103 + bool success = await couponProvider
  104 + .getActivityById(context, {'id': widget.idstr}, isShowLoading: true);
  105 + if (success) {
  106 + nickNameShow = couponProvider.couponSunModel?.nickNameShow ?? '编辑';
  107 + }
  108 + setState(() {});
  109 + }
  110 +
90 ///时间选择 111 ///时间选择
91 - Widget _select(String title, String hintText, GestureTapCallback onTap) { 112 + Widget _select(String title, String hintText, GestureTapCallback onTap,{bool canEdit = false}) {
92 return InkWell( 113 return InkWell(
93 onTap: onTap, 114 onTap: onTap,
94 child: Container( 115 child: Container(
@@ -108,20 +129,21 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -108,20 +129,21 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
108 ), 129 ),
109 ), 130 ),
110 HEmptyView(20), 131 HEmptyView(20),
111 - Spacer(),  
112 - Text(hintText,  
113 - style: TextStyle(  
114 - color: hintText == '点击选择'  
115 - ? MyColours.color_999999  
116 - : MyColours.color_515151,  
117 - fontSize: ScreenUtil().setSp(32),  
118 - )), 132 + // Spacer(),
  133 + Expanded(
  134 + child: Text(hintText,
  135 + style: TextStyle(
  136 + color: hintText == '点击选择'
  137 + ? MyColours.color_999999
  138 + : MyColours.color_515151,
  139 + fontSize: ScreenUtil().setSp(32),
  140 + ))),
119 HEmptyView(20), 141 HEmptyView(20),
120 Image.asset( 142 Image.asset(
121 - Utils.getImgPath('arrow_right_new'), 143 + Utils.getImgPath(canEdit ? 'enter_store_arrow_r':'arrow_right_new'),
122 width: ScreenUtil().setWidth(20), 144 width: ScreenUtil().setWidth(20),
123 ), 145 ),
124 - HEmptyView(32), 146 + // HEmptyView(32),
125 ], 147 ],
126 ), 148 ),
127 ), 149 ),
@@ -778,10 +800,28 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -778,10 +800,28 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
778 color: MyColours.color_E7E7E7, 800 color: MyColours.color_E7E7E7,
779 ), 801 ),
780 VEmptyView(24), 802 VEmptyView(24),
781 - _item(  
782 - '谁可以发放',  
783 - couponProvider  
784 - .couponSunModel!.nickNameShow!), 803 + Utils.getAuthority(context, '优惠券详情-编辑发放人')
  804 + ? _select('谁可以发放', nickNameShow,canEdit: true,
  805 + () async {
  806 + Map? temp = await NavigatorUtil
  807 + .goCouponToPersonnalPage(
  808 + context,
  809 + couponProvider
  810 + .couponSunModel
  811 + ?.uidList ??
  812 + '',
  813 + id: widget.idstr ?? '',
  814 + needSave: true);
  815 + // if (temp != null &&
  816 + // temp['object'] != null) {
  817 + // uids = temp['object'];
  818 + // }
  819 + })
  820 + : _item(
  821 + '谁可以发放',
  822 + couponProvider.couponSunModel!
  823 + .nickNameShow!),
  824 +
785 Container( 825 Container(
786 height: ScreenUtil().setWidth(2), 826 height: ScreenUtil().setWidth(2),
787 color: MyColours.color_E7E7E7, 827 color: MyColours.color_E7E7E7,
@@ -1466,7 +1466,7 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> { @@ -1466,7 +1466,7 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
1466 widget.isMine 1466 widget.isMine
1467 ? SizedBox() 1467 ? SizedBox()
1468 : _select('谁可以发放', '编辑', () async { 1468 : _select('谁可以发放', '编辑', () async {
1469 - Map temp = await NavigatorUtil 1469 + dynamic temp = await NavigatorUtil
1470 .goCouponToPersonnalPage( 1470 .goCouponToPersonnalPage(
1471 context, uids); 1471 context, uids);
1472 if (temp != null && 1472 if (temp != null &&
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter_screenutil/flutter_screenutil.dart'; 2 import 'package:flutter_screenutil/flutter_screenutil.dart';
3 import 'package:one_key/models/personnel_manage_model.dart'; 3 import 'package:one_key/models/personnel_manage_model.dart';
  4 +import 'package:one_key/provider/coupon_provider.dart';
4 import 'package:one_key/provider/personnel_provider.dart'; 5 import 'package:one_key/provider/personnel_provider.dart';
5 import 'package:one_key/provider/user_model.dart'; 6 import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/res/colors.dart'; 7 import 'package:one_key/res/colors.dart';
@@ -15,7 +16,14 @@ import 'package:provider/provider.dart'; @@ -15,7 +16,14 @@ import 'package:provider/provider.dart';
15 class CouponToPersonnalPage extends StatefulWidget { 16 class CouponToPersonnalPage extends StatefulWidget {
16 final String? uids; 17 final String? uids;
17 final bool onlyShow; 18 final bool onlyShow;
18 - CouponToPersonnalPage({Key? key, this.uids, this.onlyShow = false}) 19 + final bool needSave;
  20 + final String id;
  21 + CouponToPersonnalPage(
  22 + {Key? key,
  23 + this.uids,
  24 + this.onlyShow = false,
  25 + this.needSave = false,
  26 + this.id = ''})
19 : super(key: key); 27 : super(key: key);
20 28
21 @override 29 @override
@@ -26,6 +34,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> { @@ -26,6 +34,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
26 late PersonnelProvider personnelProvider; 34 late PersonnelProvider personnelProvider;
27 ScrollController _scrollController = ScrollController(); 35 ScrollController _scrollController = ScrollController();
28 List<String> titleList = []; 36 List<String> titleList = [];
  37 + late CouponProvider couponProvider;
29 38
30 @override 39 @override
31 void initState() { 40 void initState() {
@@ -178,6 +187,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> { @@ -178,6 +187,7 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
178 187
179 @override 188 @override
180 Widget build(BuildContext context) { 189 Widget build(BuildContext context) {
  190 + couponProvider = Provider.of<CouponProvider>(context, listen: true);
181 personnelProvider = Provider.of<PersonnelProvider>(context, listen: true); 191 personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
182 return Scaffold( 192 return Scaffold(
183 backgroundColor: MyColours.color_ffffff, 193 backgroundColor: MyColours.color_ffffff,
@@ -775,8 +785,29 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> { @@ -775,8 +785,29 @@ class _CouponToPersonnalPageState extends State<CouponToPersonnalPage> {
775 uids = uids.substring(0, uids.length - 1); 785 uids = uids.substring(0, uids.length - 1);
776 } 786 }
777 787
778 - Map temp = {'object': uids};  
779 - Navigator.of(context).pop(temp); 788 + if (widget.needSave) {
  789 + //接口保存发放人信息uids
  790 +
  791 + Map<String, String?> params = {
  792 + "id": widget.id,
  793 + "uid_list": uids,
  794 + };
  795 + bool isSuccess = await couponProvider.setCustomerActivity(
  796 + context, params,
  797 + isShowLoading: true);
  798 + print(isSuccess);
  799 +
  800 + if(isSuccess){
  801 + Utils.showToast('保存成功');
  802 + bus.emit('refresh_coupon_detail');
  803 + Navigator.of(context).pop();
  804 + }
  805 +
  806 + // 提交接口修改,成功后刷新前一个页面的数据 bus.emit 并返回前一个页面
  807 + } else {
  808 + Map temp = {'object': uids};
  809 + Navigator.of(context).pop(temp);
  810 + }
780 }), 811 }),
781 VEmptyView(30) 812 VEmptyView(30)
782 ])); 813 ]));
@@ -1093,9 +1093,9 @@ class NavigatorUtil { @@ -1093,9 +1093,9 @@ class NavigatorUtil {
1093 ///优惠券----可发放员工 1093 ///优惠券----可发放员工
1094 static Future<dynamic> goCouponToPersonnalPage( 1094 static Future<dynamic> goCouponToPersonnalPage(
1095 BuildContext context, String? uids, 1095 BuildContext context, String? uids,
1096 - {replace = false, bool onlyShow = false}) { 1096 + {replace = false,bool needSave = false, bool onlyShow = false,String id = ''}) {
1097 return _navigateTo(context, 1097 return _navigateTo(context,
1098 - "${Routes.coupon_to_personnel_page}?uids=$uids&onlyShow=$onlyShow", 1098 + "${Routes.coupon_to_personnel_page}?uids=$uids&onlyShow=$onlyShow&needSave=$needSave&id=$id",
1099 replace: replace); 1099 replace: replace);
1100 } 1100 }
1101 1101
@@ -2076,9 +2076,14 @@ var couponToPersonnelPageHandle = new Handler( @@ -2076,9 +2076,14 @@ var couponToPersonnelPageHandle = new Handler(
2076 2076
2077 bool onlyShow = 2077 bool onlyShow =
2078 FluroConvertUtils.string2bool(params["onlyShow"]!.first as String); 2078 FluroConvertUtils.string2bool(params["onlyShow"]!.first as String);
  2079 +
  2080 +
  2081 + String id = params["id"]!.first as String;
  2082 +
  2083 + bool needSave = FluroConvertUtils.string2bool(params["needSave"]!.first as String);
2079 return ChangeNotifierProvider<PersonnelProvider>( 2084 return ChangeNotifierProvider<PersonnelProvider>(
2080 create: (_) => PersonnelProvider(), 2085 create: (_) => PersonnelProvider(),
2081 - child: CouponToPersonnalPage(uids: uids, onlyShow: onlyShow)); 2086 + child: CouponToPersonnalPage(uids: uids, onlyShow: onlyShow,needSave:needSave,id:id));
2082 }); 2087 });
2083 2088
2084 ///宴会----宴会看板 2089 ///宴会----宴会看板