stockSearch.vue 5.8 KB

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