| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:city_pickers/city_pickers.dart';
- import 'package:flutter_picker/flutter_picker.dart';
- import 'dart:async';
- import 'send_express_page/order_detail_page.dart';
- import '../util/util.dart';
- import '../util/api.dart';
- import '../util/models.dart';
- import '../showAlert.dart';
- import '../send_Dialog.dart';
- import '../util/session.dart';
- import '../showLineModal.dart';
- import '../util/bluetooth_utils.dart';
- class SendExpressPage extends StatefulWidget {
- final Widget child;
- SendExpressPage({
- Key key,
- this.child
- }): super(key: key);
- _SendExpressPageState createState() => _SendExpressPageState();
- }
- class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
- ScrollController _scrollController = ScrollController();
- //组件自用字段-----------------------------
- GlobalKey _sendPhoneKey = GlobalKey();
- GlobalKey _getPhoneKey = GlobalKey();
- GlobalKey _sendCompanyCodeKey = GlobalKey();
- GlobalKey _sendCompanyNameKey = GlobalKey();
- GlobalKey _getCompanyNameKey = GlobalKey();
- GlobalKey _goodsKey = GlobalKey();
- double tipWidth = 0;
- double tipHeight = 0;
- double tipPosX = 0;
- double tipPosY = 0;
- bool tipStatus = true;//是否展示公司信息匹配列表,true为不展示
- bool goodsTipStatus = true;//是否展示货物匹配列表,true为不展示
- bool lineModalStatus = false;
- bool submitStatus = true;
- bool checkedLine = false;//当收件方有多条线路时,此状态表示是否已经选择过线路了
- bool checkedGoodsName1 = false;//有没有选择货物
- String stationId;//司机端站点id
- List < LikePhoneList > likePhoneList = [];
- List <GoodsPriceList> goodsPriceList = [];
- var timer;
- bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
- TextEditingController sendCompanyPhoneController = TextEditingController();
- TextEditingController sendCompanyCodeController = TextEditingController();
- TextEditingController sendCompanyNameController = TextEditingController();
- TextEditingController receiptCompanyPhoneController = TextEditingController();
- TextEditingController receiptCompanyNameController = TextEditingController();
- TextEditingController sendCompanyAddressController = TextEditingController();
- TextEditingController receiptCompanyAddressController = TextEditingController();
- TextEditingController bankCardController = TextEditingController();
- TextEditingController bankNameController = TextEditingController();
- TextEditingController openBankNameController = TextEditingController();
- TextEditingController openBankPhoneController = TextEditingController();
- TextEditingController goodsController = TextEditingController();
- TextEditingController goodsQuantityController = TextEditingController();
- TextEditingController goodsFreightController = TextEditingController();
- TextEditingController goodsAgencyFundController = TextEditingController();
- TextEditingController goodsPriceProtectionController = TextEditingController();
- TextEditingController goodsWeightController = TextEditingController();
- TextEditingController memoController = TextEditingController();
- FocusNode bankCardFocusNode = FocusNode();
- List < dynamic > goodsCateGoryList = [];
- List < dynamic > goodsPackageList = [];
- //请求字段-------------------------
- String lineId = '-1';//收件公司匹配的线路id
- String sendCompanyId = '0'; //寄件公司Id
- String sendCompanyName = ''; //寄件公司名称 不能为空
- String sendCompanyPhone = ''; //寄件公司电话 不能为空
- String sendCompanyCode = ''; //寄件公司编码
- String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
- String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
- String sendCompanyCityName = ''; //寄件公司市名称 不能为空
- String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
- String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
- String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
- String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
- String receiptCompanyId = '0'; //收件公司id
- String receiptCompanyPhone = ''; //收件公司电话 不能为空
- String receiptCompanyName = ''; //收件公司名称 不能为空
- String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
- String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
- String receiptCompanyCityName = ''; //收件公司市名称 不能为空
- String receiptCompanyCityCode = ''; //收件公市编码 不能为空
- String receiptCompanyAreaName = ''; //收件公区名称 不能为空
- String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
- String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
- String goods = ''; //商品名称 不能为空
- int goodsQuantity = 1; //商品数量 不能为空
- int goodsPackingId; //商品包装ID
- int goodsCategoryId; //商品类别ID
- int goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
- double goodsWeight = 0.0; //商品重量
- double goodsPriceProtection = 0.0; //商品保价
- double goodsAgencyFund = 0.0; //商品代收款
- double goodsFreight = 0.0; //商品运费 不能为空
- String memo = ''; //备注
- String bankCard = '';//银行卡号
- String bankName = '';//所属银行
- String openBankName = '';//开户人
- String openBankPhone = '';//开户电话
- List<CompanyOfLineList> lineList = [];
- String sendPCA = ' '; //Text组件内容必须有空格,否则报null
- String getPCA = ' ';
- String showTextGoodsCategory = ' ';
- String showTextGoodsPackage = ' ';
- String showTextPaymentMehod = '到付';
- BluetoothUtils bluetooth = BluetoothUtils();
-
- bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
- bool checkedGoodsName = false;//选择货物名称填充时不匹配
- String likeWord ='';//以什么为匹配的字段用户控制高亮_tipsItem中的哪一个字段
- @override
- void initState() {
- super.initState();
- goodsCategory().then((resp) {//获取商品类型
- if (isNotError(context, resp) && this.mounted) {
- GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
- setState(() {
- goodsCateGoryList = goodsCategoryObj.data;
- showTextGoodsCategory = goodsCateGoryList[0].name;
- goodsCategoryId = goodsCateGoryList[0].id;
- });
- }
- });
- goodsPackage().then((resp) {//获取包装类型
- if (isNotError(context, resp) && this.mounted) {
- GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
- setState(() {
- goodsPackageList = goodsPackageObj.data;
- showTextGoodsPackage = goodsPackageList[0].name;
- goodsPackingId = goodsPackageList[0].id;
- });
- }
- });
- getKey('stationId').then((resp){
- stationId = resp;
- });
- getKey('defaultFreightPrice').then((resp){
- setState(() {
- goodsFreightController.text = (double.parse(resp)/100).toString();
- });
- });
- _scrollController.addListener(() {
- if (!tipStatus) {
- setState(() {
- tipStatus = true;
- });
- }
- if(!goodsTipStatus){
- setState(() {
- goodsTipStatus = true;
- });
- }
- //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
- });
- //发件公司电话监听
- sendCompanyPhoneController.addListener(() {
- if(checkedCompanyInfo){
- return;
- }
- setState(() {
- sendCompanyPhone = sendCompanyPhoneController.text;
-
- });
- if (timer != null) {
- timer.cancel();
- }
- if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length <= 11) {
- likePhone(sendCompanyPhoneController.text).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = true;
- RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = sendPhoneObj.paintBounds.size.width;
- tipHeight = sendPhoneObj.paintBounds.size.height;
- tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
- tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- likeWord='phone';
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- //发件公司编码监听
- sendCompanyCodeController.addListener(() {
- if(checkedCompanyInfo){
- return;
- }
- setState(() {
- sendCompanyCode = sendCompanyCodeController.text;
-
- });
- if (timer != null) {
- timer.cancel();
- }
- if (sendCompanyCodeController.text.length < 2 || sendCompanyCodeController.text.length > 6) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (sendCompanyCodeController.text.length >= 2 && sendCompanyCodeController.text.length <= 6) {
- likeCompanyCode(sendCompanyCodeController.text).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = true;
- RenderObject sendPhoneObj = _sendCompanyCodeKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = sendPhoneObj.paintBounds.size.width;
- tipHeight = sendPhoneObj.paintBounds.size.height;
- tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
- tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- likeWord='code';
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- //发件公司名字监听
- sendCompanyNameController.addListener(() {
- if(checkedCompanyInfo){
- return;
- }
- setState(() {
- sendCompanyName = sendCompanyNameController.text;
-
- });
- if (timer != null) {
- timer.cancel();
- }
- if (sendCompanyNameController.text.length < 2 || sendCompanyNameController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (sendCompanyNameController.text.length >= 2 && sendCompanyNameController.text.length <= 11) {
- likeCompanyName(sendCompanyNameController.text).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = true;
- RenderObject sendPhoneObj = _sendCompanyNameKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = sendPhoneObj.paintBounds.size.width;
- tipHeight = sendPhoneObj.paintBounds.size.height;
- tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
- tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- likeWord='name';
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- //收件公司电话监听
- receiptCompanyPhoneController.addListener(() {
- if(checkedCompanyInfo){
- return;
- }
- setState(() {
- receiptCompanyPhone = receiptCompanyPhoneController.text;
- });
-
- if (timer != null) {
- timer.cancel();
- }
- if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length <= 11) {
- likePhone(receiptCompanyPhoneController.text).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = false;
- RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = getPhoneKey.paintBounds.size.width;
- tipHeight = getPhoneKey.paintBounds.size.height;
- tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
- tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- likeWord='phone';
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- //收件公司名称监听
- receiptCompanyNameController.addListener(() {
- if(checkedCompanyInfo){
- return;
- }
- setState(() {
- receiptCompanyName = receiptCompanyNameController.text;
- });
-
- if (timer != null) {
- timer.cancel();
- }
- if (receiptCompanyNameController.text.length < 2 || receiptCompanyNameController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (receiptCompanyNameController.text.length >= 2 && receiptCompanyNameController.text.length <= 11) {
- likeCompanyName(receiptCompanyNameController.text).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = false;
- RenderObject getPhoneKey = _getCompanyNameKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = getPhoneKey.paintBounds.size.width;
- tipHeight = getPhoneKey.paintBounds.size.height;
- tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
- tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- likeWord='name';
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- //货物名称监听
- goodsController.addListener(() {
- if(checkedGoodsName){
- return;
- }
- setState(() {
- goods = goodsController.text;
- });
-
- if (timer != null) {
- timer.cancel();
- }
- if (goodsController.text.length < 1) {
- setState(() {
- goodsTipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 250), () {
- if (goodsController.text.length >= 1) {
- goodsNameLike(stationId,goodsController.text,lineId).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- GoodsPriceObj goodsPriceObj = GoodsPriceObj.fromJson(resp.data);
- goodsPriceList = goodsPriceObj.data;
- }
- if (goodsPriceList.length > 0) {
- RenderObject goodsKey = _goodsKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = goodsKey.paintBounds.size.width;
- tipHeight = goodsKey.paintBounds.size.height;
- tipPosX = goodsKey.getTransformTo(null).getTranslation().x;
- tipPosY = goodsKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- goodsTipStatus = false;
- });
- } else {
- setState(() {
- goodsTipStatus = true;
- });
- }
- });
- }
- });
- });
- sendCompanyAddressController.addListener(() {
- setState(() {
- sendCompanyAddress = sendCompanyAddressController.text;
- });
- });
- receiptCompanyAddressController.addListener(() {
- setState(() {
- receiptCompanyAddress = receiptCompanyAddressController.text;
- });
- });
- bankCardFocusNode.addListener((){
- if(!bankCardFocusNode.hasFocus){
- if(bankCardController.text!=''){
- getBankName(bankCardController.text).then((resp){
- if(isNotError(context, resp) && this.mounted){
- BankNameObj obj = BankNameObj.fromJson(resp.data);
- setState(() {
- bankNameController.text = obj.data;
- });
- }
- });
- }
- }
- });
- }
- @override
- bool get wantKeepAlive => true;
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Scaffold(
- appBar: AppBar(
- title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- ),
- body:
- Stack(
- children: < Widget > [
- Container(
- color: Color.fromRGBO(246, 246, 254, 1),
- padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
- child: ListView(
- controller: _scrollController,
- children: < Widget > [
- _sendInfo(context),
- _getInfo(context),
- _itemInfoWidget(),
- _bankInfo(context),
- _submitBtn()
- ],
- ),
- ),
- Positioned(
- top: tipPosY,
- left: tipPosX,
- child: Offstage(
- offstage: tipStatus,
- child: Container(
- width: tipWidth,
- height: ScreenUtil.getInstance().setHeight(450),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- decoration: BoxDecoration(
- color: Color.fromRGBO(244, 248, 251, 1),
- ),
- child: ListView.builder(
- itemCount: likePhoneList.length,
- itemBuilder: (BuildContext context, int index) {
- return _tipItem(likePhoneList[index]);
- },
- )
- ),
- )
- ),
- Positioned(
- top: tipPosY,
- left: tipPosX,
- child: Offstage(
- offstage: goodsTipStatus,
- child: Container(
- width: tipWidth,
- height: ScreenUtil.getInstance().setHeight(450),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- decoration: BoxDecoration(
- color: Color.fromRGBO(244, 248, 251, 1),
- ),
- child: ListView.builder(
- itemCount: goodsPriceList.length,
- itemBuilder: (BuildContext context, int index) {
- return _goodsTipItem(goodsPriceList[index]);
- },
- )
- ),
- )
- )
- ],
- ),
- resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
- ),
- );
- }
- Widget _sendInfo(BuildContext context) {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- _titleWidget('lib/images/icon_send.png', '发件信息'),
- _underLine(),
- _inputWiget('send_phone','发件电话', _sendPhoneKey,sendCompanyPhoneController),
- _inputWiget('send_code','企业编码', _sendCompanyCodeKey, sendCompanyCodeController,true),
- _inputWiget('send_name','企业名称', _sendCompanyNameKey, sendCompanyNameController,true),
- _cityWiget('城市/区域', context, 'send'),
- _lastContentWiget('详细地址', 'send')
- ],
- )
- );
- }
- Widget _getInfo(BuildContext context) {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
- _underLine(),
- _inputWiget('get_phone','收件电话', _getPhoneKey,receiptCompanyPhoneController),
- _inputWiget('get_name','企业名称', _getCompanyNameKey,receiptCompanyNameController ,true),
- _cityWiget('城市/区域', context, 'get'),
- _lastContentWiget('详细地址', 'get')
- ],
- )
- );
- }
- Widget _itemInfoWidget() {
- return Container(
- child: Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: < Widget > [
- _titleWidget('lib/images/icon_huowu.png', "货物信息"),
- _underLine(),
- _itemContentWiget("货物名称", goodsController, true),
- _itemContentWiget("数量", goodsQuantityController),
- _itemContentWiget("运费", goodsFreightController),
- _itemContentWiget("代收", goodsAgencyFundController),
- _itemContentWiget("保价", goodsPriceProtectionController),
- _itemContentWiget("重量", goodsWeightController),
- _packageType('包装类型'),
- _packageType('货物类型'),
- _packageType('付款方式'),
- _descWidget()
- ],
- ),
- )
- );
- }
- Widget _bankInfo(BuildContext context) {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- _titleWidget('lib/images/icon_bank.png', '银行信息'),
- _underLine(),
- _contentBankWiget('银行卡号', 'bank'),
- _contentBankWiget('银行名称', 'bank',true),
- _contentBankWiget('开户人', 'bank',true),
- _lastBankContentWiget('开户电话', 'bank'),
- ],
- )
- );
- }
- Widget _titleWidget(String iconUrl, String str) {
- return Container(
- height: ScreenUtil.getInstance().setHeight(90),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
- child: Image.asset(
- iconUrl,
- width: ScreenUtil.getInstance().setWidth(40),
- height: ScreenUtil.getInstance().setHeight(40),
- )
- ),
- Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
- ],
- ),
- ),
- );
- }
- Widget _underLine() {
- return Container(
- color: Color.fromRGBO(223, 223, 223, 1),
- height: ScreenUtil.getInstance().setHeight(1),
- );
- }
- Widget _inputWiget(String key,String title GlobalKey tab,TextEditingController tab1,[bool keyboardType = false]) {
- return Padding(
- key: tab,
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(title, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child: TextField(
- controller: tab1,
- keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- onEditingComplete: () {
- setState(() {
- FocusScope.of(context).requestFocus(FocusNode());
- tipStatus = true;
- });
- },
- onChanged: (value){
- checkedCompanyInfo = false;
- if(key=='send_phone'){
- sendCompanyCode = '';
- sendCompanyName = '';
- sendCompanyId ='0';
- sendCompanyCodeController.text = '';
- sendCompanyNameController.text = '';
- sendPCA = '';
- sendCompanyProvinceName = '';
- sendCompanyProvinceCode = '';
- sendCompanyCityName = '';
- sendCompanyCityCode = '';
- sendCompanyAreaName = '';
- sendCompanyAreaCode = '';
- bankCardController.text = '';
- bankNameController.text = '';
- openBankNameController.text = '';
- openBankPhoneController.text = '';
- sendCompanyAddressController.text = '';
- }else if(key=='get_phone'){
- receiptCompanyName = '';
- receiptCompanyNameController.text = '';
- receiptCompanyId = '0';
-
- getPCA = '';
- receiptCompanyProvinceName = '';
- receiptCompanyProvinceCode = '';
- receiptCompanyCityName = '';
- receiptCompanyCityCode = '';
- receiptCompanyAreaName = '';
- receiptCompanyAreaCode = '';
- receiptCompanyAddressController.text = '';
- }else if(key=='send_code'){
- sendCompanyPhone = '';
- sendCompanyName = '';
- sendCompanyId ='0';
- sendCompanyPhoneController.text = '';
- sendCompanyNameController.text = '';
- sendPCA = '';
- sendCompanyProvinceName = '';
- sendCompanyProvinceCode = '';
- sendCompanyCityName = '';
- sendCompanyCityCode = '';
- sendCompanyAreaName = '';
- sendCompanyAreaCode = '';
- bankCardController.text = '';
- bankNameController.text = '';
- openBankNameController.text = '';
- openBankPhoneController.text = '';
- sendCompanyAddressController.text = '';
- }else if(key=='send_name'){
- sendCompanyCode = '';
- sendCompanyPhone = '';
- sendCompanyId ='0';
- sendCompanyCodeController.text = '';
- sendCompanyPhoneController.text = '';
- sendPCA = '';
- sendCompanyProvinceName = '';
- sendCompanyProvinceCode = '';
- sendCompanyCityName = '';
- sendCompanyCityCode = '';
- sendCompanyAreaName = '';
- sendCompanyAreaCode = '';
- bankCardController.text = '';
- bankNameController.text = '';
- openBankNameController.text = '';
- openBankPhoneController.text = '';
- sendCompanyAddressController.text = '';
- }else if(key=='get_name'){
- receiptCompanyPhone = '';
- receiptCompanyPhoneController.text = '';
- receiptCompanyId = '0';
-
- getPCA = '';
- receiptCompanyProvinceName = '';
- receiptCompanyProvinceCode = '';
- receiptCompanyCityName = '';
- receiptCompanyCityCode = '';
- receiptCompanyAreaName = '';
- receiptCompanyAreaCode = '';
- receiptCompanyAddressController.text = '';
- }
-
- },
- ),
- )
-
- ),
- // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- Widget _itemContentWiget(String key,TextEditingController controller, [bool keyboardType = false]) { //false是数字键盘
- return Padding(
- key: key=='货物名称'?_goodsKey:null,
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child:TextField(
- controller: controller,
- keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- onChanged: (value) {
- if (key == '货物名称') {
- goods = value;
- } else if (key == '数量') {
- goodsQuantity = int.parse(value);
- } else if (key == '运费') {
- goodsFreight = double.parse(value);
- String temp = goodsFreight.toStringAsFixed(1);
- goodsFreight = double.parse(temp);
- } else if (key == '代收') {
- goodsAgencyFund = double.parse(value);
- String temp = goodsAgencyFund.toStringAsFixed(1);
- goodsAgencyFund = double.parse(temp);
- } else if (key == '保价') {
- goodsPriceProtection = double.parse(value);
- String temp = goodsPriceProtection.toStringAsFixed(1);
- goodsPriceProtection = double.parse(temp);
- } else if (key == '重量') {
- goodsWeight = double.parse(value);
- String temp = goodsWeight.toStringAsFixed(1);
- goodsWeight = double.parse(temp);
- }
- },
- ),
- )
-
- ),
- // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
-
- Widget _contentBankWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child:
- Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child:TextField(
- focusNode: key == '银行卡号'?bankCardFocusNode:null,
- controller: key == '银行卡号'?bankCardController:key=='银行名称'?bankNameController:openBankNameController,
- keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- ),
- )
-
- ),
- // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- Widget _cityWiget(String key, BuildContext context, String type) {
- return
- GestureDetector(
- child: Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- ),
- onTap: () {
- getCity(context).then((resp) {
- if (resp == null) {
- return;
- }
- print(resp.toString());
- setState(() {
- if (type == 'send') {
- sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
- sendCompanyProvinceName = resp.provinceName;
- sendCompanyProvinceCode = resp.provinceId;
- sendCompanyCityName = resp.cityName;
- sendCompanyCityCode = resp.cityId;
- sendCompanyAreaName = resp.areaName;
- sendCompanyAreaCode = resp.areaId;
- } else {
- getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
- receiptCompanyProvinceName = resp.provinceName;
- receiptCompanyProvinceCode = resp.provinceId;
- receiptCompanyCityName = resp.cityName;
- receiptCompanyCityCode = resp.cityId;
- receiptCompanyAreaName = resp.areaName;
- receiptCompanyAreaCode = resp.areaId;
- }
- });
- //print(value);
- });
- },
- );
- }
- Widget _lastContentWiget(String key, String type) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child: TextField(
- controller: type == 'send' ? sendCompanyAddressController : receiptCompanyAddressController,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- ),
- )
-
- ),
- // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- )
- );
- }
- Widget _lastBankContentWiget(String key, String type) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
- child: TextField(
- controller: openBankPhoneController,
- textAlign: TextAlign.end,
- keyboardType: TextInputType.number,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- ),
- )
-
- ),
- // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- )
- );
- }
- Widget _descWidget() {
- return
- Container(
- padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
- //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- child: TextField(
- maxLines: 3,
- controller: memoController,
- decoration: InputDecoration(
- border: InputBorder.none,
- hintText: "请输入备注内容"
- ),
- onChanged: (value) {
- setState(() {
- memo = value;
- });
- },
- ),
- );
- }
- Widget _submitBtn() {
- return GestureDetector(
- child: Container(
- margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
- height: ScreenUtil.getInstance().setHeight(88),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(4)),
- color: Color.fromRGBO(37, 102, 242, 1),
- ),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: < Widget > [
- Offstage(
- offstage: submitStatus,
- child: SizedBox(
- width: ScreenUtil.getInstance().setWidth(45),
- height: ScreenUtil.getInstance().setHeight(45),
- child: Image.asset('lib/images/loading.gif'),
- ),
- ),
- Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
- ],
- )
- ),
- ),
- onTap: () {
- if (!submitStatus) {
- return;
- }
- String errStr = '';
- print('sendCompanyId---${sendCompanyId}');
- print('sendCompanyName---${sendCompanyName}');
- print('sendCompanyPhone---${sendCompanyPhone}');
- print('sendCompanyCode---${sendCompanyCode}');
- print('sendCompanyProvinceName---${sendCompanyProvinceName}');
- print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
- print('sendCompanyCityName---${sendCompanyCityName}');
- print('sendCompanyCityCode---${sendCompanyCityCode}');
- print('sendCompanyAreaName---${sendCompanyAreaName}');
- print('sendCompanyAreaCode---${sendCompanyAreaCode}');
- print('sendCompanyAddress---${sendCompanyAddress}');
- print('receiptCompanyId---${receiptCompanyId}');
- print('receiptCompanyPhone---${receiptCompanyPhone}');
- print('receiptCompanyName---${receiptCompanyName}');
- print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
- print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
- print('receiptCompanyCityName---${receiptCompanyCityName}');
- print('receiptCompanyCityCode---${receiptCompanyCityCode}');
- print('receiptCompanyAreaName---${receiptCompanyAreaName}');
- print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
- print('receiptCompanyAddress---${receiptCompanyAddress}');
- print('goods---${goods}');
- print('goodsQuantity---${goodsQuantity}');
- print('goodsPackingId---${goodsPackingId}');
- print('goodsCategoryId---${goodsCategoryId}');
- print('goodsPaymentMethod---${goodsPaymentMethod}');
- print('goodsWeight---${goodsWeight}');
- print('goodsPriceProtection---${goodsPriceProtection}');
- print('goodsAgencyFund---${goodsAgencyFund}');
- print('goodsFreight---${goodsFreight}');
- print('memo---${memo}');
- if (sendCompanyPhone == '') {
- errStr = '请填写发件电话';
- }
- if (sendCompanyName == '') {
- errStr = '请填写发件企业名称';
- }
- if (sendCompanyProvinceName == '') {
- errStr = '请填写发件城市/区域';
- }
- if (sendCompanyAddress == '') {
- errStr = '请填写发件详细地址';
- }
- if (receiptCompanyPhone == '') {
- errStr = '请填写收件电话';
- }
- if (receiptCompanyName == '') {
- errStr = '请填写收件企业名称';
- }
- if (receiptCompanyProvinceName == '') {
- errStr = '请填写收件城市/区域';
- }
- if (receiptCompanyAddress == '') {
- errStr = '请填写收件详细地址';
- }
- // if (goods == '') {
- // errStr = '请填写货物名称';
- // }
- if (goodsQuantity == 0) {
- errStr = '请填写货物数量';
- }
- if (int.tryParse(goodsQuantity.toString()) == null) {
- errStr = '货物数量格式错误';
- }
- if (goodsFreight < 0.0) {
- errStr = '运费输入错误';
- }
- if (sendCompanyPhone == '' || receiptCompanyPhone == '' ) {
- errStr = '请输入正确的电话';
- }
- if (goodsAgencyFund>0) {//如果有代收
- if(bankNameController.text=='' || bankCardController.text=='' || openBankNameController.text=='' || openBankPhoneController.text==''){
- errStr = "请补全银行卡信息";
- }
- }
- if (errStr != '') {
- showError(errStr);
- return;
- }
-
- if(lineList.length>1 && !checkedLine &&!checkedGoodsName1){
- showLineModal(lineList);
- return;
- }
- submitOrder();
- },
- );
- }
- submitOrder(){
- setState(() {
- submitStatus = false;
- });
- getKey('stationId').then((value) {
- createOrder(
- lineId,//收件线路Id
- value,//当前用户选择的站点id
- sendCompanyId, //寄件公司Id
- sendCompanyName, //寄件公司名称 不能为空
- sendCompanyPhone, //寄件公司电话 不能为空
- sendCompanyCode ?? '', //寄件公司编码
- sendCompanyProvinceName, //寄件公司省名称 不能为空
- sendCompanyProvinceCode, //寄件公司省编码 不能为空
- sendCompanyCityName, //寄件公司市名称 不能为空
- sendCompanyCityCode, //寄件公司市编码 不能为空
- sendCompanyAreaName, //寄件公司区名称 不能为空
- sendCompanyAreaCode, //寄件公司区编码 不能为空
- sendCompanyAddress, //寄件公司详细地址,不能为空
- receiptCompanyId, //收件公司id
- receiptCompanyPhone, //收件公司电话 不能为空
- receiptCompanyName, //收件公司名称 不能为空
- receiptCompanyProvinceName, //收件公司省名称 不能为空
- receiptCompanyProvinceCode, //收件公司省编码 不能为空
- receiptCompanyCityName, //收件公司市名称 不能为空
- receiptCompanyCityCode, //收件公市编码 不能为空
- receiptCompanyAreaName, //收件公区名称 不能为空
- receiptCompanyAreaCode, //收件公司区编码 不能为空
- receiptCompanyAddress, //收件公司地址详情 不能为空
- goods, //商品名称 不能为空
- goodsQuantity, //商品数量 不能为空
- goodsPackingId, //商品包装ID
- goodsCategoryId, //商品类别ID
- goodsPaymentMethod, //付款方式 1,现付 2 到付
- goodsWeight, //商品重量
- goodsPriceProtection * 100, //商品保价,已分为单位
- goodsAgencyFund * 100, //商品代收款,已分为单位
- goodsFreight * 100, //商品运费 不能为空 ,已分为单位
- memo, //备注
- bankCardController.text,
- bankNameController.text,
- openBankNameController.text,
- openBankPhoneController.text
- ).then((resp) {
- if (isNotError(context, resp) && this.mounted) {
- setState(() {
- submitStatus = true;
- });
- OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- //打印
- getKey('printType').then((printType){
- getKey('stationName').then((stationName){
- getKey('nickName').then((nickName){
- getKey('companyName').then((companyName){
- getKey('companyCustomerPhone').then((companyCustomerPhone){
- double goodsYs = data.goodsPaymentMethod==2?(data.goodsFreight/100)+(data.goodsAgencyFund/100):data.goodsAgencyFund/100;
- String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
- String createTime = fromatDate(data.createTime);
- double goodsAgencyFunds = data.goodsAgencyFund/100;
- double goodsDFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
- double goodsXFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
- String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
-
- Map<String, String> pum = {
- "[logisticsNo]": "${data.orderNo ?? ''}",
- "[createTime]": "$createTime",
- "[sendStationName]": "$stationName",
- "[dealerCode]": "${data.sendCompanyCode ?? ''}",
- "[dealerName]": "${data.sendCompanyName}",
- "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
- "[repairName]": "${data.receiptCompanyName ?? ''}",
- "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
- "[endStationName]": "${data.receiptStationName ?? ''}",
- "[goodsLineCode]": "${data.lineCode ?? ''}",
- "[goodsLine]": "${data.lineName ?? ''}",
- "[repairAddress]": "${receiptAddress?? ''}",
- "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
- "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
- "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
- // 到付 现付 金额
- "[goodsDFreight]": "$goodsDFreight",
- "[goodsXFreight]": "$goodsXFreight",
- "[goodsAgencyFund]": "$goodsAgencyFunds",
- "[goodsYs]": "$goodsYs",
- "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
- "[goodsRemark]": "${data.memo ?? ''}",
- "[realName]": "${nickName?? ''}",
- "[currentTime]": "$nowDate",
- "[currentGoodNumber]": "1/1",
- "[companyCustomerPhone]":"$companyCustomerPhone",
- "[companyName]":"$companyName"
- };
- bluetooth.printOrder(pum, int.parse(printType)).then((value){
- if(value==null){
- showDialog <Null> (
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog(text: '未连接打印机',childCallback:(val){});
- }
- );
- }
- });
- });
- });
- });
- });
- });
- return SendDialog( //调用对话框
- orderNo: data.orderNo,
- childCallback: (val) {
- if (!val) {
- //跳转
- Navigator.push(context, MaterialPageRoute(builder: (context) {
- return OrderDetail(orderNo: data.orderNo, );
- }));
- }else{
- setState(() {
- //----------------清除信息--------------------
- lineId = '-1';
- sendCompanyCode = '';
- sendCompanyName = '';
- sendCompanyId ='0';
- sendCompanyPhoneController.text= '';
- sendCompanyCodeController.text = '';
- sendCompanyNameController.text = '';
- sendPCA = '';
- sendCompanyProvinceName = '';
- sendCompanyProvinceCode = '';
- sendCompanyCityName = '';
- sendCompanyCityCode = '';
- sendCompanyAreaName = '';
- sendCompanyAreaCode = '';
- bankCardController.text = '';
- bankNameController.text = '';
- openBankNameController.text = '';
- openBankPhoneController.text = '';
- sendCompanyAddressController.text = '';
- receiptCompanyName = '';
- receiptCompanyPhoneController.text= '';
- receiptCompanyNameController.text = '';
- receiptCompanyId = '0';
-
- getPCA = '';
- receiptCompanyProvinceName = '';
- receiptCompanyProvinceCode = '';
- receiptCompanyCityName = '';
- receiptCompanyCityCode = '';
- receiptCompanyAreaName = '';
- receiptCompanyAreaCode = '';
- receiptCompanyAddressController.text = '';
- goods = ''; //商品名称 不能为空
- goodsQuantity = 1; //商品数量 不能为空
- goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
- goodsWeight = 0.0; //商品重量
- goodsPriceProtection = 0.0; //商品保价
- goodsAgencyFund = 0.0; //商品代收款
- goodsFreight = 0.0; //商品运费 不能为空
- memo = ''; //备注
- goodsController.text = '';
- goodsQuantityController.text = '';
- goodsFreightController.text = '';
- goodsAgencyFundController.text = '';
- goodsPriceProtectionController.text = '';
- goodsWeightController.text = '';
- memoController.text = '';
- //---------------------------------------------
- });
- }
- },
- );
- });
- } else {
- setState(() {
- submitStatus = true;
- });
- }
- });
- });
- }
- showError(String str) {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog( //调用对话框
- text: str, childCallback: (val) {},
- );
- });
- }
- showLineModal(List<CompanyOfLineList> list){
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return ShowLineModal(
- lineList: list, childCallback: (val) {
- lineId = val;
- checkedLine = true;
- // goodsNameAccurate(stationId,goodsController.text,lineId).then((resp){
- // if(isNotError(context, resp) && this.mounted){
- // if(resp.data['data']['goods']!=null){
- // GoodsPriceList tempObj = GoodsPriceObjAccurate.fromJson(resp.data).data;
- // setState(() {
- // goods=tempObj.goods;
- // goodsController.text = tempObj.goods;
- // goodsFreight = tempObj.price/100;
- // goodsFreightController.text = (tempObj.price/100).toString();
- // });
- // }
-
- // }
- // });
- },
- );
- });
- }
- Future getCity(context) async {
- Result result = await CityPickers.showCityPicker(
- context: context,
- );
- return result;
- }
- Widget _tipItem(LikePhoneList obj) {
- return Container(
- child: Column(
- children: < Widget > [
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
- child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: likeWord=='phone'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
- ), )
- ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(185),
- child: Text(obj.companyCode,
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: likeWord=='code'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
- ), ),
- ),
- Text(obj.companyName,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: likeWord=='name'?Color.fromRGBO(74, 74, 74, 1):Color.fromRGBO(155, 155, 155, 1)
- ),
- )
- ],
- ),
- ),
- ),
- onTap: () {
- checkedCompanyInfo = true;
- if (sendPhoneOrGetPhoneTab) {
- sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
- sendCompanyCode = obj.companyCode;
- sendCompanyName = obj.companyName;
- sendCompanyId = obj.id.toString();
- sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
- sendCompanyCodeController.text = obj.companyCode;
- sendCompanyNameController.text = obj.companyName;
- sendPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
- sendCompanyProvinceName = obj.provinceName;
- sendCompanyProvinceCode = obj.provinceCode;
- sendCompanyCityName = obj.cityName;
- sendCompanyCityCode = obj.cityCode;
- sendCompanyAreaName = obj.areaName;
- sendCompanyAreaCode = obj.areaCode;
- sendCompanyAddressController.text = obj.address;
- bankCardController.text = obj.bankCard;
- bankNameController.text = obj.bankName;
- openBankNameController.text = obj.openBankName;
- openBankPhoneController.text = obj.openBankPhone;
- } else {
- receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
- receiptCompanyName = obj.companyName;
- receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
- receiptCompanyNameController.text = obj.companyName;
- receiptCompanyId = obj.id.toString();
- getLineOfCompanyId(receiptCompanyId).then((resp){
- if(isNotError(context, resp) && this.mounted){
- CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
- setState(() {
- lineList = obj.data;
- });
- }
- });
- getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
- receiptCompanyProvinceName = obj.provinceName;
- receiptCompanyProvinceCode = obj.provinceCode;
- receiptCompanyCityName = obj.cityName;
- receiptCompanyCityCode = obj.cityCode;
- receiptCompanyAreaName = obj.areaName;
- receiptCompanyAreaCode = obj.areaCode;
- receiptCompanyAddressController.text = obj.address;
- }
- setState(() {
- FocusScope.of(context).requestFocus(FocusNode());
- tipStatus = true;
- });
- },
- ),
- _underLine()
- ],
- ),
- );
- }
- Widget _goodsTipItem(GoodsPriceList obj){
- return Container(
- child: Column(
- children: < Widget > [
- InkWell(
- child: Container(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(250),
- child: Text(obj.goods,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(74, 74, 74, 1)
- ), )
- ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(250),
- child: Text(obj.lineName,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ), ),
- ),
- Text((obj.price/100).toString(),
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ),
- )
- ],
- ),
- ),
- ),
- onTap: () {
- checkedGoodsName = true;
- setState(() {
- FocusScope.of(context).requestFocus(FocusNode());
- goodsTipStatus = true;
- goods = obj.goods;
- goodsController.text = obj.goods;
- goodsFreight = (obj.price/100);
- goodsFreightController.text = (obj.price/100).toString();
- checkedGoodsName1 = true;
- lineId = obj.lineId.toString();
- });
- },
- ),
- _underLine()
- ],
- ),
- );
-
- }
-
- Widget _packageType(String key) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- InkWell(
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Text(key == '包装类型' ? showTextGoodsPackage : key == '货物类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- onTap: () {
- showPickerModal(context, key);
- },
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- showPickerModal(BuildContext context, String type) {
- List < dynamic > data = [];
- if (type == '包装类型') {
- for (int i = 0; i < goodsPackageList.length; i++) {
- data.add(goodsPackageList[i].name);
- }
- } else if (type == '货物类型') {
- for (int i = 0; i < goodsCateGoryList.length; i++) {
- data.add(goodsCateGoryList[i].name);
- }
- } else if (type == '付款方式') {
- data = ['现付', '到付'];
- }
- new Picker(
- adapter: PickerDataAdapter < String > (pickerdata: data),
- height: ScreenUtil.getInstance().setHeight(450),
- confirmText: '确定',
- confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
- cancelText: '取消',
- cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
- headercolor: Color.fromRGBO(245, 245, 245, 1),
- itemExtent: ScreenUtil.getInstance().setHeight(80),
- textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
- changeToFirst: true,
- hideHeader: false,
- onConfirm: (Picker picker, List value) {
- if (type == '包装类型') {
- setState(() {
- showTextGoodsPackage = goodsPackageList[value[0]].name;
- goodsPackingId = goodsPackageList[value[0]].id;
- });
- } else if (type == '货物类型') {
- setState(() {
- showTextGoodsCategory = goodsCateGoryList[value[0]].name;
- goodsCategoryId = goodsCateGoryList[value[0]].id;
- });
- } else if (type == '付款方式') {
- setState(() {
- showTextPaymentMehod = data[value[0]];
- });
- if (showTextPaymentMehod == '现付') {
- goodsPaymentMethod = 1;
- } else {
- goodsPaymentMethod = 2;
- }
- }
- }
- ).showModal(this.context); //_scaffoldKey.currentState);
- }
- }
|