export class dictManage { constructor(data) { this.data = data this.valueMap = new Map(data.map(item => [item.value, item.name])) this.nameMap = new Map(data.map(item => [item.name, item.value])) } getAll() { return this.data } getValue(name) { return this.nameMap.get(name) || '' } getName(value) { return this.valueMap.get(value) || '' } // 获取所有value的数组 getValues() { return Array.from(this.valueMap.keys()); } // 获取所有name的数组 getNames() { return Array.from(this.valueMap.values()); } }