selectDesigner.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="xq-community-component">
  3. <div class="xq-community-mask" v-if="showDesigner" @click="showDesigner=false;">
  4. <div class="xq-community-block" @click.stop>
  5. <div class="xq-community-title font30">选择设计师</div>
  6. <div class="xq-community-content">
  7. <van-search v-model="keyword" show-action placeholder="请输入搜索关键词" @search="onSearch">
  8. <template #action>
  9. <div @click="onSearch">搜索</div>
  10. </template>
  11. </van-search>
  12. <van-radio-group v-model="val" @change="getChangeFunc">
  13. <van-cell-group>
  14. <template v-for="item in list">
  15. <van-cell :title="item.name" :key="item.id" clickable @click="val = item.id">
  16. <template #right-icon>
  17. <van-radio :name="item.id" />
  18. </template>
  19. </van-cell>
  20. </template>
  21. </van-cell-group>
  22. </van-radio-group>
  23. <!-- 搜索提示 -->
  24. <van-empty v-if="!list.length" image="search" description="没有查找到内容!" />
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import {
  32. Search,
  33. RadioGroup,
  34. Radio,
  35. Empty
  36. } from 'vant';
  37. export default {
  38. components: {
  39. [Search.name]: Search,
  40. [RadioGroup.name]: RadioGroup,
  41. [Radio.name]: Radio,
  42. [Empty.name]: Empty
  43. },
  44. props: {
  45. dataArr: {
  46. type: Array,
  47. default: () => {
  48. return [];
  49. }
  50. },
  51. value: {
  52. type: String|Number,
  53. default: ""
  54. }
  55. },
  56. data() {
  57. return {
  58. showDesigner: false,
  59. keyword: "",
  60. val: "",
  61. list: [],
  62. }
  63. },
  64. watch: {
  65. dataArr: {
  66. handler(val) {
  67. if (val.length) {
  68. this.list = JSON.parse(JSON.stringify(val));
  69. }
  70. },
  71. immediate: true
  72. },
  73. value: {
  74. handler(val) {
  75. if (val) {
  76. this.val = parseInt(val);
  77. }
  78. },
  79. immediate: true
  80. }
  81. },
  82. methods: {
  83. onSearch() {
  84. if (this.keyword.trim()) {
  85. this.list = this.dataArr.filter(item => {
  86. if (item.name.indexOf(this.keyword) > -1) {
  87. return item;
  88. }
  89. })
  90. } else {
  91. this.list = JSON.parse(JSON.stringify(this.dataArr));
  92. }
  93. },
  94. getChangeFunc(e) {
  95. let item = this.dataArr.filter(v => v.id == e);
  96. this.$emit('setValClick',item[0]);
  97. this.showDesigner = false;
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped lang="less">
  103. .xq-community-component {
  104. .xq-community-mask {
  105. width: 100%;
  106. height: 100vh;
  107. position: fixed;
  108. top: 0px;
  109. left: 0px;
  110. background-color: rgba(0, 0, 0, 0.4);
  111. .xq-community-block {
  112. width: 100%;
  113. height: 70%;
  114. background-color: #fff;
  115. position: absolute;
  116. bottom: 0px;
  117. left: 0px;
  118. box-sizing: border-box;
  119. padding-top: 88px;
  120. .xq-community-title {
  121. width: 100%;
  122. height: 88px;
  123. background-color: #249EFB;
  124. color: #fff;
  125. text-align: center;
  126. line-height: 88px;
  127. position: absolute;
  128. top: 0px;
  129. left: 0px;
  130. }
  131. .xq-community-content {
  132. width: 100%;
  133. height: 100%;
  134. overflow: auto;
  135. }
  136. }
  137. }
  138. }
  139. </style>