stockSearch.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="240" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  46. </view>
  47. <view style="padding: 20upx;" v-if="totalNum>pageSize || status=='loading'">
  48. <u-loadmore :status="status" />
  49. </view>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </template>
  54. <script>
  55. import { toThousands } from '@/libs/tools'
  56. import { stockList, stockCount } from '@/api/stock'
  57. export default{
  58. data(){
  59. return {
  60. totalData: null,
  61. totalNum: 0,
  62. status: 'loading',
  63. listData: [],
  64. pageNo: 1,
  65. pageSize: 50,
  66. params: {},
  67. noDataText: '暂无数据',
  68. theme: '',
  69. toThousands
  70. }
  71. },
  72. onLoad(option) {
  73. this.theme = getApp().globalData.theme
  74. this.params = option.data ? JSON.parse(option.data) : {}
  75. this.getList()
  76. },
  77. methods: {
  78. // 列表
  79. getList(pageNo){
  80. const _this = this
  81. if (pageNo) {
  82. this.pageNo = pageNo
  83. }
  84. this.status = 'loading'
  85. let params = Object.assign(this.params, { pageNo: this.pageNo, pageSize: this.pageSize })
  86. stockList(params).then(res => {
  87. this.getTotal(params)
  88. if(res.status == 200){
  89. let list = res.data.list
  90. if (list && list.length){
  91. // 分页 拼接数据
  92. if (_this.pageNo != 1) {
  93. _this.listData = _this.listData ? _this.listData.concat(list) : list
  94. } else {
  95. _this.listData = list
  96. }
  97. this.totalNum = res.data.count
  98. if (_this.listData.length == res.data.count) {
  99. _this.status = 'nomore'
  100. } else {
  101. _this.status = 'loadmore'
  102. }
  103. } else {
  104. _this.listData = list || []
  105. this.totalNum = 0
  106. _this.status = 'nomore'
  107. }
  108. _this.noDataText = '暂无配件'
  109. }else{
  110. _this.status = 'loadmore'
  111. _this.listData = []
  112. _this.totalNum = 0
  113. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  114. }
  115. })
  116. },
  117. // 合计
  118. getTotal (params) {
  119. stockCount(params).then(res => {
  120. if (res.status == 200 && res.data) {
  121. this.totalData = res.data
  122. } else {
  123. this.totalData = null
  124. }
  125. })
  126. },
  127. // scroll-view到底部加载更多
  128. onreachBottom() {
  129. if(this.listData.length < this.totalNum){
  130. this.pageNo += 1
  131. this.getList()
  132. }else{
  133. this.status = "nomore"
  134. }
  135. },
  136. // 详情
  137. getDetail(data){
  138. uni.navigateTo({ url: "/pages/stock/detaiList?data="+JSON.stringify(data) })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. .stockSearch-wrap{
  145. width: 100%;
  146. height: 100vh;
  147. .panel-box {
  148. background-color: #ffffff;
  149. padding: 20upx 0;
  150. box-shadow: 3upx 2upx 6upx #eee;
  151. margin-bottom: 20upx;
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. .item-box{
  156. text-align: center;
  157. width: 33.33%;
  158. border-right: 1px solid #e4e7ed;
  159. }
  160. .item-box:last-child{
  161. border-right: none;
  162. }
  163. }
  164. .stockSearch-con{
  165. height: calc(100vh - 138upx);
  166. .stockSearch-main{
  167. .stockSearch-main-item{
  168. background: #ffffff;
  169. padding: 20upx;
  170. margin-bottom: 25upx;
  171. border-radius: 25upx;
  172. box-shadow: 1px 1px 3px #EEEEEE;
  173. .stockSearch-tit{
  174. padding-bottom: 20upx;
  175. border-bottom: 1px solid #e4e7ed;
  176. white-space: nowrap;
  177. overflow: hidden;
  178. text-overflow: ellipsis;
  179. .u-line{
  180. display: inline-block;
  181. width: 6upx;
  182. height: 40upx;
  183. background-color: red;
  184. vertical-align: bottom;
  185. margin: 0 20upx 0 10upx;
  186. }
  187. }
  188. .stockSearch-item-con{
  189. padding: 20upx 20upx 6upx;
  190. font-size: 26upx;
  191. .pimgs{
  192. margin-right: 16upx;
  193. }
  194. .font_13{
  195. font-size: 26upx;
  196. }
  197. .padding_3{
  198. padding: 6upx 0;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. </style>