记录下拉问题修复

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

View File

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

View File

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

View File

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