Commit 95f16c3a2562a0bfcc0f2b95fd85c7441fc7739b

Authored by wdn127929
1 parent ad9ee071

图片备注OK

@@ -8,8 +8,10 @@ import 'package:provider/provider.dart'; @@ -8,8 +8,10 @@ import 'package:provider/provider.dart';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import "table.dart"; 9 import "table.dart";
10 import 'package:one_key/models/table.dart' as t; 10 import 'package:one_key/models/table.dart' as t;
  11 +import 'dart:convert' as convert;
11 part 'notebook_detail.g.dart'; 12 part 'notebook_detail.g.dart';
12 13
  14 +
13 @JsonSerializable() 15 @JsonSerializable()
14 class NotebookDetail { 16 class NotebookDetail {
15 NotebookDetail(); 17 NotebookDetail();
@@ -114,6 +116,8 @@ class NotebookDetail { @@ -114,6 +116,8 @@ class NotebookDetail {
114 116
115 String log_photo; //下单照片 117 String log_photo; //下单照片
116 118
  119 + List<String> photo_note; //图片备注
  120 +
117 String get statuImgAssets { 121 String get statuImgAssets {
118 switch (status) { 122 switch (status) {
119 case "0": 123 case "0":
@@ -308,7 +312,7 @@ class NotebookDetail { @@ -308,7 +312,7 @@ class NotebookDetail {
308 312
309 @override 313 @override
310 String toString() { 314 String toString() {
311 - return 'NotebookDetail{id: $id, uid: $uid ,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, seller_user_phone:$seller_user_phone, nick_name: $nick_name,channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel, gid: $gid,guest_uid:$guest_uid,reserve_type:$reserve_type,place_order_name:$place_order_name,is_user_comments:$is_user_comments,deposit_cancel:$deposit_cancel,up_date:$up_date,log_photo:$log_photo}'; 315 + return 'NotebookDetail{id: $id, uid: $uid ,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, seller_user_phone:$seller_user_phone, nick_name: $nick_name,channel: $channel, cdate: $cdate, demands: $demands, tables: $tables, cancel: $cancel, gid: $gid,guest_uid:$guest_uid,reserve_type:$reserve_type,place_order_name:$place_order_name,is_user_comments:$is_user_comments,deposit_cancel:$deposit_cancel,up_date:$up_date,log_photo:$log_photo,photo_note:$photo_note}';
312 } 316 }
313 } 317 }
314 318
@@ -7,6 +7,18 @@ part of 'notebook_detail.dart'; @@ -7,6 +7,18 @@ part of 'notebook_detail.dart';
7 // ************************************************************************** 7 // **************************************************************************
8 8
9 NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) { 9 NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) {
  10 + List<String> images = [];
  11 + if (json['photo_note'] != null) {
  12 + if (json['photo_note'] is List) {
  13 + json['photo_note'].forEach((v) {
  14 + images.add(v);
  15 + });
  16 + } else {
  17 + convert.jsonDecode(json['photo_note']).forEach((v) {
  18 + images.add(v);
  19 + });
  20 + }
  21 + }
10 return NotebookDetail() 22 return NotebookDetail()
11 ..id = json['id'] as String 23 ..id = json['id'] as String
12 ..uid = json['uid'] as String 24 ..uid = json['uid'] as String
@@ -56,7 +68,8 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) { @@ -56,7 +68,8 @@ NotebookDetail _$NotebookDetailFromJson(Map<String, dynamic> json) {
56 ..is_user_comments = json['is_user_comments'] as dynamic 68 ..is_user_comments = json['is_user_comments'] as dynamic
57 ..up_date = json['up_date'] as String 69 ..up_date = json['up_date'] as String
58 ..deposit_cancel = json['deposit_cancel'] as String 70 ..deposit_cancel = json['deposit_cancel'] as String
59 - ..log_photo = json['log_photo'] as String; 71 + ..log_photo = json['log_photo'] as String
  72 + ..photo_note = images;
60 } 73 }
61 74
62 Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) => 75 Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) =>
@@ -98,6 +111,7 @@ Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) => @@ -98,6 +111,7 @@ Map<String, dynamic> _$NotebookDetailToJson(NotebookDetail instance) =>
98 'up_date': instance.up_date, 111 'up_date': instance.up_date,
99 'deposit_cancel': instance.deposit_cancel, 112 'deposit_cancel': instance.deposit_cancel,
100 'log_photo': instance.log_photo, 113 'log_photo': instance.log_photo,
  114 + 'photo_note': instance.photo_note
101 }; 115 };
102 OrderInfo _$OrderInfoFromJson(Map<String, dynamic> json) { 116 OrderInfo _$OrderInfoFromJson(Map<String, dynamic> json) {
103 return OrderInfo( 117 return OrderInfo(
@@ -169,7 +183,7 @@ Map<String, dynamic> _$CancelToJson(Cancel instance) => <String, dynamic>{ @@ -169,7 +183,7 @@ Map<String, dynamic> _$CancelToJson(Cancel instance) => <String, dynamic>{
169 'uname': instance.uname, 183 'uname': instance.uname,
170 'desc': instance.desc, 184 'desc': instance.desc,
171 'cdate': instance.cdate, 185 'cdate': instance.cdate,
172 - 'log_photo':instance.log_photo 186 + 'log_photo': instance.log_photo
173 }; 187 };
174 188
175 Order _$OrderFromJson(Map<String, dynamic> json) { 189 Order _$OrderFromJson(Map<String, dynamic> json) {
@@ -65,6 +65,8 @@ import '../../widgets/special_text/my_extended_text_selection_controls.dart'; @@ -65,6 +65,8 @@ import '../../widgets/special_text/my_extended_text_selection_controls.dart';
65 import '../online_check/img_picker_widget.dart'; 65 import '../online_check/img_picker_widget.dart';
66 import '../online_check/photo_view_wiget.dart'; 66 import '../online_check/photo_view_wiget.dart';
67 67
  68 +typedef BoolCallback = void Function(bool value);
  69 +
68 class NotebookDetailPage extends StatefulWidget { 70 class NotebookDetailPage extends StatefulWidget {
69 final String rid; 71 final String rid;
70 final String mid; 72 final String mid;
@@ -495,13 +497,26 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -495,13 +497,26 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
495 } 497 }
496 498
497 ///订座详情 499 ///订座详情
498 - _getReserveDetail({bool showCicle = false}) async { 500 + _getReserveDetail({bool showCicle = false, bool isShowLoading = true}) async {
499 detailEntity = await detailModel.getReserveDetail( 501 detailEntity = await detailModel.getReserveDetail(
500 context, 502 context,
501 { 503 {
502 "rid": widget.rid, 504 "rid": widget.rid,
503 }, 505 },
504 - showCircle: showCicle); 506 + showCircle: showCicle,
  507 + isShowLoading: isShowLoading);
  508 +
  509 + remarkImgs = [];
  510 +
  511 + if (detailEntity.photo_note != null && detailEntity.photo_note.length > 0) {
  512 + detailEntity.photo_note.forEach((element) {
  513 + UploadImgModel imageModel = UploadImgModel();
  514 + imageModel.qiniuUrl = element;
  515 + imageModel.isUpload = true;
  516 + imageModel.process = 1;
  517 + remarkImgs.add(imageModel);
  518 + });
  519 + }
505 520
506 reserveType = 521 reserveType =
507 detailEntity.reserve_type == null || detailEntity.reserve_type == '' 522 detailEntity.reserve_type == null || detailEntity.reserve_type == ''
@@ -1871,96 +1886,120 @@ class NotebookDetailPageState extends State<NotebookDetailPage> { @@ -1871,96 +1886,120 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
1871 ]); 1886 ]);
1872 } 1887 }
1873 1888
  1889 + _updatePhotoNote() async {
  1890 + List<String> imageQiniuUrlList = [];
  1891 + // if (isDelete) {
  1892 + for (int i = 0; i < remarkImgs.length; i++) {
  1893 + imageQiniuUrlList.add(remarkImgs[i].qiniuUrl);
  1894 + }
  1895 + // } else {
  1896 + // for (int i = 0; i < remarkImgs.length; i++) {
  1897 + // // if (!remarkImgs[i].isUpload) {
  1898 + // imageQiniuUrlList.add(remarkImgs[i].qiniuUrl);
  1899 + // // }
  1900 + // }
  1901 + // }
  1902 +
  1903 + print(imageQiniuUrlList); //全部图片,详情接口请求后赋值,初始化数据
  1904 + //调用接口绑定数据
  1905 + // _setTablePhoto(
  1906 + // context, imageQiniuUrlList);
  1907 +
  1908 + bool sucess = await detailModel.upReserveInfo(context, widget.rid,
  1909 + photoNote: json.encode(imageQiniuUrlList));
  1910 +
  1911 + if (sucess) {
  1912 + // bus.emit("refresh_book_list"); //刷新已预订列表
  1913 +
  1914 + // EventBus().emit("refresh_tablemanager"); //刷新桌位
  1915 + await _getReserveDetail(showCicle: false, isShowLoading: false);
  1916 + }
  1917 + }
  1918 +
1874 ///图片备注 1919 ///图片备注
1875 Widget _imageRemark() { 1920 Widget _imageRemark() {
1876 bool show = Utils.getAuthority(context, '图片备注') || 1921 bool show = Utils.getAuthority(context, '图片备注') ||
1877 widget.uid == 1922 widget.uid ==
1878 Provider.of<UserModel>(context, listen: false).user.openid; 1923 Provider.of<UserModel>(context, listen: false).user.openid;
1879 - return (!show && remarkImgs.length == 0) ? SizedBox(): Column(crossAxisAlignment: CrossAxisAlignment.start, children: [  
1880 - VEmptyView(36),  
1881 - Text(  
1882 - '图片备注',  
1883 - overflow: TextOverflow.ellipsis,  
1884 - style: TextStyle(color: MyColours.color_515151, fontSize: font(15)),  
1885 - ),  
1886 - VEmptyView(30),  
1887 - show  
1888 - ? Padding(  
1889 - padding: EdgeInsets.only(left: w(20), right: w(15)),  
1890 - child:  
1891 - Consumer<UploadImageProvider>(builder: (context, model, _) {  
1892 - return ImgPickerWidget(  
1893 - scrollController: controller,  
1894 - model: _uploadImageProvider,  
1895 - maxImageNumber: 3,  
1896 - maxRemind: '三',  
1897 - imageList: remarkImgs,  
1898 - uploadType: UploadType.RemarkImagesType,  
1899 - deleteCallback: (int index) {  
1900 - remarkImgs  
1901 - .removeWhere((element) => element == remarkImgs[index]);  
1902 - setState(() {});  
1903 - //删除图片接口??????  
1904 - },  
1905 - callback: () {  
1906 - print(remarkImgs);  
1907 - for (UploadImgModel item in remarkImgs) {  
1908 - if (item.process < 1) {  
1909 - Utils.showToast('正在上传图片,请稍等');  
1910 - return;  
1911 - }  
1912 - }  
1913 - //接口,和订单绑定  
1914 - List imageQiniuUrlList = [];  
1915 - for (int i = 0; i < remarkImgs.length; i++) {  
1916 - if (!remarkImgs[i].isUpload) {  
1917 - imageQiniuUrlList.add({"url": remarkImgs[i].qiniuUrl});  
1918 - }  
1919 - }  
1920 -  
1921 - print(imageQiniuUrlList); //全部图片,详情接口请求后赋值,初始化数据  
1922 - //调用接口绑定数据  
1923 - // _setTablePhoto(  
1924 - // context, imageQiniuUrlList);  
1925 - },  
1926 - );  
1927 - }))  
1928 - : GridView.builder(  
1929 - controller: controller,  
1930 - // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),  
1931 - shrinkWrap: true,  
1932 - itemCount: remarkImgs.length,  
1933 -  
1934 - //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget  
1935 - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(  
1936 - //横轴元素个数  
1937 - crossAxisCount: 3,  
1938 - //纵轴间距  
1939 - mainAxisSpacing: ScreenUtil().setWidth(40),  
1940 - //横轴间距  
1941 - crossAxisSpacing: ScreenUtil().setWidth(36),  
1942 - //子组件宽高长度比例  
1943 - childAspectRatio: 1.0),  
1944 - itemBuilder: (BuildContext context, int index) {  
1945 - return InkWell(  
1946 - onTap: () {  
1947 - ///没有上传完成的不可以点击  
1948 - _showPhotoView(context, index,  
1949 - remarkImgs.map((e) => e.qiniuUrl).toList());  
1950 - },  
1951 - child: CachedNetworkImage(  
1952 - imageUrl: remarkImgs[index].qiniuUrl,  
1953 - fit: BoxFit.cover,  
1954 - width: ScreenUtil().setWidth(100 * 2),  
1955 - height: ScreenUtil().setWidth(100 * 2),  
1956 - ));  
1957 - }),  
1958 - VEmptyView(36),  
1959 - Container(  
1960 - height: ScreenUtil().setWidth(2),  
1961 - color: MyColours.color_E7E7E7,  
1962 - ),  
1963 - ]); 1924 + return (!show && remarkImgs.length == 0)
  1925 + ? SizedBox()
  1926 + : Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
  1927 + VEmptyView(36),
  1928 + Text(
  1929 + '图片备注',
  1930 + overflow: TextOverflow.ellipsis,
  1931 + style:
  1932 + TextStyle(color: MyColours.color_515151, fontSize: font(15)),
  1933 + ),
  1934 + VEmptyView(30),
  1935 + show
  1936 + ? Padding(
  1937 + padding: EdgeInsets.only(left: w(20), right: w(15)),
  1938 + child: Consumer<UploadImageProvider>(
  1939 + builder: (context, model, _) {
  1940 + return ImgPickerWidget(
  1941 + scrollController: controller,
  1942 + model: _uploadImageProvider,
  1943 + maxImageNumber: 3,
  1944 + maxRemind: '三',
  1945 + imageList: remarkImgs,
  1946 + uploadType: UploadType.RemarkImagesType,
  1947 + deleteCallback: (int index) {
  1948 + remarkImgs.removeWhere(
  1949 + (element) => element == remarkImgs[index]);
  1950 + setState(() {});
  1951 + //删除图片接口??????
  1952 + _updatePhotoNote();
  1953 + },
  1954 + callback: () async {
  1955 + print(remarkImgs);
  1956 + for (UploadImgModel item in remarkImgs) {
  1957 + if (item.process < 1) {
  1958 + Utils.showToast('正在上传图片,请稍等');
  1959 + return;
  1960 + }
  1961 + }
  1962 + //接口,和订单绑定
  1963 + _updatePhotoNote();
  1964 + },
  1965 + );
  1966 + }))
  1967 + : GridView.builder(
  1968 + controller: controller,
  1969 + // padding: EdgeInsets.only(top: ScreenUtil().getAdapterSize(10)),
  1970 + shrinkWrap: true,
  1971 + itemCount: remarkImgs.length,
  1972 +
  1973 + //SliverGridDelegateWithFixedCrossAxisCount 构建一个横轴固定数量Widget
  1974 + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1975 + //横轴元素个数
  1976 + crossAxisCount: 3,
  1977 + //纵轴间距
  1978 + mainAxisSpacing: ScreenUtil().setWidth(40),
  1979 + //横轴间距
  1980 + crossAxisSpacing: ScreenUtil().setWidth(36),
  1981 + //子组件宽高长度比例
  1982 + childAspectRatio: 1.0),
  1983 + itemBuilder: (BuildContext context, int index) {
  1984 + return InkWell(
  1985 + onTap: () {
  1986 + ///没有上传完成的不可以点击
  1987 + _showPhotoView(context, index,
  1988 + remarkImgs.map((e) => e.qiniuUrl).toList());
  1989 + },
  1990 + child: CachedNetworkImage(
  1991 + imageUrl: remarkImgs[index].qiniuUrl,
  1992 + fit: BoxFit.cover,
  1993 + width: ScreenUtil().setWidth(100 * 2),
  1994 + height: ScreenUtil().setWidth(100 * 2),
  1995 + ));
  1996 + }),
  1997 + VEmptyView(36),
  1998 + Container(
  1999 + height: ScreenUtil().setWidth(2),
  2000 + color: MyColours.color_E7E7E7,
  2001 + ),
  2002 + ]);
1964 } 2003 }
1965 2004
1966 //查看大图 2005 //查看大图
@@ -634,7 +634,9 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> { @@ -634,7 +634,9 @@ class _ImgPickerWidgetState extends DisposableState<ImgPickerWidget> {
634 ), 634 ),
635 onTap: () { 635 onTap: () {
636 if (widget.uploadType == 636 if (widget.uploadType ==
637 - UploadType.TableManagerType) { 637 + UploadType.TableManagerType ||
  638 + widget.uploadType ==
  639 + UploadType.RemarkImagesType) {
638 if (temp[index].isUpload) { 640 if (temp[index].isUpload) {
639 //已经传到服务器,弹提醒窗口,是否删除 641 //已经传到服务器,弹提醒窗口,是否删除
640 //修改之前有内容,则弹框 642 //修改之前有内容,则弹框
@@ -431,7 +431,8 @@ class NotebookDetailModel extends ChangeNotifier { @@ -431,7 +431,8 @@ class NotebookDetailModel extends ChangeNotifier {
431 String ymd, 431 String ymd,
432 String reserveType, 432 String reserveType,
433 bool showLoading = false, 433 bool showLoading = false,
434 - bool needToast = true}) async { 434 + bool needToast = true,
  435 + String photoNote}) async {
435 if (phone != null && phone != '') { 436 if (phone != null && phone != '') {
436 //判断是否可以输入自己的手机号 437 //判断是否可以输入自己的手机号
437 CustomerProvider customerProvider = 438 CustomerProvider customerProvider =
@@ -451,6 +452,10 @@ class NotebookDetailModel extends ChangeNotifier { @@ -451,6 +452,10 @@ class NotebookDetailModel extends ChangeNotifier {
451 "rid": rid, 452 "rid": rid,
452 'note_name': Provider.of<UserModel>(context, listen: false).user.account 453 'note_name': Provider.of<UserModel>(context, listen: false).user.account
453 }; 454 };
  455 +
  456 + if (photoNote != null) {
  457 + params['photo_note'] = photoNote;
  458 + }
454 if (actualPum != null) { 459 if (actualPum != null) {
455 params['actual_pum'] = actualPum; 460 params['actual_pum'] = actualPum;
456 } 461 }