dictionary.ts 441 B

12345678910111213141516
  1. import { toRaw } from 'vue';
  2. import { DictionaryStore } from '/@/stores/dictionary';
  3. /**
  4. * @method 获取指定name字典
  5. */
  6. export const dictionary = (name: string,key?:string|number|undefined) => {
  7. const dict = DictionaryStore()
  8. const dictionary = toRaw(dict.data)
  9. if(key!=undefined){
  10. const obj = dictionary[name].find((item:any) => item.value === key)
  11. return obj?obj.label:''
  12. }else{
  13. return dictionary[name]
  14. }
  15. }