【add】枚举和双语文件的整理

This commit is contained in:
fengchenchen
2023-08-16 09:50:45 +08:00
parent 74ac8c07d0
commit 9cc5f6443e
6 changed files with 175 additions and 24 deletions
+4 -7
View File
@@ -1,3 +1,6 @@
const system = require('./system/en.js')
module.exports = {
// 共用
pleaseSelect: 'Please Select ',
@@ -331,11 +334,5 @@ module.exports = {
file: 'File'
},
// 系统管理
system: {
// 标签管理
tag: {
tagItemManagement: '标签项管理',
labelContentManagement: '标签内容管理'
}
}
system
}
+22
View File
@@ -0,0 +1,22 @@
module.exports = {
// 标签管理
tag: {
tagItemManagement: '标签项管理',
labelContentManagement: '标签内容管理',
attributeName: '属性名称',
attributeNameEnglish: '英文名称',
attributeType: '属性类型',
fieldLength: '字段长度',
displayOrder: '展示顺序',
showArea: '展示区域',
exhibitionAreaManagement: '展示区域管理',
labelName: '标签名称',
labelType: '标签类型',
essentialInformation: '基本信息',
domesticLaws: '国内法规',
foreignStandards: '海外标准',
enterpriseStandards: '企业标准',
clauseSplitting: '条款拆分'
}
}
+22
View File
@@ -0,0 +1,22 @@
module.exports = {
// 标签管理
tag: {
tagItemManagement: '标签项管理',
labelContentManagement: '标签内容管理',
attributeName: '属性名称',
attributeNameEnglish: '英文名称',
attributeType: '属性类型',
fieldLength: '字段长度',
displayOrder: '展示顺序',
showArea: '展示区域',
exhibitionAreaManagement: '展示区域管理',
labelName: '标签名称',
labelType: '标签类型',
essentialInformation: '基本信息',
domesticLaws: '国内法规',
foreignStandards: '海外标准',
enterpriseStandards: '企业标准',
clauseSplitting: '条款拆分'
}
}
+4 -17
View File
@@ -1,3 +1,5 @@
const system = require('./system/zh.js')
module.exports = {
// 共用
pleaseSelect: '请选择',
@@ -333,7 +335,7 @@ module.exports = {
jpnArticle: 'JPN Article',
gb: 'GB',
gbt: 'GB/T',
gso: 'GSO',
gso: 'GSO'
}
},
// 标准选择器
@@ -354,20 +356,5 @@ module.exports = {
file: '文件'
},
// 系统管理
system: {
// 标签管理
tag: {
tagItemManagement: '标签项管理',
labelContentManagement: '标签内容管理',
attributeName: '属性名称',
attributeNameEnglish: '英文名称',
attributeType: '属性类型',
fieldLength: '字段长度',
displayOrder: '展示顺序',
showArea: '展示区域',
exhibitionAreaManagement: '展示区域管理',
labelName: '标签名称',
labelType: '标签类型',
}
}
system
}
+103
View File
@@ -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 '--'
}
}
+20
View File
@@ -1,3 +1,16 @@
import EsEnums from './EsEnum'
import DomesticList from '../views/system/tags/pages/DomesticList'
import ForeignList from '../views/system/tags/pages/ForeignList'
import EnterpriseList from '../views/system/tags/pages/EnterpriseList'
import ClauseSplittingList from '../views/system/tags/pages/ClauseSplittingList'
export const YesOrNoEnum = new EsEnums({
NO: { name: '否', index: 0 },
YES: { name: '是', index: 1 }
})
// 既可以使用EsEnums 也可以单独写明
export const FieldType = {
TREE: { text: '树形结构', value: '0' },
TEXT_STRING: { text: '输入框(字符串)', value: '1' },
@@ -12,3 +25,10 @@ export const FieldType = {
STANDARD: { text: '标准选择', value: '10' },
TEXT_LINK: { text: '输入框(链接)', value: '11' }
}
export const TagsTypeEnums = {
DOMESTIC_LIST: { text: '国内法规', langKey: '', value: 1 },
FOREIGN_LIST: { text: '海外标准', langKey: '', value: 2 },
ENTERPRISE_LIST: { text: '企业标准', langKey: '', value: 3 },
CLAUSE_SPLITTING_LIST: { text: '条款拆分', langKey: '', value: 4 }
}