product.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="search-box">
  3. <up-search placeholder="搜索关键词" v-model="keyword" height="35" @blur="onSearch" :clearabled="false"
  4. :showAction="false" />
  5. <view v-if="content.where.condition" class="clear" @click.stop="onSearch('')">
  6. <up-icon name="close-circle-fill" size="20" />
  7. </view>
  8. </view>
  9. <view style="height: 20rpx; " />
  10. <My_listbox ref="listBox" :empty="!list.length" @getlist="getList">
  11. <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.itemid"
  12. @click="selected(item)">
  13. <view class="itemname">{{ item.itemname }}</view>
  14. <view class="row">
  15. <view class="label">
  16. 产品编号:
  17. </view>
  18. <view class="value">
  19. {{ item.itemno || '--' }}
  20. </view>
  21. </view>
  22. <view class="row">
  23. <view class="label">
  24. 型号/规格:
  25. </view>
  26. <view class="value">
  27. {{ item.model }}/{{ item.spec || '--' }}
  28. </view>
  29. </view>
  30. <view class="row">
  31. <view class="label">
  32. 计量单位:
  33. </view>
  34. <view class="value">
  35. {{ item.unitname || '--' }}
  36. </view>
  37. </view>
  38. </view>
  39. </My_listbox>
  40. </template>
  41. <script setup>
  42. import { ref, reactive, getCurrentInstance } from 'vue';
  43. const { $Http } = getCurrentInstance().proxy;
  44. import { onLoad } from '@dcloudio/uni-app';
  45. const keyword = ref('');
  46. const listBox = ref(null);
  47. const content = reactive({
  48. loading: false,
  49. "pageNumber": 1,
  50. "pageSize": 20,
  51. "where": {
  52. "status": '',
  53. "condition": ""
  54. }
  55. });
  56. function onSearch(e) {
  57. if (content.where.condition == e) return;
  58. content.where.condition = e;
  59. keyword.value = e;
  60. getList(true);
  61. }
  62. const list = ref([])
  63. onLoad(() => {
  64. getList();
  65. });
  66. function getList(init = false) {
  67. if (content.loading) return;
  68. content.loading = true;
  69. if (init) content.pageNumber = 1;
  70. $Http.basic({
  71. "id": "20220923140602",
  72. content
  73. }).then(res => {
  74. content.loading = false;
  75. console.log("获取产品列表", res)
  76. listBox.value.refreshToComplete();
  77. listBox.value.setHeight();
  78. if (res.code == 1) {
  79. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  80. content.pageTotal = res.pageTotal;
  81. content.pageNumber = res.pageNumber;
  82. } else {
  83. if (res.msg) uni.showToast({
  84. title: res.msg,
  85. icon: 'none'
  86. });
  87. }
  88. })
  89. }
  90. function selected(item) {
  91. $Http.onSelected && $Http.onSelected(item)
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .search-box {
  96. position: relative;
  97. padding: 20rpx;
  98. background: #fff;
  99. .clear {
  100. position: absolute;
  101. display: flex;
  102. align-items: center;
  103. right: 0;
  104. top: 50%;
  105. transform: translateY(-50%);
  106. width: 80rpx;
  107. padding-left: 10rpx;
  108. height: 70rpx;
  109. z-index: 2;
  110. }
  111. }
  112. .item {
  113. width: 690rpx;
  114. background: #FFFFFF;
  115. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  116. border-radius: 10rpx;
  117. padding: 40rpx;
  118. box-sizing: border-box;
  119. margin: 0 auto 20rpx;
  120. .itemname {
  121. line-height: 38rpx;
  122. font-family: Microsoft YaHei, Microsoft YaHei;
  123. font-size: 32rpx;
  124. color: #333333;
  125. }
  126. .row {
  127. display: flex;
  128. line-height: 32rpx;
  129. font-family: Microsoft YaHei, Microsoft YaHei;
  130. font-size: 28rpx;
  131. margin-top: 20rpx;
  132. .label {
  133. color: #999999;
  134. }
  135. .value {
  136. color: #333333;
  137. }
  138. }
  139. }
  140. </style>