From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/components/FormCreate/src/config/useDictSelectRule.ts |   64 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/components/FormCreate/src/config/useDictSelectRule.ts b/src/components/FormCreate/src/config/useDictSelectRule.ts
new file mode 100644
index 0000000..f232f48
--- /dev/null
+++ b/src/components/FormCreate/src/config/useDictSelectRule.ts
@@ -0,0 +1,64 @@
+import { generateUUID } from '@/utils'
+import * as DictDataApi from '@/api/system/dict/dict.type'
+import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
+import { selectRule } from '@/components/FormCreate/src/config/selectRule'
+import { cloneDeep } from 'lodash-es'
+
+/**
+ * 瀛楀吀閫夋嫨鍣ㄨ鍒欙紝濡傛灉瑙勫垯浣跨敤鍒板姩鎬佹暟鎹垯闇�瑕佸崟鐙厤缃笉鑳戒娇鐢� useSelectRule
+ */
+export const useDictSelectRule = () => {
+  const label = '瀛楀吀閫夋嫨鍣�'
+  const name = 'DictSelect'
+  const rules = cloneDeep(selectRule)
+  const dictOptions = ref<{ label: string; value: string }[]>([]) // 瀛楀吀绫诲瀷涓嬫媺鏁版嵁
+  onMounted(async () => {
+    const data = await DictDataApi.getSimpleDictTypeList()
+    if (!data || data.length === 0) {
+      return
+    }
+    dictOptions.value =
+      data?.map((item: DictDataApi.DictTypeVO) => ({
+        label: item.name,
+        value: item.type
+      })) ?? []
+  })
+  return {
+    icon: 'icon-doc-text',
+    label,
+    name,
+    rule() {
+      return {
+        type: name,
+        field: generateUUID(),
+        title: label,
+        info: '',
+        $required: false
+      }
+    },
+    props(_, { t }) {
+      return localeProps(t, name + '.props', [
+        makeRequiredRule(),
+        {
+          type: 'select',
+          field: 'dictType',
+          title: '瀛楀吀绫诲瀷',
+          value: '',
+          options: dictOptions.value
+        },
+        {
+          type: 'select',
+          field: 'valueType',
+          title: '瀛楀吀鍊肩被鍨�',
+          value: 'str',
+          options: [
+            { label: '鏁板瓧', value: 'int' },
+            { label: '瀛楃涓�', value: 'str' },
+            { label: '甯冨皵鍊�', value: 'bool' }
+          ]
+        },
+        ...rules
+      ])
+    }
+  }
+}

--
Gitblit v1.8.0