|
...
|
...
|
@@ -5,11 +5,12 @@ import 'package:flutter_screenutil/screenutil.dart'; |
|
|
|
import 'package:one_key/models/table_photo_model.dart';
|
|
|
|
import 'package:one_key/models/upload_img_model.dart';
|
|
|
|
import 'package:one_key/pages/online_check/img_picker_widget.dart';
|
|
|
|
import 'package:one_key/provider/table_photo_anager_provider.dart';
|
|
|
|
import 'package:one_key/provider/table_photo_manager_provider.dart';
|
|
|
|
import 'package:one_key/provider/upload_img_provider.dart';
|
|
|
|
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/upload_image_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
...
|
...
|
@@ -30,13 +31,19 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { |
|
|
|
ScrollController _controller = ScrollController();
|
|
|
|
UploadImageProvider _uploadImageProvider;
|
|
|
|
TablePhotoManagerModel _tablePhotoManagerModel;
|
|
|
|
String tname;
|
|
|
|
String tid;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
tid = widget.tid;
|
|
|
|
tname = widget.tname;
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_getTablePhoto(context);
|
|
|
|
_getQiniuInfo();
|
|
|
|
Future.delayed(const Duration(milliseconds: 200), () {
|
|
|
|
_getTablePhoto(context, widget.tid);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -51,7 +58,7 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { |
|
|
|
_setTablePhoto(BuildContext context, List tablePhoto) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
"tableid": widget.tid,
|
|
|
|
"tableid": tid,
|
|
|
|
"photoList": jsonEncode(tablePhoto)
|
|
|
|
};
|
|
|
|
print(_uploadImageProvider.tableImageList);
|
|
...
|
...
|
@@ -76,13 +83,15 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
///获取桌位图片
|
|
|
|
_getTablePhoto(BuildContext context) async {
|
|
|
|
_getTablePhoto(BuildContext context, String tid,
|
|
|
|
{bool showLoading = false}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
"tableid": widget.tid,
|
|
|
|
"tableid": tid,
|
|
|
|
};
|
|
|
|
List<TablePhotoSunModel> tablePhotoList =
|
|
|
|
await _tablePhotoManagerModel.getTablePhoto(context, params);
|
|
|
|
_uploadImageProvider.tableImageList = [];
|
|
|
|
List<TablePhotoSunModel> tablePhotoList = await _tablePhotoManagerModel
|
|
|
|
.getTablePhoto(context, params, isShowLoading: showLoading);
|
|
|
|
if (tablePhotoList.length > 0) {
|
|
|
|
print(_uploadImageProvider.tableImageList);
|
|
|
|
for (int i = 0; i < tablePhotoList.length; i++) {
|
|
...
|
...
|
@@ -93,6 +102,25 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { |
|
|
|
model.process = 1;
|
|
|
|
_uploadImageProvider.tableImageList.add(model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_uploadImageProvider.notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
///删除桌子图片
|
|
|
|
///
|
|
|
|
_delTablePhoto(BuildContext context, String photoIds, int index) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
"photoIds": photoIds
|
|
|
|
};
|
|
|
|
print(_uploadImageProvider.tableImageList);
|
|
|
|
bool success = await _tablePhotoManagerModel.delTablePhoto(context, params,
|
|
|
|
isShowLoading: true);
|
|
|
|
if (success) {
|
|
|
|
print('删除成功');
|
|
|
|
//调用删除桌子图片接口
|
|
|
|
_uploadImageProvider.tableImageList.removeWhere(
|
|
|
|
(element) => element == _uploadImageProvider.tableImageList[index]);
|
|
|
|
_uploadImageProvider.notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -115,92 +143,126 @@ class _TablePhotoManagerPageState extends State<TablePhotoManagerPage> { |
|
|
|
appBar: SystemAppBar(
|
|
|
|
'照片管理',
|
|
|
|
onTap: () {
|
|
|
|
bus.emit('refresh_tablePhoto');
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
body: WillPopScope(
|
|
|
|
onWillPop: () {
|
|
|
|
bus.emit('refresh_tablePhoto');
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
child: Column(children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f5f5f5))),
|
|
|
|
height: ScreenUtil().setWidth(100),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text('当前桌位:${widget.tname}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
Text('切换桌位',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_199095,
|
|
|
|
fontSize: ScreenUtil().setSp(32))),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: _controller,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
VEmptyView(60),
|
|
|
|
Consumer<UploadImageProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
return ImgPickerWidget(
|
|
|
|
scrollController: _controller,
|
|
|
|
model: model,
|
|
|
|
maxImageNumber: 5,
|
|
|
|
uploadType: UploadType.TableManagerType,
|
|
|
|
callbackDelete: () {
|
|
|
|
//调用删除桌子图片接口
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
]))),
|
|
|
|
RoundButton(
|
|
|
|
text: '确定上传',
|
|
|
|
gradientStart: MyColours.color_199095,
|
|
|
|
gradientEnd: MyColours.color_199095,
|
|
|
|
// borderColor: MyColours.color_999999,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
fontSize: 34,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
isBold: false,
|
|
|
|
onPressed: () {
|
|
|
|
for (UploadImgModel item
|
|
|
|
in _uploadImageProvider.tableImageList) {
|
|
|
|
if (item.process < 1) {
|
|
|
|
Utils.showToast('正在上传图片,请稍等');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//接口,和桌子绑定
|
|
|
|
List imageQiniuUrlList = [];
|
|
|
|
for (int i = 0;
|
|
|
|
i < _uploadImageProvider.tableImageList.length;
|
|
|
|
i++) {
|
|
|
|
if (!_uploadImageProvider.tableImageList[i].isUpload) {
|
|
|
|
imageQiniuUrlList.add({
|
|
|
|
"url":
|
|
|
|
_uploadImageProvider.tableImageList[i].qiniuUrl
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_setTablePhoto(context, imageQiniuUrlList);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]))));
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
),
|
|
|
|
child: Column(children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f5f5f5))),
|
|
|
|
height: ScreenUtil().setWidth(100),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text('当前桌位:${tname}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
Map temp =
|
|
|
|
await NavigatorUtil.goSelectTablePage(
|
|
|
|
context,
|
|
|
|
"",
|
|
|
|
DateTime.now()
|
|
|
|
.millisecondsSinceEpoch,
|
|
|
|
"1",
|
|
|
|
canChoose: true,
|
|
|
|
object: null,
|
|
|
|
fromPage: "tablePhoto",
|
|
|
|
tid: tid);
|
|
|
|
if (temp != null && temp['tid'] != '') {
|
|
|
|
print(temp['tid']);
|
|
|
|
print(temp['tname']);
|
|
|
|
tname = temp['tname'];
|
|
|
|
tid = temp['tid'];
|
|
|
|
_getTablePhoto(context, temp['tid'],
|
|
|
|
showLoading: true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Text('切换桌位',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_199095,
|
|
|
|
fontSize: ScreenUtil().setSp(32)))),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: _controller,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
VEmptyView(60),
|
|
|
|
Consumer<UploadImageProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
return ImgPickerWidget(
|
|
|
|
scrollController: _controller,
|
|
|
|
model: model,
|
|
|
|
maxImageNumber: 5,
|
|
|
|
uploadType: UploadType.TableManagerType,
|
|
|
|
deleteCallback: (int index) {
|
|
|
|
_delTablePhoto(
|
|
|
|
context,
|
|
|
|
_uploadImageProvider
|
|
|
|
.tableImageList[index]
|
|
|
|
.photoID,
|
|
|
|
index);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
]))),
|
|
|
|
RoundButton(
|
|
|
|
text: '确定上传',
|
|
|
|
gradientStart: MyColours.color_199095,
|
|
|
|
gradientEnd: MyColours.color_199095,
|
|
|
|
// borderColor: MyColours.color_999999,
|
|
|
|
radius: ScreenUtil().setWidth(10),
|
|
|
|
fontSize: 34,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
isBold: false,
|
|
|
|
onPressed: () {
|
|
|
|
for (UploadImgModel item
|
|
|
|
in _uploadImageProvider.tableImageList) {
|
|
|
|
if (item.process < 1) {
|
|
|
|
Utils.showToast('正在上传图片,请稍等');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//接口,和桌子绑定
|
|
|
|
List imageQiniuUrlList = [];
|
|
|
|
for (int i = 0;
|
|
|
|
i < _uploadImageProvider.tableImageList.length;
|
|
|
|
i++) {
|
|
|
|
if (!_uploadImageProvider
|
|
|
|
.tableImageList[i].isUpload) {
|
|
|
|
imageQiniuUrlList.add({
|
|
|
|
"url": _uploadImageProvider
|
|
|
|
.tableImageList[i].qiniuUrl
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_setTablePhoto(context, imageQiniuUrlList);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
])))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|