<template>
|
<ul class="list-container">
|
<el-scrollbar>
|
<template v-for="(item, index) in dataList" :key="index">
|
<li
|
:class="
|
'list-item ' +
|
(item.selected ? 'list-item__selected' : '')
|
"
|
@click="selectItem(item)"
|
v-if="!item.delete"
|
>
|
<div style="display: flex; gap: 8px">
|
<div>{{ item.cid }}</div>
|
<div>{{ item.cclueName }}</div>
|
</div>
|
</li>
|
</template>
|
</el-scrollbar>
|
</ul>
|
</template>
|
|
<script>
|
export default {
|
props: {
|
dataList: Array
|
},
|
emits: ['itemSelected'],
|
data() {
|
return {};
|
},
|
watch: {},
|
methods: {
|
// 列表选择
|
selectItem(item) {
|
this.clearSelect();
|
item.selected = true;
|
this.$emit('itemSelected', item);
|
},
|
clearSelect() {
|
this.dataList.forEach((e) => {
|
e.selected = false;
|
});
|
}
|
}
|
};
|
</script>
|
<style scoped>
|
.list-container {
|
/* background-color: antiquewhite; */
|
padding: initial;
|
height: 50vh;
|
overflow: auto;
|
overflow-x: hidden;
|
border: var(--el-border);
|
font-size: var(--el-font-size-small);
|
}
|
|
.list-item {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding: 4px;
|
list-style-type: none;
|
/* background-color: aqua; */
|
/* border: var(--el-border); */
|
border-radius: var(--el-border-radius-base);
|
box-shadow: var(--el-box-shadow-lighter);
|
margin-bottom: 2px;
|
cursor: pointer;
|
line-height: 36px;
|
}
|
|
.list-item:hover {
|
background-color: var(--el-color-primary-light-9);
|
}
|
|
.list-item__selected {
|
background-color: var(--el-color-primary-light-9);
|
}
|
|
.v-enter-from,
|
.v-leave-to {
|
opacity: 0;
|
transform: translateX(8px);
|
}
|
|
.v-enter-active,
|
.v-leave-active {
|
transition: all 0.3s ease-out;
|
}
|
</style>
|