删除修改功能添加

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

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

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

Loading…
Cancel
Save