view_new.dart 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vnoteapp/components/cell.dart';
  5. import 'package:vnoteapp/components/checkbox_button.dart';
  6. import 'package:vnoteapp/components/dialog_input.dart';
  7. import 'package:vnoteapp/components/dialog_select.dart';
  8. import 'package:vnoteapp/components/dynamic_drawer.dart.dart';
  9. import 'package:vnoteapp/pages/controllers/crowd_labels.dart';
  10. import 'package:vnoteapp/pages/patient/create/controller.dart';
  11. class CreatePatientPageNew extends GetView<CreatePatientController> {
  12. const CreatePatientPageNew({super.key});
  13. @override
  14. Widget build(BuildContext context) {
  15. return Stack(
  16. children: [
  17. Scrollbar(
  18. thumbVisibility: true,
  19. child: SingleChildScrollView(
  20. child: Container(
  21. alignment: Alignment.topCenter,
  22. margin: const EdgeInsets.only(bottom: 24),
  23. child: SizedBox(
  24. width: 800,
  25. child: Column(
  26. children: [
  27. _AreaPanel(),
  28. const SizedBox(height: 12),
  29. _PatientInfoPanel(),
  30. const SizedBox(height: 12),
  31. _AddressPanel(),
  32. const SizedBox(height: 12),
  33. _CrowdLabelPanel(),
  34. ],
  35. ),
  36. ),
  37. ),
  38. ),
  39. ),
  40. Positioned(
  41. top: 20,
  42. right: 20,
  43. child: SizedBox(
  44. width: 90,
  45. height: 90,
  46. child: ElevatedButton(
  47. style: ButtonStyle(
  48. shape: MaterialStatePropertyAll(
  49. RoundedRectangleBorder(
  50. borderRadius: BorderRadius.circular(45),
  51. side: BorderSide(color: Theme.of(context).primaryColor),
  52. ),
  53. ),
  54. ),
  55. onPressed: () {
  56. Get.snackbar(
  57. "提示",
  58. "此功能尚未开发",
  59. duration: const Duration(seconds: 2),
  60. );
  61. },
  62. child: const Text(
  63. "读卡",
  64. style: TextStyle(fontWeight: FontWeight.bold),
  65. ),
  66. ),
  67. ),
  68. ),
  69. ],
  70. );
  71. }
  72. }
  73. class _PatientInfoPanel extends GetView<CreatePatientController> {
  74. @override
  75. Widget build(BuildContext context) {
  76. return VListFormCellGroup(
  77. children: [
  78. VListFormCell(
  79. label: "证件类型",
  80. ),
  81. VListFormCell(
  82. label: "证件号",
  83. ),
  84. VListFormCell(
  85. label: "姓名",
  86. ),
  87. VListFormCell(
  88. label: "性别",
  89. ),
  90. VListFormCell(
  91. label: "民族",
  92. ),
  93. VListFormCell(
  94. label: "出生日期",
  95. ),
  96. VListFormCell(
  97. label: "年龄",
  98. ),
  99. VListFormCell(
  100. label: "手机号码",
  101. ),
  102. ],
  103. );
  104. }
  105. }
  106. class _AddressPanel extends GetView<CreatePatientController> {
  107. @override
  108. Widget build(BuildContext context) {
  109. return VListFormCellGroup(
  110. children: [
  111. VListFormCell(
  112. label: "同步户籍地址到现住地址",
  113. labelWidth: 250,
  114. contentWidget: Container(
  115. child: Obx(
  116. () => Switch(
  117. onChanged: (value) {
  118. controller.state.isSyncAddresses = value;
  119. },
  120. value: controller.state.isSyncAddresses,
  121. ),
  122. ),
  123. ),
  124. ),
  125. VListFormCell(
  126. label: "户籍地址",
  127. content: controller.state.censusRegister,
  128. onTap: () {},
  129. ),
  130. VListFormCell(
  131. label: "现住地址",
  132. content: controller.state.address,
  133. onTap: () {},
  134. ),
  135. ],
  136. );
  137. }
  138. }
  139. class _AreaPanel extends GetView<CreatePatientController> {
  140. @override
  141. Widget build(BuildContext context) {
  142. String area = "阳光社区";
  143. return VListFormCellGroup(
  144. children: [
  145. VListFormCell(
  146. label: "签约区域",
  147. content: "重庆市沙坪坝区童家桥街道",
  148. ),
  149. VListFormCell(
  150. label: "所在村",
  151. content: area,
  152. onTap: () async {
  153. final result = await VDialogSelect<String, String>(
  154. title: "选择签约所在村",
  155. source: const ["阳光社区", "磁器口社区", "烈士墓社区"],
  156. valueGetter: (data) => data,
  157. labelGetter: (data) => data,
  158. initialValue: area,
  159. ).show();
  160. if (result != null) {
  161. // TODO:
  162. area = result;
  163. }
  164. },
  165. ),
  166. ],
  167. );
  168. }
  169. }
  170. class _CrowdLabelPanel extends GetView<CrowdLabelsController> {
  171. final createController = Get.find<CreatePatientController>();
  172. @override
  173. Widget build(BuildContext context) {
  174. return VListFormCellGroup(
  175. children: [
  176. Obx(
  177. () => VListFormCell(
  178. label: "个人编号",
  179. content: createController.state.personalNo,
  180. onTap: () async {
  181. final result = await VDialogInput(
  182. title: "个人编号",
  183. initialValue: createController.state.personalNo,
  184. placeholder: "请填写个人编号",
  185. ).show();
  186. if (result != null) {
  187. createController.state.personalNo = result;
  188. }
  189. },
  190. ),
  191. ),
  192. VListFormCell(
  193. label: "人群分类",
  194. contentWidget: _buildContent(context),
  195. onTap: () {
  196. VDynamicDrawerWrapper.show(
  197. scaffoldKey: createController.homeScaffoldKey,
  198. builder: (_) => _buildDrawer(),
  199. );
  200. },
  201. ),
  202. ],
  203. );
  204. }
  205. Widget _buildDrawer() {
  206. final state = controller.state;
  207. List<String> selectedNormalCodes = state.selectedNormalCodes;
  208. List<String> selectedDiseaseCodes = state.selectedDiseaseCodes;
  209. List<String> selectedSpecialCareCodes = state.selectedSpecialCareCodes;
  210. final scrollController = ScrollController();
  211. return VDrawer(
  212. width: 600,
  213. title: "设置人群分类",
  214. scaffoldKey: createController.homeScaffoldKey,
  215. onConfirm: () {
  216. VDynamicDrawerWrapper.hide(
  217. scaffoldKey: createController.homeScaffoldKey,
  218. );
  219. state.selectedNormalCodes = selectedNormalCodes;
  220. state.selectedDiseaseCodes = selectedDiseaseCodes;
  221. state.selectedSpecialCareCodes = selectedSpecialCareCodes;
  222. },
  223. child: Scrollbar(
  224. controller: scrollController,
  225. thumbVisibility: true,
  226. child: SingleChildScrollView(
  227. controller: scrollController,
  228. child: Padding(
  229. padding: const EdgeInsets.symmetric(horizontal: 50),
  230. child: Column(
  231. children: [
  232. const SizedBox(height: 24),
  233. VCheckBoxButtonGroup<LabelDTO, String>(
  234. source: state.normalOptions,
  235. values: state.selectedNormalCodes,
  236. labelGetter: (LabelDTO data) => data.labelName!,
  237. valueGetter: (LabelDTO data) => data.code!,
  238. onChanged: (value) {
  239. selectedNormalCodes = value;
  240. },
  241. ),
  242. const SizedBox(height: 8),
  243. Divider(
  244. indent: 32,
  245. endIndent: 32,
  246. thickness: 1,
  247. color: Colors.grey.shade300,
  248. ),
  249. const SizedBox(height: 8),
  250. VCheckBoxButtonGroup<LabelDTO, String>(
  251. source: state.diseaseOptions,
  252. values: state.selectedDiseaseCodes,
  253. labelGetter: (LabelDTO data) => data.labelName!,
  254. valueGetter: (LabelDTO data) => data.code!,
  255. onChanged: (value) {
  256. selectedDiseaseCodes = value;
  257. },
  258. ),
  259. const SizedBox(height: 8),
  260. Divider(
  261. indent: 32,
  262. endIndent: 32,
  263. thickness: 1,
  264. color: Colors.grey.shade300,
  265. ),
  266. const SizedBox(height: 8),
  267. VCheckBoxButtonGroup<LabelDTO, String>(
  268. source: state.specialCareOptions,
  269. values: state.selectedSpecialCareCodes,
  270. labelGetter: (LabelDTO data) => data.labelName!,
  271. valueGetter: (LabelDTO data) => data.code!,
  272. onChanged: (value) {
  273. selectedSpecialCareCodes = value;
  274. },
  275. ),
  276. ],
  277. ),
  278. ),
  279. ),
  280. ),
  281. );
  282. }
  283. Widget _buildContent(BuildContext context) {
  284. return Obx(
  285. () {
  286. final themeData = Theme.of(context);
  287. final color = themeData.secondaryHeaderColor;
  288. final names = controller.state.selectedNames;
  289. const itemHeight = 32.0;
  290. const itemRadius = itemHeight / 2;
  291. final itemTextStyle = TextStyle(
  292. color: themeData.primaryColor,
  293. fontSize: 14,
  294. );
  295. return Wrap(
  296. spacing: 16,
  297. runSpacing: 16,
  298. children: names.map(
  299. (e) {
  300. return Container(
  301. height: itemHeight,
  302. alignment: Alignment.center,
  303. padding: const EdgeInsets.symmetric(horizontal: 12),
  304. decoration: BoxDecoration(
  305. color: color,
  306. border: Border.all(style: BorderStyle.none),
  307. borderRadius: BorderRadius.circular(itemRadius),
  308. ),
  309. child: Text(e, style: itemTextStyle),
  310. );
  311. },
  312. ).toList(),
  313. );
  314. },
  315. );
  316. }
  317. }