|
|
@@ -18,27 +18,34 @@ class OrderTakingPage extends StatefulWidget {
|
|
|
class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
|
|
|
|
|
|
ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
|
|
|
- List listObj = [];
|
|
|
+ List < OrderList > orderList = []; //订单列表
|
|
|
+ bool hasNextPage = true;
|
|
|
List lineList = [];
|
|
|
String stationId;
|
|
|
List < bool > checkStatusList = [];
|
|
|
bool showLineStatus = true;
|
|
|
+ String lineIdStr = '';
|
|
|
+ int page = 1;
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
- // getOrderList().then((resp) {
|
|
|
- // setState(() {
|
|
|
- // listObj = resp.orderList;
|
|
|
- // });
|
|
|
- // });
|
|
|
- getKey('stationId').then((value){
|
|
|
+ getKey('stationId').then((value) {
|
|
|
setState(() {
|
|
|
stationId = value;
|
|
|
});
|
|
|
- getLine(value);
|
|
|
+ getLine(value).then((childValue) {
|
|
|
+ getOrderList(value, lineIdStr, page).then((resp) {
|
|
|
+ if (resp.success && resp.code == 1) {
|
|
|
+ setState(() {
|
|
|
+ orderList = resp.data.items;
|
|
|
+ hasNextPage = resp.data.hasNextPage;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
_scrollController.addListener(() {
|
|
|
- if(!showLineStatus){
|
|
|
+ if (!showLineStatus) {
|
|
|
setState(() {
|
|
|
showLineStatus = true;
|
|
|
});
|
|
|
@@ -51,26 +58,28 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
// });
|
|
|
// });
|
|
|
}
|
|
|
- //print(_scrollController.position.pixels);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
- void getLine(value){
|
|
|
- getLineFromStation(value).then((resp) {
|
|
|
+ Future getLine(value) async {
|
|
|
+ await getLineFromStation(value).then((resp) {
|
|
|
if (resp.success && resp.code == 1) {
|
|
|
setState(() {
|
|
|
checkStatusList = [];
|
|
|
lineList = resp.data;
|
|
|
- for(int i=0;i<lineList.length;i++){
|
|
|
- if(i==0){
|
|
|
- checkStatusList.add(true);
|
|
|
- }else{
|
|
|
- checkStatusList.add(false);
|
|
|
+ for (int i = 0; i < lineList.length; i++) {
|
|
|
+ checkStatusList.add(true);
|
|
|
+ if (i < lineList.length - 1) {
|
|
|
+ lineIdStr += lineList[i].id.toString() + ',';
|
|
|
+ } else {
|
|
|
+ lineIdStr += lineList[i].id.toString();
|
|
|
}
|
|
|
}
|
|
|
stationId = value;
|
|
|
});
|
|
|
+ print(lineIdStr);
|
|
|
+ return lineIdStr;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -96,7 +105,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
});
|
|
|
if (!showLineStatus) {
|
|
|
getKey('stationId').then((value) {
|
|
|
- if(stationId!=value){
|
|
|
+ if (stationId != value) {
|
|
|
getLine(value);
|
|
|
}
|
|
|
});
|
|
|
@@ -106,31 +115,36 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
),
|
|
|
body: Stack(
|
|
|
children: < Widget > [
|
|
|
- InkWell(
|
|
|
- child: Container(
|
|
|
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
- ),
|
|
|
- child: RefreshIndicator( //下拉刷新组件
|
|
|
- onRefresh: _onRefresh, //回调方法
|
|
|
+ RefreshIndicator(
|
|
|
+ onRefresh: _onRefresh, //回调方法
|
|
|
+ child: InkWell(
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
+ ),
|
|
|
+
|
|
|
+
|
|
|
child: ListView.builder(
|
|
|
controller: _scrollController,
|
|
|
- itemCount: listObj.length + 1,
|
|
|
+ itemCount: orderList.length + 1,
|
|
|
itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
|
|
|
- if (index < listObj.length) {
|
|
|
- return OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
|
|
|
+ if (index < orderList.length) {
|
|
|
+ return OrderCardContainer(order: orderList[index], index: index, callback: (val) => deleteOrder(val));
|
|
|
+ }
|
|
|
+ if (hasNextPage) {
|
|
|
+ return _getMoreWidget();
|
|
|
}
|
|
|
- return _getMoreWidget();
|
|
|
},
|
|
|
)
|
|
|
+
|
|
|
),
|
|
|
+ onTap: () {
|
|
|
+ setState(() {
|
|
|
+ showLineStatus = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
),
|
|
|
- onTap: () {
|
|
|
- setState(() {
|
|
|
- showLineStatus = true;
|
|
|
- });
|
|
|
- },
|
|
|
),
|
|
|
Positioned(
|
|
|
top: 0,
|
|
|
@@ -151,7 +165,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
itemCount: lineList.length,
|
|
|
itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
|
|
|
if (index < lineList.length) {
|
|
|
- return _lineWidget(lineList[index],index,checkStatusList[index]);
|
|
|
+ return _lineWidget(lineList[index], index, checkStatusList[index]);
|
|
|
}
|
|
|
},
|
|
|
),
|
|
|
@@ -164,7 +178,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _lineWidget(LineObj lineObj,int index,bool checked) {
|
|
|
+ Widget _lineWidget(LineObj lineObj, int index, bool checked) {
|
|
|
return InkWell(
|
|
|
child: Container(
|
|
|
height: ScreenUtil.getInstance().setHeight(80),
|
|
|
@@ -175,7 +189,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
children: < Widget > [
|
|
|
Padding(
|
|
|
padding: EdgeInsets.only(right: 10),
|
|
|
- child:checked?Icon(Icons.check, color: Colors.white, ):Icon(Icons.check, color: Color.fromRGBO(0, 0, 0, 0.0) ),
|
|
|
+ child: checked ? Icon(Icons.check, color: Colors.white, ) : Icon(Icons.check, color: Color.fromRGBO(0, 0, 0, 0.0)),
|
|
|
),
|
|
|
Expanded(
|
|
|
flex: 1,
|
|
|
@@ -186,7 +200,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
- onTap: (){
|
|
|
+ onTap: () {
|
|
|
setState(() {
|
|
|
checkStatusList[index] = !checked;
|
|
|
});
|
|
|
@@ -220,22 +234,20 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
}
|
|
|
|
|
|
Future < Null > _onRefresh() async {
|
|
|
- await getOrderList().then((resp) {
|
|
|
- setState(() {
|
|
|
- listObj = resp.orderList;
|
|
|
+ getKey('stationId').then((value) {
|
|
|
+ getOrderList(value, lineIdStr, 1).then((resp) {
|
|
|
+ setState(() {
|
|
|
+ orderList = resp.data.items;
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
void deleteOrder(val) {
|
|
|
setState(() {
|
|
|
- listObj.removeAt(val);
|
|
|
- if (listObj.length < 4) {
|
|
|
- getOrderList().then((resp) {
|
|
|
- setState(() {
|
|
|
- listObj.addAll(resp.orderList);
|
|
|
- });
|
|
|
- });
|
|
|
+ orderList.removeAt(val);
|
|
|
+ if (orderList.length < 4) {
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -295,9 +307,9 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
|
|
|
child: Column(
|
|
|
children: < Widget > [
|
|
|
orderNoRow(widget.order.orderNo, widget.order.createTime),
|
|
|
- orderAddress(widget.order.startAddress, widget.order.endAddress),
|
|
|
- orderItem('货物名称', widget.order.itemName, 15),
|
|
|
- orderItem('货物件数', '${widget.order.itemNo}件', 30),
|
|
|
+ orderAddress(widget.order.receiptCompanyName, widget.order.sendCompanyName),
|
|
|
+ orderItem('货物名称', widget.order.goods, 15),
|
|
|
+ orderItem('货物件数', '${widget.order.goodsQuantity}件', 30),
|
|
|
orderCutLine(),
|
|
|
orderBtn(context, animationStatus, controller, str),
|
|
|
AnimatedOpen(animation: animation, openInfo: widget.order, )
|
|
|
@@ -394,14 +406,14 @@ class AnimatedOpen extends AnimatedWidget {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
-Widget orderNoRow(int orderNo, String createTime) { //订单号及时间
|
|
|
+Widget orderNoRow(String orderNo, int createTime) { //订单号及时间
|
|
|
return Container(
|
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: < Widget > [
|
|
|
Text("订单号:${orderNo}", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
|
|
|
- Text(createTime, style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
|
|
|
+ Text('${createTime}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
@@ -430,10 +442,10 @@ Widget orderDetailInfo(OrderList obj) { //卡片展开信息
|
|
|
child: Wrap(
|
|
|
children: < Widget > [
|
|
|
orderCutLine(),
|
|
|
- orderPhone('发件电话', obj.sendPhone, 15),
|
|
|
- orderItem('发件地址', obj.sendAddress, 30),
|
|
|
- orderPhone('收件电话', obj.getPhone, 15),
|
|
|
- orderItem('收件地址', obj.getAddress, 30),
|
|
|
+ orderPhone('发件电话', obj.sendCompanyPhone, 15),
|
|
|
+ orderItem('发件地址', obj.sendCompanyAddress, 30),
|
|
|
+ orderPhone('收件电话', obj.receiptCompanyPhone, 15),
|
|
|
+ orderItem('收件地址', obj.receiptCompanyAddress, 30),
|
|
|
],
|
|
|
)
|
|
|
);
|