系统整体功能测试

This commit is contained in:
lvys 2025-07-04 22:38:58 +08:00
parent dd02518422
commit c4f29f060f
1 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,89 @@
<template>
<div class="dict-container">
<template v-for="(item, index) in options">
<template v-if="values.includes(item.value)">
<span
v-if="(item.elTagType == 'default' || item.elTagType == '') && (item.elTagClass == '' || item.elTagClass == null)"
:key="item.value"
:index="index"
:class="item.elTagClass"
>{{ item.label + " " }}</span>
<el-tag
v-else
:disable-transitions="true"
:key="item.value + ''"
:index="index"
:type="item.elTagType"
:class="item.elTagClass"
>{{ item.label + " " }}</el-tag>
</template>
</template>
<template v-if="unmatch && showValue">
{{ unmatchArray | handleArray }}
</template>
</div>
</template>
<script setup>
//
const unmatchArray = ref([]);
const props = defineProps({
//
options: {
type: Array,
default: null,
},
//
value: [Number, String, Array],
// value
showValue: {
type: Boolean,
default: true,
},
separator: {
type: String,
default: ",",
}
});
const values = computed(() => {
if (props.value === null || typeof props.value === 'undefined' || props.value === '') return [];
return Array.isArray(props.value) ? props.value.map(item => '' + item) : String(props.value).split(props.separator);
});
const unmatch = computed(() => {
unmatchArray.value = [];
// value
if (props.value === null || typeof props.value === 'undefined' || props.value === '' || !Array.isArray(props.options) || props.options.length === 0) return false
//
let unmatch = false //
values.value.forEach(item => {
if (!props.options.some(v => v.value === item)) {
unmatchArray.value.push(item)
unmatch = true // true
}
})
return unmatch //
});
function handleArray(array) {
if (array.length === 0) return "";
return array.reduce((pre, cur) => {
return pre + " " + cur;
});
}
</script>
<style lang="scss" scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
// .dict-container {
// &:deep(.el-tag) {
// background-color: transparent;
// border: 0;
// font-size: 14px;
// }
// }
</style>