selectMachine.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view>
  3. <view style="background-color: #fd4b09;">
  4. <u-tabs :list="tabbar" @click="click" lineColor="#fff" :activeStyle="{ color: '#fff' }" keyName="title"
  5. :inactiveStyle="{ color: '#ffffff80' }">></u-tabs>
  6. <view style="padding: 20rpx;">
  7. <u-search placeholder="请输入设备名称" v-model="name" @custom="custom"></u-search>
  8. </view>
  9. </view>
  10. <view class="list" v-for="(item1, index1) in itemArrTwo" :key="index1">
  11. <view>
  12. <u--image :showLoading="true" :src="item1.url" width="80px" height="80px" @click="click"></u--image>
  13. </view>
  14. <view class="list__item" @click="choice(item1,index1)">
  15. <view class="list__item__user-name">{{item1.cname}}</view>
  16. </view>
  17. </view>
  18. <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page>
  19. <u-modal :show="show" :content="'是否确认选择:'+this.form.cname" @confirm="confirm" @cancel="show = false"
  20. :showCancelButton="true" style="text-align: center;"></u-modal>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. goodsdescDescList,
  26. goodstypeTree
  27. } from '@/api/device/index.js'
  28. const indexList = () => {
  29. const indexList = []
  30. const charCodeOfA = 'A'.charCodeAt(0)
  31. for (let i = 0; i < 26; i++) {
  32. indexList.push(String.fromCharCode(charCodeOfA + i))
  33. }
  34. indexList.push('#')
  35. return indexList
  36. }
  37. export default {
  38. data() {
  39. return {
  40. name: '',
  41. indexList: indexList(),
  42. itemArrTwo: [],
  43. loading: true,
  44. show: false,
  45. form: {},
  46. params: {},
  47. re: {
  48. current: 1,
  49. size: 20
  50. },
  51. tabbar: []
  52. }
  53. },
  54. onLoad(params) {
  55. this.params = {
  56. ...params,
  57. adminProfiles: uni.getStorageSync('userInfo').user_id
  58. }
  59. goodstypeTree().then(res => {
  60. var data = res.data
  61. var datas = {title: '全部', id: null}
  62. data.unshift(datas)
  63. this.tabbar = data
  64. })
  65. goodsdescDescList(this.re).then(res => {
  66. this.itemArrTwo = res.data.records
  67. this.loading = false
  68. })
  69. },
  70. onReachBottom() {
  71. this.re.current++;
  72. goodsdescDescList(this.re).then(res => {
  73. this.itemArrTwo = this.itemArrTwo.concat(res.data.records);
  74. })
  75. },
  76. computed: {
  77. itemArr() {
  78. return this.indexList.map((item, index) => {
  79. return this.itemArrTwo[index]
  80. })
  81. }
  82. },
  83. onNavigationBarButtonTap(e) {
  84. uni.$u.route('/pages/views/customer/customerDetails');
  85. },
  86. methods: {
  87. click(tab) {
  88. this.re.goodsTypeId = tab.id
  89. this.name = ''
  90. goodsdescDescList(this.re).then(res => {
  91. this.itemArrTwo = res.data.records
  92. this.loading = false
  93. })
  94. },
  95. custom() {
  96. this.loading = true
  97. goodsdescDescList({
  98. ...this.re,
  99. cname: this.name
  100. }).then(res => {
  101. this.itemArrTwo = res.data.records
  102. this.loading = false
  103. })
  104. },
  105. choice(item1, index1) {
  106. this.form = item1
  107. this.show = true
  108. },
  109. confirm() {
  110. let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  111. let prevPage = pages[pages.length - 2] //上一页页面实例
  112. prevPage.$vm.machineOtherFun(this.form)
  113. uni.navigateBack()
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. .list {
  120. background-color: #fff;
  121. display: flex;
  122. padding: 20rpx;
  123. border-top: 1px solid #f0f0f0;
  124. // border-bottom: 1px solid red;
  125. &__item {
  126. @include flex;
  127. padding: 6px 12px;
  128. align-items: center;
  129. justify-content: space-between;
  130. &__user-name {
  131. font-size: 32rpx;
  132. color: $u-main-color;
  133. }
  134. &__user-tel {
  135. font-size: 32rpx;
  136. margin-right: 20rpx;
  137. color: $u-main-color;
  138. }
  139. }
  140. &__footer {
  141. color: $u-tips-color;
  142. font-size: 14px;
  143. text-align: center;
  144. margin: 15px 0;
  145. }
  146. }
  147. </style>