stockSearchGroup.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="stockSearch-wrap">
  3. <!-- 查询结果 -->
  4. <scroll-view class="stockSearch-con" scroll-y @scrolltolower="onreachBottom">
  5. <view class="stockSearch-main">
  6. <view class="stockSearch-main-item" v-for="(item, index) in listData" :key="item.id">
  7. <view class="stockSearch-tit flex">
  8. <view class="u-line" :style="{backgroundColor: $config('primaryColor')}"></view>
  9. <view class="u-name">
  10. {{item.productEntity?item.productEntity.name?item.productEntity.name:'--':'--'}}
  11. </view>
  12. <view class="u-last" v-if="item.productEntity">
  13. <copyText :text="item.productEntity.name" label="产品名称"></copyText>
  14. </view>
  15. </view>
  16. <view class="stockSearch-item-con flex align_center">
  17. <view class="pimgs" v-if="item.productEntity">
  18. <u-image :src="item.productEntity.productMsg?item.productEntity.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  19. </view>
  20. <view class="flex_1" v-if="item.productEntity">
  21. <view>产品编码:{{item.productEntity.code || '--'}} <copyText :text="item.productEntity.code" label="产品编码"></copyText></view>
  22. <view class="padding_3">原厂编码:{{item.productEntity.origCode && item.productEntity.origCode !== ' '? item.productEntity.origCode : '--'}}</view>
  23. </view>
  24. </view>
  25. <view class="stockSearch-item-footer flex align_center">
  26. <view class="font_13" v-if="$hasPermissions('M_showCostPrice_mobile')">
  27. 门店名称
  28. <view class="u-line-1">{{item.dealerName}}</view>
  29. </view>
  30. <view class="font_13">
  31. 可用库存数量
  32. <view>{{toThousands(item.currentStockQty||0)}}{{item.productEntity?item.productEntity.unit?item.productEntity.unit:'--':'--'}}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="listData&&listData.length==0">
  37. <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>
  38. </view>
  39. <view style="padding: 20upx;" v-if="totalNum>pageSize || status=='loading'">
  40. <u-loadmore :status="status" />
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </template>
  46. <script>
  47. import { toThousands } from '@/libs/tools'
  48. import { stockQueryLinkPage } from '@/api/stock'
  49. import copyText from '@/pages/common/copyText.vue'
  50. export default{
  51. components:{copyText},
  52. data(){
  53. return {
  54. totalData: null,
  55. totalNum: 0,
  56. status: 'loading',
  57. listData: [],
  58. pageNo: 1,
  59. pageSize: 50,
  60. params: {},
  61. noDataText: '暂无数据',
  62. theme: '',
  63. toThousands
  64. }
  65. },
  66. onLoad(option) {
  67. this.theme = getApp().globalData.theme
  68. this.params = option.data ? JSON.parse(option.data) : {}
  69. this.getList()
  70. },
  71. methods: {
  72. // 格式化滞销天数为几个月零几天
  73. num (val) {
  74. let days
  75. if (val != null && val != undefined) {
  76. if (val >= 30) {
  77. const a = Math.floor(val / 30)
  78. const b = val - a * 30
  79. if (b > 0) {
  80. days = a + '个月' + b + '天'
  81. } else {
  82. days = a + '个月'
  83. }
  84. } else {
  85. days = val + '天'
  86. }
  87. } else {
  88. days = '--'
  89. }
  90. return days
  91. },
  92. // 列表
  93. getList(pageNo){
  94. const _this = this
  95. if (pageNo) {
  96. this.pageNo = pageNo
  97. }
  98. this.status = 'loading'
  99. let params = Object.assign(this.params, { pageNo: this.pageNo, pageSize: this.pageSize })
  100. stockQueryLinkPage(params).then(res => {
  101. if(res.status == 200){
  102. let list = res.data.list
  103. if (list && list.length){
  104. // 分页 拼接数据
  105. if (_this.pageNo != 1) {
  106. _this.listData = _this.listData ? _this.listData.concat(list) : list
  107. } else {
  108. _this.listData = list
  109. }
  110. this.totalNum = res.data.count
  111. if (_this.listData.length == res.data.count) {
  112. _this.status = 'nomore'
  113. } else {
  114. _this.status = 'loadmore'
  115. }
  116. } else {
  117. _this.listData = list || []
  118. this.totalNum = 0
  119. _this.status = 'nomore'
  120. }
  121. _this.noDataText = '暂无配件'
  122. }else{
  123. _this.status = 'loadmore'
  124. _this.listData = []
  125. _this.totalNum = 0
  126. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  127. }
  128. })
  129. },
  130. // scroll-view到底部加载更多
  131. onreachBottom() {
  132. if(this.listData.length < this.totalNum){
  133. this.pageNo += 1
  134. this.getList()
  135. }else{
  136. this.status = "nomore"
  137. }
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="less">
  143. .stockSearch-wrap{
  144. width: 100%;
  145. height: 100vh;
  146. .stockSearch-con{
  147. height: calc(100vh - 138upx);
  148. .stockSearch-main{
  149. padding-top:25upx;
  150. .stockSearch-main-item{
  151. background: #ffffff;
  152. padding: 20upx;
  153. margin: 25upx;
  154. border-radius: 20upx;
  155. box-shadow: 1px 1px 3px #EEEEEE;
  156. &:first-child{
  157. margin-top: 0;
  158. }
  159. .stockSearch-tit{
  160. padding-bottom: 20upx;
  161. border-bottom: 1px solid #e4e7ed;
  162. font-weight: 900;
  163. // white-space: nowrap;
  164. // overflow: hidden;
  165. // text-overflow: ellipsis;
  166. .u-line{
  167. display: inline-block;
  168. width: 6upx;
  169. height: 30upx;
  170. margin: 6upx 10upx 0 10upx;
  171. border-radius: 5upx;
  172. }
  173. .u-name{
  174. flex-grow: 1;
  175. width: 80%;
  176. }
  177. .u-last{
  178. width: 100upx;
  179. text-align: center;
  180. }
  181. }
  182. .stockSearch-item-con{
  183. padding: 20upx;
  184. font-size: 28upx;
  185. .pimgs{
  186. margin-right: 16upx;
  187. }
  188. .padding_3{
  189. padding: 6upx 0;
  190. word-break: break-all;
  191. }
  192. }
  193. .stockSearch-item-footer{
  194. border-top: 2upx solid #eee;
  195. .font_13{
  196. width: 50%;
  197. font-size: 26upx;
  198. text-align: center;
  199. border-left: 2upx solid #eee;
  200. padding-top: 20upx;
  201. &:first-child{
  202. border: 0;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. </style>