stockSearch.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="stockSearch-wrap">
  3. <!-- 统计 -->
  4. <view class="panel-box">
  5. <view class="item-box">
  6. <view>查询结果</view>
  7. <view>{{toThousands(totalNum||0)}}条</view>
  8. </view>
  9. <view class="item-box">
  10. <view>可用库存数量</view>
  11. <view>{{toThousands(totalData&&totalData.totalCurrentStockQty||0)}}个</view>
  12. </view>
  13. <view class="item-box">
  14. <view>可用库存成本</view>
  15. <view>¥{{toThousands(totalData&&totalData.totalCurrentStockCost||0, 2)}}</view>
  16. </view>
  17. </view>
  18. <!-- 查询结果 -->
  19. <scroll-view class="stockSearch-con" scroll-y @scrolltolower="onreachBottom">
  20. <view class="stockSearch-main">
  21. <view class="stockSearch-main-item" v-for="(item, index) in listData" :key="item.id" @click="getDetail(item)">
  22. <view class="stockSearch-tit">
  23. <view class="u-line" :style="{backgroundColor: $config('primaryColor')}"></view>{{item.productName}}
  24. </view>
  25. <view class="stockSearch-item-con flex align_center">
  26. <view class="pimgs">
  27. <u-image :src="item.productMsg?item.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  28. </view>
  29. <view class="flex_1">
  30. <view>产品编码:{{item.productCode || '--'}}</view>
  31. <view class="padding_3">原厂编码:{{item.productOrigCode || '--'}}</view>
  32. <view class="flex align_center justify_between">
  33. <view class="font_13">
  34. 可用数量:{{toThousands(item.currentStockQty||0)}}{{item.productUnit}}
  35. </view>
  36. <view class="font_13">
  37. 库存成本:
  38. ¥{{toThousands(item.currentStockCost||0, 2)}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="listData && listData.length == 0">
  45. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="30"></u-empty>
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. import { toThousands } from '@/libs/tools'
  53. import { stockList, stockCount } from '@/api/stock'
  54. export default{
  55. data(){
  56. return {
  57. totalData: null,
  58. totalNum: 0,
  59. listData: [],
  60. pageNo: 1,
  61. pageSize: 6,
  62. params: {},
  63. noDataText: '暂无数据',
  64. theme: '',
  65. toThousands
  66. }
  67. },
  68. onLoad(option) {
  69. this.theme = getApp().globalData.theme
  70. this.params = option.data ? JSON.parse(option.data) : {}
  71. this.getList()
  72. },
  73. methods: {
  74. // 列表
  75. getList(pageNo){
  76. const _this = this
  77. if (pageNo) {
  78. this.pageNo = pageNo
  79. }
  80. let params = Object.assign(this.params, { pageNo: this.pageNo, pageSize: this.pageSize })
  81. stockList(params).then(res => {
  82. this.getTotal(params)
  83. if (res.status == 200) {
  84. if(this.pageNo>1){
  85. this.listData = this.listData.concat(res.data.list || [])
  86. }else{
  87. this.listData = res.data.list || []
  88. }
  89. this.totalNum = res.data.count || 0
  90. } else {
  91. this.listData = []
  92. this.totalNum = 0
  93. this.noDataText = res.message
  94. }
  95. })
  96. },
  97. // 合计
  98. getTotal (params) {
  99. stockCount(params).then(res => {
  100. if (res.status == 200 && res.data) {
  101. this.totalData = res.data
  102. } else {
  103. this.totalData = null
  104. }
  105. })
  106. },
  107. // scroll-view到底部加载更多
  108. onreachBottom() {
  109. if(this.listData.length < this.totalNum){
  110. this.pageNo += 1
  111. this.getList()
  112. }
  113. },
  114. // 详情
  115. getDetail(data){
  116. uni.navigateTo({ url: "/pages/stock/detaiList?data="+JSON.stringify(data) })
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss">
  122. .stockSearch-wrap{
  123. width: 100%;
  124. height: 100vh;
  125. .panel-box {
  126. background-color: #ffffff;
  127. padding: 20upx 0;
  128. box-shadow: 3upx 2upx 6upx #eee;
  129. margin-bottom: 20upx;
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. .item-box{
  134. text-align: center;
  135. width: 33.33%;
  136. border-right: 1px solid #e4e7ed;
  137. }
  138. .item-box:last-child{
  139. border-right: none;
  140. }
  141. }
  142. .stockSearch-con{
  143. height: calc(100vh - 138upx);
  144. .stockSearch-main{
  145. .stockSearch-main-item{
  146. background: #ffffff;
  147. padding: 20upx;
  148. margin-bottom: 25upx;
  149. border-radius: 25upx;
  150. box-shadow: 1px 1px 3px #EEEEEE;
  151. .stockSearch-tit{
  152. padding-bottom: 20upx;
  153. border-bottom: 1px solid #e4e7ed;
  154. white-space: nowrap;
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. .u-line{
  158. display: inline-block;
  159. width: 6upx;
  160. height: 40upx;
  161. background-color: red;
  162. vertical-align: bottom;
  163. margin: 0 20upx 0 10upx;
  164. }
  165. }
  166. .stockSearch-item-con{
  167. padding: 20upx 20upx 6upx;
  168. font-size: 26upx;
  169. .pimgs{
  170. margin-right: 16upx;
  171. }
  172. .font_13{
  173. font-size: 26upx;
  174. }
  175. .padding_3{
  176. padding: 6upx 0;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. </style>