stockSearch.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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="100" height="100" 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. page{
  182. background: #f8f8f8;
  183. }
  184. .stockSearch-wrap{
  185. width: 100%;
  186. height: 100vh;
  187. .panel-box {
  188. background-color: #ffffff;
  189. margin: 25upx;
  190. padding: 20upx 0;
  191. .item-box{
  192. padding: 5upx 30upx;
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. }
  197. .item-box:last-child{
  198. border-bottom: none;
  199. }
  200. }
  201. .stockSearch-con{
  202. height: calc(100vh - 138upx);
  203. .stockSearch-main{
  204. .stockSearch-main-item{
  205. background: #ffffff;
  206. padding: 20upx;
  207. margin: 25upx;
  208. border-radius: 20upx;
  209. box-shadow: 3upx 2upx 6upx #eee;
  210. &:first-child{
  211. margin-top: 0;
  212. }
  213. .stockSearch-tit{
  214. font-size: 14px;
  215. padding-bottom: 20upx;
  216. font-weight: 900;
  217. // white-space: nowrap;
  218. // overflow: hidden;
  219. // text-overflow: ellipsis;
  220. .u-line{
  221. display: inline-block;
  222. width: 6upx;
  223. height: 30upx;
  224. margin: 6upx 10upx 0 10upx;
  225. border-radius: 5upx;
  226. }
  227. .u-name{
  228. flex-grow: 1;
  229. width: 80%;
  230. }
  231. .u-last{
  232. width: 100upx;
  233. text-align: center;
  234. }
  235. }
  236. .stockSearch-item-con{
  237. padding: 20upx;
  238. font-size: 14px;
  239. .pimgs{
  240. margin-right: 16upx;
  241. }
  242. .padding_3{
  243. padding: 6upx 0;
  244. word-break: break-all;
  245. }
  246. }
  247. .stockSearch-item-footer{
  248. border-top: 2upx solid #eee;
  249. .font_13{
  250. width: 49%;
  251. font-size: 14px;
  252. text-align: center;
  253. border-left: 2upx solid #eee;
  254. padding-top: 20upx;
  255. &:first-child{
  256. border: 0;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>