mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2026-02-03 14:28:13 +00:00
优化
This commit is contained in:
parent
795d1a2cc0
commit
8323a4f8ba
@ -5,7 +5,7 @@ import { service } from "/@/cool";
|
|||||||
import { deepTree } from "/@/cool/utils";
|
import { deepTree } from "/@/cool/utils";
|
||||||
import { isDev } from "/@/config";
|
import { isDev } from "/@/config";
|
||||||
import { isArray } from "lodash-es";
|
import { isArray } from "lodash-es";
|
||||||
import { deepFind } from "../utils";
|
import { deepFind, isEmpty } from "../utils";
|
||||||
|
|
||||||
const useDictStore = defineStore("dict", () => {
|
const useDictStore = defineStore("dict", () => {
|
||||||
// 对象数据
|
// 对象数据
|
||||||
@ -26,7 +26,7 @@ const useDictStore = defineStore("dict", () => {
|
|||||||
async function refresh(types?: string[]) {
|
async function refresh(types?: string[]) {
|
||||||
return service.dict.info
|
return service.dict.info
|
||||||
.data({
|
.data({
|
||||||
types
|
types: types?.filter((e) => !isEmpty(e))
|
||||||
})
|
})
|
||||||
.then((res: Dict.Data) => {
|
.then((res: Dict.Data) => {
|
||||||
const d = {};
|
const d = {};
|
||||||
@ -35,7 +35,7 @@ const useDictStore = defineStore("dict", () => {
|
|||||||
arr.forEach((e) => {
|
arr.forEach((e) => {
|
||||||
e.label = e.name;
|
e.label = e.name;
|
||||||
|
|
||||||
if (e.value === undefined || e.value === "" || e.value === null) {
|
if (isEmpty(e.value)) {
|
||||||
e.value = e.id;
|
e.value = e.id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -15,3 +15,7 @@ export function deepFind(value: any, list: any[]) {
|
|||||||
|
|
||||||
return deep(list);
|
return deep(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEmpty(val: any) {
|
||||||
|
return val === "" || val === null || val === undefined;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user