删除修改功能添加

master
王亚玲 2 years ago
parent 8a2b0bd307
commit 1e43a0090a

@ -10,24 +10,40 @@ import '../../../../utils/toast/cloud_toast.dart';
class ExcludeFunc { class ExcludeFunc {
// //
static Future<List<ExcludePhoneModel>> getContacts() async { static Future<List<ExcludePhoneModel>> getContacts() async {
BaseListModel res=await apiClient.requestList(API.exclude.find,); BaseListModel res = await apiClient.requestList(
if(res.code==0){ API.exclude.find,
return res.nullSafetyList.map((e) => ExcludePhoneModel.fromJson(e)).toList(); );
}else{ if (res.code == 0) {
CloudToast.show(res.msg); return res.nullSafetyList
return []; .map((e) => ExcludePhoneModel.fromJson(e))
.toList();
} else {
CloudToast.show(res.msg);
return [];
} }
} }
// //
static Future<bool> getContactsList(List numList) async{ static Future<bool> getContactsList(List numList) async {
BaseModel res=await apiClient.request(API.exclude.add,data: {"exclude":numList}); BaseModel res =
await apiClient.request(API.exclude.add, data: {"exclude": numList});
if (res.code == 0) {
return true;
} else {
CloudToast.show(res.msg);
return false;
}
}
static Future<bool> getUpdate(int id, String phone, String remark) async {
BaseModel res = await apiClient.request(API.exclude.update,
data: {"id": id, "phone": phone, "remark": remark});
if(res.code==0){ if(res.code==0){
return true; return true;
}else{ }else{
CloudToast.show(res.msg); CloudToast.show(res.msg);
return false; return false;
} }
}
}
} }

@ -27,7 +27,8 @@ class SpecifyPhonePage extends StatefulWidget {
class _SpecifyPhonePageState extends State<SpecifyPhonePage> { class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
final EasyRefreshController _refreshController = EasyRefreshController(); final EasyRefreshController _refreshController = EasyRefreshController();
List<ExcludePhoneModel> findList = []; List<ExcludePhoneModel> findList = [];
String name="";
String phone="";
@override @override
void dispose() { void dispose() {
_refreshController.dispose(); _refreshController.dispose();
@ -136,13 +137,13 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
_getNum() { _getNum() {
return ListView.builder( return ListView.builder(
itemBuilder: (context, index) { itemBuilder: (context, index) {
return _getNumContant(findList[index]); return _getNumContant(findList[index],findList[index].id);
}, },
itemCount: findList.length, itemCount: findList.length,
); );
} }
_getNumContant(ExcludePhoneModel item) { _getNumContant(ExcludePhoneModel item,int id) {
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 16.w), margin: EdgeInsets.symmetric(horizontal: 16.w),
child: ListTile( child: ListTile(
@ -181,7 +182,10 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
placeholderStyle: placeholderStyle:
const TextStyle(color: BaseStyle.color333333), const TextStyle(color: BaseStyle.color333333),
placeholder: item.remark, placeholder: item.remark,
onChanged: (value) {}, onChanged: (value) {
name=value;
setState(() {});
},
), ),
20.hb, 20.hb,
Text( Text(
@ -202,7 +206,10 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
// ), // ),
color: const Color(0xFFF9F9F9)), color: const Color(0xFFF9F9F9)),
placeholder: item.phone, placeholder: item.phone,
onChanged: (value) {}, onChanged: (value) {
phone=value;
setState(() {});
},
), ),
82.hb, 82.hb,
// _getUpdate("爸爸", "123123123"), // _getUpdate("爸爸", "123123123"),
@ -211,7 +218,12 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
border: true, border: true,
color1: const Color(0xFF1890FF), color1: const Color(0xFF1890FF),
color2: const Color(0xFF74BCFF), color2: const Color(0xFF74BCFF),
onTap: () {}, onTap: () async{
Navigator.pop(context);
var res=await ExcludeFunc.getUpdate(id, phone, item.remark.isEmpty?name:item.remark);
_refreshController.callRefresh();
print(res);
},
text: "保存", text: "保存",
) )
], ],
@ -222,7 +234,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
}); });
}, },
title: Text( title: Text(
item.phone, item.remark.isEmpty? item.phone:item.remark,
style: TextStyle( style: TextStyle(
fontSize: 32.sp, fontSize: 32.sp,
color: BaseStyle.color333333, color: BaseStyle.color333333,
@ -236,8 +248,9 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
side: MaterialStateProperty.all( side: MaterialStateProperty.all(
BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))), BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))),
onPressed: () async { onPressed: () async {
print(id);
var res = var res =
await apiClient.request(API.exclude.find, data: {item.id}); await apiClient.request(API.exclude.delete, data: {"id":id});
if (res.code == 0) { if (res.code == 0) {
_refreshController.callRefresh(); _refreshController.callRefresh();
CloudToast.show(res.msg); CloudToast.show(res.msg);

Loading…
Cancel
Save