send_express_page.dart 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:city_pickers/city_pickers.dart';
  5. import 'package:flutter_picker/flutter_picker.dart';
  6. import 'dart:async';
  7. import 'send_express_page/order_detail_page.dart';
  8. import '../util/util.dart';
  9. import '../util/api.dart';
  10. import '../util/models.dart';
  11. import '../showAlert.dart';
  12. import '../send_Dialog.dart';
  13. import '../util/session.dart';
  14. import '../showLineModal.dart';
  15. import '../util/bluetooth_utils.dart';
  16. class SendExpressPage extends StatefulWidget {
  17. final Widget child;
  18. SendExpressPage({
  19. Key key,
  20. this.child
  21. }): super(key: key);
  22. _SendExpressPageState createState() => _SendExpressPageState();
  23. }
  24. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  25. ScrollController _scrollController = ScrollController();
  26. //组件自用字段-----------------------------
  27. GlobalKey _sendPhoneKey = GlobalKey();
  28. GlobalKey _getPhoneKey = GlobalKey();
  29. double tipWidth = 0;
  30. double tipHeight = 0;
  31. double tipPosX = 0;
  32. double tipPosY = 0;
  33. bool tipStatus = true;
  34. bool lineModalStatus = false;
  35. bool submitStatus = true;
  36. List < LikePhoneList > likePhoneList = [];
  37. var timer;
  38. bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
  39. TextEditingController sendCompanyPhoneController = TextEditingController();
  40. TextEditingController sendCompanyCodeController = TextEditingController();
  41. TextEditingController sendCompanyNameController = TextEditingController();
  42. TextEditingController receiptCompanyPhoneController = TextEditingController();
  43. TextEditingController receiptCompanyNameController = TextEditingController();
  44. TextEditingController sendCompanyAddressController = TextEditingController();
  45. TextEditingController receiptCompanyAddressController = TextEditingController();
  46. TextEditingController bankCardController = TextEditingController();
  47. TextEditingController bankNameController = TextEditingController();
  48. TextEditingController openBankNameController = TextEditingController();
  49. TextEditingController openBankPhoneController = TextEditingController();
  50. FocusNode bankCardFocusNode = FocusNode();
  51. List < dynamic > goodsCateGoryList = [];
  52. List < dynamic > goodsPackageList = [];
  53. //请求字段-------------------------
  54. String lineId = '-1';//收件公司匹配的线路id
  55. String sendCompanyId = '0'; //寄件公司Id
  56. String sendCompanyName = ''; //寄件公司名称 不能为空
  57. String sendCompanyPhone = ''; //寄件公司电话 不能为空
  58. String sendCompanyCode = ''; //寄件公司编码
  59. String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
  60. String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
  61. String sendCompanyCityName = ''; //寄件公司市名称 不能为空
  62. String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
  63. String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
  64. String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
  65. String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
  66. String receiptCompanyId = '0'; //收件公司id
  67. String receiptCompanyPhone = ''; //收件公司电话 不能为空
  68. String receiptCompanyName = ''; //收件公司名称 不能为空
  69. String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
  70. String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
  71. String receiptCompanyCityName = ''; //收件公司市名称 不能为空
  72. String receiptCompanyCityCode = ''; //收件公市编码 不能为空
  73. String receiptCompanyAreaName = ''; //收件公区名称 不能为空
  74. String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
  75. String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
  76. String goods = ''; //商品名称 不能为空
  77. int goodsQuantity = 1; //商品数量 不能为空
  78. int goodsPackingId; //商品包装ID
  79. int goodsCategoryId; //商品类别ID
  80. int goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
  81. double goodsWeight = 0.0; //商品重量
  82. double goodsPriceProtection = 0.0; //商品保价
  83. double goodsAgencyFund = 0.0; //商品代收款
  84. double goodsFreight = 0.0; //商品运费 不能为空
  85. String memo = ''; //备注
  86. String bankCard = '';//银行卡号
  87. String bankName = '';//所属银行
  88. String openBankName = '';//开户人
  89. String openBankPhone = '';//开户电话
  90. List<CompanyOfLineList> lineList = [];
  91. String sendPCA = ' '; //Text组件内容必须有空格,否则报null
  92. String getPCA = ' ';
  93. String showTextGoodsCategory = ' ';
  94. String showTextGoodsPackage = ' ';
  95. String showTextPaymentMehod = '到付';
  96. BluetoothUtils bluetooth = BluetoothUtils();
  97. bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
  98. @override
  99. void initState() {
  100. super.initState();
  101. goodsCategory().then((resp) {
  102. if (isNotError(context, resp) && this.mounted) {
  103. GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
  104. setState(() {
  105. goodsCateGoryList = goodsCategoryObj.data;
  106. showTextGoodsCategory = goodsCateGoryList[0].name;
  107. goodsCategoryId = goodsCateGoryList[0].id;
  108. });
  109. }
  110. });
  111. goodsPackage().then((resp) {
  112. if (isNotError(context, resp) && this.mounted) {
  113. GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
  114. setState(() {
  115. goodsPackageList = goodsPackageObj.data;
  116. showTextGoodsPackage = goodsPackageList[0].name;
  117. goodsPackingId = goodsPackageList[0].id;
  118. });
  119. }
  120. });
  121. _scrollController.addListener(() {
  122. if (!tipStatus) {
  123. setState(() {
  124. tipStatus = true;
  125. });
  126. }
  127. //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
  128. });
  129. sendCompanyPhoneController.addListener(() {
  130. if(checkedCompanyInfo){
  131. return;
  132. }
  133. setState(() {
  134. sendCompanyPhone = sendCompanyPhoneController.text;
  135. });
  136. if (timer != null) {
  137. timer.cancel();
  138. }
  139. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
  140. setState(() {
  141. tipStatus = true;
  142. });
  143. }
  144. timer = Timer(Duration(milliseconds: 250), () {
  145. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length <= 11) {
  146. likePhone(sendCompanyPhoneController.text).then((resp) {
  147. if (isNotError(context, resp) && this.mounted) {
  148. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  149. likePhoneList = likePhoneObj.data;
  150. }
  151. if (likePhoneList.length > 0) {
  152. sendPhoneOrGetPhoneTab = true;
  153. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  154. setState(() {
  155. tipWidth = sendPhoneObj.paintBounds.size.width;
  156. tipHeight = sendPhoneObj.paintBounds.size.height;
  157. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  158. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  159. tipStatus = false;
  160. });
  161. } else {
  162. setState(() {
  163. tipStatus = true;
  164. });
  165. }
  166. });
  167. }
  168. });
  169. });
  170. receiptCompanyPhoneController.addListener(() {
  171. if(checkedCompanyInfo){
  172. return;
  173. }
  174. setState(() {
  175. receiptCompanyPhone = receiptCompanyPhoneController.text;
  176. });
  177. if (timer != null) {
  178. timer.cancel();
  179. }
  180. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
  181. setState(() {
  182. tipStatus = true;
  183. });
  184. }
  185. timer = Timer(Duration(milliseconds: 250), () {
  186. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length <= 11) {
  187. likePhone(receiptCompanyPhoneController.text).then((resp) {
  188. if (isNotError(context, resp) && this.mounted) {
  189. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  190. likePhoneList = likePhoneObj.data;
  191. }
  192. if (likePhoneList.length > 0) {
  193. sendPhoneOrGetPhoneTab = false;
  194. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  195. setState(() {
  196. tipWidth = getPhoneKey.paintBounds.size.width;
  197. tipHeight = getPhoneKey.paintBounds.size.height;
  198. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  199. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  200. tipStatus = false;
  201. });
  202. } else {
  203. setState(() {
  204. tipStatus = true;
  205. });
  206. }
  207. });
  208. }
  209. });
  210. });
  211. sendCompanyAddressController.addListener(() {
  212. setState(() {
  213. sendCompanyAddress = sendCompanyAddressController.text;
  214. });
  215. });
  216. receiptCompanyAddressController.addListener(() {
  217. setState(() {
  218. receiptCompanyAddress = receiptCompanyAddressController.text;
  219. });
  220. });
  221. bankCardFocusNode.addListener((){
  222. if(!bankCardFocusNode.hasFocus){
  223. if(bankCardController.text!=''){
  224. getBankName(bankCardController.text).then((resp){
  225. if(isNotError(context, resp) && this.mounted){
  226. BankNameObj obj = BankNameObj.fromJson(resp.data);
  227. setState(() {
  228. bankNameController.text = obj.data;
  229. });
  230. }
  231. });
  232. }
  233. }
  234. });
  235. }
  236. @override
  237. bool get wantKeepAlive => true;
  238. @override
  239. Widget build(BuildContext context) {
  240. return Container(
  241. child: Scaffold(
  242. appBar: AppBar(
  243. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  244. centerTitle: true,
  245. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  246. ),
  247. body:
  248. Stack(
  249. children: < Widget > [
  250. Container(
  251. color: Color.fromRGBO(246, 246, 254, 1),
  252. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  253. child: ListView(
  254. controller: _scrollController,
  255. children: < Widget > [
  256. _sendInfo(context),
  257. _getInfo(context),
  258. _itemInfoWidget(),
  259. _bankInfo(context),
  260. _submitBtn()
  261. ],
  262. ),
  263. ),
  264. Positioned(
  265. top: tipPosY,
  266. left: tipPosX,
  267. child: Offstage(
  268. offstage: tipStatus,
  269. child: Container(
  270. width: tipWidth,
  271. height: ScreenUtil.getInstance().setHeight(450),
  272. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  273. decoration: BoxDecoration(
  274. color: Color.fromRGBO(244, 248, 251, 1),
  275. ),
  276. child: ListView.builder(
  277. itemCount: likePhoneList.length,
  278. itemBuilder: (BuildContext context, int index) {
  279. return _tipItem(likePhoneList[index]);
  280. },
  281. )
  282. ),
  283. )
  284. )
  285. ],
  286. ),
  287. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  288. ),
  289. );
  290. }
  291. Widget _sendInfo(BuildContext context) {
  292. return Container(
  293. color: Colors.white,
  294. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  295. child: Column(
  296. children: < Widget > [
  297. _titleWidget('lib/images/icon_send.png', '发件信息'),
  298. _underLine(),
  299. _inputWiget('电话', 'sendPhone'),
  300. _contentWiget('企业编码', 'send', true),
  301. _contentWiget('企业名称', 'send', true),
  302. _cityWiget('城市/区域', context, 'send'),
  303. _lastContentWiget('详细地址', 'send')
  304. ],
  305. )
  306. );
  307. }
  308. Widget _getInfo(BuildContext context) {
  309. return Container(
  310. color: Colors.white,
  311. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  312. child: Column(
  313. children: < Widget > [
  314. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  315. _underLine(),
  316. _inputWiget('电话', 'getPhone'),
  317. _contentWiget('企业名称', 'get', true),
  318. _cityWiget('城市/区域', context, 'get'),
  319. _lastContentWiget('详细地址', 'get')
  320. ],
  321. )
  322. );
  323. }
  324. Widget _itemInfoWidget() {
  325. return Container(
  326. child: Container(
  327. color: Colors.white,
  328. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  329. child: Column(
  330. crossAxisAlignment: CrossAxisAlignment.start,
  331. children: < Widget > [
  332. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  333. _underLine(),
  334. _contentWiget("货物名称", 'goods', true),
  335. _contentWiget("数量", 'goods'),
  336. _contentWiget("运费", 'goods'),
  337. _contentWiget("代收", 'goods'),
  338. _contentWiget("保价", 'goods'),
  339. _contentWiget("重量", 'goods'),
  340. _packageType('包装类型'),
  341. _packageType('货物类型'),
  342. _packageType('付款方式'),
  343. _descWidget()
  344. ],
  345. ),
  346. )
  347. );
  348. }
  349. Widget _bankInfo(BuildContext context) {
  350. return Container(
  351. color: Colors.white,
  352. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  353. child: Column(
  354. children: < Widget > [
  355. _titleWidget('lib/images/icon_bank.png', '银行信息'),
  356. _underLine(),
  357. _contentBankWiget('银行卡号', 'bank'),
  358. _contentBankWiget('银行名称', 'bank',true),
  359. _contentBankWiget('开户人', 'bank',true),
  360. _lastBankContentWiget('开户电话', 'bank'),
  361. ],
  362. )
  363. );
  364. }
  365. Widget _titleWidget(String iconUrl, String str) {
  366. return Container(
  367. height: ScreenUtil.getInstance().setHeight(90),
  368. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  369. child: Center(
  370. child: Row(
  371. mainAxisAlignment: MainAxisAlignment.start,
  372. children: < Widget > [
  373. Padding(
  374. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  375. child: Image.asset(
  376. iconUrl,
  377. width: ScreenUtil.getInstance().setWidth(40),
  378. height: ScreenUtil.getInstance().setHeight(40),
  379. )
  380. ),
  381. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  382. ],
  383. ),
  384. ),
  385. );
  386. }
  387. Widget _underLine() {
  388. return Container(
  389. color: Color.fromRGBO(223, 223, 223, 1),
  390. height: ScreenUtil.getInstance().setHeight(1),
  391. );
  392. }
  393. Widget _inputWiget(String key, String tab) {
  394. return Padding(
  395. key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
  396. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  397. child: Column(
  398. children: < Widget > [
  399. SizedBox(
  400. height: ScreenUtil.getInstance().setHeight(89),
  401. child: Center(
  402. child: Row(
  403. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  404. children: < Widget > [
  405. Expanded(
  406. flex: 0,
  407. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  408. ),
  409. Expanded(
  410. child: Row(
  411. mainAxisAlignment: MainAxisAlignment.end,
  412. children: < Widget > [
  413. SizedBox(
  414. width: ScreenUtil.getInstance().setWidth(500),
  415. child: TextField(
  416. controller: tab == 'sendPhone' ? sendCompanyPhoneController : receiptCompanyPhoneController,
  417. keyboardType: TextInputType.number,
  418. textAlign: TextAlign.end,
  419. decoration: InputDecoration(
  420. border: InputBorder.none
  421. ),
  422. onEditingComplete: () {
  423. setState(() {
  424. FocusScope.of(context).requestFocus(FocusNode());
  425. tipStatus = true;
  426. });
  427. },
  428. onChanged: (value){
  429. checkedCompanyInfo = false;
  430. if(tab=='sendPhone'){
  431. sendCompanyCode = '';
  432. sendCompanyName = '';
  433. sendCompanyId ='0';
  434. sendCompanyCodeController.text = '';
  435. sendCompanyNameController.text = '';
  436. sendPCA = '';
  437. sendCompanyProvinceName = '';
  438. sendCompanyProvinceCode = '';
  439. sendCompanyCityName = '';
  440. sendCompanyCityCode = '';
  441. sendCompanyAreaName = '';
  442. sendCompanyAreaCode = '';
  443. bankCardController.text = '';
  444. bankNameController.text = '';
  445. openBankNameController.text = '';
  446. openBankPhoneController.text = '';
  447. sendCompanyAddressController.text = '';
  448. }else if(tab=='getPhone'){
  449. receiptCompanyName = '';
  450. receiptCompanyNameController.text = '';
  451. receiptCompanyId = null;
  452. getPCA = '';
  453. receiptCompanyProvinceName = '';
  454. receiptCompanyProvinceCode = '';
  455. receiptCompanyCityName = '';
  456. receiptCompanyCityCode = '';
  457. receiptCompanyAreaName = '';
  458. receiptCompanyAreaCode = '';
  459. receiptCompanyAddressController.text = '';
  460. }
  461. },
  462. ),
  463. ),
  464. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  465. ],
  466. )
  467. )
  468. ],
  469. ),
  470. )
  471. ),
  472. Expanded(
  473. flex: 0,
  474. child: _underLine()
  475. )
  476. ],
  477. )
  478. );
  479. }
  480. Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  481. return Padding(
  482. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  483. child: Column(
  484. children: < Widget > [
  485. SizedBox(
  486. height: ScreenUtil.getInstance().setHeight(89),
  487. child: Center(
  488. child: Row(
  489. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  490. children: < Widget > [
  491. Expanded(
  492. flex: 0,
  493. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  494. ),
  495. Expanded(
  496. child: Row(
  497. mainAxisAlignment: MainAxisAlignment.end,
  498. children: < Widget > [
  499. SizedBox(
  500. width: ScreenUtil.getInstance().setWidth(500),
  501. child: TextField(
  502. controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
  503. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  504. textAlign: TextAlign.end,
  505. decoration: InputDecoration(
  506. border: InputBorder.none
  507. ),
  508. onChanged: (value) {
  509. if (type == 'send') {
  510. if (key == '企业编码') {
  511. setState(() {
  512. sendCompanyCode = value;
  513. });
  514. } else if (key == '企业名称') {
  515. setState(() {
  516. sendCompanyName = value;
  517. });
  518. }
  519. } else if (type == 'get') {
  520. if (key == '企业编码') {
  521. setState(() {
  522. sendCompanyCode = value;
  523. });
  524. } else if (key == '企业名称') {
  525. setState(() {
  526. receiptCompanyName = value;
  527. });
  528. }
  529. } else if(type=='goods') {
  530. if (key == '货物名称') {
  531. goods = value;
  532. } else if (key == '数量') {
  533. goodsQuantity = int.parse(value);
  534. } else if (key == '运费') {
  535. goodsFreight = double.parse(value);
  536. String temp = goodsFreight.toStringAsFixed(1);
  537. goodsFreight = double.parse(temp);
  538. } else if (key == '代收') {
  539. goodsAgencyFund = double.parse(value);
  540. String temp = goodsAgencyFund.toStringAsFixed(1);
  541. goodsAgencyFund = double.parse(temp);
  542. } else if (key == '保价') {
  543. goodsPriceProtection = double.parse(value);
  544. String temp = goodsPriceProtection.toStringAsFixed(1);
  545. goodsPriceProtection = double.parse(temp);
  546. } else if (key == '重量') {
  547. goodsWeight = double.parse(value);
  548. String temp = goodsWeight.toStringAsFixed(1);
  549. goodsWeight = double.parse(temp);
  550. }
  551. }else if(type=='bank'){
  552. if(key == '银行卡号'){
  553. bankCard = value;
  554. }else if(key=='银行名称'){
  555. bankName = value;
  556. }else if(key == '开户人'){
  557. openBankName = value;
  558. }else if(key == '开户电话'){
  559. openBankPhone = value;
  560. }
  561. }
  562. },
  563. ),
  564. ),
  565. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  566. ],
  567. )
  568. )
  569. ],
  570. ),
  571. )
  572. ),
  573. Expanded(
  574. flex: 0,
  575. child: _underLine()
  576. )
  577. ],
  578. )
  579. );
  580. }
  581. Widget _contentBankWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  582. return Padding(
  583. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  584. child: Column(
  585. children: < Widget > [
  586. SizedBox(
  587. height: ScreenUtil.getInstance().setHeight(89),
  588. child: Center(
  589. child: Row(
  590. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  591. children: < Widget > [
  592. Expanded(
  593. flex: 0,
  594. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  595. ),
  596. Expanded(
  597. child: Row(
  598. mainAxisAlignment: MainAxisAlignment.end,
  599. children: < Widget > [
  600. SizedBox(
  601. width: ScreenUtil.getInstance().setWidth(500),
  602. child: TextField(
  603. focusNode: key == '银行卡号'?bankCardFocusNode:null,
  604. controller: key == '银行卡号'?bankCardController:key=='银行名称'?bankNameController:openBankNameController,
  605. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  606. textAlign: TextAlign.end,
  607. decoration: InputDecoration(
  608. border: InputBorder.none
  609. ),
  610. ),
  611. ),
  612. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  613. ],
  614. )
  615. )
  616. ],
  617. ),
  618. )
  619. ),
  620. Expanded(
  621. flex: 0,
  622. child: _underLine()
  623. )
  624. ],
  625. )
  626. );
  627. }
  628. Widget _cityWiget(String key, BuildContext context, String type) {
  629. return
  630. GestureDetector(
  631. child: Padding(
  632. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  633. child: Column(
  634. children: < Widget > [
  635. SizedBox(
  636. height: ScreenUtil.getInstance().setHeight(89),
  637. child: Center(
  638. child: Row(
  639. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  640. children: < Widget > [
  641. Expanded(
  642. flex: 0,
  643. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  644. ),
  645. Expanded(
  646. child: Row(
  647. mainAxisAlignment: MainAxisAlignment.end,
  648. children: < Widget > [
  649. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  650. SizedBox(
  651. width: ScreenUtil.getInstance().setWidth(500),
  652. child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
  653. ),
  654. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  655. ],
  656. )
  657. )
  658. ],
  659. ),
  660. )
  661. ),
  662. Expanded(
  663. flex: 0,
  664. child: _underLine()
  665. )
  666. ],
  667. )
  668. ),
  669. onTap: () {
  670. getCity(context).then((resp) {
  671. if (resp == null) {
  672. return;
  673. }
  674. print(resp.toString());
  675. setState(() {
  676. if (type == 'send') {
  677. sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  678. sendCompanyProvinceName = resp.provinceName;
  679. sendCompanyProvinceCode = resp.provinceId;
  680. sendCompanyCityName = resp.cityName;
  681. sendCompanyCityCode = resp.cityId;
  682. sendCompanyAreaName = resp.areaName;
  683. sendCompanyAreaCode = resp.areaId;
  684. } else {
  685. getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  686. receiptCompanyProvinceName = resp.provinceName;
  687. receiptCompanyProvinceCode = resp.provinceId;
  688. receiptCompanyCityName = resp.cityName;
  689. receiptCompanyCityCode = resp.cityId;
  690. receiptCompanyAreaName = resp.areaName;
  691. receiptCompanyAreaCode = resp.areaId;
  692. }
  693. });
  694. //print(value);
  695. });
  696. },
  697. );
  698. }
  699. Widget _lastContentWiget(String key, String type) {
  700. return Padding(
  701. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  702. child: SizedBox(
  703. height: ScreenUtil.getInstance().setHeight(89),
  704. child: Center(
  705. child: Row(
  706. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  707. children: < Widget > [
  708. Expanded(
  709. flex: 0,
  710. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  711. ),
  712. Expanded(
  713. child: Row(
  714. mainAxisAlignment: MainAxisAlignment.end,
  715. children: < Widget > [
  716. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  717. SizedBox(
  718. width: ScreenUtil.getInstance().setWidth(500),
  719. child: TextField(
  720. controller: type == 'send' ? sendCompanyAddressController : receiptCompanyAddressController,
  721. textAlign: TextAlign.end,
  722. decoration: InputDecoration(
  723. border: InputBorder.none
  724. ),
  725. ),
  726. ),
  727. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  728. ],
  729. )
  730. )
  731. ],
  732. ),
  733. )
  734. )
  735. );
  736. }
  737. Widget _lastBankContentWiget(String key, String type) {
  738. return Padding(
  739. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  740. child: SizedBox(
  741. height: ScreenUtil.getInstance().setHeight(89),
  742. child: Center(
  743. child: Row(
  744. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  745. children: < Widget > [
  746. Expanded(
  747. flex: 0,
  748. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  749. ),
  750. Expanded(
  751. child: Row(
  752. mainAxisAlignment: MainAxisAlignment.end,
  753. children: < Widget > [
  754. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  755. SizedBox(
  756. width: ScreenUtil.getInstance().setWidth(500),
  757. child: TextField(
  758. controller: openBankPhoneController,
  759. textAlign: TextAlign.end,
  760. keyboardType: TextInputType.number,
  761. decoration: InputDecoration(
  762. border: InputBorder.none
  763. ),
  764. ),
  765. ),
  766. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  767. ],
  768. )
  769. )
  770. ],
  771. ),
  772. )
  773. )
  774. );
  775. }
  776. Widget _descWidget() {
  777. return
  778. Container(
  779. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  780. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  781. child: TextField(
  782. maxLines: 3,
  783. decoration: InputDecoration(
  784. border: InputBorder.none,
  785. hintText: "请输入备注内容"
  786. ),
  787. onChanged: (value) {
  788. setState(() {
  789. memo = value;
  790. });
  791. },
  792. ),
  793. );
  794. }
  795. Widget _submitBtn() {
  796. return GestureDetector(
  797. child: Container(
  798. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  799. height: ScreenUtil.getInstance().setHeight(88),
  800. decoration: BoxDecoration(
  801. borderRadius: BorderRadius.all(Radius.circular(4)),
  802. color: Color.fromRGBO(37, 102, 242, 1),
  803. ),
  804. child: Center(
  805. child: Row(
  806. mainAxisAlignment: MainAxisAlignment.center,
  807. children: < Widget > [
  808. Offstage(
  809. offstage: submitStatus,
  810. child: SizedBox(
  811. width: ScreenUtil.getInstance().setWidth(45),
  812. height: ScreenUtil.getInstance().setHeight(45),
  813. child: Image.asset('lib/images/loading.gif'),
  814. ),
  815. ),
  816. Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  817. ],
  818. )
  819. ),
  820. ),
  821. onTap: () {
  822. if (!submitStatus) {
  823. return;
  824. }
  825. String errStr = '';
  826. print('sendCompanyId---${sendCompanyId}');
  827. print('sendCompanyName---${sendCompanyName}');
  828. print('sendCompanyPhone---${sendCompanyPhone}');
  829. print('sendCompanyCode---${sendCompanyCode}');
  830. print('sendCompanyProvinceName---${sendCompanyProvinceName}');
  831. print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
  832. print('sendCompanyCityName---${sendCompanyCityName}');
  833. print('sendCompanyCityCode---${sendCompanyCityCode}');
  834. print('sendCompanyAreaName---${sendCompanyAreaName}');
  835. print('sendCompanyAreaCode---${sendCompanyAreaCode}');
  836. print('sendCompanyAddress---${sendCompanyAddress}');
  837. print('receiptCompanyId---${receiptCompanyId}');
  838. print('receiptCompanyPhone---${receiptCompanyPhone}');
  839. print('receiptCompanyName---${receiptCompanyName}');
  840. print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
  841. print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
  842. print('receiptCompanyCityName---${receiptCompanyCityName}');
  843. print('receiptCompanyCityCode---${receiptCompanyCityCode}');
  844. print('receiptCompanyAreaName---${receiptCompanyAreaName}');
  845. print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
  846. print('receiptCompanyAddress---${receiptCompanyAddress}');
  847. print('goods---${goods}');
  848. print('goodsQuantity---${goodsQuantity}');
  849. print('goodsPackingId---${goodsPackingId}');
  850. print('goodsCategoryId---${goodsCategoryId}');
  851. print('goodsPaymentMethod---${goodsPaymentMethod}');
  852. print('goodsWeight---${goodsWeight}');
  853. print('goodsPriceProtection---${goodsPriceProtection}');
  854. print('goodsAgencyFund---${goodsAgencyFund}');
  855. print('goodsFreight---${goodsFreight}');
  856. print('memo---${memo}');
  857. if (sendCompanyPhone == '') {
  858. errStr = '请填写发件电话';
  859. }
  860. if (sendCompanyName == '') {
  861. errStr = '请填写发件企业名称';
  862. }
  863. if (sendCompanyProvinceName == '') {
  864. errStr = '请填写发件城市/区域';
  865. }
  866. if (sendCompanyAddress == '') {
  867. errStr = '请填写发件详细地址';
  868. }
  869. if (receiptCompanyPhone == '') {
  870. errStr = '请填写收件电话';
  871. }
  872. if (receiptCompanyName == '') {
  873. errStr = '请填写收件企业名称';
  874. }
  875. if (receiptCompanyProvinceName == '') {
  876. errStr = '请填写收件城市/区域';
  877. }
  878. if (receiptCompanyAddress == '') {
  879. errStr = '请填写收件详细地址';
  880. }
  881. if (goods == '') {
  882. errStr = '请填写货物名称';
  883. }
  884. if (goodsQuantity == 0) {
  885. errStr = '请填写货物数量';
  886. }
  887. if (int.tryParse(goodsQuantity.toString()) == null) {
  888. errStr = '货物数量格式错误';
  889. }
  890. if (goodsFreight == 0.0) {
  891. errStr = '请填写运费';
  892. }
  893. if (sendCompanyPhone == '' || receiptCompanyPhone == '' ) {
  894. errStr = '请输入正确的电话';
  895. }
  896. if (goodsAgencyFund>0 && sendCompanyId=='0') {//如果有代收,接没有拿到公司id
  897. if(bankNameController.text=='' || bankCardController.text=='' || openBankNameController.text=='' || openBankPhoneController.text==''){
  898. errStr = "请补全银行卡信息";
  899. }
  900. }
  901. if (errStr != '') {
  902. showError(errStr);
  903. return;
  904. }
  905. if(lineList.length>1){
  906. showLineModal(lineList);
  907. return;
  908. }
  909. submitOrder();
  910. },
  911. );
  912. }
  913. submitOrder(){
  914. setState(() {
  915. submitStatus = false;
  916. });
  917. getKey('stationId').then((value) {
  918. createOrder(
  919. lineId,//收件线路Id
  920. value,//当前用户选择的站点id
  921. sendCompanyId, //寄件公司Id
  922. sendCompanyName, //寄件公司名称 不能为空
  923. sendCompanyPhone, //寄件公司电话 不能为空
  924. sendCompanyCode ?? '', //寄件公司编码
  925. sendCompanyProvinceName, //寄件公司省名称 不能为空
  926. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  927. sendCompanyCityName, //寄件公司市名称 不能为空
  928. sendCompanyCityCode, //寄件公司市编码 不能为空
  929. sendCompanyAreaName, //寄件公司区名称 不能为空
  930. sendCompanyAreaCode, //寄件公司区编码 不能为空
  931. sendCompanyAddress, //寄件公司详细地址,不能为空
  932. receiptCompanyId, //收件公司id
  933. receiptCompanyPhone, //收件公司电话 不能为空
  934. receiptCompanyName, //收件公司名称 不能为空
  935. receiptCompanyProvinceName, //收件公司省名称 不能为空
  936. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  937. receiptCompanyCityName, //收件公司市名称 不能为空
  938. receiptCompanyCityCode, //收件公市编码 不能为空
  939. receiptCompanyAreaName, //收件公区名称 不能为空
  940. receiptCompanyAreaCode, //收件公司区编码 不能为空
  941. receiptCompanyAddress, //收件公司地址详情 不能为空
  942. goods, //商品名称 不能为空
  943. goodsQuantity, //商品数量 不能为空
  944. goodsPackingId, //商品包装ID
  945. goodsCategoryId, //商品类别ID
  946. goodsPaymentMethod, //付款方式 1,现付 2 到付
  947. goodsWeight, //商品重量
  948. goodsPriceProtection * 100, //商品保价,已分为单位
  949. goodsAgencyFund * 100, //商品代收款,已分为单位
  950. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  951. memo, //备注
  952. bankCardController.text,
  953. bankNameController.text,
  954. openBankNameController.text,
  955. openBankPhoneController.text
  956. ).then((resp) {
  957. if (isNotError(context, resp) && this.mounted) {
  958. setState(() {
  959. submitStatus = true;
  960. });
  961. OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
  962. showDialog < Null > (
  963. context: context, //BuildContext对象
  964. barrierDismissible: false,
  965. builder: (BuildContext context) {
  966. //打印
  967. getKey('printType').then((printType){
  968. getKey('stationName').then((stationName){
  969. getKey('nickName').then((nickName){
  970. getKey('companyName').then((companyName){
  971. getKey('companyCustomerPhone').then((companyCustomerPhone){
  972. double goodsYs = data.goodsPaymentMethod==2?(data.goodsFreight/100)+(data.goodsAgencyFund/100):data.goodsAgencyFund/100;
  973. String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
  974. String createTime = fromatDate(data.createTime);
  975. double goodsAgencyFunds = data.goodsAgencyFund/100;
  976. double goodsDFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
  977. double goodsXFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
  978. String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
  979. Map<String, String> pum = {
  980. "[logisticsNo]": "${data.orderNo ?? ''}",
  981. "[createTime]": "$createTime",
  982. "[sendStationName]": "$stationName",
  983. "[dealerCode]": "${data.sendCompanyCode ?? ''}",
  984. "[dealerName]": "${data.sendCompanyName}",
  985. "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
  986. "[repairName]": "${data.receiptCompanyName ?? ''}",
  987. "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
  988. "[endStationName]": "${data.receiptStationName ?? ''}",
  989. "[goodsLineCode]": "${data.lineCode ?? ''}",
  990. "[goodsLine]": "${data.lineName ?? ''}",
  991. "[repairAddress]": "${receiptAddress?? ''}",
  992. "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
  993. "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
  994. "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
  995. // 到付 现付 金额
  996. "[goodsDFreight]": "$goodsDFreight",
  997. "[goodsXFreight]": "$goodsXFreight",
  998. "[goodsAgencyFund]": "$goodsAgencyFunds",
  999. "[goodsYs]": "$goodsYs",
  1000. "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
  1001. "[goodsRemark]": "${data.memo ?? ''}",
  1002. "[realName]": "${nickName?? ''}",
  1003. "[currentTime]": "$nowDate",
  1004. "[currentGoodNumber]": "1/1",
  1005. "[companyCustomerPhone]":"$companyCustomerPhone",
  1006. "[companyName]":"$companyName"
  1007. };
  1008. bluetooth.printOrder(pum, int.parse(printType)).then((value){
  1009. if(value==null){
  1010. showDialog <Null> (
  1011. context: context,
  1012. barrierDismissible: false,
  1013. builder: (BuildContext context) {
  1014. return MyAlertDialog(text: '未连接打印机',childCallback:(val){});
  1015. }
  1016. );
  1017. }
  1018. });
  1019. });
  1020. });
  1021. });
  1022. });
  1023. });
  1024. return SendDialog( //调用对话框
  1025. orderNo: data.orderNo,
  1026. childCallback: (val) {
  1027. if (!val) {
  1028. //跳转
  1029. Navigator.push(context, MaterialPageRoute(builder: (context) {
  1030. return OrderDetail(orderNo: data.orderNo, );
  1031. }));
  1032. }
  1033. },
  1034. );
  1035. });
  1036. } else {
  1037. setState(() {
  1038. submitStatus = true;
  1039. });
  1040. }
  1041. });
  1042. });
  1043. }
  1044. showError(String str) {
  1045. showDialog < Null > (
  1046. context: context, //BuildContext对象
  1047. barrierDismissible: false,
  1048. builder: (BuildContext context) {
  1049. return MyAlertDialog( //调用对话框
  1050. text: str, childCallback: (val) {},
  1051. );
  1052. });
  1053. }
  1054. showLineModal(List<CompanyOfLineList> list){
  1055. showDialog < Null > (
  1056. context: context, //BuildContext对象
  1057. barrierDismissible: false,
  1058. builder: (BuildContext context) {
  1059. return ShowLineModal(
  1060. lineList: list, childCallback: (val) {
  1061. lineId = val;
  1062. submitOrder();
  1063. },
  1064. );
  1065. });
  1066. }
  1067. Future getCity(context) async {
  1068. Result result = await CityPickers.showCityPicker(
  1069. context: context,
  1070. );
  1071. return result;
  1072. }
  1073. Widget _tipItem(LikePhoneList obj) {
  1074. return Container(
  1075. child: Column(
  1076. children: < Widget > [
  1077. InkWell(
  1078. child: Container(
  1079. height: ScreenUtil.getInstance().setHeight(89),
  1080. child: Center(
  1081. child: Row(
  1082. mainAxisAlignment: MainAxisAlignment.start,
  1083. children: < Widget > [
  1084. Padding(
  1085. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  1086. child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
  1087. fontSize: ScreenUtil.getInstance().setSp(28),
  1088. color: Color.fromRGBO(74, 74, 74, 1)
  1089. ), )
  1090. ),
  1091. SizedBox(
  1092. width: ScreenUtil.getInstance().setWidth(185),
  1093. child: Text(obj.areaCode,
  1094. textAlign: TextAlign.left,
  1095. style: TextStyle(
  1096. fontSize: ScreenUtil.getInstance().setSp(28),
  1097. color: Color.fromRGBO(155, 155, 155, 1)
  1098. ), ),
  1099. ),
  1100. Text(obj.companyName,
  1101. textAlign: TextAlign.left,
  1102. overflow: TextOverflow.ellipsis,
  1103. style: TextStyle(
  1104. fontSize: ScreenUtil.getInstance().setSp(28),
  1105. color: Color.fromRGBO(155, 155, 155, 1)
  1106. ),
  1107. )
  1108. ],
  1109. ),
  1110. ),
  1111. ),
  1112. onTap: () {
  1113. checkedCompanyInfo = true;
  1114. if (sendPhoneOrGetPhoneTab) {
  1115. sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1116. sendCompanyCode = obj.companyCode;
  1117. sendCompanyName = obj.companyName;
  1118. sendCompanyId = obj.id.toString();
  1119. sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1120. sendCompanyCodeController.text = obj.companyCode;
  1121. sendCompanyNameController.text = obj.companyName;
  1122. sendPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1123. sendCompanyProvinceName = obj.provinceName;
  1124. sendCompanyProvinceCode = obj.provinceCode;
  1125. sendCompanyCityName = obj.cityName;
  1126. sendCompanyCityCode = obj.cityCode;
  1127. sendCompanyAreaName = obj.areaName;
  1128. sendCompanyAreaCode = obj.areaCode;
  1129. sendCompanyAddressController.text = obj.address;
  1130. bankCardController.text = obj.bankCard;
  1131. bankNameController.text = obj.bankName;
  1132. openBankNameController.text = obj.openBankName;
  1133. openBankPhoneController.text = obj.openBankPhone;
  1134. } else {
  1135. receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1136. receiptCompanyName = obj.companyName;
  1137. receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1138. receiptCompanyNameController.text = obj.companyName;
  1139. receiptCompanyId = obj.id.toString();
  1140. getLineOfCompanyId(receiptCompanyId).then((resp){
  1141. if(isNotError(context, resp) && this.mounted){
  1142. CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
  1143. setState(() {
  1144. lineList = obj.data;
  1145. });
  1146. }
  1147. });
  1148. getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1149. receiptCompanyProvinceName = obj.provinceName;
  1150. receiptCompanyProvinceCode = obj.provinceCode;
  1151. receiptCompanyCityName = obj.cityName;
  1152. receiptCompanyCityCode = obj.cityCode;
  1153. receiptCompanyAreaName = obj.areaName;
  1154. receiptCompanyAreaCode = obj.areaCode;
  1155. receiptCompanyAddressController.text = obj.address;
  1156. }
  1157. setState(() {
  1158. FocusScope.of(context).requestFocus(FocusNode());
  1159. tipStatus = true;
  1160. });
  1161. },
  1162. ),
  1163. _underLine()
  1164. ],
  1165. ),
  1166. );
  1167. }
  1168. Widget _packageType(String key) {
  1169. return Padding(
  1170. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  1171. child: Column(
  1172. children: < Widget > [
  1173. InkWell(
  1174. child: SizedBox(
  1175. height: ScreenUtil.getInstance().setHeight(89),
  1176. child: Center(
  1177. child: Row(
  1178. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1179. children: < Widget > [
  1180. Expanded(
  1181. flex: 0,
  1182. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  1183. ),
  1184. Expanded(
  1185. child: Row(
  1186. mainAxisAlignment: MainAxisAlignment.end,
  1187. children: < Widget > [
  1188. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  1189. SizedBox(
  1190. width: ScreenUtil.getInstance().setWidth(500),
  1191. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '货物类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  1192. ),
  1193. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  1194. ],
  1195. )
  1196. )
  1197. ],
  1198. ),
  1199. )
  1200. ),
  1201. onTap: () {
  1202. showPickerModal(context, key);
  1203. },
  1204. ),
  1205. Expanded(
  1206. flex: 0,
  1207. child: _underLine()
  1208. )
  1209. ],
  1210. )
  1211. );
  1212. }
  1213. showPickerModal(BuildContext context, String type) {
  1214. List < dynamic > data = [];
  1215. if (type == '包装类型') {
  1216. for (int i = 0; i < goodsPackageList.length; i++) {
  1217. data.add(goodsPackageList[i].name);
  1218. }
  1219. } else if (type == '货物类型') {
  1220. for (int i = 0; i < goodsCateGoryList.length; i++) {
  1221. data.add(goodsCateGoryList[i].name);
  1222. }
  1223. } else if (type == '付款方式') {
  1224. data = ['现付', '到付'];
  1225. }
  1226. new Picker(
  1227. adapter: PickerDataAdapter < String > (pickerdata: data),
  1228. height: ScreenUtil.getInstance().setHeight(450),
  1229. confirmText: '确定',
  1230. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  1231. cancelText: '取消',
  1232. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  1233. headercolor: Color.fromRGBO(245, 245, 245, 1),
  1234. itemExtent: ScreenUtil.getInstance().setHeight(80),
  1235. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  1236. changeToFirst: true,
  1237. hideHeader: false,
  1238. onConfirm: (Picker picker, List value) {
  1239. if (type == '包装类型') {
  1240. setState(() {
  1241. showTextGoodsPackage = goodsPackageList[value[0]].name;
  1242. goodsPackingId = goodsPackageList[value[0]].id;
  1243. });
  1244. } else if (type == '货物类型') {
  1245. setState(() {
  1246. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  1247. goodsCategoryId = goodsCateGoryList[value[0]].id;
  1248. });
  1249. } else if (type == '付款方式') {
  1250. setState(() {
  1251. showTextPaymentMehod = data[value[0]];
  1252. });
  1253. if (showTextPaymentMehod == '现付') {
  1254. goodsPaymentMethod = 1;
  1255. } else {
  1256. goodsPaymentMethod = 2;
  1257. }
  1258. }
  1259. }
  1260. ).showModal(this.context); //_scaffoldKey.currentState);
  1261. }
  1262. }