123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <div class="xq-community-component">
- <div class="xq-community-mask" v-if="showDesigner" @click="showDesigner=false;">
- <div class="xq-community-block" @click.stop>
- <div class="xq-community-title font30">选择设计师</div>
- <div class="xq-community-content">
- <van-search v-model="keyword" show-action placeholder="请输入搜索关键词" @search="onSearch">
- <template #action>
- <div @click="onSearch">搜索</div>
- </template>
- </van-search>
- <van-radio-group v-model="val" @change="getChangeFunc">
- <van-cell-group>
- <template v-for="item in list">
- <van-cell :title="item.name" :key="item.id" clickable @click="val = item.id">
- <template #right-icon>
- <van-radio :name="item.id" />
- </template>
- </van-cell>
- </template>
- </van-cell-group>
- </van-radio-group>
- <!-- 搜索提示 -->
- <van-empty v-if="!list.length" image="search" description="没有查找到内容!" />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- Search,
- RadioGroup,
- Radio,
- Empty
- } from 'vant';
- export default {
- components: {
- [Search.name]: Search,
- [RadioGroup.name]: RadioGroup,
- [Radio.name]: Radio,
- [Empty.name]: Empty
- },
- props: {
- dataArr: {
- type: Array,
- default: () => {
- return [];
- }
- },
- value: {
- type: String|Number,
- default: ""
- }
- },
- data() {
- return {
- showDesigner: false,
- keyword: "",
- val: "",
- list: [],
- }
- },
- watch: {
- dataArr: {
- handler(val) {
- if (val.length) {
- this.list = JSON.parse(JSON.stringify(val));
- }
- },
- immediate: true
- },
- value: {
- handler(val) {
- if (val) {
- this.val = parseInt(val);
- }
- },
- immediate: true
- }
- },
- methods: {
- onSearch() {
- if (this.keyword.trim()) {
- this.list = this.dataArr.filter(item => {
- if (item.name.indexOf(this.keyword) > -1) {
- return item;
- }
- })
- } else {
- this.list = JSON.parse(JSON.stringify(this.dataArr));
- }
- },
- getChangeFunc(e) {
- let item = this.dataArr.filter(v => v.id == e);
- this.$emit('setValClick',item[0]);
- this.showDesigner = false;
- }
- }
- }
- </script>
- <style scoped lang="less">
- .xq-community-component {
- .xq-community-mask {
- width: 100%;
- height: 100vh;
- position: fixed;
- top: 0px;
- left: 0px;
- background-color: rgba(0, 0, 0, 0.4);
- .xq-community-block {
- width: 100%;
- height: 70%;
- background-color: #fff;
- position: absolute;
- bottom: 0px;
- left: 0px;
- box-sizing: border-box;
- padding-top: 88px;
- .xq-community-title {
- width: 100%;
- height: 88px;
- background-color: #249EFB;
- color: #fff;
- text-align: center;
- line-height: 88px;
- position: absolute;
- top: 0px;
- left: 0px;
- }
- .xq-community-content {
- width: 100%;
- height: 100%;
- overflow: auto;
- }
- }
- }
- }
- </style>
|