stockSearch.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="stockSearch-wrap">
  3. <!-- 统计 -->
  4. <view class="panel-box" v-if="totalNum">
  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" v-if="$hasPermissions('M_showCostPrice_mobile')">
  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: '#00aaff'}"></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/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  34. </view>
  35. <view class="flex_1">
  36. <view>产品编码:{{item.productCode || '--'}} <copyText :text="item.productCode" label="产品编码"></copyText></view>
  37. <view class="padding_3">原厂编码:{{item.productOrigCode && item.productOrigCode !== ' '? item.productOrigCode : '--'}}</view>
  38. </view>
  39. </view>
  40. <view class="stockSearch-item-footer flex align_center">
  41. <view class="font_13">
  42. 可用库存数量
  43. <view>{{toThousands(item.currentStockQty||0)}}{{item.productUnit}}</view>
  44. </view>
  45. <view class="font_13" v-if="$hasPermissions('M_showCostPrice_mobile')">
  46. 可用库存成本
  47. <view>¥{{toThousands(item.currentStockCost||0, 2)}}</view>
  48. </view>
  49. <view class="font_13">
  50. 滞销天数
  51. <view>
  52. <span v-if="item.unsalableDays>=180&&item.unsalableDays<=360" style="color:#FF9900">{{ num(item.unsalableDays) }}</span>
  53. <span v-else-if="item.unsalableDays>360" style="color:#FF0000">{{ num(item.unsalableDays) }}</span>
  54. <span v-else >{{ num(item.unsalableDays) }}</span>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="listData&&listData.length==0">
  60. <u-empty v-if="status!='loading'" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  61. </view>
  62. <view style="padding: 20upx;" v-if="totalNum>pageSize || status=='loading'">
  63. <u-loadmore :status="status" />
  64. </view>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. </template>
  69. <script>
  70. import { toThousands } from '@/libs/tools'
  71. import { stockList, stockCount } from '@/config/api.js'
  72. import copyText from '@/pages/common/copyText.vue'
  73. export default{
  74. components:{copyText},
  75. data(){
  76. return {
  77. totalData: null,
  78. totalNum: 0,
  79. status: 'loading',
  80. listData: [],
  81. pageNo: 1,
  82. pageSize: 50,
  83. params: {},
  84. noDataText: '暂无数据',
  85. theme: '',
  86. toThousands
  87. }
  88. },
  89. onLoad(option) {
  90. this.theme = getApp().globalData.theme
  91. this.params = option.data ? JSON.parse(option.data) : {}
  92. this.getList()
  93. },
  94. methods: {
  95. // 格式化滞销天数为几个月零几天
  96. num (val) {
  97. let days
  98. if (val != null && val != undefined) {
  99. if (val >= 30) {
  100. const a = Math.floor(val / 30)
  101. const b = val - a * 30
  102. if (b > 0) {
  103. days = a + '个月' + b + '天'
  104. } else {
  105. days = a + '个月'
  106. }
  107. } else {
  108. days = val + '天'
  109. }
  110. } else {
  111. days = '--'
  112. }
  113. return days
  114. },
  115. // 列表
  116. getList(pageNo){
  117. const _this = this
  118. if (pageNo) {
  119. this.pageNo = pageNo
  120. }
  121. this.status = 'loading'
  122. let params = Object.assign(this.params, { pageNo: this.pageNo, pageSize: this.pageSize })
  123. stockList(params).then(res => {
  124. this.getTotal(params)
  125. if(res.status == 200){
  126. let list = res.data.list
  127. if (list && list.length){
  128. // 分页 拼接数据
  129. if (_this.pageNo != 1) {
  130. _this.listData = _this.listData ? _this.listData.concat(list) : list
  131. } else {
  132. _this.listData = list
  133. }
  134. this.totalNum = res.data.count
  135. if (_this.listData.length == res.data.count) {
  136. _this.status = 'nomore'
  137. } else {
  138. _this.status = 'loadmore'
  139. }
  140. } else {
  141. _this.listData = list || []
  142. this.totalNum = 0
  143. _this.status = 'nomore'
  144. }
  145. _this.noDataText = '暂无数据'
  146. }else{
  147. _this.status = 'loadmore'
  148. _this.listData = []
  149. _this.totalNum = 0
  150. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  151. }
  152. })
  153. },
  154. // 合计
  155. getTotal (params) {
  156. stockCount(params).then(res => {
  157. if (res.status == 200 && res.data) {
  158. this.totalData = res.data
  159. } else {
  160. this.totalData = null
  161. }
  162. })
  163. },
  164. // scroll-view到底部加载更多
  165. onreachBottom() {
  166. if(this.listData.length < this.totalNum){
  167. this.pageNo += 1
  168. this.getList()
  169. }else{
  170. this.status = "nomore"
  171. }
  172. },
  173. // 详情
  174. getDetail(data){
  175. uni.navigateTo({ url: "/pages/stock/detaiList?data="+JSON.stringify(data) })
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="less">
  181. .stockSearch-wrap{
  182. width: 100%;
  183. height: 100vh;
  184. .panel-box {
  185. background-color: #ffffff;
  186. padding: 20upx 0;
  187. .item-box{
  188. padding: 10upx 30upx;
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. }
  193. .item-box:last-child{
  194. border-bottom: none;
  195. }
  196. }
  197. .stockSearch-con{
  198. height: calc(100vh - 138upx);
  199. .stockSearch-main{
  200. .stockSearch-main-item{
  201. background: #ffffff;
  202. padding: 20upx;
  203. margin: 25upx;
  204. border-radius: 20upx;
  205. border: 1px solid #e4e7ed;
  206. &:first-child{
  207. margin-top: 0;
  208. }
  209. .stockSearch-tit{
  210. font-size: 14px;
  211. padding-bottom: 20upx;
  212. font-weight: 900;
  213. // white-space: nowrap;
  214. // overflow: hidden;
  215. // text-overflow: ellipsis;
  216. .u-line{
  217. display: inline-block;
  218. width: 6upx;
  219. height: 30upx;
  220. margin: 6upx 10upx 0 10upx;
  221. border-radius: 5upx;
  222. }
  223. .u-name{
  224. flex-grow: 1;
  225. width: 80%;
  226. }
  227. .u-last{
  228. width: 100upx;
  229. text-align: center;
  230. }
  231. }
  232. .stockSearch-item-con{
  233. padding: 20upx;
  234. font-size: 28upx;
  235. .pimgs{
  236. margin-right: 16upx;
  237. }
  238. .padding_3{
  239. padding: 6upx 0;
  240. word-break: break-all;
  241. }
  242. }
  243. .stockSearch-item-footer{
  244. border-top: 2upx solid #eee;
  245. .font_13{
  246. width: 33%;
  247. font-size: 26upx;
  248. text-align: center;
  249. border-left: 2upx solid #eee;
  250. padding-top: 20upx;
  251. &:first-child{
  252. border: 0;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>