工单管理tab切换内容覆盖

master
戴余标 3 years ago
parent c55216d90c
commit 4511f94d23

@ -1,5 +1,6 @@
import 'package:aku_new_community_manager/const/saas_api.dart'; import 'package:aku_new_community_manager/const/saas_api.dart';
import 'package:aku_new_community_manager/new_ui/work_order/distributor/distributor_card.dart'; import 'package:aku_new_community_manager/new_ui/work_order/distributor/distributor_card.dart';
import 'package:aku_new_community_manager/new_ui/work_order/distributor/work_order_distributor_view.dart';
import 'package:aku_new_community_manager/saas_models/work_order/work_order_list_model.dart'; import 'package:aku_new_community_manager/saas_models/work_order/work_order_list_model.dart';
import 'package:aku_new_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_new_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_new_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:aku_new_community_manager/ui/widgets/inner/aku_tab_bar.dart';
@ -32,20 +33,20 @@ class _WorkOrderDistributorPageState extends State<WorkOrderDistributorPage>
'已取消' '已取消'
]; ];
late TabController _tabController; late TabController _tabController;
EasyRefreshController _refreshController = EasyRefreshController(); List<EasyRefreshController> _refreshControllers = [];
int _page = 1;
int _size = 10;
List<WorkOrderListModel> _models = [];
@override @override
void initState() { void initState() {
_refreshControllers = List.filled(_tabs.length, EasyRefreshController());
_tabController = TabController(length: _tabs.length, vsync: this); _tabController = TabController(length: _tabs.length, vsync: this);
super.initState(); super.initState();
} }
@override @override
void dispose() { void dispose() {
_refreshController.dispose(); _refreshControllers.forEach((element) {
element.dispose();
});
_tabController.dispose(); _tabController.dispose();
super.dispose(); super.dispose();
} }
@ -73,51 +74,8 @@ class _WorkOrderDistributorPageState extends State<WorkOrderDistributorPage>
body: TabBarView( body: TabBarView(
controller: _tabController, controller: _tabController,
children: children:
_tabs.mapIndexed((e, index) => _getOrderView(index)).toList()), _tabs.mapIndexed((e, index) => WorkOrderDistributorView(refreshController: _refreshControllers[index], index: index,
)).toList()),
); );
} }
Widget _getOrderView(int index) {
return EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
_page = 1;
var base = await NetUtil().getList(SAASAPI.workOrder.list, params: {
'pageNum': _page,
'size': _size,
'status': index == 0 ? null : index,
});
_models =
base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList();
setState(() {});
},
onLoad: () async {
_page++;
var base = await NetUtil().getList(SAASAPI.workOrder.list, params: {
'pageNum': _page,
'size': _size,
'status': index == 0 ? null : index,
});
if (_models.length < base.total) {
_models.addAll(
base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList());
setState(() {});
} else {
_refreshController.finishLoad();
}
},
child: ListView.separated(
padding: EdgeInsets.all(24.w),
itemBuilder: (context, index) {
return DistributorCard(
model: _models[index],
refresh: _refreshController.callRefresh,
);
},
separatorBuilder: (context, index) {
return 24.w.heightBox;
},
itemCount: _models.length));
}
} }

@ -0,0 +1,69 @@
import 'package:aku_new_community_manager/style/app_style.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:velocity_x/velocity_x.dart';
import '../../../const/saas_api.dart';
import '../../../saas_models/work_order/work_order_list_model.dart';
import '../../../utils/network/net_util.dart';
import 'distributor_card.dart';
class WorkOrderDistributorView extends StatefulWidget {
final EasyRefreshController refreshController;
final int index;
const WorkOrderDistributorView({Key? key, required this.refreshController, required this.index}) : super(key: key);
@override
_WorkOrderDistributorViewState createState() => _WorkOrderDistributorViewState();
}
class _WorkOrderDistributorViewState extends State<WorkOrderDistributorView> {
int _page = 1;
int _size = 10;
List<WorkOrderListModel> _models = [];
@override
Widget build(BuildContext context) {
return EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
_page = 1;
var base = await NetUtil().getList(SAASAPI.workOrder.list, params: {
'pageNum': _page,
'size': _size,
'status': widget.index == 0 ? null : widget.index,
});
_models =
base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList();
setState(() {});
},
onLoad: () async {
_page++;
var base = await NetUtil().getList(SAASAPI.workOrder.list, params: {
'pageNum': _page,
'size': _size,
'status': widget.index == 0 ? null : widget.index,
});
if (_models.length < base.total) {
_models.addAll(
base.rows.map((e) => WorkOrderListModel.fromJson(e)).toList());
setState(() {});
} else {
widget.refreshController.finishLoad();
}
},
child: ListView.separated(
padding: EdgeInsets.all(24.w),
itemBuilder: (context, index) {
return DistributorCard(
model: _models[index],
refresh: widget.refreshController.callRefresh,
);
},
separatorBuilder: (context, index) {
return 24.w.heightBox;
},
itemCount: _models.length));
}
}

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
import '../../../models/message/notice_model.dart'; import '../../../models/message/notice_model.dart';
import 'announce_view.dart'; import 'announce_view.dart';

Loading…
Cancel
Save