|
@@ -7,18 +7,18 @@ import { getStoreObject, setStoreObject } from './common'
|
|
|
const DICT_NAME = '_dict';
|
|
|
export const useDictStoreWithOut = () => {
|
|
|
const listSimpleDictData = async () => {
|
|
|
- const result = await request.get('/system/dict-data/list-all-simple')
|
|
|
+ const result = await request.get('/admin-api/system/dict-data/list-all-simple')
|
|
|
return result.data;
|
|
|
}
|
|
|
const dictObj = getStoreObject(DICT_NAME);
|
|
|
- if (!dictObj) {
|
|
|
- const resultData = listSimpleDictData()
|
|
|
- if (resultData && resultData?.length > 0) {
|
|
|
- setStoreObject(DICT_NAME, resultData);
|
|
|
- }
|
|
|
+ if (!dictObj) {
|
|
|
+ listSimpleDictData().then((resultData) => {
|
|
|
+ if (resultData && resultData?.length > 0) {
|
|
|
+ setStoreObject(DICT_NAME, resultData);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
-const dictStore = useDictStoreWithOut()
|
|
|
|
|
|
/**
|
|
|
* 获取 dictType 对应的数据字典数组
|
|
@@ -33,8 +33,25 @@ export interface DictDataType {
|
|
|
cssClass: string
|
|
|
}
|
|
|
|
|
|
-export const getDictOptions = (dictType: string) => {
|
|
|
- return dictStore.getDictByType(dictType) || []
|
|
|
+export const getDictOptions = (dictType: string, option: {
|
|
|
+ dictType?: string
|
|
|
+ label?: string
|
|
|
+ value?: string
|
|
|
+ cssClass?: string
|
|
|
+}) => {
|
|
|
+ const dictStore = getStoreObject(DICT_NAME);
|
|
|
+ const nDicts: any[] = []
|
|
|
+ dictStore.forEach((dict: DictDataType) => {
|
|
|
+ if (dict.dictType === dictType) {
|
|
|
+ nDicts.push({
|
|
|
+ [option.dictType ?? 'dictType']: dict.dictType,
|
|
|
+ [option.label ?? 'label']: dict.label,
|
|
|
+ [option.value ?? 'value']: dict.value,
|
|
|
+ [option.cssClass ?? 'cssClass']: dict.cssClass,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return nDicts;
|
|
|
}
|
|
|
|
|
|
export const getIntDictOptions = (dictType: string) => {
|
|
@@ -162,5 +179,6 @@ export enum DICT_TYPE {
|
|
|
POST_TYPE = 'post_type',
|
|
|
ABILITY_LEVEL = 'ABILITY_LEVEL',
|
|
|
INVOICE_OUT_STATUS = 'INVOICE_OUT_STATUS',
|
|
|
- INVOICE_TYPE = 'invoice_type'
|
|
|
+ INVOICE_TYPE = 'invoice_type',
|
|
|
+ WF_LEAVE_TYPE = 'WF_LEAVE_TYPE'
|
|
|
}
|