Commit 81d0314a76a15abc307d7c0fd8454d3b9f446e87

Authored by 蓋亞光
1 parent 3cf97eb0

历史录入联系人弹框

import 'package:json_annotation/json_annotation.dart';
part 'user_history_entity.g.dart';
@JsonSerializable()
class UserHistoryEntity extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'sid')
String sid;
@JsonKey(name: 'rname')
String rname;
@JsonKey(name: 'sex')
String sex;
@JsonKey(name: 'phone')
String phone;
@JsonKey(name: 'cusdem')
String cusdem;
UserHistoryEntity(this.id,this.sid,this.rname,this.sex,this.phone,this.cusdem,);
factory UserHistoryEntity.fromJson(Map<String, dynamic> srcJson) => _$UserHistoryEntityFromJson(srcJson);
Map<String, dynamic> toJson() => _$UserHistoryEntityToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_history_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UserHistoryEntity _$UserHistoryEntityFromJson(Map<String, dynamic> json) {
return UserHistoryEntity(
json['id'] as String,
json['sid'] as String,
json['rname'] as String,
json['sex'] as String,
json['phone'] as String,
json['cusdem'] as String);
}
Map<String, dynamic> _$UserHistoryEntityToJson(UserHistoryEntity instance) =>
<String, dynamic>{
'id': instance.id,
'sid': instance.sid,
'rname': instance.rname,
'sex': instance.sex,
'phone': instance.phone,
'cusdem': instance.cusdem
};
... ...
... ... @@ -53,4 +53,7 @@ class HttpUrl {
static const String add_custom_remark=
"?service=App.User.AddCustomRemark"; //添加常用备注
static const String get_reserve_user=
"?service=App.Reserve.GetReserveUser"; //获取历史录入联系人
}
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:ui';
import 'package:common_utils/common_utils.dart';
// import 'package:contacts_service/contacts_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
... ... @@ -18,6 +19,7 @@ import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/triangle_custom_painter.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/app_bar.dart';
... ... @@ -40,6 +42,7 @@ class NoteBookChangePage extends StatefulWidget {
const NoteBookChangePage({Key key, this.detailEntity, this.rid})
: super(key: key);
@override
_NoteBookChangePageState createState() => _NoteBookChangePageState();
}
... ... @@ -55,6 +58,12 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
RemarkManagerModel remarkManagerModel;
String currentRemark = '';
bool showPhoneHistory = false; //显示客户历史记录
String sid = ""; //商户id
ScrollController _controller = ScrollController();
@override
void initState() {
super.initState();
... ... @@ -62,6 +71,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// _notebookDetailChangeModel =
// Provider.of<NotebookDetailChangeModel>(context, listen: false);
sid = Provider.of<UserModel>(context, listen: false).user.sellerid;
_notebookDetailChangeModel.initDateHourMinuteList(context);
String ddate = widget.detailEntity.ddate.toString() + '000';
_notebookDetailChangeModel.getNewTableList(
... ... @@ -75,23 +85,6 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
"uid": Provider.of<UserModel>(context, listen: false).user.openid
};
remarkManagerModel.getRemarks(context, params);
// //输入框焦点
// _nameNode.addListener(() {
// if (!_nameNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// _phoneNode.unfocus();
// }
// });
// //输入框焦点
// _phoneNode.addListener(() {
// if (!_phoneNode.hasFocus) {
// print('失去焦点');
// } else {
// print('得到焦点');
// }
// });
});
}
... ... @@ -598,11 +591,34 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
border: InputBorder.none,
),
onChanged: (value) {},
onChanged: (value) {
LogUtil.v("value:$value");
if (value.isEmpty || value.length >= 11) {
//内容为空,或 超过11位
setState(() {
showPhoneHistory = false;
_notebookDetailChangeModel.userHistorys.clear();
});
return;
}
Map<String, String> params = {
"keywords": value,
"sid": sid
};
_notebookDetailChangeModel.getUserHistorys(context, params);
},
onEditingComplete: () {
print('fff');
_phoneNode.unfocus();
},
onTap: () {
setState(() {
showPhoneHistory = true;
});
Future.delayed(Duration(milliseconds: 300),(){
_controller.jumpTo(_controller.position.maxScrollExtent);
});
},
keyboardType: TextInputType.number,
),
),
... ... @@ -637,71 +653,166 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
)
],
),
VEmptyView(40),
MyDivider(ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_F1F0F4),
VEmptyView(52),
Row(
Stack(
children: [
Expanded(
child: TextField(
maxLines: 1,
inputFormatters: [LengthLimitingTextInputFormatter(25)],
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_353535),
controller: _notebookDetailChangeModel.customController,
focusNode: _needNode,
// textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(
hintText: "客户要求(25字以内,选填)",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(34),
Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(40),
MyDivider(
ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_F1F0F4),
VEmptyView(52),
Row(
children: [
Expanded(
child: TextField(
maxLines: 1,
inputFormatters: [LengthLimitingTextInputFormatter(25)],
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_353535),
controller: _notebookDetailChangeModel.customController,
focusNode: _needNode,
// textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(
hintText: "客户要求(25字以内,选填)",
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(34),
),
// contentPadding:
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
border: InputBorder.none,
),
onChanged: (value) {
print(value);
currentRemark = value;
// print();
},
onEditingComplete: () {
print('fff');
_needNode.unfocus();
},
// keyboardType: TextInputType.number,
)),
InkWell(
onTap: () {
DialogUtil.showRemarkDialog(
context, remarkManagerModel.remarks, (item) {
int index =
remarkManagerModel.remarks.indexOf(item);
_refreshRemark(remarkManagerModel.remarks, index);
});
},
child: Container(
margin:
EdgeInsets.only(left: ScreenUtil().setWidth(40)),
width: ScreenUtil().setWidth(122),
height: ScreenUtil().setWidth(42),
child: Text(
'快速备注',
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095),
),
),
),
],
),
// contentPadding:
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
border: InputBorder.none,
),
onChanged: (value) {
print(value);
currentRemark = value;
// print();
},
onEditingComplete: () {
print('fff');
_needNode.unfocus();
},
// keyboardType: TextInputType.number,
)),
InkWell(
onTap: () {
DialogUtil.showRemarkDialog(
context, remarkManagerModel.remarks, (item) {
int index = remarkManagerModel.remarks.indexOf(item);
_refreshRemark(remarkManagerModel.remarks, index);
});
},
VEmptyView(40),
MyDivider(
ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_F1F0F4),
VEmptyView(30),
_remarkListWidget()
],
),
Offstage(
offstage: !(showPhoneHistory &&
_notebookDetailChangeModel.userHistorys.length > 0),
child: Container(
margin: EdgeInsets.only(left: ScreenUtil().setWidth(40)),
width: ScreenUtil().setWidth(122),
height: ScreenUtil().setWidth(42),
child: Text(
'快速备注',
style: TextStyle(
fontSize: ScreenUtil().setSp(30),
color: MyColours.color_199095),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.white),
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
color: MyColours.color_e5e5e5,
blurRadius: ScreenUtil().setWidth(20))
]),
width: ScreenUtil().setWidth(440),
height: _notebookDetailChangeModel.userHistorys.length>1?ScreenUtil().setWidth(208):ScreenUtil().setWidth(104),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30)),
child: Align(
alignment: Alignment.topCenter,
child: MediaQuery.removePadding(context: context, removeTop:true,child: ListView.builder(
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
showPhoneHistory = false;
_notebookDetailChangeModel
.phoneController.text =
_notebookDetailChangeModel
.userHistorys[index].phone;
_notebookDetailChangeModel.nameController.text =
_notebookDetailChangeModel
.userHistorys[index].rname;
_phoneNode.unfocus();
_notebookDetailChangeModel.userHistorys.clear();
});
},
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(102),
decoration: BoxDecoration(
border: Border(
bottom: (index !=
(_notebookDetailChangeModel
.userHistorys.length -
1) &&
_notebookDetailChangeModel
.userHistorys.length >
1)
? BorderSide(
color: MyColours.color_e5e5e5,
width: ScreenUtil().setWidth(2))
: BorderSide.none)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
_notebookDetailChangeModel
.userHistorys[index].phone,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(32)),
),
Text(
_notebookDetailChangeModel
.userHistorys[index].rname,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(32)),
)
],
),
),
);
},
itemExtent: ScreenUtil().setWidth(104),
itemCount:
_notebookDetailChangeModel.userHistorys.length,
))
),
),
),
)
],
),
VEmptyView(40),
MyDivider(ScreenUtil().setWidth(335 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_F1F0F4),
VEmptyView(30),
_remarkListWidget()
)
// VEmptyView(62),
],
),
... ... @@ -966,7 +1077,6 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
} else {
fullName = contact.fullName;
}
_notebookDetailChangeModel.phoneController.text = contact.phoneNumber;
_notebookDetailChangeModel.nameController.text = fullName;
});
... ... @@ -992,9 +1102,14 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
),
Expanded(
child: SingleChildScrollView(
controller: _controller,
child: Column(
children: [_topWidget(), _middleWidget(), _bottomWidget()],
))),
children: [
_topWidget(),
_middleWidget(),
_bottomWidget()
],
))),
Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
... ... @@ -1102,12 +1217,14 @@ class CustomButton extends StatefulWidget {
this.model,
this.height = 25,
}) : super(key: key);
@override
_ButtonState createState() => _ButtonState();
}
class _ButtonState extends State<CustomButton> {
FocusNode _cancelNode = FocusNode();
@override
Widget build(BuildContext context) {
String imgStrSelect = widget.isImage && !widget.isTextFiled
... ...
... ... @@ -6,6 +6,7 @@ import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/reserve_info_model.dart';
import 'package:one_key/models/seller_info.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
... ... @@ -15,6 +16,7 @@ import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class NotebookDetailChangeModel with ChangeNotifier {
List dateList = []; //日期选择 月-日 某天
List sunDateList = []; // 早市、午市、晚市
List personNumList = []; // 人数
... ... @@ -35,6 +37,8 @@ class NotebookDetailChangeModel with ChangeNotifier {
bool isRecommend = false; //是否展示推荐
List oldTableList = [];
List<UserHistoryEntity> userHistorys=[];//历史录入
clearData() {
dateList = []; //日期选择 月-日 某天
sunDateList = []; // 早市、午市、晚市
... ... @@ -796,4 +800,20 @@ class NotebookDetailChangeModel with ChangeNotifier {
return itemModel;
}
}
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.get_reserve_user,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
}).toList();
notifyListeners();
}
}
}
... ...
import 'package:flutter/material.dart';
//自定义 坐标
class Coordinate {
final double cx;
final double cy;
Coordinate({this.cx, this.cy});
}
class TriangleCustomPainter extends CustomPainter {
Paint _paint = new Paint(); //画笔富含各种属性方法。仔细查看源码
final BuildContext context;
final List spots;
final Color color;
TriangleCustomPainter(this.context, this.spots, {this.color});
@override
void paint(Canvas canvas, Size size) {
Path path = new Path()..moveTo(spots[0].cx, spots[0].cy);
path.lineTo(spots[1].cx, spots[1].cy);
path.lineTo(spots[2].cx, spots[2].cy);
canvas.drawPath(
path,
_paint
..style = PaintingStyle.fill
..color = color);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
... ...