numsear.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="container">
  3. <label class="sel_event" @click="sel_show ()">
  4. <view class="sel_point">
  5. <view class="sel_field">
  6. {{sel_item}}
  7. </view>
  8. <view class="triangle" :style="tri_style">
  9. </view>
  10. </view>
  11. </label>
  12. <u-select v-model="show" value-name="id" label-name="name" mode="single-column" :list="list" @confirm="confirm">
  13. </u-select>
  14. <view class="content">
  15. <view class="table_hed">
  16. <view class="table_cell_h">
  17. <span>编号</span>
  18. <span>名称</span>
  19. <span class="introduce">介绍</span>
  20. <span>库存</span>
  21. </view>
  22. </view>
  23. <scroll-view :scroll-top="scrollTop" @scrolltolower="lower()" scroll-y="true" class="scroll-Y"
  24. v-if="numList != null">
  25. <view class="table_cell" v-for="(item,i) in numList" :key="item.id">
  26. <span>{{item.id}}</span>
  27. <span>{{item.name}}</span>
  28. <span class="introduce u-line-1">{{item.description}}</span>
  29. <span>{{item.count}}</span>
  30. </view>
  31. </scroll-view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. num,
  38. numType
  39. } from '@/api/index.js'
  40. export default {
  41. data() {
  42. return {
  43. sel_item: '', //选择框值
  44. show: false, //选择框弹出
  45. tri_style: '', //三角样式
  46. //物品类别列表
  47. list: [{
  48. value: '1',
  49. label: '电子产品'
  50. },
  51. {
  52. value: '2',
  53. label: '抗疫物资'
  54. },
  55. ],
  56. numList: [], //库存物品列表
  57. scrollnum: 2, //页码(懒加载)
  58. }
  59. },
  60. onLoad() {
  61. this.getNumType()
  62. },
  63. watch: {
  64. sel_item(newOption, oldOption) {
  65. this.getNum(newOption);
  66. },
  67. show(newOption, oldOption) {
  68. if (!newOption) {
  69. this.tri_style =
  70. 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color:transparent;';
  71. }
  72. }
  73. },
  74. methods: {
  75. sel_show() {
  76. this.show = !this.show;
  77. this.tri_style =
  78. 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;';
  79. },
  80. lower() {
  81. this.getNum(this.sel_item, this.scrollnum, 10);
  82. this.scrollnum += 1;
  83. },
  84. //获取库存类别
  85. async getNumType() {
  86. let {
  87. data
  88. } = await numType()
  89. this.list.length = 0
  90. data.list.forEach(ite => {
  91. this.list.push(ite)
  92. })
  93. this.$nextTick(function() {
  94. this.sel_item = this.list[0].name;
  95. })
  96. },
  97. async getNum(type, page, size) {
  98. page || (page = 1)
  99. size || (size = 10)
  100. let {
  101. data
  102. } = await num({
  103. type,
  104. page,
  105. size
  106. })
  107. data.list.forEach(ite => {
  108. this.numList.push(ite)
  109. })
  110. },
  111. // 回调参数为包含多个元素的数组,每个元素分别反应每一列的选择情况
  112. confirm(e) {
  113. this.$nextTick(function() {
  114. this.sel_item = e[0].label;
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .container {
  122. display: flex;
  123. flex-direction: column;
  124. align-items: center;
  125. width: 100%;
  126. height: 100%;
  127. background-color: #FFFFFF;
  128. }
  129. .sel_point {
  130. display: flex;
  131. justify-content: flex-start;
  132. align-items: center;
  133. width: 690rpx;
  134. height: 30rpx;
  135. margin: 29rpx 0 38rpx 0;
  136. text-align: left;
  137. }
  138. .sel_field {
  139. margin-right: 30rpx;
  140. font-size: 28rpx;
  141. font-family: Microsoft YaHei-3970(82674968);
  142. font-weight: 400;
  143. color: #333333;
  144. text-indent: 10rpx;
  145. }
  146. .triangle {
  147. margin-top: 10rpx;
  148. display: inline-block;
  149. /* Base Style */
  150. border: solid 10rpx transparent;
  151. border-top-color: #808080;
  152. }
  153. .content {
  154. display: flex;
  155. flex-direction: column;
  156. justify-content: flex-start;
  157. align-items: center;
  158. width: 690rpx;
  159. height: 100%;
  160. background: #FFFFFF;
  161. box-shadow: 0px 0px 24px 0px rgba(6, 0, 1, 0.1);
  162. border-radius: 10px 10px 0px 0px;
  163. overflow: hidden;
  164. .table_hed {
  165. width: 690rpx;
  166. height: 70rpx;
  167. background: #EBF8FF;
  168. }
  169. .table_cell,
  170. .table_cell_h {
  171. display: flex;
  172. justify-content: space-around;
  173. align-items: center;
  174. width: 630rpx;
  175. height: 70rpx;
  176. margin: 0 auto;
  177. border-bottom: solid 1rpx #E6E6E6;
  178. span {
  179. width: 140rpx;
  180. font-size: 28rpx;
  181. font-family: Microsoft YaHei-3970(82674968);
  182. font-weight: 400;
  183. color: #333333;
  184. text-align: center;
  185. }
  186. .introduce {
  187. max-width: 308rpx;
  188. overflow: hidden;
  189. white-space: nowrap;
  190. text-overflow: ellipsis;
  191. }
  192. }
  193. .table_cell_h {
  194. border-bottom: none;
  195. }
  196. .scroll-Y {
  197. width: 690rpx;
  198. height: calc( 100vh - 180rpx );
  199. }
  200. }
  201. </style>