From 5209c2fb7f9b764aed59f827420e151bf649bdb3 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 26 九月 2025 14:33:49 +0800
Subject: [PATCH] 生产派工页面开发联调
---
src/utils/dict.ts | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/utils/dict.ts b/src/utils/dict.ts
new file mode 100644
index 0000000..bd4284f
--- /dev/null
+++ b/src/utils/dict.ts
@@ -0,0 +1,30 @@
+import useDictStore from "@/store/modules/dict";
+import { getDicts } from "@/api/system/dict/data";
+import { Ref, ref, toRefs } from "vue";
+
+/**
+ * 鑾峰彇瀛楀吀鏁版嵁
+ */
+export function useDict(...args: any[]) {
+ const res: Ref<any> = ref({});
+ return (() => {
+ args.forEach((dictType, index) => {
+ res.value[dictType] = [];
+ const dicts = useDictStore().getDict(dictType);
+ if (dicts) {
+ res.value[dictType] = dicts;
+ } else {
+ getDicts(dictType).then((resp) => {
+ res.value[dictType] = resp.data.map((p: any) => ({
+ label: p.dictLabel,
+ value: p.dictValue,
+ elTagType: p.listClass,
+ elTagClass: p.cssClass,
+ }));
+ useDictStore().setDict(dictType, res.value[dictType]);
+ });
+ }
+ });
+ return toRefs(res.value);
+ })();
+}
--
Gitblit v1.9.3