yanzhen-design-vue
Version:
61 lines (60 loc) • 1.82 kB
JavaScript
import "../../../_utils/index.mjs";
import { Contacts, contactsTypes } from "../constants/contacts.mjs";
import { ListMode } from "../constants/list-mode.mjs";
import { CONTACTS_API_KEY } from "../constants/apis.mjs";
import { getUserListMode, getUserDefaultRefs } from "./user.mjs";
import { createContactsDefaultRef } from "./createContactsDefaultRef.mjs";
import { $enum } from "ts-enum-util";
import { handleUndefined } from "../../../_utils/enum-utils.mjs";
const getApiSymbol = () => {
return { ...CONTACTS_API_KEY };
};
const contactsEnum = $enum(Contacts);
function getContactsLabel(contacts) {
return $enum.mapValue(contacts).with({
[]: "常用",
[]: "用户",
[]: "往来单位",
[]: "角色",
[]: "组织",
[]: "群组",
[]: "Unspecified"
});
}
function getContactsListMode(contacts, children) {
return $enum.mapValue(contacts).with({
[]: ListMode.LIST,
[]: getUserListMode(children),
[]: ListMode.LIST,
[]: ListMode.LIST,
[]: ListMode.TREE,
[]: ListMode.LIST,
[]: "Unspecified"
});
}
const getContactsTypesMaps = () => {
return contactsEnum.map((k) => {
return {
value: k,
label: getContactsLabel(k)
};
});
};
const useContactsDefaultRefs = () => {
return contactsTypes.reduce((prev, key) => {
if (key === Contacts.USER) {
prev[key] = getUserDefaultRefs();
} else {
prev[key] = createContactsDefaultRef(key);
}
return prev;
}, {});
};
export {
contactsEnum,
getApiSymbol,
getContactsLabel,
getContactsListMode,
getContactsTypesMaps,
useContactsDefaultRefs
};