From f35825c1922149df154e3913d6dfebee57ee8cee Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 16 七月 2026 15:52:40 +0800
Subject: [PATCH] 部分功能修改

---
 src/views/basicData/mdm/data.ts |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/views/basicData/mdm/data.ts b/src/views/basicData/mdm/data.ts
index bbde65a..3ff52a2 100644
--- a/src/views/basicData/mdm/data.ts
+++ b/src/views/basicData/mdm/data.ts
@@ -1,12 +1,18 @@
-import type { VbenFormSchema } from "#/adapter/form";
+import type { VbenFormApi, VbenFormSchema } from "#/adapter/form";
 import type { VxeTableGridOptions } from "#/adapter/vxe-table";
+
+import { h } from 'vue';
 
 import { CommonStatusEnum, DICT_TYPE } from "#/packages/constants/src";
 import { getDictOptions } from "#/packages/effects/hooks/src";
 
 import { z } from '#/adapter/form';
+import { generateAutoCode } from '#/api/mes/md/autocode/record';
+import { MesAutoCodeRuleCode } from '@vben/constants';
 import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
 import { getUnitPage } from '#/api/mdm/unit';
+
+import { Button } from 'ant-design-vue';
 
 // 缂撳瓨鍗曚綅鍒楄〃
 let unitListCache: any[] | null = null;
@@ -30,7 +36,7 @@
 }
 
 /** 鏂板/淇敼鐨勮〃鍗� */
-export function useFormSchema(): VbenFormSchema[] {
+export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
   return [
     {
       component: "Input",
@@ -45,9 +51,24 @@
       fieldName: "code",
       label: "鐗╂枡缂栫爜",
       componentProps: {
+        maxLength: 64,
         placeholder: "璇疯緭鍏ョ墿鏂欑紪鐮�",
       },
-      rules: "required",
+      rules: z.string().min(1, '鐗╂枡缂栫爜涓嶈兘涓虹┖').max(64),
+      suffix: () =>
+        h(
+          Button,
+          {
+            type: 'default',
+            onClick: async () => {
+              const code = await generateAutoCode(
+                MesAutoCodeRuleCode.MD_ITEM_CODE,
+              );
+              await formApi?.setFieldValue('code', code);
+            },
+          },
+          { default: () => '鐢熸垚' },
+        ),
     },
     {
       component: "Input",

--
Gitblit v1.9.3