diff --git a/nezha-fronted/src/components/common/copy.vue b/nezha-fronted/src/components/common/copy.vue index dab1fb1a7..b0879e8fe 100644 --- a/nezha-fronted/src/components/common/copy.vue +++ b/nezha-fronted/src/components/common/copy.vue @@ -12,7 +12,7 @@ export default { name: 'copy', props: { copyData: String, - showInfo: String + showInfo: {} }, data () { return { diff --git a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue index 776281a34..89b7e87c9 100644 --- a/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue +++ b/nezha-fronted/src/components/common/rightBox/assetMetaBox.vue @@ -69,7 +69,9 @@ - + + + {{$t('config.assetLabel.default')}} @@ -162,6 +164,7 @@ export default { type: [{ required: true, message: this.$t('validate.required'), trigger: 'change' }] }, value: '', + checkItemsArr: [], typeData: [ { icon: 'nz-icon nz-icon-text', @@ -393,7 +396,9 @@ export default { case 'CHECKBOX' : case 'SELECT' : this.showParam = true - this.editAssetMeta.param = {} + this.editAssetMeta.param = { + items: [] + } this.editAssetMeta.param.items = [{ name: 'Option 1', check: false @@ -423,6 +428,7 @@ export default { } }, inputChange (index, val) { + this.$refs.editAssetMetaForm.clearValidate('param.items.' + index + '.name') this.$forceUpdate() }, radioChange (i) { @@ -469,6 +475,29 @@ export default { }) } this.$forceUpdate() + }, + checkItems (rule, value, callback) { // 校验是否有重复项 + const nowIndex = rule.field.split('.')[2] + const findItem = this.editAssetMeta.param.items.find((item, index) => (item.name === value) && (index != nowIndex)) + if (!findItem) { + if (!this.checkItemsArr.length) { + setTimeout(() => { + this.checkItemsArr = this.editAssetMeta.param.items.map((item, index) => { + if (item.name) { + return 'param.items.' + index + '.name' + } else { + return false + } + }) + this.checkItemsArr = this.checkItemsArr.filter(item => item) + this.$refs.editAssetMetaForm.validateField(this.checkItemsArr) + this.checkItemsArr = [] + }) + } + callback() + } else { + callback(new Error(this.$t('error.nameDuplicate'))) + } } } }