shelfList.vue 7.3 KB

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