Files
mayfly-go/mayfly_go_web/src/common/Enum.ts

38 lines
804 B
TypeScript
Raw Normal View History

/**
*
* @author meilin.huang
*/
export class Enum {
/**
*
*
* @param {string} field
* @param {string} label
* @param {Object} value
*/
add(field: string, label: string, value: any) {
this[field] = { label, value }
return this
}
/**
* value获取其label
*
* @param {Object} value
*/
getLabelByValue(value: any) {
// 字段不存在返回‘’
if (value === undefined || value === null) {
return ''
}
for (const i in this) {
const e: any = this[i]
if (e && e.value === value) {
return e.label
}
}
return ''
}
}