123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
- import 'package:liftmanager/internal/wode/model/piao_tou_model.dart';
- import 'package:liftmanager/internal/wode/presenter/piao_tou_list_presenter.dart';
- import 'package:liftmanager/internal/wode/wode_router.dart';
- import 'package:liftmanager/mvp/base_page_state.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/utils/fast_notification.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/my_refresh_list.dart';
- import 'package:liftmanager/widgets/state_layout.dart';
- import 'package:provider/provider.dart';
- import 'package:umeng_common_sdk/umeng_common_sdk.dart';
- class Piaotou extends StatefulWidget {
- Piaotou(this.checkTou, this.type);
- final String checkTou;
- final String type;
- @override
- PiaotouState createState() => PiaotouState();
- }
- class PiaotouState extends BasePageState<Piaotou, PiaotouListPresenter> {
- BaseListProvider<Records> provider = BaseListProvider<Records>();
- int _page = 1;
- @override
- void initState() {
- UmengCommonSdk.onPageStart("发票抬头");
- provider.setStateTypeNotNotify(StateType.loading);
- super.initState();
- _onRefresh();
- print("tou6666");
- FastNotification.addListener("initThis", (initThisString) {
- setState(() {});
- _onRefresh();
- });
- }
- @override
- void dispose() {
- UmengCommonSdk.onPageEnd("发票抬头");
- // TODO: implement dispose
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- double height = MediaQuery.of(context).size.height;
- return ChangeNotifierProvider<BaseListProvider<Records>>(
- create: (_) => provider,
- child: Scaffold(
- // resizeToAvoidBottomPadding: true,
- appBar: MyAppBar(
- centerTitle: "发票抬头",
- ),
- body: Container(
- color: Color(0xFFF6F6F6),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- widget.checkTou != "checkTou"
- ? GestureDetector(
- onTap: () {
- NavigatorUtils.push(context,
- "${WodeRouter.piaotouEdit}?type=add&id=");
- },
- child: Container(
- color: ThemeUtils.getDialogTextFieldColor(context),
- width: width,
- padding: EdgeInsets.only(
- left: ScreenUtil().setWidth(15),
- right: ScreenUtil().setWidth(15),
- top: ScreenUtil().setWidth(10),
- bottom: ScreenUtil().setWidth(10)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text(
- "添加发票抬头",
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(15),
- ),
- ),
- Icon(
- Icons.keyboard_arrow_right,
- color: Color(0xffcccccc),
- ),
- ]),
- ),
- )
- : Container(
- child: null,
- ),
- Expanded(
- flex: 1,
- child: Consumer<BaseListProvider<Records>>(
- builder: (_, provider, __) {
- return MyListView(
- key: Key('piao_tou_list'),
- itemCount: provider.list.length,
- stateType: provider.stateType,
- onRefresh: _onRefresh,
- loadMore: _loadMore,
- pageSize: 10,
- hasMore: provider.hasMore,
- itemBuilder: (_, index) {
- return Container(
- // height: 20,
- padding: EdgeInsets.only(
- left: 10, bottom: 15, top: 15, right: 10),
- margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius:
- BorderRadius.all(Radius.circular(5.0)),
- ),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- print(456);
- if (widget.checkTou == "checkTou") {
- Navigator.pop(context);
- dynamic piaoTouObj = provider.list[index];
- FastNotification.push(
- "piaoTou", piaoTouObj);
- } else {
- NavigatorUtils.push(context,
- "${WodeRouter.piaotouEdit}?type=edit&id=${provider.list[index].id.toString()}");
- }
- },
- child: Column(
- children: [
- Row(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- children: <Widget>[
- Text(
- provider.list[index].name ?? "",
- style: TextStyle(
- color: Color(0xff333333),
- fontSize:
- ScreenUtil().setSp(15)),
- textAlign: TextAlign.start,
- ),
- provider.list[index].isDefault == 1
- ? Container(
- margin:
- EdgeInsets.only(left: 10),
- padding: EdgeInsets.only(
- left: 5, right: 5),
- decoration: BoxDecoration(
- color:
- Colours.blue_app_main,
- borderRadius:
- BorderRadius.all(
- Radius.circular(
- 5.0)),
- ),
- child: Text(
- "默认",
- style: TextStyle(
- color: Colors.white,
- fontSize: ScreenUtil()
- .setSp(13)),
- textAlign: TextAlign.start,
- ),
- )
- : Container(child: null)
- ]),
- Row(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- children: <Widget>[
- Text(
- "发票类型:",
- style: TextStyle(
- color: Color(0xff999999),
- fontSize:
- ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- Container(
- padding: EdgeInsets.only(left: 5),
- child: Text(
- provider.list[index].type == 1
- ? "个人"
- : "公司",
- style: TextStyle(
- color: Color(0xff999999),
- fontSize:
- ScreenUtil().setSp(14)),
- textAlign: TextAlign.start,
- ),
- )
- ]),
- provider.list[index].type == 2
- ? Row(
- // crossAxisAlignment:
- // CrossAxisAlignment.center,
- // mainAxisAlignment:
- // MainAxisAlignment.center,
- children: <Widget>[
- Text(
- "税号:",
- style: TextStyle(
- color: Color(0xff999999),
- fontSize: ScreenUtil()
- .setSp(14)),
- textAlign: TextAlign.start,
- ),
- Container(
- padding:
- EdgeInsets.only(left: 5),
- child: Text(
- provider.list[index]
- .enterpriseNumber ??
- "",
- style: TextStyle(
- color:
- Color(0xff999999),
- fontSize: ScreenUtil()
- .setSp(14)),
- textAlign: TextAlign.start,
- ),
- )
- ])
- : Container(),
- Row(
- crossAxisAlignment:
- CrossAxisAlignment.end,
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- InkWell(
- onTap: () {
- showAlert(
- context,
- "提示",
- "确定要删除吗?",
- "确定",
- () {
- Navigator.pop(context);
- showLoading(
- context, "正在删除...");
- getTouDelete(provider
- .list[index].id
- .toString());
- },
- txt2: "取消",
- onPre2: () {
- NavigatorUtils.goBack(
- context);
- });
- },
- child: Container(
- padding: EdgeInsets.fromLTRB(
- 8, 1, 8, 1),
- decoration: BoxDecoration(
- border: new Border.all(
- width: 1,
- color: Colors.black),
- color: Colors.white,
- borderRadius: BorderRadius.all(
- Radius.circular(18.0)),
- ),
- child: Text('删除'),
- )),
- SizedBox(
- width: 10,
- ),
- InkWell(
- onTap: () {
- NavigatorUtils.push(context,
- "${WodeRouter.piaotouEdit}?type=edit&id=${provider.list[index].id.toString()}");
- },
- child: Container(
- padding:
- EdgeInsets.fromLTRB(8, 1, 8, 1),
- decoration: BoxDecoration(
- border: new Border.all(
- width: 1,
- color: Colors.black),
- color: Colors.white,
- borderRadius: BorderRadius.all(
- Radius.circular(18.0)),
- ),
- child: Text('编辑'),
- ),
- )
- ],
- )
- ],
- ),
- )
- // Row(
- // crossAxisAlignment: CrossAxisAlignment.start,
- // children: <Widget>[
- // Expanded(
- // child: GestureDetector(
- // behavior: HitTestBehavior.opaque,
- // onTap: () {
- // print(456);
- // if (widget.checkTou == "checkTou") {
- // Navigator.pop(context);
- // dynamic piaoTouObj = provider.list[index];
- // FastNotification.push(
- // "piaoTou", piaoTouObj);
- // } else {
- // NavigatorUtils.push(context,
- // "${WodeRouter.piaotouEdit}?type=edit&id=${provider.list[index].id.toString()}");
- // }
- // },
- // child: Row(
- // crossAxisAlignment:
- // CrossAxisAlignment.start,
- // children: <Widget>[
- // Expanded(
- // child: Container(
- // padding: EdgeInsets.only(
- // right: 15, left: 15),
- // child: Column(
- // children: <Widget>[
- // Container(
- // child: Row(
- // mainAxisAlignment:
- // MainAxisAlignment
- // .spaceBetween,
- // children: <Widget>[
- // Row(
- // crossAxisAlignment:
- // CrossAxisAlignment
- // .center,
- // children: <
- // Widget>[
- // Text(
- // provider
- // .list[
- // index]
- // .name ??
- // "",
- // style: TextStyle(
- // color: Color(
- // 0xff333333),
- // fontSize:
- // ScreenUtil()
- // .setSp(15)),
- // textAlign:
- // TextAlign
- // .start,
- // ),
- // provider.list[index].isDefault ==
- // 1
- // ? Container(
- // padding:
- // EdgeInsets.only(left: 5),
- // child:
- // Text(
- // "(默认)",
- // style: TextStyle(
- // color: Color(0xffff0000),
- // fontSize: ScreenUtil().setSp(15)),
- // textAlign:
- // TextAlign.start,
- // ),
- // )
- // : Container(
- // child:
- // null)
- // ]),
- // widget.checkTou !=
- // "checkTou"
- // ? Icon(
- // const IconData(
- // 0xe626,
- // fontFamily:
- // "myfont"),
- // size: 18.0,
- // color: Color(
- // 0xff666666),
- // )
- // : Container(
- // child: null,
- // ),
- // // Text("123")
- // ])),
- // Container(
- // child: Row(
- // mainAxisAlignment:
- // MainAxisAlignment
- // .spaceBetween,
- // children: <Widget>[
- // Row(
- // crossAxisAlignment:
- // CrossAxisAlignment
- // .center,
- // children: <
- // Widget>[
- // Text(
- // "发票类型:",
- // style: TextStyle(
- // color: Color(
- // 0xff999999),
- // fontSize:
- // ScreenUtil()
- // .setSp(14)),
- // textAlign:
- // TextAlign
- // .start,
- // ),
- // Container(
- // padding: EdgeInsets
- // .only(
- // left:
- // 5),
- // child: Text(
- // provider.list[index].type ==
- // 1
- // ? "个人"
- // : "公司",
- // style: TextStyle(
- // color: Color(
- // 0xff999999),
- // fontSize:
- // ScreenUtil().setSp(14)),
- // textAlign:
- // TextAlign
- // .start,
- // ),
- // )
- // ]),
- // ])),
- // provider.list[index].type ==
- // 2
- // ? Container(
- // child: Row(
- // mainAxisAlignment:
- // MainAxisAlignment
- // .spaceBetween,
- // children: <
- // Widget>[
- // Row(
- // crossAxisAlignment:
- // CrossAxisAlignment
- // .center,
- // mainAxisAlignment:
- // MainAxisAlignment
- // .center,
- // children: <
- // Widget>[
- // Text(
- // "税号:",
- // style: TextStyle(
- // color:
- // Color(0xff999999),
- // fontSize: ScreenUtil().setSp(14)),
- // textAlign:
- // TextAlign.start,
- // ),
- // Container(
- // padding:
- // EdgeInsets.only(left: 5),
- // child:
- // Text(
- // provider.list[index].enterpriseNumber ??
- // "",
- // style: TextStyle(
- // color: Color(0xff999999),
- // fontSize: ScreenUtil().setSp(14)),
- // textAlign:
- // TextAlign.start,
- // ),
- // )
- // ]),
- // ]))
- // : Container(
- // child: null),
- // ],
- // )))
- // ]),
- // )),
- // ],
- // ),
- );
- },
- );
- }))
- ],
- ),
- ),
- ));
- }
- Future _onRefresh() async {
- _page = 1;
- await presenter.getList(
- _page,
- widget.type != null && widget.type != ""
- ? int.parse(widget.type)
- : null);
- }
- Future _loadMore() async {
- _page++;
- await presenter.getList(
- _page,
- widget.type != null && widget.type != ""
- ? int.parse(widget.type)
- : null);
- }
- Future getTouDelete(id) async {
- await NewApiService().getTouDelete(int.parse(id), onSuccess: (res) {
- toasts("删除成功");
- String initThisString = randomInt(1111, 9999).toString() +
- DateTime.now().millisecondsSinceEpoch.toString();
- FastNotification.push("initThis", initThisString);
- Navigator.of(context).pop();
- // setState(() {});
- // _onRefresh();
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- PiaotouListPresenter createPresenter() {
- return PiaotouListPresenter();
- }
- }
|