!417 优化字典标签支持传分隔符分隔的字符串和数组,优化渲染效果

Merge pull request !417 from 抓蛙师/dev
This commit is contained in:
疯狂的狮子Li 2023-09-08 07:28:18 +00:00 committed by Gitee
commit 3b498c4939
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -40,6 +40,10 @@ export default {
showValue: { showValue: {
type: Boolean, type: Boolean,
default: true, default: true,
},
separator: {
type: String,
default: ","
} }
}, },
data() { data() {
@ -49,29 +53,22 @@ export default {
}, },
computed: { computed: {
values() { values() {
if (this.value !== null && typeof this.value !== 'undefined') { if (this.value === null || typeof this.value !== 'undefined' || this.value === '') return []
return Array.isArray(this.value) ? this.value : [String(this.value)]; return Array.isArray(this.value) ? this.value.map(item => '' + item) : String(this.value).split(this.separator)
} else {
return [];
}
}, },
unmatch() { unmatch() {
this.unmatchArray = []; this.unmatchArray = []
if (this.value !== null && typeof this.value !== 'undefined') {
//
if(!Array.isArray(this.value)){
if(this.options.some(v=> v.value == this.value )) return false;
this.unmatchArray.push(this.value);
return true;
}
// Array
this.value.forEach(item => {
if (!this.options.some(v=> v.value == item )) this.unmatchArray.push(item)
});
return true;
}
// value // value
return false; if (this.value === null || typeof this.value !== 'undefined' || this.value === '' || this.options.length === 0) return false
//
let unmatch = false //
this.values.forEach(item => {
if (!this.options.some(v => v.value === item)) {
this.unmatchArray.push(item)
unmatch = true // true
}
})
return unmatch //
}, },
}, },