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

diff --git a/src/views/archive/document/data.ts b/src/views/archive/document/data.ts
new file mode 100644
index 0000000..fa71c7d
--- /dev/null
+++ b/src/views/archive/document/data.ts
@@ -0,0 +1,442 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { ArchiveDocumentApi } from '#/api/archive/document';
+
+import { DICT_TYPE } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
+import { handleTree } from '@vben/utils';
+
+import { getCategoryList } from '#/api/archive/category';
+
+/** 琛ㄥ崟绫诲瀷 */
+export type FormType = 'create' | 'detail' | 'edit';
+
+/** 妗f琛ㄥ崟閰嶇疆 */
+export function useFormSchema(formType: FormType): VbenFormSchema[] {
+  const readonly = formType === 'detail';
+  // 妗f缂栧彿銆佹潵婧愩�佺姸鎬併�佸綊妗d汉鐢卞悗绔淮鎶わ紝浠呯紪杈�/璇︽儏鍙
+  const showBackendFields = formType !== 'create';
+
+  return [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'no',
+      label: '妗f缂栧彿',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => showBackendFields,
+      },
+      componentProps: {
+        disabled: true,
+        placeholder: '绯荤粺鑷姩鐢熸垚',
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '妗f鐘舵��',
+      component: 'Select',
+      dependencies: {
+        triggerFields: [''],
+        show: () => showBackendFields,
+      },
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_DOCUMENT_STATUS, 'number'),
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'title',
+      label: '妗f鏍囬',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        disabled: readonly,
+        placeholder: '璇疯緭鍏ユ。妗堟爣棰�',
+      },
+      rules: 'required',
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'categoryId',
+      label: '妗f鍒嗙被',
+      component: 'ApiTreeSelect',
+      componentProps: {
+        allowClear: true,
+        api: async () => handleTree(await getCategoryList({ status: 0 })),
+        fieldNames: { label: 'name', value: 'id', children: 'children' },
+        placeholder: '璇烽�夋嫨妗f鍒嗙被',
+        showSearch: true,
+        treeDefaultExpandAll: true,
+        disabled: readonly,
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'secretLevel',
+      label: '瀵嗙骇',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_SECRET_LEVEL, 'number'),
+        placeholder: '璇烽�夋嫨瀵嗙骇',
+        disabled: readonly,
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'carrierType',
+      label: '杞戒綋',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_CARRIER_TYPE, 'number'),
+        placeholder: '璇烽�夋嫨杞戒綋',
+        disabled: readonly,
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'archiveDate',
+      label: '褰掓。鏃ユ湡',
+      component: 'DatePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: '璇烽�夋嫨褰掓。鏃ユ湡',
+        disabled: readonly,
+      },
+      rules: 'required',
+    },
+    {
+      fieldName: 'shelfNo',
+      label: '涔︽灦鍙�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '濡� A鏋�',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'layerNo',
+      label: '灞傚彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '濡� 2灞�',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'columnNo',
+      label: '鍒楀彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '濡� 3鍒�',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'boxNo',
+      label: '鍐屽彿/妗f鐩掑彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '濡� 妗f鐩�-001',
+        disabled: readonly,
+      },
+    },
+    {
+      fieldName: 'storePlace',
+      label: '瀛樻斁浣嶇疆',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '濡� 3鍙峰簱鎴緼鏋�2灞�',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'tags',
+      label: '鍏抽敭璇�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '澶氫釜鍏抽敭璇嶇敤鑻辨枃閫楀彿鍒嗛殧锛屼究浜庢绱�',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'summary',
+      label: '鎽樿',
+      component: 'Textarea',
+      componentProps: {
+        rows: 2,
+        placeholder: '璇疯緭鍏ユ憳瑕�',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'sourceType',
+      label: '鏉ユ簮绫诲瀷',
+      component: 'Select',
+      dependencies: {
+        triggerFields: [''],
+        show: () => showBackendFields,
+      },
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_SOURCE_TYPE, 'number'),
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'sourceNo',
+      label: '鏉ユ簮鍗曞彿',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => showBackendFields,
+      },
+      componentProps: {
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'archivistName',
+      label: '褰掓。浜�',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => showBackendFields,
+      },
+      componentProps: {
+        disabled: true,
+      },
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: {
+        rows: 2,
+        placeholder: '璇疯緭鍏ュ娉�',
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+    {
+      fieldName: 'blobIds',
+      label: '鐢靛瓙鏂囦欢',
+      component: 'FileUpload',
+      componentProps: {
+        valueKey: 'id',
+        maxNumber: 10,
+        multiple: true,
+        showDescription: !readonly,
+        disabled: readonly,
+      },
+      formItemClass: 'col-span-2',
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'no',
+      label: '妗f缂栧彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ。妗堢紪鍙�',
+      },
+    },
+    {
+      fieldName: 'title',
+      label: '妗f鏍囬',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ。妗堟爣棰�',
+      },
+    },
+    {
+      fieldName: 'categoryId',
+      label: '妗f鍒嗙被',
+      component: 'ApiTreeSelect',
+      componentProps: {
+        allowClear: true,
+        api: async () => handleTree(await getCategoryList({ status: 0 })),
+        fieldNames: { label: 'name', value: 'id', children: 'children' },
+        placeholder: '璇烽�夋嫨妗f鍒嗙被',
+        showSearch: true,
+        treeDefaultExpandAll: true,
+      },
+    },
+    {
+      fieldName: 'secretLevel',
+      label: '瀵嗙骇',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_SECRET_LEVEL, 'number'),
+        allowClear: true,
+        placeholder: '璇烽�夋嫨瀵嗙骇',
+      },
+    },
+    {
+      fieldName: 'carrierType',
+      label: '杞戒綋',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_CARRIER_TYPE, 'number'),
+        allowClear: true,
+        placeholder: '璇烽�夋嫨杞戒綋',
+      },
+    },
+    {
+      fieldName: 'sourceType',
+      label: '鏉ユ簮绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_SOURCE_TYPE, 'number'),
+        allowClear: true,
+        placeholder: '璇烽�夋嫨鏉ユ簮绫诲瀷',
+      },
+    },
+    {
+      fieldName: 'sourceNo',
+      label: '鏉ユ簮鍗曞彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ潵婧愬崟鍙�',
+      },
+    },
+    {
+      fieldName: 'tags',
+      label: '鍏抽敭璇�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ュ叧閿瘝',
+      },
+    },
+    {
+      fieldName: 'status',
+      label: '妗f鐘舵��',
+      component: 'Select',
+      componentProps: {
+        options: getDictOptions(DICT_TYPE.ARCHIVE_DOCUMENT_STATUS, 'number'),
+        allowClear: true,
+        placeholder: '璇烽�夋嫨妗f鐘舵��',
+      },
+    },
+    {
+      fieldName: 'archiveDate',
+      label: '褰掓。鏃ユ湡',
+      component: 'RangePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD',
+        valueFormat: 'YYYY-MM-DD',
+        placeholder: ['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡'],
+      },
+    },
+  ];
+}
+
+/** 琛ㄦ牸鍒楅厤缃� */
+export function useGridColumns(): VxeTableGridOptions<ArchiveDocumentApi.Document>['columns'] {
+  return [
+    {
+      field: 'no',
+      title: '妗f缂栧彿',
+      minWidth: 170,
+    },
+    {
+      field: 'title',
+      title: '妗f鏍囬',
+      minWidth: 220,
+    },
+    {
+      field: 'categoryName',
+      title: '妗f鍒嗙被',
+      minWidth: 120,
+    },
+    {
+      field: 'secretLevel',
+      title: '瀵嗙骇',
+      minWidth: 90,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ARCHIVE_SECRET_LEVEL },
+      },
+    },
+    {
+      field: 'carrierType',
+      title: '杞戒綋',
+      minWidth: 110,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ARCHIVE_CARRIER_TYPE },
+      },
+    },
+    {
+      field: 'sourceType',
+      title: '鏉ユ簮',
+      minWidth: 90,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ARCHIVE_SOURCE_TYPE },
+      },
+    },
+    {
+      field: 'sourceNo',
+      title: '鏉ユ簮鍗曞彿',
+      minWidth: 160,
+    },
+    {
+      field: 'storePlace',
+      title: '瀛樻斁浣嶇疆',
+      minWidth: 170,
+    },
+    {
+      field: 'archiveDate',
+      title: '褰掓。鏃ユ湡',
+      minWidth: 120,
+    },
+    {
+      field: 'status',
+      title: '妗f鐘舵��',
+      minWidth: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.ARCHIVE_DOCUMENT_STATUS },
+      },
+    },
+    {
+      field: 'hasAttachment',
+      title: '鐢靛瓙鏂囦欢',
+      minWidth: 100,
+      slots: { default: 'hasAttachment' },
+    },
+    {
+      title: '鎿嶄綔',
+      width: 200,
+      fixed: 'right',
+      slots: { default: 'actions' },
+    },
+  ];
+}

--
Gitblit v1.9.3