From 982c97ab82f3beb1b4febcf014562eda34b9fc05 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期二, 29 九月 2026 17:59:41 +0800
Subject: [PATCH] feat(ui): 江苏商贸品牌视觉与首页/登录页改版

---
 src/views/archive/borrow/data.ts |  307 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 307 insertions(+), 0 deletions(-)

diff --git a/src/views/archive/borrow/data.ts b/src/views/archive/borrow/data.ts
new file mode 100644
index 0000000..c251154
--- /dev/null
+++ b/src/views/archive/borrow/data.ts
@@ -0,0 +1,307 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { ArchiveBorrowApi } from '#/api/archive/borrow';
+
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+
+import { getDocumentPage } from '#/api/archive/document';
+import { getSimpleUserList } from '#/api/system/user';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'detail' | 'edit';
+
+/** 鍊熼槄鍗曠姸鎬侊紙瀵瑰簲瀛楀吀 archive_borrow_status锛� */
+export const BorrowStatus = {
+  DRAFT: 0, // 鑽夌
+  APPROVING: 15, // 瀹℃壒涓�
+  BORROWED: 20, // 鍊熷嚭涓�
+  RETURNED: 30, // 宸插綊杩�
+  REJECTED: 35, // 宸查┏鍥�
+} as const;
+
+/** 鍊熼槄鐧昏琛ㄥ崟閰嶇疆 */
+export function useFormSchema(
+  formType: FormType,
+  documentId?: number,
+): VbenFormSchema[] {
+  const readonly = formType === 'detail';
+  return [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'documentId',
+      label: '鍊熼槄妗f',
+      component: 'ApiSelect',
+      componentProps: {
+        allowClear: true,
+        showSearch: true,
+        placeholder: '璇烽�夋嫨鍦ㄥ簱妗f',
+        api: async () => {
+          const { list } = await getDocumentPage({
+            pageNo: 1,
+            pageSize: 100,
+            status: 10,
+          });
+          return list.map((item) => ({
+            id: item.id,
+            label: item.no ? `${item.no} ${item.title}` : item.title,
+          }));
+        },
+        labelField: 'label',
+        valueField: 'id',
+        disabled: readonly || !!documentId,
+      },
+      rules: 'selectRequired',
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'borrowerUserId',
+      label: '鍊熼槄浜�',
+      component: 'ApiSelect',
+      componentProps: {
+        allowClear: true,
+        showSearch: true,
+        placeholder: '璇烽�夋嫨鍊熼槄浜�',
+        api: getSimpleUserList,
+        labelField: 'nickname',
+        valueField: 'id',
+        disabled: readonly,
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'borrowerName',
+      label: '鍊熼槄浜哄鍚�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ュ�熼槄浜哄鍚�',
+        disabled: readonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'borrowerDept',
+      label: '鍊熼槄浜洪儴闂�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ュ�熼槄浜洪儴闂�',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'borrowerPhone',
+      label: '鑱旂郴鐢佃瘽',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ヨ仈绯荤數璇�',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'borrowDate',
+      label: '鍊熼槄鏃ユ湡',
+      component: 'DatePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: '璇烽�夋嫨鍊熼槄鏃ユ湡',
+        disabled: readonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'returnDeadline',
+      label: '褰掕繕鏈熼檺',
+      component: 'DatePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: '璇烽�夋嫨褰掕繕鏈熼檺',
+        disabled: readonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'borrowPurpose',
+      label: '鍊熼槄鐩殑',
+      component: 'Textarea',
+      componentProps: {
+        rows: 2,
+        placeholder: '璇疯緭鍏ュ�熼槄鐩殑',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: {
+        rows: 2,
+        placeholder: '璇疯緭鍏ュ娉�',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'no',
+      label: '鍊熼槄鍗曞彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ュ�熼槄鍗曞彿',
+      },
+    },
+    {
+      fieldName: 'documentNo',
+      label: '妗f缂栧彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ。妗堢紪鍙�',
+      },
+    },
+    {
+      fieldName: 'documentTitle',
+      label: '妗f鏍囬',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ。妗堟爣棰�',
+      },
+    },
+    {
+      fieldName: 'borrowerName',
+      label: '鍊熼槄浜�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ュ�熼槄浜哄鍚�',
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '鐘舵��',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_BORROW_STATUS, 'number'),
+        allowClear: true,
+        placeholder: '璇烽�夋嫨鐘舵��',
+      },
+    },
+    {
+      fieldName: 'borrowDate',
+      label: '鍊熼槄鏃ユ湡',
+      component: 'RangePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: ['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡'],
+      },
+    },
+    {
+      fieldName: 'returnDeadline',
+      label: '褰掕繕鏈熼檺',
+      component: 'RangePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: ['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡'],
+      },
+    },
+  ];
+}
+
+/** 琛ㄦ牸鍒楅厤缃� */
+export function useGridColumns(): VxeTableGridOptions<ArchiveBorrowApi.Borrow>['columns'] {
+  return [
+    {
+      field: 'no',
+      title: '鍊熼槄鍗曞彿',
+      minWidth: 170,
+    },
+    {
+      field: 'documentNo',
+      title: '妗f缂栧彿',
+      minWidth: 170,
+    },
+    {
+      field: 'documentTitle',
+      title: '妗f鏍囬',
+      minWidth: 200,
+    },
+    {
+      field: 'borrowerName',
+      title: '鍊熼槄浜�',
+      minWidth: 100,
+    },
+    {
+      field: 'borrowerDept',
+      title: '閮ㄩ棬',
+      minWidth: 120,
+    },
+    {
+      field: 'borrowDate',
+      title: '鍊熼槄鏃ユ湡',
+      minWidth: 120,
+    },
+    {
+      field: 'returnDeadline',
+      title: '褰掕繕鏈熼檺',
+      minWidth: 120,
+    },
+    {
+      field: 'overdue',
+      title: '閫炬湡',
+      minWidth: 110,
+      slots: { default: 'overdue' },
+    },
+    {
+      field: 'status',
+      title: '鐘舵��',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ARCHIVE_BORROW_STATUS },
+      },
+    },
+    {
+      field: 'approveTime',
+      title: '鍊熷嚭鏃堕棿',
+      minWidth: 170,
+      formatter: 'formatDateTime',
+    },
+    {
+      field: 'returnTime',
+      title: '褰掕繕鏃堕棿',
+      minWidth: 170,
+      formatter: 'formatDateTime',
+    },
+    {
+      title: '鎿嶄綔',
+      width: 230,
+      fixed: 'right',
+      slots: { default: 'actions' },
+    },
+  ];
+}

--
Gitblit v1.9.3