view.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. import 'dart:convert';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vitalapp/components/appbar.dart';
  5. import 'package:vitalapp/components/button.dart';
  6. import 'package:vitalapp/components/dialog_select.dart';
  7. import 'package:vitalapp/components/side_nav/defines.dart';
  8. import 'package:vitalapp/components/side_nav/side_nav.dart';
  9. import 'package:vitalapp/pages/contract/package_list/widgets/capture_portrait.dart';
  10. import 'package:vitalapp/pages/contract/package_list/widgets/family_doctor_service_package.dart';
  11. import 'package:vitalapp/pages/contract/package_list/widgets/personal_information.dart';
  12. import 'package:vitalapp/pages/contract/package_list/widgets/service_information.dart';
  13. import 'package:vitalapp/pages/contract/package_list/widgets/signing_status.dart';
  14. import 'controller.dart';
  15. class ServicePackageContractPage
  16. extends GetView<ServicePackageContractController> {
  17. const ServicePackageContractPage({super.key});
  18. static const double labelSize = 20;
  19. @override
  20. Widget build(BuildContext context) {
  21. return Scaffold(
  22. appBar: VAppBar(
  23. titleText: "签约",
  24. ),
  25. backgroundColor: Colors.white,
  26. body: _buildContent(context),
  27. );
  28. }
  29. static const TextStyle _textStyle = TextStyle(fontSize: 20);
  30. Widget _buildContent(BuildContext context) {
  31. TextEditingController? textEditingController =
  32. TextEditingController(text: controller.state.reasonRefusal);
  33. return Column(
  34. children: [
  35. Padding(
  36. padding: const EdgeInsets.only(left: 24.0),
  37. child: Obx(
  38. () => Row(
  39. children: [
  40. const Text(
  41. "签约选项:",
  42. style: _textStyle,
  43. ),
  44. const SizedBox(
  45. width: 8,
  46. ),
  47. SizedBox(
  48. height: 50,
  49. child: Row(
  50. children: [
  51. _OptionWidget(
  52. text: "签约",
  53. checked: !controller.state.isDenySbaVisa,
  54. onTap: () {
  55. if (controller.state.isDenySbaVisa) {
  56. controller.state.isDenySbaVisa = false;
  57. }
  58. },
  59. ),
  60. _OptionWidget(
  61. text: "拒签",
  62. checked: controller.state.isDenySbaVisa,
  63. onTap: () async {
  64. if (!controller.state.isDenySbaVisa) {
  65. controller.state.isDenySbaVisa = true;
  66. }
  67. // final result = await VDialogSelect<String, String>(
  68. // title: "拒签原因",
  69. // source: controller.state.reasonRefusals,
  70. // valueGetter: (data) => data,
  71. // labelGetter: (data) => data,
  72. // initialValue: controller.state.reasonRefusal,
  73. // ).show();
  74. // if (result != null) {
  75. // controller.state.reasonRefusal = result;
  76. // }
  77. },
  78. ),
  79. ],
  80. ),
  81. ),
  82. const SizedBox(
  83. width: 20,
  84. ),
  85. if (controller.state.isDenySbaVisa)
  86. ElevatedButton(
  87. onPressed: () {
  88. controller.submitContract();
  89. },
  90. style: ButtonStyle(
  91. foregroundColor:
  92. const MaterialStatePropertyAll(Colors.white),
  93. backgroundColor: MaterialStatePropertyAll(
  94. Theme.of(context).primaryColor),
  95. elevation: const MaterialStatePropertyAll(0),
  96. padding: const MaterialStatePropertyAll(
  97. EdgeInsets.symmetric(horizontal: 1, vertical: 1),
  98. ),
  99. ),
  100. child: const Text(
  101. "提交",
  102. style: _textStyle,
  103. ),
  104. ),
  105. ],
  106. ),
  107. ),
  108. ),
  109. Obx(() {
  110. if (!controller.state.isDenySbaVisa) {
  111. return Container();
  112. }
  113. return Padding(
  114. padding: const EdgeInsets.only(left: 24.0),
  115. child: Row(
  116. children: [
  117. const Text(
  118. "拒签原因:",
  119. style: _textStyle,
  120. ),
  121. Radio<int>(
  122. value: 0,
  123. groupValue: controller.state.selectedReasonIndex,
  124. onChanged: (value) {
  125. controller.state.selectedReasonIndex = value!;
  126. },
  127. ),
  128. const Text(
  129. '不自愿',
  130. style: _textStyle,
  131. ),
  132. Radio<int>(
  133. value: 1,
  134. groupValue: controller.state.selectedReasonIndex,
  135. onChanged: (value) {
  136. controller.state.selectedReasonIndex = value!;
  137. },
  138. ),
  139. const Text(
  140. '举家外出',
  141. style: _textStyle,
  142. ),
  143. Radio<int>(
  144. value: 2,
  145. groupValue: controller.state.selectedReasonIndex,
  146. onChanged: (value) {
  147. controller.state.selectedReasonIndex = value!;
  148. },
  149. ),
  150. const Text(
  151. '外出上学',
  152. style: _textStyle,
  153. ),
  154. Radio<int>(
  155. value: 3,
  156. groupValue: controller.state.selectedReasonIndex,
  157. onChanged: (value) {
  158. controller.state.selectedReasonIndex = value!;
  159. },
  160. ),
  161. const Text(
  162. '婚出',
  163. style: _textStyle,
  164. ),
  165. Radio<int>(
  166. value: 4,
  167. groupValue: controller.state.selectedReasonIndex,
  168. onChanged: (value) {
  169. controller.state.selectedReasonIndex = value!;
  170. },
  171. ),
  172. const Text(
  173. '服役',
  174. style: _textStyle,
  175. ),
  176. Radio<int>(
  177. value: 5,
  178. groupValue: controller.state.selectedReasonIndex,
  179. onChanged: (value) {
  180. controller.state.selectedReasonIndex = value!;
  181. },
  182. ),
  183. const Text(
  184. '服刑',
  185. style: _textStyle,
  186. ),
  187. Radio<int>(
  188. value: 6,
  189. groupValue: controller.state.selectedReasonIndex,
  190. onChanged: (value) {
  191. controller.state.selectedReasonIndex = value!;
  192. },
  193. ),
  194. const Text(
  195. '其他',
  196. style: _textStyle,
  197. ),
  198. const SizedBox(
  199. width: 8,
  200. ),
  201. if (controller.state.selectedReasonIndex == 6)
  202. Expanded(
  203. child: TextField(
  204. keyboardType: TextInputType.text,
  205. controller: textEditingController,
  206. onChanged: (value) {
  207. controller.state.reasonRefusal = value;
  208. },
  209. ),
  210. ),
  211. const SizedBox(
  212. width: 30,
  213. ),
  214. ],
  215. ),
  216. );
  217. }),
  218. const SizedBox(
  219. height: 8,
  220. ),
  221. const Divider(height: 1),
  222. Expanded(
  223. child: VSideNavView(
  224. // navId: NavIds.CONTRACT,
  225. items: _buildItems(),
  226. ),
  227. ),
  228. const Divider(height: 1),
  229. const SizedBox(
  230. height: 8,
  231. ),
  232. Obx(() {
  233. if (controller.state.isDenySbaVisa) {
  234. return Container();
  235. }
  236. return VButton(
  237. label: "签约协议",
  238. onTap: () {
  239. if (!controller.verifyData()) {
  240. return;
  241. }
  242. Get.toNamed(
  243. "/contract/contract_template",
  244. parameters: {
  245. "templateCode": controller.templateCode,
  246. "patientInfo": json.encode(controller.patient.toJson()),
  247. "servicePackageCodes":
  248. controller.state.selectedServicePackageCode,
  249. "servicePackageNames":
  250. controller.state.selectedServicePackageName,
  251. "serviceTime": controller.state.serviceTime.toString(),
  252. "serviceStartDate":
  253. controller.state.serviceStartDate.toString(),
  254. "base64Image": controller.state.userImage ?? '',
  255. "notes": controller.state.notes,
  256. },
  257. );
  258. },
  259. );
  260. }),
  261. const SizedBox(
  262. height: 8,
  263. ),
  264. ],
  265. );
  266. }
  267. List<VSideNavMenuItem> _buildItems() {
  268. final items = <VSideNavMenuItem>[];
  269. // items.add(_buildCapturePortrait());
  270. items.add(_buildPersonalInformation());
  271. items.add(_buildServiceInformation());
  272. items.add(_buildFamilyDoctorServicePackage());
  273. // items.add(_buildSigningStatusItem());
  274. return items;
  275. }
  276. // VSideNavMenuItem _buildCapturePortrait() {
  277. // return VSideNavMenuItem(
  278. // title: "人像采集",
  279. // icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
  280. // pageBuilder: (context) {
  281. // return const CapturePortraitPage();
  282. // },
  283. // );
  284. // }
  285. VSideNavMenuItem _buildServiceInformation() {
  286. return VSideNavMenuItem(
  287. title: "服务信息",
  288. icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
  289. pageBuilder: (context) {
  290. return const ServiceInformationPage();
  291. },
  292. );
  293. }
  294. VSideNavMenuItem _buildFamilyDoctorServicePackage() {
  295. return VSideNavMenuItem(
  296. title: "服务包",
  297. icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
  298. pageBuilder: (context) {
  299. return const FamilyDoctorServicePackagePage();
  300. },
  301. );
  302. }
  303. VSideNavMenuItem _buildPersonalInformation() {
  304. return VSideNavMenuItem(
  305. title: "个人信息",
  306. icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
  307. pageBuilder: (context) {
  308. return const PersonalInformationPage();
  309. },
  310. );
  311. }
  312. // VSideNavMenuItem _buildSigningStatusItem() {
  313. // return VSideNavMenuItem(
  314. // title: "签约状态",
  315. // isRequired: true,
  316. // icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
  317. // pageBuilder: (context) {
  318. // return const SigningStatusPage();
  319. // },
  320. // );
  321. // }
  322. }
  323. class _OptionWidget extends StatelessWidget {
  324. final String text;
  325. final bool checked;
  326. final VoidCallback onTap;
  327. const _OptionWidget({
  328. super.key,
  329. required this.text,
  330. required this.checked,
  331. required this.onTap,
  332. });
  333. @override
  334. Widget build(BuildContext context) {
  335. return GestureDetector(
  336. onTap: onTap,
  337. child: Container(
  338. height: 32,
  339. width: 80,
  340. alignment: Alignment.center,
  341. decoration: BoxDecoration(
  342. borderRadius: BorderRadius.circular(4),
  343. color: checked ? Theme.of(context).primaryColor : null,
  344. ),
  345. child: Text(
  346. text,
  347. style: TextStyle(color: checked ? Colors.white : null, fontSize: 20),
  348. ),
  349. ),
  350. );
  351. }
  352. }