shelfList.vue 7.1 KB

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