index.js 734 Bytes
import { defineStore } from 'pinia'

export const useStore = defineStore('chronic', {
    state: () => {
        return {
            // 字典
            dict: []
        }
    },
    getters: {},
    actions: {
        getDict(dict) {
            if (!dict) return []
            return this.dict[dict] || []
        },
        getDictValue(dict, value) {
            let array = []
            if (typeof dict === 'string') {
                array = this.dict[dict]
            } else {
                array = dict
            }
            if (!array || !array.length) {
                return ''
            }
            let temp = array.find(e => e.value == value) || {}
            return temp.name || ''
        }
    }
})