shelfList.vue 7.3 KB

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