<template>
|
<div class="tree-list-main">
|
<div class="tree-search">
|
<div class="main-search" style="margin-bottom: 0;">
|
<input class="search-input" v-model="queryParams.name" @keyup.enter.prevent="getList" placeholder="请输入名称"/>
|
</div>
|
</div>
|
|
<div class="main-tree">
|
<div class="question-list" v-for="item in list" :key="item.id">
|
<div class="question-item text-ellipsis" :class="item.id === id ? 'question-current' : ''">
|
<div class="question-item-text text-ellipsis" @click="handleClick(item.id)">{{item.name}}</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import {listSchool} from "@/api/common/common";
|
|
export default {
|
name: "QuestionType",
|
watch: {
|
'queryParams.name': function (val) {
|
this.getList()
|
}
|
},
|
data() {
|
return {
|
id: undefined,
|
// 查询参数
|
queryParams: {
|
name: undefined
|
},
|
list: []
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
getList() {
|
this.loading = true;
|
listSchool(this.queryParams).then(r => {
|
this.list = r.data;
|
if (this.list.length > 0) {
|
this.id = this.list[0].id;
|
this.$emit('schoolChange', this.id)
|
}
|
})
|
},
|
// 选中
|
handleClick(id) {
|
if (this.id === id) return
|
this.$emit('schoolChange', id)
|
this.id = id
|
}
|
}
|
};
|
</script>
|
<style scoped lang="scss">
|
.tree-search {
|
display: flex;
|
flex-direction: row;
|
align-items: center;
|
height: 32px;
|
margin-bottom: 10px;
|
.search-add {
|
width: 60px;
|
text-align: center;
|
cursor: pointer;
|
line-height: 32px;
|
font-size: 14px;
|
height: 100%;
|
background-color: #3CA2E0;
|
color: #ffffff;
|
}
|
}
|
|
.question-list {
|
display: flex;
|
flex-direction: column;
|
|
.question-item {
|
height: 30px;
|
line-height: 30px;
|
width: 100%;
|
color: #333333;
|
font-size: 14px;
|
padding: 0 5px;
|
cursor: pointer;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
|
.question-item-text {
|
flex: 1;
|
}
|
}
|
|
.question-current {
|
background: #53A3FF;
|
color: #ffffff !important;
|
}
|
|
.operation-region {
|
display: none;
|
cursor: pointer;
|
}
|
|
.question-item:hover .operation-region {
|
display: block;
|
}
|
.question-item:hover {
|
background: #F5F7FA;
|
color: #333333!important;
|
}
|
}
|
</style>
|