神仙都没用 1 năm trước cách đây
mục cha
commit
8323a4f8ba
2 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 3 3
      src/modules/dict/store/dict.ts
  2. 4 0
      src/modules/dict/utils/index.ts

+ 3 - 3
src/modules/dict/store/dict.ts

@@ -5,7 +5,7 @@ import { service } from "/@/cool";
 import { deepTree } from "/@/cool/utils";
 import { isDev } from "/@/config";
 import { isArray } from "lodash-es";
-import { deepFind } from "../utils";
+import { deepFind, isEmpty } from "../utils";
 
 const useDictStore = defineStore("dict", () => {
 	// 对象数据
@@ -26,7 +26,7 @@ const useDictStore = defineStore("dict", () => {
 	async function refresh(types?: string[]) {
 		return service.dict.info
 			.data({
-				types
+				types: types?.filter((e) => !isEmpty(e))
 			})
 			.then((res: Dict.Data) => {
 				const d = {};
@@ -35,7 +35,7 @@ const useDictStore = defineStore("dict", () => {
 					arr.forEach((e) => {
 						e.label = e.name;
 
-						if (e.value === undefined || e.value === "" || e.value === null) {
+						if (isEmpty(e.value)) {
 							e.value = e.id;
 						}
 					});

+ 4 - 0
src/modules/dict/utils/index.ts

@@ -15,3 +15,7 @@ export function deepFind(value: any, list: any[]) {
 
 	return deep(list);
 }
+
+export function isEmpty(val: any) {
+	return val === "" || val === null || val === undefined;
+}