记录下拉问题修复

This commit is contained in:
“DaisyWu” 2024-07-10 13:56:10 +08:00
parent 834fdc80d7
commit 4e7bbfa139
4 changed files with 78 additions and 53 deletions

View File

@ -29,6 +29,7 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
Future<void> loadBuyRecordList(bool load) async { Future<void> loadBuyRecordList(bool load) async {
if (!load) { if (!load) {
buyPageNo = 1; buyPageNo = 1;
state.buyRecordList.clear();
} }
final UseRecordListEntity entity = await ApiRepository.to.getBuyRecordList( final UseRecordListEntity entity = await ApiRepository.to.getBuyRecordList(
type: type, type: type,
@ -36,11 +37,16 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
pageNo: buyPageNo, pageNo: buyPageNo,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if (load) { if (pageNo == 1) {
state.buyRecordList.addAll(entity.data!.recordList!);
} else {
state.buyRecordList.value = entity.data!.recordList!; state.buyRecordList.value = entity.data!.recordList!;
pageNo++;
} else {
if (entity.data!.recordList!.isNotEmpty) {
state.buyRecordList.value.addAll(entity.data!.recordList!);
pageNo++;
}
} }
state.buyRecordList.refresh(); state.buyRecordList.refresh();
} }
@ -51,16 +57,21 @@ class ValueAddedServicesRecordLogic extends BaseGetXController {
Future<void> loadUseRecordList(bool load) async { Future<void> loadUseRecordList(bool load) async {
if (!load) { if (!load) {
usePageNo = 1; usePageNo = 1;
state.useRecordList.clear();
} }
final UseRecordListEntity entity = await ApiRepository.to.getUseRecordList( final UseRecordListEntity entity = await ApiRepository.to.getUseRecordList(
type: type, type: type,
pageNo: buyPageNo, pageNo: buyPageNo,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if (load) { if (pageNo == 1) {
state.useRecordList.addAll(entity.data!.recordList!);
} else {
state.useRecordList.value = entity.data!.recordList!; state.useRecordList.value = entity.data!.recordList!;
pageNo++;
} else {
if (entity.data!.recordList!.isNotEmpty) {
state.useRecordList.value.addAll(entity.data!.recordList!);
pageNo++;
}
} }
state.useRecordList.refresh(); state.useRecordList.refresh();
} }

View File

@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/use_record_list_entity.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart'; import 'package:star_lock/mine/valueAddedServices/valueAddedServicesRecord/value_added_services_record_logic.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/noData.dart'; import 'package:star_lock/tools/noData.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
import '../../../tools/titleAppBar.dart'; import '../../../tools/titleAppBar.dart';
@ -75,7 +76,7 @@ class _PurchaseRecords extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EasyRefresh( return EasyRefreshTool(
onRefresh: () async { onRefresh: () async {
logic.loadBuyRecordList(false); logic.loadBuyRecordList(false);
}, },
@ -138,7 +139,7 @@ class _UseRecordsTable extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return EasyRefresh( return EasyRefreshTool(
onRefresh: () async { onRefresh: () async {
logic.loadUseRecordList(false); logic.loadUseRecordList(false);
}, },

View File

@ -23,49 +23,54 @@ class NewSMSTemplatePage extends StatefulWidget {
class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> { class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
final NewSMSTemplateLogic logic = Get.put(NewSMSTemplateLogic()); final NewSMSTemplateLogic logic = Get.put(NewSMSTemplateLogic());
final NewSMSTemplateState state = Get.find<NewSMSTemplateLogic>().state; final NewSMSTemplateState state = Get.find<NewSMSTemplateLogic>().state;
final FocusNode focusNode = FocusNode();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, resizeToAvoidBottomInset: false,
appBar: TitleAppBar( backgroundColor: AppColors.mainBackgroundColor,
barTitle: state.isUpdate.value == false appBar: TitleAppBar(
? state.channelType.value == 1 barTitle: state.isUpdate.value == false
? '新建短信模版'.tr ? state.channelType.value == 1
: '新建邮件模版'.tr ? '新建短信模版'.tr
: state.channelType.value == 1 : '新建邮件模版'.tr
? '编辑短信模版'.tr : state.channelType.value == 1
: '编辑邮件模版'.tr, ? '编辑短信模版'.tr
haveBack: true, : '编辑邮件模版'.tr,
backgroundColor: AppColors.mainColor, haveBack: true,
), backgroundColor: AppColors.mainColor,
body: SingleChildScrollView(
child: Column(
children: <Widget>[
_buildEditTopInfo(),
SizedBox(height: 10.h),
_buildEditTemplate(),
SizedBox(height: 10.h),
_buildPreView(),
SizedBox(height: 42.h),
Container(
margin: EdgeInsets.symmetric(horizontal: 20.w),
child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.save!.tr,
onClick: () {
if (state.currentTemplate.value.isUpdate == true) {
logic.updateTemplateInfo();
} else {
logic.addSMSTemplate();
}
},
),
),
SizedBox(height: 40.h),
],
), ),
), body: GestureDetector(
); onTap: () {
FocusScope.of(context).unfocus();
},
child: SingleChildScrollView(
child: Column(
children: <Widget>[
_buildEditTopInfo(),
SizedBox(height: 10.h),
_buildEditTemplate(),
SizedBox(height: 10.h),
_buildPreView(),
SizedBox(height: 42.h),
Container(
margin: EdgeInsets.symmetric(horizontal: 20.w),
child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.save!.tr,
onClick: () {
if (state.currentTemplate.value.isUpdate == true) {
logic.updateTemplateInfo();
} else {
logic.addSMSTemplate();
}
},
),
),
SizedBox(height: 40.h),
],
),
)));
} }
Widget _buildEditTopInfo() { Widget _buildEditTopInfo() {
@ -123,7 +128,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
Container( Container(
margin: EdgeInsets.symmetric(horizontal: 25.w, vertical: 25.h), margin: EdgeInsets.symmetric(horizontal: 25.w, vertical: 25.h),
height: 100, height: 100,
child: _buildTextField(state.templateOneTf), child: _buildContentTF(state.templateOneTf),
), ),
Obx(() => Container( Obx(() => Container(
width: 1.sw - 50.w, width: 1.sw - 50.w,
@ -138,7 +143,7 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
child: Stack( child: Stack(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
children: <Widget>[ children: <Widget>[
_buildTextField(state.templateTwoTf), _buildContentTF(state.templateTwoTf),
], ],
), ),
) )
@ -166,8 +171,6 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
), ),
Obx(() => Container( Obx(() => Container(
width: 1.sw - 50.w, width: 1.sw - 50.w,
// margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 20.h),
// padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h),
margin: EdgeInsets.only(left: 25.w, right: 25.w), margin: EdgeInsets.only(left: 25.w, right: 25.w),
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h), padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -216,12 +219,13 @@ class _NewSMSTemplatePageState extends State<NewSMSTemplatePage> {
} }
} }
Widget _buildTextField(TextEditingController controller) { Widget _buildContentTF(TextEditingController controller) {
return TextField( return TextField(
maxLines: 8, maxLines: 8,
textAlign: TextAlign.start, textAlign: TextAlign.start,
controller: controller, controller: controller,
style: state.defaultStyle, style: state.defaultStyle,
autofocus: false,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.all(20.w), contentPadding: EdgeInsets.all(20.w),
border: OutlineInputBorder( border: OutlineInputBorder(

View File

@ -24,8 +24,17 @@ class CustomSMSTemplateListLogic extends BaseGetXController {
pageNo: pageNo, pageNo: pageNo,
pageSize: int.parse(pageSize)); pageSize: int.parse(pageSize));
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.smsTemplateList.value = if (pageNo == 1) {
entity.data?.list ?? <CustomSMSTemplateItem>[]; state.smsTemplateList.value =
entity.data?.list ?? <CustomSMSTemplateItem>[];
pageNo++;
} else {
if (state.smsTemplateList.isNotEmpty) {
state.smsTemplateList
.addAll(entity.data?.list ?? <CustomSMSTemplateItem>[]);
pageNo++;
}
}
state.smsTemplateList.refresh(); state.smsTemplateList.refresh();
} }
} }