project_detail_page.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:keyboard_actions/keyboard_actions.dart';
  5. import 'package:liftmanager/common/common.dart';
  6. import 'package:liftmanager/internal/project/model/project_list_entity.dart';
  7. import 'package:liftmanager/internal/project/project_router.dart';
  8. import 'package:liftmanager/net/api_service.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/app_bar.dart';
  11. import 'package:liftmanager/widgets/click_item.dart';
  12. import 'package:oktoast/oktoast.dart';
  13. class ProjectDetailPage extends StatefulWidget {
  14. ProjectDetailPage(this.id);
  15. final String id;
  16. @override
  17. State<StatefulWidget> createState() {
  18. return ProjectDetailPageState();
  19. }
  20. }
  21. class ProjectDetailPageState extends State<ProjectDetailPage> {
  22. bool _hasData = false;
  23. ProjectListItem item;
  24. @override
  25. void initState() {
  26. super.initState();
  27. _getProjectDetail();
  28. }
  29. ///获取项目详情
  30. _getProjectDetail() {
  31. ApiService(context: context).projectDetail(widget.id, onSuccess: (data) {
  32. if (data != null) {
  33. _hasData = true;
  34. item = data;
  35. setState(() {});
  36. }
  37. }, onError: (code, msg) {
  38. showToast(msg);
  39. });
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. return Scaffold(
  44. appBar: MyAppBar(
  45. centerTitle: "项目详情",
  46. ),
  47. body: SafeArea(
  48. child: Column(
  49. children: <Widget>[
  50. Expanded(
  51. flex: 1,
  52. child: _hasData
  53. ? defaultTargetPlatform == TargetPlatform.iOS
  54. ? FormKeyboardActions(child: _buildBody())
  55. : SingleChildScrollView(child: _buildBody())
  56. : Center(
  57. child: Text("正在加载..."),
  58. ),
  59. )
  60. ],
  61. ),
  62. ),
  63. );
  64. }
  65. _buildBody() {
  66. return Column(
  67. crossAxisAlignment: CrossAxisAlignment.start,
  68. children: <Widget>[
  69. ClickItem(
  70. title: "项目名称",
  71. content: "${item?.projectName}",
  72. ),
  73. ClickItem(
  74. title: "项目用途",
  75. content: "${Constant.projectUsageText[item?.projectUsage]}",
  76. ),
  77. ClickItem(
  78. title: "项目地址",
  79. content: "${item?.address}",
  80. ),
  81. ClickItem(
  82. title: "项目台量",
  83. content: "${item?.actualNum}",
  84. ),
  85. ClickItem(
  86. title: "行政区域",
  87. content: "${item?.province}-${item?.city}-${item?.district}",
  88. ),
  89. ClickItem(
  90. title: "区域",
  91. content: "${item?.areaName}",
  92. ),
  93. ClickItem(
  94. title: "区域主管",
  95. content: "${item?.areaDirector}",
  96. ),
  97. ClickItem(
  98. title: "文员",
  99. content: "${item?.clerkName}",
  100. ),
  101. ClickItem(
  102. title: "项目开始时间",
  103. content: "${item?.startDate}",
  104. ),
  105. ClickItem(
  106. title: "项目结束时间",
  107. content: "${item?.endDate}",
  108. ),
  109. ClickItem(
  110. title: "甲方公司",
  111. content: "${item?.companyName}",
  112. ),
  113. ClickItem(
  114. title: "甲方联系人",
  115. content: "${item?.companyContact}",
  116. ),
  117. ClickItem(
  118. title: "甲方联系人电话",
  119. content: "${item?.telephone}",
  120. ),
  121. ClickItem(
  122. title: "维保人员",
  123. content: "",
  124. onTap: (){
  125. NavigatorUtils.push(context, "${ProjectRouter.projectUsersPage}?id=${widget.id}&type=0");
  126. },
  127. )
  128. ],
  129. );
  130. }
  131. }