productBrand.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. }
  103. },
  104. watch: {
  105. // 父页面传过来的弹框状态
  106. openModal (newValue, oldValue) {
  107. this.isShow = newValue
  108. },
  109. // 重定义的弹框状态
  110. isShow (newValue, oldValue) {
  111. if (!newValue) {
  112. this.$emit('close')
  113. }
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .brand-picker{
  120. .brand-header{
  121. padding: 20upx 30upx;
  122. position: relative;
  123. .brand-picker-btn{
  124. color: rgb(96, 98, 102);
  125. }
  126. }
  127. .brand-header:after{
  128. content: "";
  129. position: absolute;
  130. border-bottom: 1px solid #eaeef1;
  131. -webkit-transform: scaleY(.5);
  132. transform: scaleY(.5);
  133. bottom: 0;
  134. right: 0;
  135. left: 0;
  136. }
  137. .search-box{
  138. padding: 10upx 20upx;
  139. }
  140. .picker-content{
  141. height: 300upx;
  142. padding: 6upx 0 20upx;
  143. position: relative;
  144. .picker-main{
  145. position: absolute;
  146. top: 50%;
  147. left: 50%;
  148. transform: translate(-50%,-50%);
  149. width: 100%;
  150. max-height: 300upx;
  151. .picker-main-item{
  152. position: relative;
  153. padding: 0 30upx;
  154. .item-name{
  155. padding: 14upx 0;
  156. text-align: center;
  157. }
  158. .item-icon{
  159. position: absolute;
  160. right: 100upx;
  161. top: 19upx;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. </style>