expense_detail_dialog.dart 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. // ignore_for_file: use_build_context_synchronously
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:tdesign_flutter/tdesign_flutter.dart';
  5. import '../../../core/i18n/app_localizations.dart';
  6. import '../../../core/theme/app_colors.dart';
  7. import '../../../core/theme/app_colors_extension.dart';
  8. import '../../../core/utils/amount_utils.dart';
  9. import '../../../shared/models/bill_file_rights.dart';
  10. import '../expense_api.dart';
  11. import '../../../shared/widgets/attachment_picker.dart';
  12. import '../../../shared/widgets/searchable_picker_sheet.dart';
  13. /// 报销明细输入数据。
  14. class ExpenseDetailInputData {
  15. final String category;
  16. final String categoryName;
  17. final String acctSubjectId;
  18. final String acctSubjectName;
  19. final String purpose;
  20. final double amount;
  21. final double taxRate;
  22. final String projectId;
  23. final String projectName;
  24. final String costDeptId;
  25. final String costDeptName;
  26. final String customerVendorId;
  27. final String customerVendorName;
  28. final double approvedAmount;
  29. final double offsetAmount;
  30. final String bankName;
  31. final String bankAccountName;
  32. final String bankAccount;
  33. final String remark;
  34. final List<String> attachmentPaths;
  35. final String sqMan;
  36. final String sqManName;
  37. final String aeNo;
  38. final String aeDd;
  39. const ExpenseDetailInputData({
  40. required this.category,
  41. required this.categoryName,
  42. required this.acctSubjectId,
  43. required this.acctSubjectName,
  44. required this.purpose,
  45. required this.amount,
  46. required this.taxRate,
  47. this.projectId = '',
  48. this.projectName = '',
  49. this.costDeptId = '',
  50. this.costDeptName = '',
  51. this.customerVendorId = '',
  52. this.customerVendorName = '',
  53. this.approvedAmount = 0.0,
  54. this.offsetAmount = 0.0,
  55. this.bankName = '',
  56. this.bankAccountName = '',
  57. this.bankAccount = '',
  58. this.remark = '',
  59. this.attachmentPaths = const [],
  60. this.sqMan = '',
  61. this.sqManName = '',
  62. this.aeNo = '',
  63. this.aeDd = '',
  64. });
  65. }
  66. /// 报销明细编辑弹窗。
  67. ///
  68. /// 使用 [TDSlidePopupRoute] 从底部滑出,卡片化展示表单字段。
  69. /// 参照 ExpenseApplyCreatePage 的 ExpenseDetailDialog 样式。
  70. class ExpenseDetailDialog extends StatefulWidget {
  71. final ExpenseApi api;
  72. final AppLocalizations l10n;
  73. final ExpenseDetailInputData? initialData;
  74. final Future<bool> Function()? checkAttachHealth;
  75. final bool showAttachments;
  76. final bool canEditApprovedAmount;
  77. final BillFileRights? billFileRights;
  78. final dynamic acctTree;
  79. final String? defaultSqMan;
  80. final String? defaultSqManName;
  81. const ExpenseDetailDialog({
  82. super.key,
  83. required this.api,
  84. required this.l10n,
  85. this.initialData,
  86. this.checkAttachHealth,
  87. this.showAttachments = true,
  88. this.canEditApprovedAmount = false,
  89. this.billFileRights,
  90. required this.acctTree,
  91. this.defaultSqMan,
  92. this.defaultSqManName,
  93. });
  94. /// 显示弹窗,返回 [ExpenseDetailInputData] 或 `null`(取消时)。
  95. static Future<ExpenseDetailInputData?> show(
  96. BuildContext context, {
  97. required ExpenseApi api,
  98. required AppLocalizations l10n,
  99. ExpenseDetailInputData? initialData,
  100. Future<bool> Function()? checkAttachHealth,
  101. bool showAttachments = true,
  102. bool canEditApprovedAmount = false,
  103. BillFileRights? billFileRights,
  104. required dynamic acctTree,
  105. String? defaultSqMan,
  106. String? defaultSqManName,
  107. }) {
  108. FocusScope.of(context).unfocus();
  109. return Navigator.push<ExpenseDetailInputData>(
  110. context,
  111. TDSlidePopupRoute<ExpenseDetailInputData>(
  112. slideTransitionFrom: SlideTransitionFrom.bottom,
  113. isDismissible: true,
  114. builder: (_) => ExpenseDetailDialog(
  115. api: api,
  116. l10n: l10n,
  117. initialData: initialData,
  118. checkAttachHealth: checkAttachHealth,
  119. showAttachments: showAttachments,
  120. canEditApprovedAmount: canEditApprovedAmount,
  121. defaultSqMan: defaultSqMan,
  122. defaultSqManName: defaultSqManName,
  123. billFileRights: billFileRights,
  124. acctTree: acctTree,
  125. ),
  126. ),
  127. );
  128. }
  129. @override
  130. State<ExpenseDetailDialog> createState() => _ExpenseDetailDialogState();
  131. }
  132. class _ExpenseDetailDialogState extends State<ExpenseDetailDialog> {
  133. late CostProjectItem _selCat;
  134. late TextEditingController _descCtrl;
  135. late TextEditingController _amountCtrl;
  136. CustomerItem? _selCustomer;
  137. late TextEditingController _approvedAmountCtrl;
  138. late TextEditingController _remarkCtrl;
  139. late TextEditingController _bankNameCtrl;
  140. late TextEditingController _bankAccountNameCtrl;
  141. late TextEditingController _bankAccountCtrl;
  142. double _taxRate = 0;
  143. ProjectCodeItem? _selProject;
  144. DepartmentItem? _selDept;
  145. EmployeeItem? _selEmployee;
  146. late final AttachmentPickerController _attachmentCtrl;
  147. final ScrollController _scrollCtrl = ScrollController();
  148. final _remarkFocus = FocusNode();
  149. final _bankNameFocus = FocusNode();
  150. final _bankAccountNameFocus = FocusNode();
  151. final _bankAccountFocus = FocusNode();
  152. bool _attachAvailable = false;
  153. void _ensureVisible(FocusNode node) {
  154. if (!node.hasFocus) return;
  155. _doEnsureVisible(node, 0, -1);
  156. }
  157. void _doEnsureVisible(FocusNode node, int attempt, double lastInsets) {
  158. if (attempt >= 15) return;
  159. WidgetsBinding.instance.addPostFrameCallback((_) {
  160. if (!mounted || !node.hasFocus || !_scrollCtrl.hasClients) return;
  161. final insets = MediaQuery.of(context).viewInsets.bottom;
  162. if (insets != lastInsets) {
  163. _doEnsureVisible(node, attempt + 1, insets);
  164. return;
  165. }
  166. final ctx = node.context;
  167. if (ctx == null) return;
  168. Future.delayed(const Duration(milliseconds: 500), () {
  169. if (!mounted || !node.hasFocus || !_scrollCtrl.hasClients) return;
  170. Scrollable.ensureVisible(
  171. ctx,
  172. alignment: 0.5,
  173. duration: const Duration(milliseconds: 300),
  174. );
  175. });
  176. });
  177. }
  178. static const _taxOptions = [0, 6, 9, 13];
  179. static const _taxLabels = ['0%', '6%', '9%', '13%'];
  180. AppLocalizations get _l10n => widget.l10n;
  181. bool get _isEdit => widget.initialData != null;
  182. @override
  183. void initState() {
  184. super.initState();
  185. final d = widget.initialData;
  186. _selCat = CostProjectItem(
  187. idx1: d?.category ?? '',
  188. name: d?.categoryName ?? '',
  189. accNo: d?.acctSubjectId ?? '',
  190. accName: d?.acctSubjectName ?? '',
  191. );
  192. _descCtrl = TextEditingController(text: d?.purpose ?? '');
  193. _amountCtrl = TextEditingController(
  194. text: d != null && d.amount > 0 ? formatAmountNumeric(d.amount) : '',
  195. );
  196. _selCustomer = (d != null && d.customerVendorId.isNotEmpty)
  197. ? CustomerItem(cusNo: '', name: '')
  198. : null;
  199. _approvedAmountCtrl = TextEditingController(
  200. text: d != null && d.approvedAmount > 0
  201. ? formatAmountNumeric(d.approvedAmount)
  202. : '',
  203. );
  204. _remarkCtrl = TextEditingController(text: d?.remark ?? '');
  205. _bankNameCtrl = TextEditingController(text: d?.bankName ?? '');
  206. _bankAccountNameCtrl = TextEditingController(
  207. text: d?.bankAccountName ?? '',
  208. );
  209. _bankAccountCtrl = TextEditingController(text: d?.bankAccount ?? '');
  210. _taxRate = d?.taxRate ?? 0;
  211. _selEmployee = (d != null && d.sqMan.isNotEmpty)
  212. ? EmployeeItem(salNo: d.sqMan, name: d.sqManName)
  213. : (widget.defaultSqMan != null
  214. ? EmployeeItem(
  215. salNo: widget.defaultSqMan!,
  216. name: widget.defaultSqManName ?? '',
  217. )
  218. : null);
  219. if (_selEmployee != null && (d == null || d.sqMan.isEmpty)) {
  220. WidgetsBinding.instance.addPostFrameCallback(
  221. (_) => _loadDefaultBankInfo(),
  222. );
  223. }
  224. _selProject = (d != null && d.projectId.isNotEmpty)
  225. ? ProjectCodeItem(objNo: d.projectId, name: d.projectName)
  226. : null;
  227. _selDept = (d != null && d.costDeptId.isNotEmpty)
  228. ? DepartmentItem(dep: d.costDeptId, name: d.costDeptName)
  229. : null;
  230. if (d != null && d.attachmentPaths.isNotEmpty) {
  231. WidgetsBinding.instance.addPostFrameCallback((_) {
  232. _attachmentCtrl.restoreFromPaths(d.attachmentPaths);
  233. });
  234. }
  235. _attachmentCtrl = AttachmentPickerController(maxCount: 9)
  236. ..addListener(() => setState(() {}));
  237. _remarkFocus.addListener(() => _ensureVisible(_remarkFocus));
  238. _bankNameFocus.addListener(() => _ensureVisible(_bankNameFocus));
  239. _bankAccountNameFocus.addListener(
  240. () => _ensureVisible(_bankAccountNameFocus),
  241. );
  242. _bankAccountFocus.addListener(() => _ensureVisible(_bankAccountFocus));
  243. _checkAttachHealth();
  244. }
  245. Future<void> _loadDefaultBankInfo() async {
  246. if (_selEmployee == null || _selEmployee!.salNo.isEmpty) return;
  247. try {
  248. final list = await widget.api.getEmployees(
  249. salNo: _selEmployee!.salNo,
  250. size: 1,
  251. );
  252. if (!mounted || list.isEmpty) return;
  253. setState(() {
  254. _selEmployee = list.first;
  255. _bankNameCtrl.text = list.first.bnkNo;
  256. _bankAccountNameCtrl.text = list.first.accName;
  257. _bankAccountCtrl.text = list.first.bnkId;
  258. });
  259. } catch (_) {}
  260. }
  261. Future<void> _checkAttachHealth() async {
  262. if (widget.checkAttachHealth == null) return;
  263. if (mounted) setState(() => _attachAvailable = false);
  264. try {
  265. final ok = await widget.checkAttachHealth!();
  266. if (mounted) setState(() => _attachAvailable = ok);
  267. } catch (_) {
  268. if (mounted) setState(() => _attachAvailable = false);
  269. }
  270. }
  271. @override
  272. void dispose() {
  273. _descCtrl.dispose();
  274. _amountCtrl.dispose();
  275. _approvedAmountCtrl.dispose();
  276. _remarkCtrl.dispose();
  277. _bankNameCtrl.dispose();
  278. _bankAccountNameCtrl.dispose();
  279. _bankAccountCtrl.dispose();
  280. _attachmentCtrl.dispose();
  281. _scrollCtrl.dispose();
  282. _remarkFocus.dispose();
  283. _bankNameFocus.dispose();
  284. _bankAccountNameFocus.dispose();
  285. _bankAccountFocus.dispose();
  286. super.dispose();
  287. }
  288. void _confirm() {
  289. final amount = double.tryParse(_amountCtrl.text) ?? 0;
  290. if (amount <= 0) {
  291. TDToast.showText(_l10n.get('amountPositive'), context: context);
  292. return;
  293. }
  294. Navigator.pop(
  295. context,
  296. ExpenseDetailInputData(
  297. category: _selCat.idx1,
  298. categoryName: _selCat.name,
  299. acctSubjectId: _selCat.accNo,
  300. acctSubjectName: _selCat.accName,
  301. purpose: '',
  302. amount: amount,
  303. taxRate: _taxRate,
  304. projectId: _selProject?.objNo ?? '',
  305. projectName: _selProject?.name ?? '',
  306. costDeptId: _selDept?.dep ?? '',
  307. costDeptName: _selDept?.name ?? '',
  308. customerVendorId: _selCustomer?.cusNo ?? '',
  309. customerVendorName: _selCustomer?.name ?? '',
  310. approvedAmount: double.tryParse(_approvedAmountCtrl.text) ?? 0,
  311. bankName: _bankNameCtrl.text.trim(),
  312. bankAccountName: _bankAccountNameCtrl.text.trim(),
  313. bankAccount: _bankAccountCtrl.text.trim(),
  314. remark: _remarkCtrl.text.trim(),
  315. attachmentPaths: _attachmentCtrl.toPathList(),
  316. sqMan: _selEmployee?.salNo ?? '',
  317. sqManName: _selEmployee?.name ?? '',
  318. aeNo: widget.initialData?.aeNo ?? '',
  319. aeDd: widget.initialData?.aeDd ?? '',
  320. ),
  321. );
  322. }
  323. double get _amountExclTax => _taxRate > 0
  324. ? (double.tryParse(_amountCtrl.text) ?? 0) / (1 + _taxRate / 100)
  325. : (double.tryParse(_amountCtrl.text) ?? 0);
  326. double get _taxAmount =>
  327. (double.tryParse(_amountCtrl.text) ?? 0) - _amountExclTax;
  328. @override
  329. Widget build(BuildContext context) {
  330. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  331. return AnimatedPadding(
  332. padding: EdgeInsets.only(
  333. bottom: MediaQuery.of(context).viewInsets.bottom,
  334. ),
  335. duration: const Duration(milliseconds: 200),
  336. child: SafeArea(
  337. child: ConstrainedBox(
  338. constraints: BoxConstraints(
  339. maxHeight: MediaQuery.of(context).size.height * 0.8,
  340. ),
  341. child: Container(
  342. decoration: BoxDecoration(
  343. color: colors.bgPage,
  344. borderRadius: const BorderRadius.vertical(
  345. top: Radius.circular(16),
  346. ),
  347. ),
  348. child: Column(
  349. mainAxisSize: MainAxisSize.min,
  350. crossAxisAlignment: CrossAxisAlignment.stretch,
  351. children: [
  352. _buildHeader(colors),
  353. Flexible(
  354. child: GestureDetector(
  355. onTap: () => FocusScope.of(context).unfocus(),
  356. behavior: HitTestBehavior.translucent,
  357. child: SingleChildScrollView(
  358. controller: _scrollCtrl,
  359. keyboardDismissBehavior:
  360. ScrollViewKeyboardDismissBehavior.manual,
  361. padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
  362. child: Column(
  363. mainAxisSize: MainAxisSize.min,
  364. crossAxisAlignment: CrossAxisAlignment.stretch,
  365. children: [
  366. if (_isEdit &&
  367. widget.initialData!.aeNo.isNotEmpty) ...[
  368. _buildAeInfoCard(colors),
  369. const SizedBox(height: 12),
  370. ],
  371. _buildCategoryCard(colors),
  372. const SizedBox(height: 12),
  373. _buildAcctSubjectCard(colors),
  374. const SizedBox(height: 12),
  375. _buildAmountCard(),
  376. const SizedBox(height: 12),
  377. _buildTaxRateCard(colors),
  378. if ((double.tryParse(_amountCtrl.text) ?? 0) > 0) ...[
  379. const SizedBox(height: 12),
  380. _buildCalcInfo(colors),
  381. ],
  382. const SizedBox(height: 12),
  383. _buildApprovedAmountCard(),
  384. const SizedBox(height: 12),
  385. _buildProjectCard(colors),
  386. const SizedBox(height: 12),
  387. _buildCostDeptCard(colors),
  388. const SizedBox(height: 12),
  389. _buildCustomerCard(colors),
  390. const SizedBox(height: 12),
  391. _buildEmployeeCard(colors),
  392. const SizedBox(height: 12),
  393. _buildBankInfoCard(colors),
  394. const SizedBox(height: 12),
  395. _buildRemarkInput(colors),
  396. if (widget.showAttachments) ...[
  397. const SizedBox(height: 12),
  398. _buildAttachmentCard(colors),
  399. ],
  400. ],
  401. ),
  402. ),
  403. ),
  404. ),
  405. Container(
  406. padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
  407. decoration: BoxDecoration(
  408. color: colors.bgCard,
  409. border: Border(
  410. top: BorderSide(color: colors.border, width: 0.5),
  411. ),
  412. ),
  413. child: _buildActions(),
  414. ),
  415. ],
  416. ),
  417. ),
  418. ),
  419. ),
  420. );
  421. }
  422. // ── 标题栏 ──
  423. Widget _buildHeader(AppColorsExtension colors) {
  424. return Column(
  425. mainAxisSize: MainAxisSize.min,
  426. children: [
  427. Center(
  428. child: Container(
  429. margin: const EdgeInsets.only(top: 8, bottom: 4),
  430. width: 36,
  431. height: 4,
  432. decoration: BoxDecoration(
  433. color: colors.border,
  434. borderRadius: BorderRadius.circular(2),
  435. ),
  436. ),
  437. ),
  438. Padding(
  439. padding: const EdgeInsets.fromLTRB(20, 8, 12, 16),
  440. child: Row(
  441. children: [
  442. const SizedBox(width: 24),
  443. Expanded(
  444. child: Center(
  445. child: Text(
  446. _isEdit
  447. ? _l10n.get('editExpenseDetail')
  448. : _l10n.get('addExpenseDetail'),
  449. style: TextStyle(
  450. fontSize: AppFontSizes.title,
  451. fontWeight: FontWeight.w600,
  452. color: colors.textPrimary,
  453. ),
  454. ),
  455. ),
  456. ),
  457. GestureDetector(
  458. onTap: () => Navigator.pop(context),
  459. child: Padding(
  460. padding: const EdgeInsets.all(4),
  461. child: Icon(
  462. Icons.close,
  463. size: 20,
  464. color: colors.textSecondary,
  465. ),
  466. ),
  467. ),
  468. ],
  469. ),
  470. ),
  471. ],
  472. );
  473. }
  474. // ── picker 卡片 ──
  475. Widget _pickerCard({
  476. required String label,
  477. required bool required,
  478. required String currentLabel,
  479. required bool hasValue,
  480. required VoidCallback onTap,
  481. VoidCallback? onClear,
  482. }) {
  483. final tdTheme = TDTheme.of(context);
  484. return GestureDetector(
  485. onTap: () {
  486. FocusManager.instance.primaryFocus?.unfocus();
  487. onTap();
  488. },
  489. child: Container(
  490. padding: const EdgeInsets.only(
  491. left: 16,
  492. right: 10,
  493. top: 12,
  494. bottom: 12,
  495. ),
  496. decoration: BoxDecoration(
  497. color: tdTheme.bgColorContainer,
  498. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  499. border: Border.all(color: tdTheme.componentStrokeColor),
  500. ),
  501. child: Row(
  502. children: [
  503. TDText(
  504. label,
  505. maxLines: 1,
  506. overflow: TextOverflow.visible,
  507. font: tdTheme.fontBodyLarge,
  508. fontWeight: FontWeight.w400,
  509. style: const TextStyle(letterSpacing: 0),
  510. ),
  511. if (required)
  512. Padding(
  513. padding: const EdgeInsets.only(left: 4),
  514. child: TDText(
  515. '*',
  516. font: tdTheme.fontBodyLarge,
  517. fontWeight: FontWeight.w400,
  518. style: TextStyle(color: tdTheme.errorColor6),
  519. ),
  520. ),
  521. const SizedBox(width: 12),
  522. Expanded(
  523. child: Row(
  524. mainAxisAlignment: MainAxisAlignment.end,
  525. mainAxisSize: MainAxisSize.max,
  526. children: [
  527. Flexible(
  528. child: TDText(
  529. currentLabel,
  530. maxLines: 1,
  531. overflow: TextOverflow.ellipsis,
  532. font: tdTheme.fontBodyLarge,
  533. fontWeight: FontWeight.w400,
  534. textColor: hasValue
  535. ? tdTheme.textColorPrimary
  536. : tdTheme.textColorPlaceholder,
  537. textAlign: TextAlign.end,
  538. ),
  539. ),
  540. const SizedBox(width: 4),
  541. SizedBox(
  542. width: 18,
  543. height: 18,
  544. child: onClear != null
  545. ? GestureDetector(
  546. onTap: onClear,
  547. child: Icon(
  548. Icons.close,
  549. size: 18,
  550. color: tdTheme.textColorPlaceholder,
  551. ),
  552. )
  553. : Icon(
  554. Icons.chevron_right,
  555. size: 18,
  556. color: tdTheme.textColorPlaceholder,
  557. ),
  558. ),
  559. ],
  560. ),
  561. ),
  562. ],
  563. ),
  564. ),
  565. );
  566. }
  567. // ── 费用项目 ──
  568. Widget _buildCategoryCard(AppColorsExtension colors) {
  569. return _pickerCard(
  570. label: _l10n.get('expenseCategory'),
  571. required: true,
  572. hasValue: _selCat.idx1.isNotEmpty,
  573. currentLabel: _selCat.idx1.isNotEmpty
  574. ? '${_selCat.idx1}/${_selCat.name}'
  575. : _l10n.get('pleaseSelect'),
  576. onTap: () async {
  577. final result = await showSearchablePicker<CostProjectItem>(
  578. context,
  579. title: '${_l10n.get('select')}${_l10n.get('expenseCategory')}',
  580. searchHint: _l10n.get('search'),
  581. loader: (keyword, page) => widget.api
  582. .getCostProjects(keyword: keyword, page: page, size: 20)
  583. .then((list) => list.cast<CostProjectItem>()),
  584. labelBuilder: (c) => '${c.idx1}/${c.name}',
  585. onRefresh: () => widget.api.clearRefCache(),
  586. );
  587. if (result != null && mounted) {
  588. setState(() => _selCat = result);
  589. }
  590. },
  591. );
  592. }
  593. // ── 输入卡片(对齐 pickerCard 样式) ──
  594. Widget _inputCard({
  595. required String label,
  596. required bool required,
  597. required TextEditingController controller,
  598. required String hintText,
  599. required AppColorsExtension colors,
  600. TextInputType? keyboardType,
  601. List<TextInputFormatter>? inputFormatters,
  602. FocusNode? focusNode,
  603. }) {
  604. final tdTheme = TDTheme.of(context);
  605. final hasValue = controller.text.isNotEmpty;
  606. return Container(
  607. padding: const EdgeInsets.only(left: 16, right: 10, top: 12, bottom: 12),
  608. decoration: BoxDecoration(
  609. color: tdTheme.bgColorContainer,
  610. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  611. border: Border.all(color: tdTheme.componentStrokeColor),
  612. ),
  613. child: Row(
  614. children: [
  615. TDText(
  616. label,
  617. maxLines: 1,
  618. overflow: TextOverflow.visible,
  619. font: tdTheme.fontBodyLarge,
  620. fontWeight: FontWeight.w400,
  621. style: const TextStyle(letterSpacing: 0),
  622. ),
  623. if (required)
  624. Padding(
  625. padding: const EdgeInsets.only(left: 4),
  626. child: TDText(
  627. '*',
  628. font: tdTheme.fontBodyLarge,
  629. fontWeight: FontWeight.w400,
  630. style: TextStyle(color: tdTheme.errorColor6),
  631. ),
  632. ),
  633. const SizedBox(width: 12),
  634. Expanded(
  635. child: Row(
  636. mainAxisAlignment: MainAxisAlignment.end,
  637. mainAxisSize: MainAxisSize.max,
  638. children: [
  639. Flexible(
  640. child: TextField(
  641. controller: controller,
  642. focusNode: focusNode,
  643. textAlign: TextAlign.end,
  644. keyboardType: keyboardType,
  645. inputFormatters: inputFormatters,
  646. style: TextStyle(fontSize: 16, color: colors.textPrimary),
  647. decoration: InputDecoration(
  648. hintText: hintText,
  649. hintStyle: TextStyle(
  650. fontSize: 16,
  651. color: colors.textPlaceholder,
  652. ),
  653. border: InputBorder.none,
  654. isDense: true,
  655. contentPadding: EdgeInsets.zero,
  656. ),
  657. onChanged: (_) => setState(() {}),
  658. ),
  659. ),
  660. const SizedBox(width: 4),
  661. SizedBox(
  662. width: 18,
  663. height: 18,
  664. child: hasValue
  665. ? GestureDetector(
  666. onTap: () {
  667. controller.clear();
  668. setState(() {});
  669. },
  670. child: Icon(
  671. Icons.close,
  672. size: 18,
  673. color: tdTheme.textColorPlaceholder,
  674. ),
  675. )
  676. : null,
  677. ),
  678. ],
  679. ),
  680. ),
  681. ],
  682. ),
  683. );
  684. }
  685. // ── 含税金额 ──
  686. Widget _buildAmountCard() {
  687. return _inputCard(
  688. label: _l10n.get('amountInclTax'),
  689. required: true,
  690. controller: _amountCtrl,
  691. hintText: '>0',
  692. colors: Theme.of(context).extension<AppColorsExtension>()!,
  693. keyboardType: const TextInputType.numberWithOptions(decimal: true),
  694. inputFormatters: [
  695. FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,2}$')),
  696. ],
  697. );
  698. }
  699. // ── 税率 ──
  700. Widget _buildTaxRateCard(AppColorsExtension colors) {
  701. final currentLabel = '${_taxRate.toStringAsFixed(0)}%';
  702. final labels = _taxLabels.toList();
  703. return _pickerCard(
  704. label: _l10n.get('taxRate'),
  705. required: false,
  706. hasValue: true,
  707. currentLabel: currentLabel,
  708. onTap: () {
  709. FocusManager.instance.primaryFocus?.unfocus();
  710. TDPicker.showMultiPicker(
  711. context,
  712. title: _l10n.get('taxRate'),
  713. backgroundColor: colors.bgCard,
  714. data: [labels],
  715. onConfirm: (selected) {
  716. if (selected.isNotEmpty && selected[0] is int) {
  717. final idx = selected[0] as int;
  718. if (idx >= 0 && idx < labels.length) {
  719. Navigator.of(context).pop();
  720. setState(() => _taxRate = _taxOptions[idx].toDouble());
  721. }
  722. }
  723. },
  724. );
  725. },
  726. );
  727. }
  728. // ── 计算信息 ──
  729. Widget _buildCalcInfo(AppColorsExtension colors) {
  730. final amount = double.tryParse(_amountCtrl.text) ?? 0;
  731. if (amount <= 0) return const SizedBox.shrink();
  732. return Container(
  733. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
  734. decoration: BoxDecoration(
  735. color: colors.primaryLight,
  736. borderRadius: BorderRadius.circular(8),
  737. ),
  738. child: Row(
  739. children: [
  740. Expanded(
  741. child: Text(
  742. '${_l10n.get('amountExcludingTax')}: ${formatAmount(_amountExclTax)}',
  743. style: TextStyle(
  744. fontSize: AppFontSizes.body,
  745. color: colors.textSecondary,
  746. ),
  747. ),
  748. ),
  749. Text(
  750. '${_l10n.get('taxAmount')}: ${formatAmount(_taxAmount)}',
  751. style: TextStyle(
  752. fontSize: AppFontSizes.body,
  753. color: colors.textSecondary,
  754. ),
  755. ),
  756. ],
  757. ),
  758. );
  759. }
  760. // ── 导入单据信息 ──
  761. Widget _buildAeInfoCard(AppColorsExtension colors) {
  762. final d = widget.initialData!;
  763. final tdTheme = TDTheme.of(context);
  764. final dateStr = d.aeDd.isNotEmpty ? _formatDate(d.aeDd) : d.aeDd;
  765. return Container(
  766. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
  767. decoration: _cardDecoration(tdTheme),
  768. child: Column(
  769. children: [
  770. _readOnlyRow(tdTheme, _l10n.get('expenseApplyNo'), d.aeNo),
  771. const SizedBox(height: 8),
  772. _readOnlyRow(tdTheme, _l10n.get('applyDate'), dateStr),
  773. ],
  774. ),
  775. );
  776. }
  777. String _formatDate(String raw) {
  778. final dt = DateTime.tryParse(raw);
  779. if (dt == null) return raw;
  780. return '${dt.year}-${dt.month.toString().padLeft(2, '0')}-${dt.day.toString().padLeft(2, '0')}';
  781. }
  782. Widget _readOnlyRow(TDThemeData tdTheme, String label, String value) {
  783. return Row(
  784. children: [
  785. TDText(
  786. label,
  787. font: tdTheme.fontBodyLarge,
  788. fontWeight: FontWeight.w400,
  789. style: const TextStyle(letterSpacing: 0),
  790. ),
  791. const SizedBox(width: 12),
  792. Expanded(
  793. child: TDText(
  794. value,
  795. maxLines: 1,
  796. overflow: TextOverflow.ellipsis,
  797. font: tdTheme.fontBodyLarge,
  798. fontWeight: FontWeight.w400,
  799. textColor: tdTheme.textColorPrimary,
  800. textAlign: TextAlign.end,
  801. ),
  802. ),
  803. ],
  804. );
  805. }
  806. BoxDecoration _cardDecoration(TDThemeData tdTheme) => BoxDecoration(
  807. color: tdTheme.bgColorContainer,
  808. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  809. border: Border.all(color: tdTheme.componentStrokeColor),
  810. );
  811. // ── 申请人 ──
  812. Widget _buildEmployeeCard(AppColorsExtension colors) {
  813. return _pickerCard(
  814. label: _l10n.get('applicant'),
  815. required: false,
  816. hasValue: _selEmployee != null,
  817. currentLabel: _selEmployee != null
  818. ? '${_selEmployee!.salNo}/${_selEmployee!.name}'
  819. : _l10n.get('pleaseSelect'),
  820. onTap: () async {
  821. final result = await showSearchablePicker<EmployeeItem>(
  822. context,
  823. title: '${_l10n.get('select')}${_l10n.get('applicant')}',
  824. searchHint: _l10n.get('search'),
  825. loader: (keyword, page) =>
  826. widget.api.getEmployees(keyword: keyword, page: page, size: 20),
  827. labelBuilder: (e) =>
  828. e.name.isEmpty ? e.salNo : '${e.salNo} ${e.name}',
  829. onRefresh: () => widget.api.clearRefCache(),
  830. );
  831. if (result != null && mounted) {
  832. setState(() {
  833. _selEmployee = result;
  834. _bankNameCtrl.text = result.bnkNo;
  835. _bankAccountNameCtrl.text = result.accName;
  836. _bankAccountCtrl.text = result.bnkId;
  837. });
  838. }
  839. },
  840. onClear: _selEmployee != null
  841. ? () => setState(() {
  842. _selEmployee = null;
  843. _bankNameCtrl.clear();
  844. _bankAccountNameCtrl.clear();
  845. _bankAccountCtrl.clear();
  846. })
  847. : null,
  848. );
  849. }
  850. // ── 客户/厂商 ──
  851. Widget _buildCustomerCard(AppColorsExtension colors) {
  852. return _pickerCard(
  853. label: _l10n.get('customerVendor'),
  854. required: false,
  855. hasValue: _selCustomer != null,
  856. currentLabel: _selCustomer != null
  857. ? '${_selCustomer!.cusNo}/${_selCustomer!.name}'
  858. : _l10n.get('pleaseSelect'),
  859. onTap: () async {
  860. final result = await showSearchablePicker<CustomerItem>(
  861. context,
  862. title: '${_l10n.get('select')}${_l10n.get('customerVendor')}',
  863. searchHint: _l10n.get('search'),
  864. loader: (keyword, page) =>
  865. widget.api.getCustomers(keyword: keyword, page: page, size: 20),
  866. labelBuilder: (v) =>
  867. v.name.isEmpty ? v.cusNo : '${v.cusNo} ${v.name}',
  868. onRefresh: () => widget.api.clearRefCache(),
  869. );
  870. if (result != null && mounted) {
  871. setState(() => _selCustomer = result);
  872. }
  873. },
  874. onClear: _selCustomer != null
  875. ? () => setState(() => _selCustomer = null)
  876. : null,
  877. );
  878. }
  879. // ── 核准金额 ──
  880. Widget _buildApprovedAmountCard() {
  881. if (!widget.canEditApprovedAmount) {
  882. final value = _approvedAmountCtrl.text.isNotEmpty
  883. ? formatAmount(double.tryParse(_approvedAmountCtrl.text) ?? 0)
  884. : '-';
  885. return _readOnlyCard(
  886. label: _l10n.get('approvedAmount'),
  887. value: value,
  888. colors: Theme.of(context).extension<AppColorsExtension>()!,
  889. );
  890. }
  891. return _inputCard(
  892. label: _l10n.get('approvedAmount'),
  893. required: false,
  894. controller: _approvedAmountCtrl,
  895. hintText: '0',
  896. colors: Theme.of(context).extension<AppColorsExtension>()!,
  897. keyboardType: const TextInputType.numberWithOptions(decimal: true),
  898. inputFormatters: [
  899. FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,2}$')),
  900. ],
  901. );
  902. }
  903. // ── 备注 ──
  904. Widget _buildRemarkInput(AppColorsExtension colors) {
  905. final tdTheme = TDTheme.of(context);
  906. return TDTextarea(
  907. controller: _remarkCtrl,
  908. focusNode: _remarkFocus,
  909. label: _l10n.get('remark'),
  910. hintText: _l10n.get('enterRemark'),
  911. maxLines: 3,
  912. minLines: 1,
  913. maxLength: 500,
  914. indicator: true,
  915. decoration: BoxDecoration(
  916. color: tdTheme.bgColorContainer,
  917. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  918. border: Border.all(color: tdTheme.componentStrokeColor),
  919. ),
  920. onChanged: (_) => setState(() {}),
  921. );
  922. }
  923. // ── 操作按钮 ──
  924. Widget _buildAttachmentCard(AppColorsExtension colors) {
  925. final tdTheme = TDTheme.of(context);
  926. Widget? hint;
  927. if (!_attachAvailable) {
  928. hint = TDText(
  929. _l10n.get('attachServiceUnavailable'),
  930. font: tdTheme.fontBodySmall,
  931. fontWeight: FontWeight.w400,
  932. textColor: tdTheme.textColorPlaceholder,
  933. );
  934. } else if (widget.billFileRights != null &&
  935. !widget.billFileRights!.canManageAttachments) {
  936. hint = TDText(
  937. _l10n.get('noAttachmentPermission'),
  938. font: tdTheme.fontBodySmall,
  939. fontWeight: FontWeight.w400,
  940. textColor: tdTheme.textColorPlaceholder,
  941. );
  942. }
  943. return Column(
  944. crossAxisAlignment: CrossAxisAlignment.start,
  945. children: [
  946. Padding(
  947. padding: const EdgeInsets.only(left: 4),
  948. child: TDText(
  949. _l10n.get('attachmentUpload'),
  950. font: tdTheme.fontBodyLarge,
  951. fontWeight: FontWeight.w400,
  952. style: const TextStyle(letterSpacing: 0),
  953. ),
  954. ),
  955. const SizedBox(height: 4),
  956. if (hint != null) ...[
  957. Padding(padding: const EdgeInsets.only(left: 4), child: hint),
  958. ] else ...[
  959. Padding(
  960. padding: const EdgeInsets.only(left: 4, top: 4),
  961. child: TDText(
  962. _l10n.get('maxAttachment'),
  963. font: tdTheme.fontBodySmall,
  964. fontWeight: FontWeight.w400,
  965. textColor: tdTheme.textColorPlaceholder,
  966. ),
  967. ),
  968. const SizedBox(height: 4),
  969. AttachmentPicker(
  970. controller: _attachmentCtrl,
  971. maxImageSizeMB: 10,
  972. maxFileSizeMB: 20,
  973. allowedExtensions: const [
  974. 'pdf',
  975. 'doc',
  976. 'docx',
  977. 'xls',
  978. 'xlsx',
  979. 'ppt',
  980. 'pptx',
  981. 'txt',
  982. ],
  983. onFileRejected: (file, reason) {
  984. if (context.mounted) TDToast.showText(reason, context: context);
  985. },
  986. ),
  987. ],
  988. ],
  989. );
  990. }
  991. // ── 会计科目(级联选择器,支持手动修改) ──
  992. Widget _buildAcctSubjectCard(AppColorsExtension colors) {
  993. final tdTheme = TDTheme.of(context);
  994. final hasValue = _selCat.accNo.isNotEmpty;
  995. final displayValue = hasValue
  996. ? (_selCat.accName.startsWith(_selCat.accNo)
  997. ? _selCat.accName
  998. : (_selCat.accName.toString().isNotEmpty
  999. ? '${_selCat.accNo}/${_selCat.accName}'
  1000. : _selCat.accNo))
  1001. : _l10n.get('pleaseSelect');
  1002. return GestureDetector(
  1003. onTap: () {
  1004. if (widget.acctTree == null) {
  1005. TDToast.showText(_l10n.get('loading'), context: context);
  1006. return;
  1007. }
  1008. FocusManager.instance.primaryFocus?.unfocus();
  1009. TDCascader.showMultiCascader(
  1010. context,
  1011. title: _l10n.get('acctSubject'),
  1012. data: widget.acctTree as List<Map>,
  1013. theme: 'step',
  1014. onChange: (List<MultiCascaderListModel> selected) {
  1015. setState(() {
  1016. _selCat = CostProjectItem(
  1017. idx1: _selCat.idx1,
  1018. name: _selCat.name,
  1019. accNo: (selected.last.value ?? '').replaceFirst('self:', ''),
  1020. accName: (selected.last.label ?? '')
  1021. .replaceFirst(RegExp(r'^> '), '')
  1022. .replaceFirst('${selected.last.value ?? ''}/', ''),
  1023. );
  1024. });
  1025. },
  1026. );
  1027. },
  1028. child: Container(
  1029. padding: const EdgeInsets.only(
  1030. left: 16,
  1031. right: 10,
  1032. top: 12,
  1033. bottom: 12,
  1034. ),
  1035. decoration: BoxDecoration(
  1036. color: tdTheme.bgColorContainer,
  1037. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  1038. border: Border.all(color: tdTheme.componentStrokeColor),
  1039. ),
  1040. child: Row(
  1041. children: [
  1042. TDText(
  1043. _l10n.get('acctSubject'),
  1044. maxLines: 1,
  1045. overflow: TextOverflow.visible,
  1046. font: tdTheme.fontBodyLarge,
  1047. fontWeight: FontWeight.w400,
  1048. style: const TextStyle(letterSpacing: 0),
  1049. ),
  1050. const SizedBox(width: 12),
  1051. Expanded(
  1052. child: Row(
  1053. mainAxisAlignment: MainAxisAlignment.end,
  1054. mainAxisSize: MainAxisSize.max,
  1055. children: [
  1056. Flexible(
  1057. child: TDText(
  1058. displayValue,
  1059. maxLines: 1,
  1060. overflow: TextOverflow.ellipsis,
  1061. font: tdTheme.fontBodyLarge,
  1062. fontWeight: FontWeight.w400,
  1063. textColor: hasValue
  1064. ? tdTheme.textColorPrimary
  1065. : tdTheme.textColorPlaceholder,
  1066. textAlign: TextAlign.end,
  1067. ),
  1068. ),
  1069. const SizedBox(width: 4),
  1070. SizedBox(
  1071. width: 18,
  1072. height: 18,
  1073. child: hasValue
  1074. ? GestureDetector(
  1075. onTap: () {
  1076. setState(() {
  1077. _selCat = CostProjectItem(
  1078. idx1: _selCat.idx1,
  1079. name: _selCat.name,
  1080. accNo: '',
  1081. accName: '',
  1082. );
  1083. });
  1084. },
  1085. child: Icon(
  1086. Icons.close,
  1087. size: 18,
  1088. color: tdTheme.textColorPlaceholder,
  1089. ),
  1090. )
  1091. : Icon(
  1092. Icons.chevron_right,
  1093. size: 18,
  1094. color: tdTheme.textColorPlaceholder,
  1095. ),
  1096. ),
  1097. ],
  1098. ),
  1099. ),
  1100. ],
  1101. ),
  1102. ),
  1103. );
  1104. }
  1105. Widget _readOnlyCard({
  1106. required String label,
  1107. required String value,
  1108. required AppColorsExtension colors,
  1109. }) {
  1110. final tdTheme = TDTheme.of(context);
  1111. return Container(
  1112. padding: const EdgeInsets.only(left: 16, right: 16, top: 12, bottom: 12),
  1113. decoration: BoxDecoration(
  1114. color: tdTheme.bgColorContainer,
  1115. borderRadius: BorderRadius.circular(tdTheme.radiusDefault),
  1116. border: Border.all(color: tdTheme.componentStrokeColor),
  1117. ),
  1118. child: Row(
  1119. children: [
  1120. TDText(
  1121. label,
  1122. maxLines: 1,
  1123. overflow: TextOverflow.visible,
  1124. font: tdTheme.fontBodyLarge,
  1125. fontWeight: FontWeight.w400,
  1126. style: const TextStyle(letterSpacing: 0),
  1127. ),
  1128. const SizedBox(width: 12),
  1129. Expanded(
  1130. child: TDText(
  1131. value,
  1132. maxLines: 1,
  1133. overflow: TextOverflow.ellipsis,
  1134. font: tdTheme.fontBodyLarge,
  1135. fontWeight: FontWeight.w400,
  1136. textColor: tdTheme.textColorPrimary,
  1137. textAlign: TextAlign.end,
  1138. ),
  1139. ),
  1140. ],
  1141. ),
  1142. );
  1143. }
  1144. // ── 关联项目 ──
  1145. Widget _buildProjectCard(AppColorsExtension colors) {
  1146. return _pickerCard(
  1147. label: _l10n.get('relatedProject'),
  1148. required: false,
  1149. hasValue: _selProject != null,
  1150. currentLabel: _selProject != null
  1151. ? '${_selProject!.objNo}/${_selProject!.name}'
  1152. : _l10n.get('pleaseSelect'),
  1153. onTap: () async {
  1154. final result = await showSearchablePicker<ProjectCodeItem>(
  1155. context,
  1156. title: '${_l10n.get('select')}${_l10n.get('relatedProject')}',
  1157. searchHint: _l10n.get('search'),
  1158. loader: (keyword, page) => widget.api
  1159. .getProjectCodes(keyword: keyword, page: page, size: 20)
  1160. .then((list) => list.cast<ProjectCodeItem>()),
  1161. labelBuilder: (p) => '${p.objNo}/${p.name}',
  1162. onRefresh: () => widget.api.clearRefCache(),
  1163. );
  1164. if (result != null && mounted) {
  1165. setState(() => _selProject = result);
  1166. }
  1167. },
  1168. onClear: _selProject != null
  1169. ? () => setState(() => _selProject = null)
  1170. : null,
  1171. );
  1172. }
  1173. // ── 费用承担部门 ──
  1174. Widget _buildCostDeptCard(AppColorsExtension colors) {
  1175. return _pickerCard(
  1176. label: _l10n.get('costDept'),
  1177. required: false,
  1178. hasValue: _selDept != null,
  1179. currentLabel: _selDept != null
  1180. ? '${_selDept!.dep}/${_selDept!.name}'
  1181. : _l10n.get('pleaseSelect'),
  1182. onTap: () async {
  1183. final result = await showSearchablePicker<DepartmentItem>(
  1184. context,
  1185. title: '${_l10n.get('select')}${_l10n.get('costDept')}',
  1186. searchHint: _l10n.get('search'),
  1187. loader: (keyword, page) =>
  1188. widget.api.getDepartments(keyword: keyword, page: page, size: 20),
  1189. labelBuilder: (d) => d.name.isEmpty ? d.dep : '${d.dep} ${d.name}',
  1190. onRefresh: () => widget.api.clearRefCache(),
  1191. );
  1192. if (result != null && mounted) {
  1193. setState(() => _selDept = result);
  1194. }
  1195. },
  1196. onClear: _selDept != null ? () => setState(() => _selDept = null) : null,
  1197. );
  1198. }
  1199. // ── 收款银行信息 ──
  1200. Widget _buildBankInfoCard(AppColorsExtension colors) {
  1201. return Column(
  1202. crossAxisAlignment: CrossAxisAlignment.start,
  1203. children: [
  1204. _inputCard(
  1205. label: _l10n.get('bankName'),
  1206. required: false,
  1207. controller: _bankNameCtrl,
  1208. hintText: _l10n.get('pleaseEnter'),
  1209. colors: colors,
  1210. focusNode: _bankNameFocus,
  1211. ),
  1212. const SizedBox(height: 12),
  1213. _inputCard(
  1214. label: _l10n.get('bankAccountName'),
  1215. required: false,
  1216. controller: _bankAccountNameCtrl,
  1217. hintText: _l10n.get('pleaseEnter'),
  1218. colors: colors,
  1219. focusNode: _bankAccountNameFocus,
  1220. ),
  1221. const SizedBox(height: 12),
  1222. _inputCard(
  1223. label: _l10n.get('bankAccount'),
  1224. required: false,
  1225. controller: _bankAccountCtrl,
  1226. hintText: _l10n.get('pleaseEnter'),
  1227. colors: colors,
  1228. focusNode: _bankAccountFocus,
  1229. ),
  1230. ],
  1231. );
  1232. }
  1233. Widget _buildActions() {
  1234. return Row(
  1235. children: [
  1236. Expanded(
  1237. child: TDButton(
  1238. text: _l10n.get('cancel'),
  1239. size: TDButtonSize.large,
  1240. type: TDButtonType.outline,
  1241. shape: TDButtonShape.rectangle,
  1242. theme: TDButtonTheme.defaultTheme,
  1243. onTap: () => Navigator.pop(context),
  1244. ),
  1245. ),
  1246. const SizedBox(width: 12),
  1247. Expanded(
  1248. child: TDButton(
  1249. text: _isEdit ? _l10n.get('confirmEdit') : _l10n.get('add'),
  1250. size: TDButtonSize.large,
  1251. type: TDButtonType.fill,
  1252. shape: TDButtonShape.rectangle,
  1253. theme: TDButtonTheme.primary,
  1254. onTap: _confirm,
  1255. ),
  1256. ),
  1257. ],
  1258. );
  1259. }
  1260. }