selectMachine.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <view style="padding: 20rpx;">
  4. <u-search placeholder="请输入设备名称" v-model="name" @custom="custom"></u-search>
  5. </view>
  6. <u-index-list :indexList="indexList" v-if="!loading">
  7. <template v-for="(item, index) in itemArr">
  8. <!-- #ifdef APP-NVUE -->
  9. <u-index-anchor :text="indexList[index]" :key="index" v-if="item.length>0"></u-index-anchor>
  10. <!-- #endif -->
  11. <u-index-item :key="index">
  12. <!-- #ifndef APP-NVUE -->
  13. <u-index-anchor :text="indexList[index]" v-if="item.length>0"></u-index-anchor>
  14. <!-- #endif -->
  15. <view class="list" v-for="(item1, index1) in item" :key="index1">
  16. <view class="list__item" @click="choice(item1,index1)">
  17. <text class="list__item__user-name">{{item1.cname}}</text>
  18. <text class="list__item__user-tel">{{item1.tel}}</text>
  19. </view>
  20. <u-line></u-line>
  21. </view>
  22. </u-index-item>
  23. </template>
  24. </u-index-list>
  25. <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page>
  26. <u-modal :show="show" :content="'是否确认选择:'+this.form.cname" @confirm="confirm" @cancel="show = false"
  27. :showCancelButton="true" style="text-align: center;"></u-modal>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. queryAllCustomer,
  33. queryInitialsCustomer
  34. } from '@/api/views/sale/index.js'
  35. const indexList = () => {
  36. const indexList = []
  37. const charCodeOfA = 'A'.charCodeAt(0)
  38. for (let i = 0; i < 26; i++) {
  39. indexList.push(String.fromCharCode(charCodeOfA + i))
  40. }
  41. indexList.push('#')
  42. return indexList
  43. }
  44. export default {
  45. data() {
  46. return {
  47. name:'',
  48. indexList: indexList(),
  49. itemArrTwo: [],
  50. loading: true,
  51. show: false,
  52. form: {},
  53. params:{}
  54. }
  55. },
  56. onLoad(params) {
  57. this.params = {
  58. ...params,
  59. adminProfiles: uni.getStorageSync('userInfo').user_id
  60. }
  61. queryAllCustomer(this.params).then(res=>{
  62. console.log(res)
  63. this.itemArrTwo = res.data
  64. this.loading = false
  65. })
  66. },
  67. computed: {
  68. itemArr() {
  69. return this.indexList.map((item,index) => {
  70. return this.itemArrTwo[index]
  71. })
  72. }
  73. },
  74. onNavigationBarButtonTap(e) {
  75. uni.$u.route('/pages/views/customer/customerDetails');
  76. },
  77. methods: {
  78. custom(){
  79. this.loading = true
  80. queryAllCustomer({
  81. ...this.params,
  82. cname:this.name
  83. }).then(res=>{
  84. this.itemArrTwo = res.data
  85. this.loading = false
  86. })
  87. },
  88. choice(item1, index1) {
  89. console.log("item1");
  90. console.log(item1);
  91. this.form = item1
  92. this.show = true
  93. },
  94. confirm() {
  95. let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  96. let prevPage = pages[pages.length - 2] //上一页页面实例
  97. prevPage.$vm.otherFun(this.form)
  98. uni.navigateBack()
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .list {
  105. &__item {
  106. @include flex;
  107. padding: 6px 12px;
  108. align-items: center;
  109. justify-content: space-between;
  110. &__user-name {
  111. font-size: 32rpx;
  112. color: $u-main-color;
  113. }
  114. &__user-tel {
  115. font-size: 32rpx;
  116. margin-right: 20rpx;
  117. color: $u-main-color;
  118. }
  119. }
  120. &__footer {
  121. color: $u-tips-color;
  122. font-size: 14px;
  123. text-align: center;
  124. margin: 15px 0;
  125. }
  126. }
  127. </style>