shelfList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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="200"></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. onReady() {
  105. uni.setNavigationBarColor({
  106. frontColor: '#ffffff',
  107. backgroundColor: this.$config('primaryColor')
  108. })
  109. },
  110. onShow() {
  111. this.search()
  112. },
  113. methods: {
  114. clearSearch(){
  115. this.queryParam.shelfName = ''
  116. this.search()
  117. },
  118. change(v){
  119. if(v==''){
  120. this.clearSearch()
  121. }
  122. },
  123. // 排序
  124. sortList(key,index){
  125. // 重置其它排序字段为空
  126. for(let i=0;i<3;i++){
  127. if(i!=index){
  128. this['sortVal'+i] = ''
  129. }
  130. }
  131. const val = this['sortVal'+index]
  132. if(val==''){
  133. this['sortVal'+index] = 'ASC'
  134. }
  135. if(val=='ASC'){
  136. this['sortVal'+index] = 'DESC'
  137. }
  138. if(val=='DESC'){
  139. this['sortVal'+index] = ''
  140. }
  141. this.queryParam.queryWord = key
  142. this.queryParam.orderBy = this['sortVal'+index]
  143. this.search()
  144. },
  145. search(){
  146. this.pageNo = 1
  147. this.shelfList = []
  148. this.getShelfList()
  149. },
  150. // 获取数字货架列表
  151. getShelfList(){
  152. const _this = this
  153. _this.status = 'loading'
  154. queryListForReplenish(this.queryParam).then(res => {
  155. uni.hideLoading()
  156. if(res.status == 200){
  157. let list = res.data
  158. if (list && list.length){
  159. // 分页 拼接数据
  160. _this.shelfList = res.data.slice(0,this.pageSize)
  161. _this.total = res.data.length
  162. if (_this.shelfList.length == res.data.length) {
  163. _this.status = 'nomore'
  164. } else {
  165. _this.status = 'loadmore'
  166. }
  167. } else {
  168. _this.shelfList = list || []
  169. _this.total = 0
  170. _this.status = 'nomore'
  171. _this.noDataText = '没有查询到相关货架'
  172. }
  173. _this.allList = res.data
  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. this.tempData.chooseKey = []
  202. this.$store.state.vuex_tempData = null
  203. uni.navigateTo({
  204. url: "/pages/soldOut/chooseProduct?data="+encodeURIComponent(JSON.stringify(this.tempData))
  205. })
  206. } else {
  207. this.toashMsg('此货架没有待补货产品')
  208. }
  209. },
  210. }
  211. }
  212. </script>
  213. <style lang="less">
  214. .moreShelfPart{
  215. width: 100%;
  216. height: 100vh;
  217. background-color: #f8f8f8;
  218. .moreShelfPart-search{
  219. padding: 20rpx;
  220. background-color: #fff;
  221. }
  222. .moreShelfPart-body{
  223. flex-grow: 1;
  224. }
  225. .nav-right{
  226. padding: 0 30upx;
  227. height: calc(100vh - 160rpx);
  228. box-sizing: border-box;
  229. .nav-right-item{
  230. padding:20upx;
  231. border: 2rpx solid #f5f5f5;
  232. border-radius: 15upx;
  233. margin-bottom: 20upx;
  234. box-shadow: 3rpx 3rpx 8rpx #eee;
  235. background-color: #fff;
  236. display: flex;
  237. align-items: center;
  238. &:active{
  239. background: #f8f8f8;
  240. }
  241. .arrow{
  242. text-align: right;
  243. padding-left: 20rpx;
  244. }
  245. .item-info{
  246. flex:1;
  247. .item-name{
  248. font-size: 30upx;
  249. display: flex;
  250. align-items: center;
  251. }
  252. .item-detail{
  253. margin-top: 10rpx;
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. color: #666;
  258. font-size: 26upx;
  259. .item-detail-text{
  260. font-size: 26upx;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>