send_express_page.dart 61 KB

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