[update]-分标委、工作组、理事会会议列表页功能的开发
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
export default class EsEnum {
|
||||
constructor(val) {
|
||||
if (!val) {
|
||||
return
|
||||
}
|
||||
Object.keys(val).forEach(key => {
|
||||
const item = val[key]
|
||||
this.addAll(key, item)
|
||||
})
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加枚举
|
||||
* @param key
|
||||
* @param item
|
||||
*/
|
||||
addAll(key, item) {
|
||||
this[key] = item
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有枚举值列表
|
||||
* @params decend --是否是降序输出
|
||||
* @returns {Array}
|
||||
*/
|
||||
getItemList(decend) {
|
||||
const optionList = []
|
||||
for (const i in this) {
|
||||
const item = this[i]
|
||||
const option = {}
|
||||
Object.assign(option, item)
|
||||
option.key = i
|
||||
optionList.push(option)
|
||||
}
|
||||
optionList.sort((a, b) => {
|
||||
const value1 = a['index']
|
||||
const value2 = b['index']
|
||||
return decend && (value2 - value1) || (value1 - value2)
|
||||
})
|
||||
return optionList
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要排除的枚举值后的所有枚举值列表
|
||||
* @param val 需要排除的枚举值或枚举值数组
|
||||
*/
|
||||
getItemListExcept(val) {
|
||||
let valueArr = []
|
||||
if (val) {
|
||||
if (Array.isArray(val)) {
|
||||
valueArr = val
|
||||
} else {
|
||||
valueArr.push(val)
|
||||
}
|
||||
}
|
||||
const optionList = []
|
||||
for (const i in this) {
|
||||
const item = this[i]
|
||||
if (!valueArr.includes(item.name)) {
|
||||
const option = {}
|
||||
Object.assign(option, item)
|
||||
option.key = i
|
||||
optionList.push(option)
|
||||
}
|
||||
}
|
||||
return optionList
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据name获取index
|
||||
* @param name
|
||||
*/
|
||||
indexOfName(name) {
|
||||
if (name) {
|
||||
for (const i in this) {
|
||||
const e = this[i]
|
||||
if (e.name.toString() === name.toString()) {
|
||||
return (e.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据index获取name
|
||||
* @param index
|
||||
* @returns {*}
|
||||
*/
|
||||
nameOfIndex(index) {
|
||||
if (index === null) {
|
||||
return '--'
|
||||
}
|
||||
for (const i in this) {
|
||||
const e = this[i]
|
||||
if (e.index !== undefined && e.index !== null && e.index.toString() === index.toString()) {
|
||||
return e.name
|
||||
}
|
||||
}
|
||||
return '--'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import EsEnums from './EsEnum'
|
||||
|
||||
/**
|
||||
* 是/否枚举
|
||||
* @type {EsEnum}
|
||||
*/
|
||||
export const YesOrNoEnum = new EsEnums({
|
||||
NO: { name: '否', index: 0 },
|
||||
YES: { name: '是', index: 1 }
|
||||
})
|
||||
|
||||
export const SignUpStatusEnum = {
|
||||
pendingReviewReportInfo: { name: '报名信息待审核', index: 1 },
|
||||
pendingReviewVoucher: { name: '凭证待审核', index: 2 },
|
||||
noParticipation: { name: '不可参会', index: 3 },
|
||||
pendingUploadVoucher: { name: '待上传凭证', index: 4 },
|
||||
rejectedVoucher: { name: '凭证被拒绝', index: 5 },
|
||||
pendingSignIn: { name: '待签到', index: 6 },
|
||||
finishSignIn: { name: '已签到', index: 7 },
|
||||
canReport: { name: '可报名', index: 8 }
|
||||
}
|
||||
Reference in New Issue
Block a user