shelfList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货架名称搜索"
  6. v-model="queryParam.shelfName"
  7. :show-action="isGobleSearch"
  8. @input="change"
  9. @focus="isGobleSearch=true"
  10. @blur="isGobleSearch=false"
  11. @custom="search"
  12. @search="search"
  13. @clear="clearSearch"
  14. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  15. </u-search>
  16. </view>
  17. <view class="flex align_center justify_between" style="padding: 10rpx 20rpx;">
  18. <view class="flex align_center" @click="sortList('productCategory',0)">
  19. <text>待补货产品款数</text>
  20. <view class="flex flex_column" style="margin-left: 5rpx;" >
  21. <u-icon name="arrow-up-fill" size="10" :color="sortVal0=='ASC'?'#666':'#ccc'"></u-icon>
  22. <u-icon name="arrow-down-fill" size="10" :color="sortVal0=='DESC'?'#666':'#ccc'"></u-icon>
  23. </view>
  24. </view>
  25. <view class="flex align_center" @click="sortList('productQty',1)">
  26. <text>待补货产品数量</text>
  27. <view class="flex flex_column" style="margin-left: 5rpx;">
  28. <u-icon name="arrow-up-fill" size="10" :color="sortVal1=='ASC'?'#666':'#ccc'"></u-icon>
  29. <u-icon name="arrow-down-fill" size="10" :color="sortVal1=='DESC'?'#666':'#ccc'"></u-icon>
  30. </view>
  31. </view>
  32. <view class="flex align_center" @click="sortList('lastDate',2)">
  33. <text>最后一次补货时间</text>
  34. <view class="flex flex_column" style="margin-left: 5rpx;">
  35. <u-icon name="arrow-up-fill" size="10" :color="sortVal2=='ASC'?'#666':'#ccc'"></u-icon>
  36. <u-icon name="arrow-down-fill" size="10" :color="sortVal2=='DESC'?'#666':'#ccc'"></u-icon>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="moreShelfPart-body">
  41. <scroll-view
  42. class="nav-right"
  43. scroll-y
  44. @scrolltolower="onreachBottom">
  45. <view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
  46. <view class="item-info">
  47. <view class="item-name">
  48. <text>{{item.shelfName}}</text>
  49. </view>
  50. <view class="item-detail">
  51. <view>
  52. 待补货产品款数:
  53. <text class="item-detail-text">{{item.productCategory}}</text>
  54. </view>
  55. <view>
  56. 待补货产品数量:
  57. <text class="item-detail-text">{{item.productQty}}</text>
  58. </view>
  59. </view>
  60. <view class="item-detail">
  61. <view>
  62. 最后一次补货时间:
  63. <text class="item-detail-text">{{item.lastDate||'--'}}</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="arrow">
  68. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  69. </view>
  70. </view>
  71. <view v-if="shelfList&&shelfList.length==0">
  72. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  73. </view>
  74. <view style="padding: 20upx;" v-else>
  75. <u-loadmore :status="status" />
  76. </view>
  77. </scroll-view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import { queryListForReplenish } from '@/api/shelf'
  83. export default {
  84. data() {
  85. return {
  86. isGobleSearch: false,
  87. shelfList: [],
  88. pageNo:1,
  89. pageSize: 15,
  90. total: 0, // 列表总数
  91. noDataText: '暂无货架',
  92. status: 'loading',
  93. tempData: null,
  94. allList: [],
  95. sortVal0:'',
  96. sortVal1:'',
  97. sortVal2:'',
  98. queryParam: {
  99. shelfName: ''
  100. }
  101. }
  102. },
  103. onLoad(opts) {
  104. },
  105. onUnload() {
  106. uni.$off("setCustome")
  107. },
  108. onShow() {
  109. this.search()
  110. },
  111. methods: {
  112. clearSearch(){
  113. this.queryParam.shelfName = ''
  114. this.search()
  115. },
  116. change(v){
  117. if(v==''){
  118. this.clearSearch()
  119. }
  120. },
  121. // 排序
  122. sortList(key,index){
  123. // 重置其它排序字段为空
  124. for(let i=0;i<3;i++){
  125. if(i!=index){
  126. this['sortVal'+i] = ''
  127. }
  128. }
  129. const val = this['sortVal'+index]
  130. if(val==''){
  131. this['sortVal'+index] = 'ASC'
  132. }
  133. if(val=='ASC'){
  134. this['sortVal'+index] = 'DESC'
  135. }
  136. if(val=='DESC'){
  137. this['sortVal'+index] = ''
  138. }
  139. this.queryParam.queryWord = key
  140. this.queryParam.orderBy = this['sortVal'+index]
  141. this.search()
  142. },
  143. search(){
  144. this.pageNo = 1
  145. this.shelfList = []
  146. this.getShelfList()
  147. },
  148. // 获取数字货架列表
  149. getShelfList(){
  150. const _this = this
  151. _this.status = 'loading'
  152. queryListForReplenish(this.queryParam).then(res => {
  153. uni.hideLoading()
  154. if(res.status == 200){
  155. let list = res.data
  156. if (list && list.length){
  157. // 分页 拼接数据
  158. _this.shelfList = res.data.slice(0,this.pageSize)
  159. _this.total = res.data.length
  160. if (_this.shelfList.length == res.data.length) {
  161. _this.status = 'nomore'
  162. } else {
  163. _this.status = 'loadmore'
  164. }
  165. } else {
  166. _this.shelfList = list || []
  167. _this.total = 0
  168. _this.status = 'nomore'
  169. _this.noDataText = '没有查询到相关货架'
  170. }
  171. _this.allList = res.data
  172. _this.noDataText = '暂无货架'
  173. }else{
  174. _this.status = 'loadmore'
  175. _this.shelfList = []
  176. _this.allList = []
  177. _this.total = 0
  178. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  179. }
  180. })
  181. },
  182. // 加载更多
  183. onreachBottom () {
  184. if(this.shelfList.length < this.total ){
  185. if(this.isGobleSearch&&this.queryParam.shelfName==''){
  186. return
  187. }
  188. this.pageNo++
  189. this.status = 'loading'
  190. const s = (this.pageNo-1)*this.pageSize
  191. const e = s + this.pageSize
  192. this.shelfList = this.shelfList.concat(this.allList.slice(s,e))
  193. }else{
  194. this.status = "nomore"
  195. }
  196. },
  197. viewDetail (row) {
  198. if (row.productCategory&&row.productQty) {
  199. this.tempData = row
  200. uni.navigateTo({
  201. url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.tempData))
  202. })
  203. } else {
  204. this.$message.info('此货架没有待补货产品')
  205. }
  206. },
  207. }
  208. }
  209. </script>
  210. <style lang="less">
  211. .moreShelfPart{
  212. width: 100%;
  213. height: 100vh;
  214. background-color: #f8f8f8;
  215. .moreShelfPart-search{
  216. padding: 0 20rpx 10rpx;
  217. background-color: #fff;
  218. }
  219. .moreShelfPart-body{
  220. flex-grow: 1;
  221. }
  222. .nav-right{
  223. padding: 0 30upx;
  224. height: calc(100vh - 160rpx);
  225. box-sizing: border-box;
  226. .nav-right-item{
  227. padding:20upx;
  228. border: 2rpx solid #f5f5f5;
  229. border-radius: 15upx;
  230. margin-bottom: 20upx;
  231. box-shadow: 3rpx 3rpx 8rpx #eee;
  232. background-color: #fff;
  233. display: flex;
  234. align-items: center;
  235. &:active{
  236. background: #f8f8f8;
  237. }
  238. .arrow{
  239. text-align: right;
  240. padding-left: 20rpx;
  241. }
  242. .item-info{
  243. flex:1;
  244. .item-name{
  245. font-size: 30upx;
  246. display: flex;
  247. align-items: center;
  248. }
  249. .item-detail{
  250. margin-top: 10rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. color: #666;
  255. font-size: 26upx;
  256. .item-detail-text{
  257. font-size: 26upx;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>