Commit 34d6830fe491a37df2a3f4971129c0f2e17bfde7

Authored by wdn127929
1 parent 70e5b34a

意向编辑赋值

import 'dart:convert' as convert;
import 'package:flutter/material.dart';
import 'package:one_key/utils/ConvertNumberToChineseMoneyWords.dart';
class GetBanquetByIdNewModel {
int ret;
... ... @@ -57,15 +58,37 @@ class GetBanquetByIdNewSunModel {
contractInfo = json['contract_info'] != null
? new ContractInfo.fromJson(json['contract_info'])
: null;
invoice = json['invoice'] != null
? new Invoice.fromJson(convert.jsonDecode(json['invoice']))
: null; //发票信息
if (json['invoice'] is Map) {
invoice = json['invoice'] != null
? new Invoice.fromJson(json['invoice'])
: null; //发票信息
} else {
invoice = json['invoice'] != null
? new Invoice.fromJson(convert.jsonDecode(json['invoice']))
: null; //发票信息
}
costInfo = <CostInfoModel>[];
if (json['cost_info'] != null && json['cost_info'].length > 0) {
double totalP = 0.0;
json['cost_info'].forEach((key, v) {
CostInfoModel model = CostInfoModel.fromJson(v);
model.title = '${key}费用';
int start = key.indexOf('第');
int end = key.indexOf('场');
String numstr = key.substring(start + 1, end);
int index = ConvertNumberToChineseMoneyWords.toInt(numstr);
SessionsInfo info = sessionsInfo[index];
model.discounttype = info.discounttype;
model.discountper = info.discountper;
model.discountprice = info.discountprice;
model.servicetype = info.servicetype;
model.serviceper = info.serviceper;
model.serviceprice = info.serviceprice;
model.totalPrice = info.totalprice;
model.service = info.servicetype == '1' ? true : false;
model.discount = info.discounttype == '1' ? true : false;
costInfo.add(model);
totalP += double.parse(model.sumPrice);
});
... ... @@ -106,6 +129,7 @@ class BasicInfo {
Jiedan jiedan;
Jiedan staff;
String classify;
List<ImagesById> images;
BasicInfo(
{this.ddate,
... ... @@ -115,7 +139,8 @@ class BasicInfo {
this.remark,
this.jiedan,
this.staff,
this.classify});
this.classify,
this.images});
BasicInfo.fromJson(Map<String, dynamic> json) {
ddate = json['ddate'];
... ... @@ -127,6 +152,18 @@ class BasicInfo {
json['jiedan'] != null ? new Jiedan.fromJson(json['jiedan']) : null;
staff = json['staff'] != null ? new Jiedan.fromJson(json['staff']) : null;
classify = json['classify'];
if (json['images'] != null) {
images = <ImagesById>[];
if (json['images'] is List) {
json['images'].forEach((v) {
images.add(new ImagesById.fromJson(v));
});
} else {
convert.jsonDecode(json['images']).forEach((v) {
images.add(new ImagesById.fromJson(v));
});
}
}
}
Map<String, dynamic> toJson() {
... ... @@ -143,6 +180,8 @@ class BasicInfo {
data['staff'] = this.staff.toJson();
}
data['classify'] = this.classify;
data['images'] = this.images;
return data;
}
}
... ... @@ -175,6 +214,13 @@ class SessionsInfo {
String remark;
List<ImagesById> images;
dynamic tableNum;
String servicetype;
String serviceper;
String serviceprice;
String discounttype;
String discountper;
String discountprice;
String totalprice;
SessionsInfo(
{this.rdate,
... ... @@ -184,7 +230,14 @@ class SessionsInfo {
this.other,
this.remark,
this.images,
this.tableNum});
this.tableNum,
this.servicetype,
this.serviceper,
this.serviceprice,
this.discounttype,
this.discountper,
this.discountprice,
this.totalprice});
SessionsInfo.fromJson(Map<String, dynamic> json) {
rdate = json['rdate'];
... ... @@ -211,12 +264,25 @@ class SessionsInfo {
if (json['images'] != null) {
images = <ImagesById>[];
convert.jsonDecode(json['images']).forEach((v) {
images.add(new ImagesById.fromJson(v));
});
if (json['images'] is List) {
json['images'].forEach((v) {
images.add(new ImagesById.fromJson(v));
});
} else {
convert.jsonDecode(json['images']).forEach((v) {
images.add(new ImagesById.fromJson(v));
});
}
}
tableNum = json['table_num'];
servicetype = json['service_type'];
serviceper = json['service_per'];
serviceprice = json['service_price'];
discounttype = json['discount_type'];
discountper = json['discount_per'];
discountprice = json['discount_price'];
totalprice = json['total_price'];
}
Map<String, dynamic> toJson() {
... ... @@ -235,6 +301,13 @@ class SessionsInfo {
data['remark'] = this.remark;
data['images'] = this.images;
data['table_num'] = this.tableNum;
data['service_type'] = this.servicetype;
data['service_per'] = this.serviceper;
data['service_price'] = this.serviceprice;
data['discount_type'] = this.discounttype;
data['discount_per'] = this.discountper;
data['discount_price'] = this.discountprice;
data['total_price'] = this.totalprice;
return data;
}
}
... ... @@ -355,12 +428,58 @@ class OtherDetail {
class CostInfoModel {
String title;
List<CostInfoSunModel> data;
bool service = true; //服务费
bool discount = true; // 优惠金额
bool service;
bool discount;
TextEditingController serviceC = TextEditingController();
TextEditingController discountC = TextEditingController();
String totalPrice; //合计
String sumPrice; //优惠和服务费之前的金额
String servicetype;
String serviceper;
String serviceprice;
String discounttype;
String discountper;
String discountprice;
String totalprice;
//详情用的服务费展示
String get showService {
double sum = double.parse(sumPrice); //原来总金额
if (service) {
//选中固定金额
return serviceprice;
} else {
//选中百分比
// 使除数为0
double input = double.parse(serviceper);
return '${sum * input / 100}';
}
}
//详情用的合计展示(原价+服务费)
String get showTotalWithService {
double sum = double.parse(sumPrice); //原来总金额
return '${sum + double.parse(showService)} 元';
}
//详情用的优惠金额展示
String get showDiscount {
double sum = double.parse(sumPrice); //原来总金额
if (discount) {
//选中固定金额
return discountprice;
} else {
//选中百分比
// 使除数为0
double input = double.parse(discountper);
return '-${sum * input / 100} 元';
}
}
CostInfoModel({this.title, this.data});
... ... @@ -447,11 +566,18 @@ class ContractInfo {
contractRname = json['contract_rname'];
contractSellerName = json['contract_seller_name'];
contractNo = json['contract_no'];
if (json['contract_images'] != null) {
contractImages = <ImagesById>[];
convert.jsonDecode(json['contract_images']).forEach((v) {
contractImages.add(new ImagesById.fromJson(v));
});
if (json['contract_images'] is List) {
json['contract_images'].forEach((v) {
contractImages.add(new ImagesById.fromJson(v));
});
} else {
convert.jsonDecode(json['contract_images']).forEach((v) {
contractImages.add(new ImagesById.fromJson(v));
});
}
}
}
... ...
... ... @@ -75,6 +75,7 @@ class SetXuanTaiModel {
});
}
remark = json['remark'];
customCxt.text = json['remark'];
if (json['images'] != null) {
images = <Images>[];
json['images'].forEach((v) {
... ... @@ -120,6 +121,7 @@ class Tids {
Tids.fromJson(Map<String, dynamic> json) {
tid = json['tid'];
numStr = json['num'];
tableNumC.text = numStr;
}
Map<String, dynamic> toJson() {
... ...
... ... @@ -40,7 +40,8 @@ import '../table/area_item_table.dart';
import 'package:one_key/models/table_list.dart' as t;
class FeastCreatePage extends StatefulWidget {
FeastCreatePage({Key key}) : super(key: key);
final GetBanquetByIdNewSunModel banquetDetail;
FeastCreatePage({Key key, this.banquetDetail}) : super(key: key);
@override
_FeastCreatePageState createState() => _FeastCreatePageState();
... ... @@ -98,12 +99,13 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
xuantaiData.add(initSetXuanTaiModel(index: 0));
initTime(context);
WidgetsBinding.instance.addPostFrameCallback((_) {
_getSellerUserBySellerid();
_getStaff();
_getClassify();
_getSetmeal();
// scrollController.jumpTo(scrollController.position.minScrollExtent);
// _getSellerUserBySellerid();
// _getStaff();
// _getClassify();
// _getSetmeal();
_getData();
});
bus.on("feast_deposit_list", (arg) {
_getBanquetDeposit();
... ... @@ -113,6 +115,83 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
});
}
_getData() async {
await Future.wait<bool>([
_getSellerUserBySellerid(),
_getStaff(),
_getClassify(),
_getSetmeal()
]).then((results) {
print(results[0]);
if (results[0] && results[1] && results[2] && results[3]) {
//成功
if (widget.banquetDetail != null) {
//旧内容编辑
// ******意向******
BasicInfo basicInfo = widget.banquetDetail.basicInfo;
// 宴会日期
dateTime = DateTime.fromMillisecondsSinceEpoch(
int.parse(basicInfo.ddate.toString()) * 1000);
dateTimeShow = createDateText(context, dateTime);
//接单人
jdShow = basicInfo.jiedan.nickName ?? basicInfo.jiedan.account;
jdSelIndex = feastModel.sellerManageList
.map((item) {
return item.title;
})
.toList()
.indexOf(jdShow);
//跟单人
gdShow = basicInfo.staff.nickName ?? basicInfo.staff.account;
gdSelIndex = feastModel.personnalList
.map((item) {
return item.title;
})
.toList()
.indexOf(gdShow);
//宴会类型
feastTypeShow = basicInfo.classify;
feastTypeSelIndex = feastModel.classifyData
.map((item) {
return item.className;
})
.toList()
.indexOf(feastTypeShow);
//预订人、性别
nameC.text = basicInfo.rname;
sexStr = basicInfo.sex;
sexSelectIndex = sexList
.map((item) {
return item['title'];
})
.toList()
.indexOf(sexStr);
//电话
phoneC.text = basicInfo.phone;
//备注
customC.text = basicInfo.remark;
//备注图片
_uploadImageProvider.feastRemarkImageList = [];
basicInfo.images.forEach((element) {
UploadImgModel imgModel = UploadImgModel();
imgModel.qiniuUrl = element.url;
imgModel.process = 1;
_uploadImageProvider.feastRemarkImageList.add(imgModel);
});
setState(() {});
}
} else {
if (!results[0]) {
// Utils.showToast('');
} else {
// Utils.showToast('');
}
}
}).catchError((e) {
print(e);
});
}
@override
void dispose() {
super.dispose();
... ... @@ -175,13 +254,25 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
///获取经理数据 ---- 接单人---全部员工
_getSellerUserBySellerid() async {
await feastModel.getAuthUserLists(context);
Future<bool> _getSellerUserBySellerid() async {
bool success = await feastModel.getAuthUserLists(context);
if (success) {
return true;
} else {
return false;
}
}
///跟单人---宴会员工
_getStaff() async {
await feastModel.getStaff(context);
Future<bool> _getStaff() async {
bool success = await feastModel.getStaff(context);
if (success) {
return true;
} else {
return false;
}
}
///获取宴会详情
... ... @@ -202,7 +293,13 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
///获取宴会分类
Future<bool> _getClassify({bool isShowLoading = true}) async {
await feastModel.getClassify(context, isShowLoading: isShowLoading);
bool success =
await feastModel.getClassify(context, isShowLoading: isShowLoading);
if (success) {
return true;
} else {
return false;
}
}
///获取宴会定金
... ... @@ -264,7 +361,13 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
/// 根据ID获取宴会套餐
Future<bool> _getSetmeal({bool isShowLoading = true}) async {
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
bool success =
await feastModel.getSetmeal(context, isShowLoading: isShowLoading);
if (success) {
return true;
} else {
return false;
}
// if (success) {
// for ( item in feastModel.setmealData.) {
... ... @@ -1031,7 +1134,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
// map['edate'] = _getEdate(element, element.dateTimext);
List tids = [];
for (Tids item in element.tids) {
Map mapTids = {'tid': item.tid, 'num': item.numStr};
Map mapTids = {'tid': item.tid, 'num': item.tableNumC.text};
tids.add(mapTids);
}
map['tids'] = tids; //桌位数据
... ... @@ -1111,7 +1214,7 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
// }
// 备注
// if (element.customCxt.text != null) {
map['remark'] = element.remark; //备注数据
map['remark'] = element.customCxt.text; //备注数据
// }
// 图片
List imageQiniuUrlList = []; //接口图片数据list
... ... @@ -1544,9 +1647,6 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
int.parse(item
.tableNumC.text);
}
xuantaiData[xuantaiSelIndex]
.tids[index]
.numStr = value;
setState(() {});
},
... ... @@ -4178,24 +4278,23 @@ class _FeastCreatePageState extends State<FeastCreatePage> {
}
_setData() async {
_setBanquetInfoPrice();
// await Future.wait<bool>(
// [_setBanquetContract(), _setInvoice(), _setBanquetInfoPrice()])
// .then((results) {
// print(results[0]);
// if (results[0] && results[1] && results[2]) {
// //成功
// Utils.showToast('保存成功');
// } else {
// if (!results[0]) {
// // Utils.showToast('');
// } else {
// // Utils.showToast('');
// }
// }
// }).catchError((e) {
// print(e);
// });
await Future.wait<bool>(
[_setBanquetContract(), _setInvoice(), _setBanquetInfoPrice()])
.then((results) {
print(results[0]);
if (results[0] && results[1] && results[2]) {
//成功
Utils.showToast('保存成功');
} else {
if (!results[0]) {
// Utils.showToast('');
} else {
// Utils.showToast('');
}
}
}).catchError((e) {
print(e);
});
}
Widget taocanTextType(String per1, String title, String per) {
... ...
... ... @@ -539,7 +539,7 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
feastModel.banquetDetail.costInfo[index];
return Padding(
padding: EdgeInsets.only(
left: w(12), right: w(12), bottom: w(27)),
left: w(12), right: w(12), bottom: w(17)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ... @@ -575,6 +575,8 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
costInfoSunModel.price.toString(),
);
}),
costItem('服务费', '', '', '${costInfoModel.showService}',
isTitle: false),
//服务费
Container(
height: h(32),
... ... @@ -585,146 +587,26 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
width: w(1),
color: MyColours.color_DBDBDB))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: w(80),
child: Text(
'服务费:',
'合计',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
color: MyColours.color_999999,
fontSize: font(14)),
),
),
InkWell(
onTap: () {
if (costInfoModel.service) {
return;
}
setState(() {
costInfoModel.service =
!costInfoModel.service;
});
if (costInfoModel.serviceC.text != '') {
// _calculatePrice(
// costInfoModel,
// );
}
},
child: Row(
children: [
Image.asset(
Utils.getImgPath(costInfoModel.service
? 'f_radio_sel'
: 'f_radio_un'),
width: w(20),
),
HEmptyView(8),
Text(
'固定金额',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
),
],
),
),
HEmptyView(16),
InkWell(
onTap: () {
if (!costInfoModel.service) {
return;
}
setState(() {
costInfoModel.service =
!costInfoModel.service;
});
if (costInfoModel.serviceC.text != '') {
// _calculatePrice(
// costInfoModel,
// );
}
},
child: Row(
children: [
Image.asset(
Utils.getImgPath(!costInfoModel.service
? 'f_radio_sel'
: 'f_radio_un'),
width: w(20),
),
HEmptyView(8),
Container(
width: w(40),
child: Text(
'百分比',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
)),
],
Padding(
padding: EdgeInsets.only(right: w(24)),
child: Text(
costInfoModel.showTotalWithService,
style: TextStyle(
color: MyColours.color_999999,
fontSize: font(14)),
),
),
HEmptyView(12),
Expanded(
child: Container(
height: h(17),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color:
MyColours.color_DBDBDB))),
child: TextField(
maxLines: 1,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_515151),
controller: costInfoModel.serviceC,
// focusNode: node,
// textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(
hintText: '请输入',
hintStyle: TextStyle(
color: true
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(24),
),
// contentPadding:
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
// border: InputBorder.none,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderSide: BorderSide.none),
),
onChanged: (value) {
print('ggg');
// _calculatePrice(
// costInfoModel,
// );
// nameStr = value;
},
onEditingComplete: () {
// print('fff');
// node.unfocus();
// _homeEnterModel.nameController.text =
// nameStr + _nameSuffix();
// _addNameSuffix(nameStr, sexStr);
},
keyboardType: TextInputType
.numberWithOptions())),
),
HEmptyView(4),
Text(
costInfoModel.service ? '元' : '%',
style: TextStyle(
color: MyColours.color_000000,
fontSize: font(12)),
),
],
)),
//优惠金额
... ... @@ -737,145 +619,31 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
width: w(1),
color: MyColours.color_DBDBDB))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: w(80),
child: Text(
'优惠金额:',
'优惠金额',
style: TextStyle(
color: MyColours.color_E34D59,
fontSize: font(12)),
fontSize: font(14)),
),
),
InkWell(
onTap: () {
if (costInfoModel.discount) {
return;
}
setState(() {
costInfoModel.discount =
!costInfoModel.discount;
});
if (costInfoModel.discountC.text != '') {
// _calculatePrice(
// costInfoModel,
// );
}
},
child: Row(children: [
Image.asset(
Utils.getImgPath(costInfoModel.discount
? 'f_radio_sel'
: 'f_radio_un'),
width: w(20),
),
HEmptyView(8),
Text(
'固定金额',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
),
])),
HEmptyView(16),
InkWell(
onTap: () {
if (!costInfoModel.discount) {
return;
}
setState(() {
costInfoModel.discount =
!costInfoModel.discount;
});
if (costInfoModel.discountC.text != '') {
// _calculatePrice(
// costInfoModel,
// );
}
},
child: Row(children: [
Image.asset(
Utils.getImgPath(!costInfoModel.discount
? 'f_radio_sel'
: 'f_radio_un'),
width: w(20),
),
HEmptyView(8),
Container(
width: w(40),
child: Text(
'折扣',
style: TextStyle(
color: MyColours.color_515151,
fontSize: font(12)),
))
])),
HEmptyView(12),
Expanded(
child: Container(
height: h(17),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: w(1),
color:
MyColours.color_DBDBDB))),
child: TextField(
maxLines: 1,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_515151),
controller: costInfoModel.discountC,
// focusNode: node,
// textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(
hintText: '请输入',
hintStyle: TextStyle(
color: true
? MyColours.color_999999
: MyColours.color_E34D59,
fontSize: ScreenUtil().setSp(24),
),
// contentPadding:
// EdgeInsets.only(bottom: ScreenUtil().setWidth(17)),
// border: InputBorder.none,
contentPadding: EdgeInsets.zero,
border: OutlineInputBorder(
borderSide: BorderSide.none),
),
onChanged: (value) {
print('ggg');
// _calculatePrice(
// costInfoModel,
// );
// nameStr = value;
},
onEditingComplete: () {
// print('fff');
// node.unfocus();
// _homeEnterModel.nameController.text =
// nameStr + _nameSuffix();
// _addNameSuffix(nameStr, sexStr);
},
keyboardType: TextInputType
.numberWithOptions())),
),
HEmptyView(4),
Text(
costInfoModel.discount ? '元' : '%',
style: TextStyle(
color: MyColours.color_000000,
fontSize: font(12)),
Padding(
padding: EdgeInsets.only(right: w(24)),
child: Text(
costInfoModel.showDiscount,
style: TextStyle(
color: MyColours.color_E34D59,
fontSize: font(14)),
),
),
],
)),
//合计
Container(
height: h(24),
height: h(32),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
... ... @@ -883,10 +651,9 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
color: MyColours.color_DBDBDB))),
child: Row(children: [
Text(
'合计',
'优惠后合计',
style: TextStyle(
color: MyColours.color_515151,
fontWeight: FontWeight.bold,
fontSize: font(14)),
),
Spacer(),
... ... @@ -894,7 +661,6 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
'${costInfoModel.totalPrice} 元',
style: TextStyle(
color: MyColours.color_515151,
fontWeight: FontWeight.bold,
fontSize: font(14)),
),
HEmptyView(48)
... ... @@ -902,6 +668,33 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
],
));
}),
Container(
// height: h(22),
padding: EdgeInsets.only(bottom: h(5)),
margin: EdgeInsets.only(bottom: h(13), left: w(12), right: w(12)),
decoration: BoxDecoration(
// color: Colors.red,
border: Border(
bottom: BorderSide(
width: w(1), color: MyColours.color_DBDBDB))),
child: Row(children: [
Text(
'最终议价合计',
style: TextStyle(
color: MyColours.color_515151,
fontWeight: FontWeight.bold,
fontSize: font(16)),
),
Spacer(),
Text(
'${feastModel.banquetDetail.contractInfo.contractFinalPrice} 元',
style: TextStyle(
color: MyColours.color_515151,
fontWeight: FontWeight.bold,
fontSize: font(16)),
),
HEmptyView(48)
]))
]));
}
... ... @@ -1022,7 +815,7 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
VEmptyView(16),
Padding(
padding: EdgeInsets.only(
left: w(12), right: w(12), top: w(11), bottom: w(35)),
left: w(12), right: w(12), top: w(8), bottom: w(35)),
child: Column(
children: [
feastModel.banquetDetail.invoice == null ||
... ... @@ -1065,6 +858,21 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
),
],
),
RoundButton(
text: '查看发票',
radius: r(7),
width: w(48),
height: h(18),
fontSize: 20,
textColor: MyColours.color_F6F6F6,
isBold: false,
gradientStart: MyColours.color_438E93,
gradientEnd: MyColours.color_438E93,
onPressed: () {
NavigatorUtil.goFeastInvoiceDetailPage(context,
invoice: feastModel.banquetDetail.invoice);
},
),
// InkWell(
// onTap: () {
// //弹框确认是否删除
... ... @@ -1165,6 +973,8 @@ class _FeastDetailPageState extends State<FeastDetailPage> {
Expanded(
child: _callButton(
onPress: () async {
NavigatorUtil.goFeastCreatePage(context,
banquetDetail: feastModel.banquetDetail);
// selectMenu = '签约';
// menuSet.add('定金');
// menuSet.add('签约');
... ...
import 'dart:convert';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/Picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/get_banquet_by_id_new_model.dart';
import 'package:one_key/provider/feast_model.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../res/colors.dart';
import '../../utils/dialog_util.dart';
import '../../utils/event_bus.dart';
import '../../utils/screen_util.dart';
import '../../utils/utils.dart';
import '../../widgets/h_empty_view.dart';
import '../../widgets/system_app_bar.dart';
/**
* 查看发票
*/
class FeastInvoiceDetailPage extends StatefulWidget {
final Invoice invoice;
FeastInvoiceDetailPage({Key key, this.invoice}) : super(key: key);
@override
_FeastInvoiceDetailPageState createState() => _FeastInvoiceDetailPageState();
}
class _FeastInvoiceDetailPageState extends State<FeastInvoiceDetailPage> {
bool type = true; //默认--增值税普通发票
TextEditingController priceC = TextEditingController(); //开票金额
TextEditingController unitNameC = TextEditingController(); //单位全称
TextEditingController numC = TextEditingController(); //税号
TextEditingController addressC = TextEditingController(); //地址
TextEditingController phoneC = TextEditingController(); //电话
TextEditingController bankC = TextEditingController(); //开户行
TextEditingController bankNumC = TextEditingController(); //开户行账号
TextEditingController mailC = TextEditingController(); //邮箱
TextEditingController addresseeC = TextEditingController(); //收件人
TextEditingController addresseePhoneC = TextEditingController(); //收件人电话
TextEditingController addresseeAddressC = TextEditingController(); // 收件人地址
TextEditingController codeC = TextEditingController(); //邮编
FeastModel feastModel;
@override
void initState() {
// TODO: implement initState
super.initState();
Utils.changeStatusColor(color: MyColours.color_438E93);
if (widget.invoice != null) {
type = widget.invoice.invoiceType == '1' ? true : false; //默认--增值税普通发票
priceC.text = widget.invoice.price; // 开票金额
unitNameC.text = widget.invoice.unitName;
numC.text = widget.invoice.numStr;
addressC.text = widget.invoice.address;
phoneC.text = widget.invoice.phone;
bankC.text = widget.invoice.bank;
bankNumC.text = widget.invoice.bankNum;
mailC.text = widget.invoice.mail;
addresseeC.text = widget.invoice.addressee;
addresseePhoneC.text = widget.invoice.addresseePhone;
addresseeAddressC.text = widget.invoice.addresseeAddress;
codeC.text = widget.invoice.code;
}
WidgetsBinding.instance.addPostFrameCallback((_) {});
}
///请输入
///输入框
Widget _textfield(
String title,
TextEditingController editingController,
// FocusNode focusNode,
String subTitle,
{TextInputType inputType = TextInputType.text,
bool need = false}) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: w(92),
child: RichText(
textScaleFactor: 1,
overflow: TextOverflow.ellipsis,
// textDirection: TextDirection.ltr,
text: TextSpan(
children: [
TextSpan(
text: title,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(28)),
recognizer: TapGestureRecognizer()..onTap = () {}),
// TextSpan(
// text: need ? '*' : '',
// style: TextStyle(
// color: MyColours.color_E34D59,
// fontSize: ScreenUtil().setSp(28)),
// //点击事件
// recognizer: TapGestureRecognizer()..onTap = () {}),
],
))),
HEmptyView(48),
Expanded(
child: Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: h(1), color: MyColours.color_DBDBDB))),
child: Row(
children: [
Expanded(
child: Container(
// height: ScreenUtil().setHeight(120),
height: ScreenUtil().setWidth(64),
child: TextField(
enabled: false,
controller: editingController,
// textAlign: TextAlign.right,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
inputFormatters: [],
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_999999),
// focusNode: focusNode,
decoration: InputDecoration(
border:
OutlineInputBorder(borderSide: BorderSide.none),
hintText: '',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(28),
),
contentPadding: EdgeInsets.zero,
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: inputType,
)),
),
Container(
child: Text(
subTitle,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(28)),
),
),
],
),
))
],
),
);
}
///请选择
Widget _selectWidget(String title, String labelShow,
{GestureTapCallback onTap, bool need = true}) {
return InkWell(
onTap: onTap,
// () {
// FocusScope.of(context).requestFocus(FocusNode()); //隐藏键盘
// DialogUtil.showSelectCusmanDialog(
// context,
// customerProvider.labelList.map((item) {
// return item.label;
// }).toList(), (value) {
// if (value != null) {
// setState(() {
// customerProvider.labelSelIndex =
// value.first;
// labelShow = customerProvider
// .labelList[
// customerProvider.labelSelIndex]
// .label;
// });
// }
// },
// selecteds:
// customerProvider.labelSelIndex == null
// ? []
// : [
// customerProvider.labelSelIndex
// ])
// .then((value) {});
// },
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
// color: Colors.red,
width: ScreenUtil().setWidth(160),
height: ScreenUtil().setWidth(35),
child: Text(
title,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_515151),
),
),
HEmptyView(60),
Expanded(
child: Container(
height: ScreenUtil().setWidth(64),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: ScreenUtil().setWidth(2),
color: Color.fromRGBO(220, 220, 220, 1)))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
labelShow,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: labelShow == '请选择'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(28),
),
)),
HEmptyView(10),
Image.asset(
Utils.getImgPath('f_arrow_down'),
width: ScreenUtil().setWidth(64),
// height: ScreenUtil().setWidth(10),
),
HEmptyView(16),
],
))),
],
),
);
}
Widget _callButton(
{GestureTapCallback onPress,
content,
hasLeftBorder = true,
isSelect = false}) {
return InkWell(
onTap: onPress,
child: Container(
height: h(48),
decoration: BoxDecoration(
color: isSelect ? MyColours.color_438E93 : MyColours.color_ffffff,
border: Border(
bottom: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
top: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)),
left: hasLeftBorder
? BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2))
: BorderSide.none,
right: BorderSide(
color: MyColours.color_438E93,
width: ScreenUtil().setWidth(2)))),
child: Align(
alignment: Alignment.center,
child: Text(
content,
style: TextStyle(
color:
isSelect ? MyColours.color_F6F6F6 : MyColours.color_438E93,
fontSize: ScreenUtil().setSp(36)),
),
),
),
);
}
///单选按钮
Widget radioBtn(
String title,
bool select,
GestureTapCallback onTap,
) {
return InkWell(
onTap: onTap,
child: Row(
children: [
Image.asset(
Utils.getImgPath(select ? 'f_select_black' : 'f_select_not'),
width: w(24),
),
HEmptyView(16),
Text(
title,
style: TextStyle(
color:
select ? MyColours.color_515151 : MyColours.color_BFC4D4,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
],
));
}
@override
Widget build(BuildContext context) {
feastModel = Provider.of<FeastModel>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'添加发票',
needWhite: true,
bgColor: MyColours.color_438E93,
titleColor: MyColours.color_F6F6F6,
onTap: () {
Navigator.pop(context);
},
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(left: w(30), right: w(13)),
child: Column(
children: [
VEmptyView(68),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
radioBtn('增值税普通发票', type, () {
// if (type) {
// return;
// }
// setState(() {
// type = !type;
// });
}),
radioBtn('增值税专用发票', !type, () {
// if (!type) {
// return;
// }
// setState(() {
// type = !type;
// });
}),
],
),
VEmptyView(80),
_textfield('开票金额', priceC, '元', need: true),
VEmptyView(40),
_textfield('单位全称', unitNameC, '', need: true),
VEmptyView(40),
_textfield('纳税人识别号', numC, '', need: true),
VEmptyView(40),
_textfield('注册地址', addressC, '', need: !type),
VEmptyView(40),
_textfield('注册电话', phoneC, '', need: !type),
VEmptyView(40),
_textfield('开户银行', bankC, '', need: !type),
VEmptyView(40),
_textfield('银行账号', bankNumC, '', need: !type),
VEmptyView(40),
_textfield('电子邮箱', mailC, ''),
VEmptyView(40),
_textfield('收件人', addresseeC, ''),
VEmptyView(40),
_textfield('收件人电话', addresseePhoneC, ''),
VEmptyView(40),
_textfield('收件地址', addresseeAddressC, ''),
VEmptyView(40),
_textfield('邮编', codeC, ''),
VEmptyView(40),
],
)),
)
// Row(
// children: [
// Expanded(
// child: _callButton(
// onPress: () {
// Navigator.pop(context);
// },
// content: '返回',
// hasLeftBorder: true,
// isSelect: false)),
// Expanded(
// child: _callButton(
// onPress: () async {
// if (priceC.text.trim().length == 0) {
// Utils.showToast('请输入开票金额');
// return;
// }
// if (unitNameC.text.trim().length == 0) {
// Utils.showToast('请输入单位全称');
// return;
// }
// if (numC.text.trim().length == 0) {
// Utils.showToast('请输入纳税人识别号');
// return;
// }
// if (!type) {
// //专用发票
// if (addressC.text.trim().length == 0) {
// Utils.showToast('请输入注册地址');
// return;
// }
// if (phoneC.text.trim().length == 0) {
// Utils.showToast('请输入注册电话');
// return;
// }
// if (bankC.text.trim().length == 0) {
// Utils.showToast('请输入开户银行');
// return;
// }
// if (bankNumC.text.trim().length == 0) {
// Utils.showToast('请输入银行账号');
// return;
// }
// }
// Map<String, String> map = {
// "invoice_type": type ? '1' : '2',
// "price": priceC.text,
// "unit_name": unitNameC.text,
// "num": numC.text,
// "address": addressC.text,
// "phone": phoneC.text,
// "bank": bankC.text,
// "bank_num": bankNumC.text,
// "mail": mailC.text,
// "addressee": addresseeC.text,
// "addressee_phone": addresseePhoneC.text,
// "addressee_address": addresseeAddressC.text,
// "code": codeC.text
// };
// Navigator.pop(context, {'object': map});
// },
// content: '保存并返回',
// hasLeftBorder: true,
// isSelect: true))
// ],
// )
);
}
}
... ...
... ... @@ -855,7 +855,15 @@ class NavigatorUtil {
///宴会----新建宴会
static Future<dynamic> goFeastCreatePage(BuildContext context,
{replace = false, bool onlyShow = false}) {
{replace = false,
bool onlyShow = false,
GetBanquetByIdNewSunModel banquetDetail}) {
if (banquetDetail != null) {
return _navigateTo(context,
"${Routes.feast_create_page}?banquetDetail=${FluroConvertUtils.object2string(banquetDetail)}",
replace: replace);
}
return _navigateTo(context, "${Routes.feast_create_page}",
replace: replace);
}
... ... @@ -928,7 +936,7 @@ class NavigatorUtil {
"${Routes.feast_invoice_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
replace: replace);
}
return _navigateTo(context, "${Routes.feast_invoice_page}?",
return _navigateTo(context, "${Routes.feast_invoice_page}",
replace: replace);
}
... ... @@ -1081,4 +1089,16 @@ class NavigatorUtil {
return _navigateTo(context, "${Routes.feast_detail_page}?rid=$rid",
replace: replace);
}
///宴会----发票详情
static Future<dynamic> goFeastInvoiceDetailPage(BuildContext context,
{replace = false, bool onlyShow = false, Invoice invoice}) {
if (invoice != null) {
return _navigateTo(context,
"${Routes.feast_invoice_detail_page}?invoice=${FluroConvertUtils.object2string(invoice)}",
replace: replace);
}
return _navigateTo(context, "${Routes.feast_invoice_detail_page}",
replace: replace);
}
}
... ...
... ... @@ -157,6 +157,7 @@ import '../pages/feast/feast_deposit_data_page.dart';
import '../pages/feast/feast_deposit_page.dart';
import '../pages/feast/feast_detail_page.dart';
import '../pages/feast/feast_followup_page.dart';
import '../pages/feast/feast_invoice_detail_page.dart';
import '../pages/feast/feast_invoice_page.dart';
import '../pages/feast/feast_menu_page.dart';
import '../pages/feast/feast_menu_show_page.dart';
... ... @@ -1366,9 +1367,14 @@ var feastCreatePageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// String uids = params["uids"].first;
// bool onlyShow = FluroConvertUtils.string2bool(params["onlyShow"].first);
GetBanquetByIdNewSunModel banquetDetail;
if (params.keys.contains('banquetDetail')) {
banquetDetail = GetBanquetByIdNewSunModel.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(params["banquetDetail"].first)));
}
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(), child: FeastCreatePage());
create: (_) => FeastModel(),
child: FeastCreatePage(banquetDetail: banquetDetail));
});
///宴会----添加定金
... ... @@ -1739,7 +1745,6 @@ var feastQYMenuPageHandle = new Handler(
///宴会----详情
var feastDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
String rid = params["rid"].first;
return ChangeNotifierProvider<FeastModel>(
... ... @@ -1748,3 +1753,16 @@ var feastDetailPageHandle = new Handler(
rid: rid,
));
});
///宴会----发票详情
var feastInvoiceDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
Invoice invoice;
if (params.keys.contains('invoice')) {
invoice = Invoice.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(params["invoice"].first)));
}
return ChangeNotifierProvider<FeastModel>(
create: (_) => FeastModel(),
child: FeastInvoiceDetailPage(invoice: invoice));
});
... ...
... ... @@ -155,6 +155,9 @@ class Routes {
"/feast_qy_menu_show_page"; //宴会-----新建宴会---签约菜单信息
static String feast_detail_page = "/feast_detail_page"; //宴会-----详情
static String feast_invoice_detail_page = "/feast_invoice_detail_page"; //宴会-----发票详情
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
... ... @@ -310,5 +313,9 @@ class Routes {
router.define(feast_qy_menu_show_page, handler: feastQYMenuPageHandle);
router.define(feast_detail_page, handler: feastDetailPageHandle);
router.define(feast_invoice_detail_page, handler: feastInvoiceDetailPageHandle);
}
}
... ...
class ConvertNumberToChineseMoneyWords{
class ConvertNumberToChineseMoneyWords {
// 大写数字
static List<String> NUMBERS = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十",""];
static List<String> NUMBERS = [
"一",
"二",
"三",
"四",
"五",
"六",
"七",
"八",
"九",
"十",
""
];
static String toChinese(int index) {
if(index > 100){
if (index > 100) {
return index.toString();
}
StringBuffer stringBuffer = StringBuffer();
if(index / 10 < 1){
if (index / 10 < 1) {
return NUMBERS[index];
}
int tenUnit = (index / 10).toInt();
int remainder = index % 10;
if(remainder == 9){
if (remainder == 9) {
tenUnit++;
remainder = 10;
}
if(tenUnit == 1){
stringBuffer..write("十")..write(NUMBERS[remainder]);
if (tenUnit == 1) {
stringBuffer
..write("十")
..write(NUMBERS[remainder]);
return stringBuffer.toString();
}
stringBuffer..write(NUMBERS[tenUnit - 1])..write("十")..write(NUMBERS[remainder]);
stringBuffer
..write(NUMBERS[tenUnit - 1])
..write("十")
..write(NUMBERS[remainder]);
return stringBuffer.toString();
}
static int toInt(String index) {
switch (index) {
case '一':
return 0;
break;
case '二':
return 1;
break;
case '三':
return 2;
break;
case '四':
return 3;
break;
case '五':
return 4;
break;
case '六':
return 5;
break;
case '七':
return 6;
break;
case '八':
return 7;
break;
case '九':
return 8;
break;
case '十':
return 9;
break;
case '十一':
return 10;
break;
default:
}
}
}
... ...