fix:assetmeta option不能删除的问题 以及option可以为空的问题

This commit is contained in:
zhangyu
2021-03-25 16:10:35 +08:00
parent d6b5a58d4b
commit aefafab313
5 changed files with 38 additions and 28 deletions

View File

@@ -468,13 +468,13 @@ export const tableSet = {
} }
break break
} }
case 'id': break
case 'startAt': { case 'startAt': {
if (from === 'alertSilence') { if (from === 'alertSilence') {
return false return false
} }
break break
} }
case 'id':
case 'alertRule': case 'alertRule':
case 'severity': case 'severity':
case 'endAt': case 'endAt':

View File

@@ -933,7 +933,8 @@ const cn = {
}, },
assetMeta: { assetMeta: {
example: '示例', example: '示例',
assetMeta: '资产标签', assetMeta: '资产元数据',
all: '全部',
addGroup: '创建分组', addGroup: '创建分组',
editGroup: '编辑分组', editGroup: '编辑分组',
addMeta: '创建Meta', addMeta: '创建Meta',
@@ -970,7 +971,8 @@ const cn = {
interval: '区间', interval: '区间',
decimals: '精度', decimals: '精度',
moreOptionsError: '选项最多20条', moreOptionsError: '选项最多20条',
onlyOptionError: '至少需要一个选项' onlyOptionError: '至少需要一个选项',
metaOptionNull: '请填写选项信息'
}, },
exprTemp: { exprTemp: {
exprTemp: 'expression模板', exprTemp: 'expression模板',

View File

@@ -937,6 +937,7 @@ const en = {
assetMeta: { assetMeta: {
example: 'Example', example: 'Example',
assetMeta: 'Asset meta', assetMeta: 'Asset meta',
all: 'All',
addGroup: 'Create group', addGroup: 'Create group',
editGroup: 'Edit group', editGroup: 'Edit group',
addMeta: 'Create meta', addMeta: 'Create meta',
@@ -973,7 +974,8 @@ const en = {
interval: 'Interval', interval: 'Interval',
decimals: 'Decimals', decimals: 'Decimals',
moreOptionsError: 'There are up to 20 options', moreOptionsError: 'There are up to 20 options',
onlyOptionError: 'You need at least one option' onlyOptionError: 'You need at least one option',
metaOptionNull: 'Please input option'
}, },
exprTemp: { exprTemp: {
exprTemp: 'Expression template', exprTemp: 'Expression template',

View File

@@ -269,6 +269,17 @@ export default {
this.$refs.editAssetMetaForm.validate((valid) => { this.$refs.editAssetMetaForm.validate((valid) => {
if (valid) { if (valid) {
const param = { ...this.editAssetMeta } const param = { ...this.editAssetMeta }
if (param.type === 'radio' || param.type === 'checkbox' || param.type === 'select') {
for (let i = 0; i < param.param.items.length; i++) {
if (!param.param.items[i].name) {
console.log(this.$refs['metaNameOption' + i])
this.$refs['metaNameOption' + i][0].focus()
this.$message.error(this.$t('config.assetMeta.metaOptionNull'))
this.prevent_opt.save = false
return
}
}
}
if (param.type !== 'radio' && param.type !== 'checkbox' && param.type !== 'select' && param.type !== 'datetime') { if (param.type !== 'radio' && param.type !== 'checkbox' && param.type !== 'select' && param.type !== 'datetime') {
delete param.param delete param.param
} else { } else {
@@ -403,6 +414,7 @@ export default {
return return
} }
this.editAssetMeta.param.items.splice(index, 1) this.editAssetMeta.param.items.splice(index, 1)
this.$forceUpdate()
}, },
copyParam (index) { copyParam (index) {
if (this.editAssetMeta.type !== 'checkbox') { if (this.editAssetMeta.type !== 'checkbox') {

View File

@@ -207,14 +207,14 @@ export default {
prop: 'id', prop: 'id',
show: true, show: true,
width: 80 width: 80
}, {
label: this.$t('config.assetMeta.key'),
prop: 'metaKey',
show: true
}, { }, {
label: this.$t('config.assetMeta.name'), label: this.$t('config.assetMeta.name'),
prop: 'name', prop: 'name',
show: true show: true
}, {
label: this.$t('config.assetMeta.key'),
prop: 'metaKey',
show: true
}, { }, {
label: this.$t('config.assetMeta.group'), label: this.$t('config.assetMeta.group'),
prop: 'group', prop: 'group',
@@ -243,7 +243,7 @@ export default {
} }
], ],
groupData: [{ groupData: [{
name: 'All', name: this.$t('config.assetMeta.all'),
id: -1, id: -1,
children: [] children: []
}], }],
@@ -280,25 +280,19 @@ export default {
searchMsg: { // 给搜索框子组件传递的信息 searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true, zheze_none: true,
searchLabelList: [ searchLabelList: [
// { {
// id: 11, id: 11,
// name: 'Id', name: 'Id',
// type: 'input', type: 'input',
// label: 'id', label: 'id',
// disabled: false disabled: false
// }, { }, {
// id: 12, id: 12,
// name: this.$t('config.assetMeta.name'), name: this.$t('config.assetMeta.name'),
// type: 'input', type: 'input',
// label: 'name', label: 'name',
// disabled: false disabled: false
// }, { }
// id: 13,
// name: this.$t('config.assetMeta.gname'),
// type: 'selectTemp',
// label: 'gname',
// disabled: false
// }
] ]
}, },
searchLabel: {}, // 搜索参数 searchLabel: {}, // 搜索参数