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/subject/data.ts |  210 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/src/views/erp/finance/subject/data.ts b/src/views/erp/finance/subject/data.ts
new file mode 100644
index 0000000..ff4572b
--- /dev/null
+++ b/src/views/erp/finance/subject/data.ts
@@ -0,0 +1,210 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { FinAccountSubjectApi } from '#/api/erp/finance/subject';
+
+import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+import { handleTree } from '@vben/utils';
+
+import { z } from '#/adapter/form';
+import { getAccountSubjectList } from '#/api/erp/finance/subject';
+
+/** 鏂板/淇敼鐨勮〃鍗� */
+export function useFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      component: 'Input',
+      fieldName: 'id',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'parentId',
+      label: '涓婄骇绉戠洰',
+      component: 'ApiTreeSelect',
+      componentProps: {
+        allowClear: true,
+        api: async () => handleTree(await getAccountSubjectList()),
+        labelField: 'subjectName',
+        valueField: 'id',
+        childrenField: 'children',
+        placeholder: '涓嶉�夋嫨鏃跺垱寤轰负涓�绾х鐩�',
+        treeDefaultExpandAll: true,
+      },
+      help: '鍙湁鏈骇绉戠洰鍙互琚嚟璇佸紩鐢紱宸插瓨鍦ㄤ笅绾х鐩椂涓嶅彲鍐嶆敼涓轰粬绉戠洰鐨勪笅绾�',
+      rules: z.number().optional(),
+    },
+    {
+      fieldName: 'subjectCode',
+      label: '绉戠洰缂栫爜',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ョ鐩紪鐮侊紝濡� 1001',
+        allowClear: true,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'subjectName',
+      label: '绉戠洰鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ョ鐩悕绉帮紝濡� 搴撳瓨鐜伴噾',
+        allowClear: true,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'subjectType',
+      label: '绉戠洰绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.FINANCE_SUBJECT_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨绉戠洰绫诲瀷',
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'balanceDirection',
+      label: '浣欓鏂瑰悜',
+      component: 'RadioGroup',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.FINANCE_BALANCE_DIRECTION, 'number'),
+        buttonStyle: 'solid',
+        optionType: 'button',
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'RadioGroup',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+        buttonStyle: 'solid',
+        optionType: 'button',
+      },
+      rules: z.number().default(CommonStatusEnum.ENABLE),
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: {
+        placeholder: '璇疯緭鍏ュ娉�',
+        rows: 3,
+      },
+      formItemClass: 'md:col-span-2',
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'subjectCode',
+      label: '绉戠洰缂栫爜',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ョ鐩紪鐮�',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'subjectName',
+      label: '绉戠洰鍚嶇О',
+      component: 'Input',
+      componentProps: {
+        placeholder: '璇疯緭鍏ョ鐩悕绉�',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'subjectType',
+      label: '绉戠洰绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.FINANCE_SUBJECT_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨绉戠洰绫诲瀷',
+        allowClear: true,
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
+        placeholder: '璇烽�夋嫨鐘舵��',
+        allowClear: true,
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<FinAccountSubjectApi.AccountSubject>['columns'] {
+  return [
+    { type: 'checkbox', width: 40 },
+    {
+      field: 'subjectCode',
+      title: '绉戠洰缂栫爜',
+      minWidth: 140,
+      fixed: 'left',
+      treeNode: true,
+    },
+    {
+      field: 'subjectName',
+      title: '绉戠洰鍚嶇О',
+      minWidth: 180,
+    },
+    {
+      field: 'subjectType',
+      title: '绉戠洰绫诲瀷',
+      minWidth: 120,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.FINANCE_SUBJECT_TYPE },
+      },
+    },
+    {
+      field: 'balanceDirection',
+      title: '浣欓鏂瑰悜',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.FINANCE_BALANCE_DIRECTION },
+      },
+    },
+    {
+      field: 'status',
+      title: '鐘舵��',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.COMMON_STATUS },
+      },
+    },
+    {
+      field: 'remark',
+      title: '澶囨敞',
+      minWidth: 150,
+      showOverflow: 'tooltip',
+    },
+    {
+      field: 'createTime',
+      title: '鍒涘缓鏃堕棿',
+      minWidth: 180,
+      formatter: 'formatDateTime',
+    },
+    {
+      title: '鎿嶄綔',
+      width: 200,
+      fixed: 'right',
+      slots: { default: 'actions' },
+    },
+  ];
+}

--
Gitblit v1.9.3