hwh
2024-09-02 86d88edcc0af550fe34253fec3a782aa83f4242a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { App } from 'vue';
import { useUserInfo } from '/@/stores/userInfo';
 
export function setupConstFilter(app: App) {
    // 全局过滤器  在vue文件中调用  $filters.codeToName(code,type)
    app.config.globalProperties.$filters = {
        codeToName(code: any, type: any) {
            return codeToName(code, type);
        },
    };
}
 
// 常量值转换
export function codeToName(code: any, type: any) {
    const userStore = useUserInfo();
    try {
        const name = userStore.constList.find((x: any) => x.code === type).data.result.find((x: any) => x.code === code)?.name;
        return name;
    } catch (error) {
        return code;
    }
}
 
export function getConstType(type: any) {
    const userStore = useUserInfo();
    const constType = userStore.constList.filter((x: any) => x.code === type)[0].data.result;
    return constType;