productBrand.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <u-popup v-model="isShow" class="brand-picker" @close="isShow=false" mode="bottom">
  3. <view class="brand-header flex justify_between align_center">
  4. <text class="brand-picker-btn" @click="onClean">清空</text>
  5. <text>产品品牌</text>
  6. <text class="brand-picker-btn color-blue" @click="isShow=false">
  7. <u-icon name="close"></u-icon>
  8. </text>
  9. </view>
  10. <view class="search-box">
  11. <u-search
  12. placeholder="请输入品牌名称搜索"
  13. v-model="queryWord"
  14. :show-action="isGobleSearch||queryWord!=''"
  15. @focus="isGobleSearch=true"
  16. @blur="isGobleSearch=false"
  17. @custom="searchBrand"
  18. @search="searchBrand"
  19. @clear="clearSearch"
  20. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': $config('primaryColor'), 'border-radius': '6upx', 'padding': '12upx 0'}">
  21. </u-search>
  22. </view>
  23. <scroll-view class="picker-content" scroll-y>
  24. <view class="picker-main">
  25. <view class="picker-main-item" v-for="(item, index) in listData" :key="item.brandSn" @click="chooseItem(index)">
  26. <view class="item-name">{{item.brandName}}</view>
  27. <u-icon v-show="item.brandSn==brandSn" class="item-icon" name="checkbox-mark" :color="$config('primaryColor')" size="28"></u-icon>
  28. </view>
  29. <view v-if="listData && listData.length == 0 && status!='loading'">
  30. <u-empty text="没有找到品牌" mode="list" :img-width="150" :margin-top="-60"></u-empty>
  31. </view>
  32. <view style="padding-bottom: 20upx;">
  33. <u-loadmore v-if="totalNum>listData.length || status=='loading'" :status="status" />
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </u-popup>
  38. </template>
  39. <script>
  40. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  41. export default {
  42. props: {
  43. openModal: { // 弹框显示状态
  44. type: Boolean,
  45. default: false
  46. },
  47. itemSn: {
  48. type: String,
  49. default: ''
  50. }
  51. },
  52. data() {
  53. return {
  54. isShow: this.openModal, // 是否打开弹框
  55. listData: [],
  56. queryWord: '',
  57. isGobleSearch: false,
  58. brandSn: this.itemSn || null,
  59. status: 'loadmore',
  60. totalNum: 0
  61. }
  62. },
  63. mounted() {
  64. this.clearSearch()
  65. },
  66. methods: {
  67. // 搜索品牌
  68. searchBrand(){
  69. this.brandSn = null
  70. this.getBrandList()
  71. },
  72. clearSearch(){
  73. this.queryWord = ''
  74. this.listData = []
  75. this.getBrandList()
  76. },
  77. getBrandList(){
  78. this.status = "loading"
  79. dealerProductBrandQuery({ brandName: this.queryWord }).then(res => {
  80. if(res.status == 200 && res.data){
  81. this.listData = res.data
  82. this.totalNum = res.data.count || 0
  83. }else{
  84. this.listData = []
  85. this.totalNum = 0
  86. }
  87. this.status = "loadmore"
  88. })
  89. },
  90. // 选择
  91. chooseItem(ind){
  92. this.brandSn = this.listData[ind].brandSn
  93. this.$emit('choose', this.listData[ind])
  94. this.isShow = false
  95. },
  96. // 清空
  97. onClean(){
  98. this.queryWord = ''
  99. this.brandSn = null
  100. this.$emit('clean')
  101. this.isShow = false
  102. this.getBrandList()
  103. }
  104. },
  105. watch: {
  106. // 父页面传过来的弹框状态
  107. openModal (newValue, oldValue) {
  108. this.isShow = newValue
  109. },
  110. // 重定义的弹框状态
  111. isShow (newValue, oldValue) {
  112. if (!newValue) {
  113. this.$emit('close')
  114. }
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .brand-picker{
  121. .brand-header{
  122. padding: 0 30upx;
  123. position: relative;
  124. .brand-picker-btn{
  125. color: rgb(96, 98, 102);
  126. margin: 10upx;
  127. }
  128. .color-blue{
  129. display: inline-block;
  130. padding: 10upx 20upx;
  131. margin: 10upx 0;
  132. }
  133. }
  134. .brand-header:after{
  135. content: "";
  136. position: absolute;
  137. border-bottom: 1px solid #eaeef1;
  138. -webkit-transform: scaleY(.5);
  139. transform: scaleY(.5);
  140. bottom: 0;
  141. right: 0;
  142. left: 0;
  143. }
  144. .search-box{
  145. padding: 10upx 20upx;
  146. }
  147. .picker-content{
  148. height: 50vh;
  149. padding: 6upx 0 20upx;
  150. position: relative;
  151. .picker-main{
  152. width: 100%;
  153. .picker-main-item{
  154. position: relative;
  155. padding: 0 30upx;
  156. .item-name{
  157. padding: 14upx 0;
  158. text-align: center;
  159. }
  160. .item-icon{
  161. position: absolute;
  162. right: 100upx;
  163. top: 19upx;
  164. }
  165. &:active{
  166. background: #f8f8f8;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. </style>