view.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. import 'dart:convert';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:get/get.dart';
  5. import 'package:intl/intl.dart';
  6. import 'package:vnoteapp/components/alert_dialog.dart';
  7. import 'package:vnoteapp/components/appbar.dart';
  8. import 'package:vnoteapp/components/cell.dart';
  9. import 'package:vnoteapp/components/dialog_date.dart';
  10. import 'package:vnoteapp/components/panel.dart';
  11. import 'controller.dart';
  12. class ServicePackageContractPage
  13. extends GetView<ServicePackageContractController> {
  14. const ServicePackageContractPage({super.key});
  15. static const double labelSize = 20;
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
  20. appBar: VAppBar(
  21. titleWidget: const Text(
  22. "签约",
  23. style: TextStyle(fontSize: 24),
  24. ),
  25. actions: [
  26. TextButton(
  27. onPressed: () {
  28. Get.toNamed(
  29. "/contract/contract_template",
  30. parameters: {
  31. "templateCode": "53C3323BB6444A109B2369703EFFDFF9",
  32. "patientInfo": json.encode(controller.patient.toJson()),
  33. "servicePackageCodes":
  34. controller.state.selectedServicePackageCode,
  35. "servicePackageNames":
  36. controller.state.selectedServicePackageName,
  37. },
  38. );
  39. },
  40. child: const Text(
  41. '下一步',
  42. style: TextStyle(color: Colors.white, fontSize: 20),
  43. ),
  44. ),
  45. const SizedBox(
  46. width: 15,
  47. ),
  48. ],
  49. ),
  50. endDrawer: _servicePackageDrawer(context),
  51. body: Builder(builder: (context) {
  52. return Padding(
  53. padding: const EdgeInsets.symmetric(horizontal: 200, vertical: 8),
  54. child: ListView(
  55. children: [
  56. Column(
  57. children: [
  58. _buildPhotoVPanel(),
  59. const SizedBox(height: 16),
  60. _buildContractDoctorVPanel(),
  61. const SizedBox(height: 16),
  62. _buildPatientVPanel(),
  63. const SizedBox(height: 16),
  64. _buildServicePackageVPanel(context),
  65. ],
  66. ),
  67. ],
  68. ),
  69. );
  70. }),
  71. );
  72. }
  73. Drawer _servicePackageDrawer(BuildContext context) {
  74. const double titleSize = 20;
  75. const double labelSize = 18;
  76. Widget buildAlertDialog(ServicePackDTO servicePackDTO) {
  77. return VAlertDialog(
  78. title: '${servicePackDTO.name}详情',
  79. content: Container(
  80. height: 200,
  81. alignment: Alignment.topLeft,
  82. padding: const EdgeInsets.symmetric(horizontal: 15),
  83. child: Column(
  84. crossAxisAlignment: CrossAxisAlignment.start,
  85. children: [
  86. LayoutBuilder(
  87. builder: (BuildContext context, BoxConstraints constraints) {
  88. return ConstrainedBox(
  89. constraints: const BoxConstraints(
  90. maxHeight: 100,
  91. ),
  92. child: Scrollbar(
  93. thumbVisibility: true,
  94. child: ListView(
  95. shrinkWrap: true,
  96. children: [
  97. Text(
  98. servicePackDTO.content ?? "",
  99. style: const TextStyle(fontSize: 16),
  100. ),
  101. ],
  102. ),
  103. ),
  104. );
  105. },
  106. ),
  107. const SizedBox(
  108. height: 5,
  109. ),
  110. const Text(
  111. '服务项目',
  112. style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
  113. ),
  114. const SizedBox(
  115. height: 5,
  116. ),
  117. Expanded(
  118. child: Text(
  119. controller.getServiceItemsName(
  120. servicePackDTO.items ?? [],
  121. ),
  122. ),
  123. )
  124. ],
  125. )),
  126. // actions: <Widget>[
  127. // TextButton(
  128. // child: const Text('取消'),
  129. // onPressed: () {
  130. // Navigator.of(context).pop(); // 关闭对话框
  131. // },
  132. // ),
  133. // TextButton(
  134. // child: const Text('确定'),
  135. // onPressed: () {
  136. // // 在这里处理确定按钮的逻辑
  137. // Navigator.of(context).pop(); // 关闭对话框
  138. // },
  139. // ),
  140. // ],
  141. );
  142. }
  143. Widget buildItem(ServicePackDTO servicePackDTO) {
  144. return InkWell(
  145. onTap: () {
  146. controller.changeServicePackage(servicePackDTO);
  147. },
  148. child: Container(
  149. margin: const EdgeInsets.symmetric(
  150. vertical: 10,
  151. horizontal: 50,
  152. ),
  153. padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
  154. decoration: BoxDecoration(
  155. color: Colors.white,
  156. borderRadius: const BorderRadius.all(
  157. Radius.circular(
  158. 8,
  159. ),
  160. ),
  161. border: Border.all(
  162. color: controller.state.selectedServicePackage
  163. .contains(servicePackDTO)
  164. ? const Color.fromRGBO(34, 164, 211, 1)
  165. : Colors.transparent,
  166. width: 2,
  167. ),
  168. ),
  169. child: Row(
  170. children: [
  171. Container(
  172. padding: const EdgeInsets.only(right: 20),
  173. child: Obx(
  174. () => Icon(
  175. Icons.check_circle_outline,
  176. size: 35,
  177. color: controller.state.selectedServicePackage
  178. .contains(servicePackDTO)
  179. ? const Color.fromRGBO(34, 164, 211, 1)
  180. : Colors.grey.shade500,
  181. ),
  182. ),
  183. ),
  184. Expanded(
  185. child: Column(
  186. children: [
  187. Row(
  188. children: [
  189. Expanded(
  190. child: Text(
  191. servicePackDTO.name ?? '',
  192. style: const TextStyle(
  193. fontSize: 25,
  194. fontWeight: FontWeight.bold,
  195. ),
  196. ),
  197. ),
  198. Expanded(
  199. child: Row(
  200. children: [
  201. const Text(
  202. '服务人群:',
  203. style: TextStyle(fontSize: titleSize),
  204. ),
  205. Text(
  206. controller.setNormalLabels(
  207. servicePackDTO.labels ?? [],
  208. ),
  209. style: const TextStyle(fontSize: labelSize),
  210. ),
  211. ],
  212. ),
  213. ),
  214. ],
  215. ),
  216. const SizedBox(
  217. height: 10,
  218. ),
  219. Row(
  220. mainAxisSize: MainAxisSize.max,
  221. children: [
  222. Expanded(
  223. child: Row(
  224. mainAxisSize: MainAxisSize.max,
  225. children: [
  226. const Text(
  227. '服务包介绍:',
  228. style: TextStyle(fontSize: titleSize),
  229. ),
  230. Expanded(
  231. child: Container(
  232. alignment: Alignment.centerLeft,
  233. height: 50,
  234. child: Text(
  235. servicePackDTO.content ?? '',
  236. overflow: TextOverflow.ellipsis,
  237. maxLines: 2,
  238. style: const TextStyle(fontSize: labelSize),
  239. ),
  240. ),
  241. ),
  242. ],
  243. ),
  244. ),
  245. ],
  246. ),
  247. ],
  248. ),
  249. ),
  250. Container(
  251. padding: const EdgeInsets.only(left: 20),
  252. child: TextButton(
  253. child: const Text(
  254. '查看',
  255. style: TextStyle(fontSize: 18),
  256. ),
  257. onPressed: () async {
  258. await Get.toNamed(
  259. '/contract/package_info',
  260. parameters: {
  261. "servicePack": json.encode(servicePackDTO.toJson()),
  262. },
  263. );
  264. // showDialog(
  265. // context: context,
  266. // builder: (BuildContext context) {
  267. // return buildAlertDialog(servicePackDTO);
  268. // },
  269. // );
  270. },
  271. ),
  272. ),
  273. ],
  274. ),
  275. ),
  276. );
  277. }
  278. Widget buildCancelButton() {
  279. return TextButton(
  280. onPressed: () {
  281. Get.back();
  282. },
  283. child: const Text(
  284. '取消',
  285. style: TextStyle(fontSize: 25),
  286. ),
  287. );
  288. }
  289. Widget buildConfirmButton() {
  290. return TextButton(
  291. onPressed: () {},
  292. child: const Text(
  293. '确定',
  294. style: TextStyle(fontSize: 25),
  295. ),
  296. );
  297. }
  298. Widget buildHeader() {
  299. return Container(
  300. decoration: const BoxDecoration(
  301. color: Colors.white,
  302. ),
  303. height: 90,
  304. padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
  305. child: Row(
  306. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  307. children: [
  308. buildCancelButton(),
  309. buildConfirmButton(),
  310. ],
  311. ),
  312. );
  313. }
  314. Widget buildServicePackageList() {
  315. return Obx(
  316. () => Expanded(
  317. child: controller.state.servicePackageItems.isEmpty
  318. ? const Center(
  319. child: Text('暂无数据'),
  320. )
  321. : ListView(
  322. children: controller.state.servicePackageItems
  323. .map((ServicePackDTO e) => buildItem(e))
  324. .toList(),
  325. ),
  326. ),
  327. );
  328. }
  329. return Drawer(
  330. shape: const RoundedRectangleBorder(
  331. borderRadius: BorderRadiusDirectional.horizontal(
  332. end: Radius.circular(0),
  333. ),
  334. ),
  335. width: MediaQuery.of(context).size.width * 0.7,
  336. child: Container(
  337. color: Colors.grey.shade300,
  338. child: Column(
  339. mainAxisSize: MainAxisSize.max,
  340. children: [
  341. // buildHeader(),
  342. const SizedBox(
  343. height: 30,
  344. ),
  345. buildServicePackageList(),
  346. const SizedBox(
  347. height: 10,
  348. ),
  349. ],
  350. ),
  351. ),
  352. );
  353. }
  354. Widget _buildPhotoVPanel() {
  355. return VPanel(
  356. child: VListFormCellGroup(
  357. children: [
  358. VListFormCell(
  359. label: '拍照',
  360. height: 70,
  361. contentWidget: const Center(
  362. child: Icon(
  363. Icons.supervised_user_circle_outlined,
  364. size: 70,
  365. ),
  366. ),
  367. onTap: () {
  368. print('拍照拍照');
  369. },
  370. ),
  371. ],
  372. ),
  373. );
  374. }
  375. Widget _buildContractDoctorVPanel() {
  376. return VPanel(
  377. child: VListFormCellGroup(
  378. children: [
  379. Obx(
  380. () => VListFormCell(
  381. label: '服务日期',
  382. content: DateFormat('yyyy-MM-dd')
  383. .format(controller.state.serviceStartDate),
  384. onTap: () async {
  385. final result = await VDialogDate(
  386. title: '服务日期',
  387. initialValue: controller.state.serviceStartDate,
  388. ).show();
  389. controller.state.serviceStartDate = result;
  390. },
  391. ),
  392. ),
  393. const VListFormCell(
  394. label: '签约医生',
  395. content: '李四',
  396. ),
  397. const VListFormCell(
  398. label: '医生电话',
  399. content: '18712341234',
  400. ),
  401. ],
  402. ),
  403. );
  404. }
  405. Widget _buildPatientVPanel() {
  406. return Stack(
  407. children: [
  408. VPanel(
  409. child: Obx(
  410. () => VListFormCellGroup(
  411. children: [
  412. VListFormCell(
  413. label: '姓名',
  414. content: controller.state.name,
  415. ),
  416. VListFormCell(
  417. label: '联系电话',
  418. content: controller.state.phone,
  419. ),
  420. if (controller.state.isExpendPatient) ...[
  421. const VListFormCell(
  422. label: '身份证号码',
  423. content: '5130221999099987',
  424. ),
  425. const VListFormCell(
  426. label: '民族',
  427. content: '汉族',
  428. ),
  429. VListFormCell(
  430. label: '性别',
  431. content: controller.state.genderDesc,
  432. ),
  433. const VListFormCell(
  434. label: '出生日期',
  435. content: '张三',
  436. ),
  437. ]
  438. ],
  439. ),
  440. )),
  441. Positioned(
  442. right: 0,
  443. top: 0,
  444. child: IconButton(
  445. onPressed: () {
  446. controller.state.isExpendPatient =
  447. !controller.state.isExpendPatient;
  448. },
  449. icon: Obx(
  450. () => Icon(
  451. controller.state.isExpendPatient
  452. ? Icons.keyboard_arrow_up_rounded
  453. : Icons.keyboard_arrow_down_rounded,
  454. color: Colors.grey.shade400,
  455. size: 30,
  456. ),
  457. ),
  458. ),
  459. )
  460. ],
  461. );
  462. }
  463. Widget _buildServicePackageVPanel(BuildContext context) {
  464. return VPanel(
  465. child: VListFormCellGroup(
  466. children: [
  467. Obx(
  468. () => VListFormCell(
  469. label: '家庭医生服务包',
  470. height: 70,
  471. content: controller.state.selectedServicePackageName,
  472. onTap: () {
  473. Scaffold.of(context).openEndDrawer();
  474. },
  475. ),
  476. ),
  477. const VListFormCell(
  478. label: '备注',
  479. content: '5130221999099987',
  480. ),
  481. ],
  482. ),
  483. );
  484. }
  485. }