From 534533425b15b183cea60fa162d9884e5d3c6243 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 13 十月 2026 17:55:50 +0800
Subject: [PATCH] Merge branch 'dev_海西州_北京同仁堂' into dev_海西州_惠牧

---
 src/views/erp/finance/ledger/data.ts |  214 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 214 insertions(+), 0 deletions(-)

diff --git a/src/views/erp/finance/ledger/data.ts b/src/views/erp/finance/ledger/data.ts
new file mode 100644
index 0000000..d41cfd2
--- /dev/null
+++ b/src/views/erp/finance/ledger/data.ts
@@ -0,0 +1,214 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { FinLedgerApi } from '#/api/erp/finance/ledger';
+
+import { DICT_TYPE } from '@vben/constants';
+
+import { z } from '#/adapter/form';
+import { getAccountSubjectList } from '#/api/erp/finance/subject';
+
+import dayjs from 'dayjs';
+
+/** 琛岀被鍨� -> 灞曠ず鏂囨 */
+export const LEDGER_ROW_TYPE_LABEL: Record<string, string> = {
+  opening: '鏈熷垵浣欓',
+  entry: '鏄庣粏',
+  monthly_total: '鏈湀鍚堣',
+  yearly_total: '鏈勾绱',
+};
+
+/** 琛岀被鍨� -> Tag 棰滆壊 */
+export const LEDGER_ROW_TYPE_COLOR: Record<string, string> = {
+  opening: 'blue',
+  entry: 'default',
+  monthly_total: 'orange',
+  yearly_total: 'purple',
+};
+
+/**
+ * 璐﹂〉鏌ヨ琛ㄥ崟
+ *
+ * 璇存槑锛氳处椤靛彧缁熻銆屽凡杩囪处銆嶇殑鍑瘉锛屾湭杩囪处銆佸凡浣滃簾鐨勫嚟璇佷笉璁″叆銆�
+ */
+export function useLedgerFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'subjectCode',
+      label: '浼氳绉戠洰',
+      component: 'ApiTreeSelect',
+      componentProps: {
+        api: getAccountSubjectList,
+        labelField: 'subjectName',
+        valueField: 'subjectCode',
+        childrenField: 'children',
+        placeholder: '璇烽�夋嫨浼氳绉戠洰',
+        treeDefaultExpandAll: true,
+        showSearch: true,
+        treeNodeFilterProp: 'subjectName',
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'startMonth',
+      label: '璧峰鏈堜唤',
+      component: 'DatePicker',
+      componentProps: {
+        picker: 'month',
+        allowClear: true,
+        valueFormat: 'YYYY-MM',
+        format: 'YYYY-MM',
+        style: { width: '100%' },
+        placeholder: '閫夋嫨璧峰鏈堜唤',
+      },
+      defaultValue: dayjs().startOf('year').format('YYYY-MM'),
+    },
+    {
+      fieldName: 'endMonth',
+      label: '缁撴潫鏈堜唤',
+      component: 'DatePicker',
+      componentProps: {
+        picker: 'month',
+        allowClear: true,
+        valueFormat: 'YYYY-MM',
+        format: 'YYYY-MM',
+        style: { width: '100%' },
+        placeholder: '閫夋嫨缁撴潫鏈堜唤',
+      },
+      defaultValue: dayjs().format('YYYY-MM'),
+    },
+    {
+      fieldName: 'includeChildren',
+      label: '鍖呭惈涓嬬骇绉戠洰',
+      component: 'Switch',
+      componentProps: {
+        checkedChildren: '鏄�',
+        unCheckedChildren: '鍚�',
+      },
+      defaultValue: false,
+      rules: z.boolean().default(false).optional(),
+      help: '寮�鍚悗锛屾墍閫夌鐩強鍏跺叏閮ㄤ笅绾х鐩殑鍙戠敓棰濅笌浣欓鍚堝苟缁熻',
+    },
+  ];
+}
+
+/** 鎬昏处鍒楋細鏈熷垵 + 閫愭湀鍚堣 + 鏈勾绱 */
+export function useGeneralColumns(): VxeTableGridOptions<FinLedgerApi.LedgerRow>['columns'] {
+  return [
+    {
+      field: 'rowType',
+      title: '琛岀被鍨�',
+      width: 110,
+      fixed: 'left',
+      slots: { default: 'rowType' },
+    },
+    {
+      field: 'period',
+      title: '鏈熼棿',
+      width: 110,
+    },
+    {
+      field: 'subjectCode',
+      title: '绉戠洰缂栫爜',
+      minWidth: 120,
+    },
+    {
+      field: 'subjectName',
+      title: '绉戠洰鍚嶇О',
+      minWidth: 160,
+    },
+    {
+      field: 'debit',
+      title: '鍊熸柟鍙戠敓棰�',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+    {
+      field: 'credit',
+      title: '璐锋柟鍙戠敓棰�',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+    {
+      field: 'direction',
+      title: '鏂瑰悜',
+      width: 80,
+      align: 'center',
+      slots: { default: 'direction' },
+    },
+    {
+      field: 'balance',
+      title: '鏈熸湯浣欓',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+  ];
+}
+
+/** 鏄庣粏璐﹀垪锛氭湡鍒� + 閫愮瑪鍒嗗綍 + 缁撹浆鍚堣 */
+export function useDetailColumns(): VxeTableGridOptions<FinLedgerApi.LedgerRow>['columns'] {
+  return [
+    {
+      field: 'rowType',
+      title: '琛岀被鍨�',
+      width: 110,
+      fixed: 'left',
+      slots: { default: 'rowType' },
+    },
+    {
+      field: 'date',
+      title: '鏃ユ湡',
+      width: 120,
+      formatter: 'formatDate',
+    },
+    {
+      field: 'voucherNo',
+      title: '鍑瘉瀛楀彿',
+      minWidth: 140,
+    },
+    {
+      field: 'subjectCode',
+      title: '绉戠洰缂栫爜',
+      minWidth: 120,
+    },
+    {
+      field: 'summary',
+      title: '鎽樿',
+      minWidth: 200,
+      showOverflow: 'tooltip',
+    },
+    {
+      field: 'debit',
+      title: '鍊熸柟閲戦',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+    {
+      field: 'credit',
+      title: '璐锋柟閲戦',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+    {
+      field: 'direction',
+      title: '鏂瑰悜',
+      width: 80,
+      align: 'center',
+      slots: { default: 'direction' },
+    },
+    {
+      field: 'balance',
+      title: '浣欓',
+      minWidth: 140,
+      align: 'right',
+      formatter: 'formatAmount2',
+    },
+  ];
+}
+
+/** 浣欓鏂瑰悜瀛楀吀绫诲瀷锛屼緵椤甸潰娓叉煋鏂瑰悜鏍囩浣跨敤 */
+export const LEDGER_DIRECTION_DICT = DICT_TYPE.FINANCE_BALANCE_DIRECTION;

--
Gitblit v1.9.3