shelfList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货架名称搜索"
  6. v-model="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 20rpx;">
  18. <view class="flex align_center">
  19. <text>待补货产品款数</text>
  20. <view class="flex flex_column" style="margin-left: 5rpx;">
  21. <u-icon name="arrow-up-fill" size="12" color="#333"></u-icon>
  22. <u-icon name="arrow-down-fill" size="12" color="#ccc"></u-icon>
  23. </view>
  24. </view>
  25. <view class="flex align_center">
  26. <text>待补货产品数量</text>
  27. <view class="flex flex_column" style="margin-left: 5rpx;">
  28. <u-icon name="arrow-up-fill" size="12" color="#ccc"></u-icon>
  29. <u-icon name="arrow-down-fill" size="12" color="#ccc"></u-icon>
  30. </view>
  31. </view>
  32. <view class="flex align_center">
  33. <text>最后一次补货时间</text>
  34. <view class="flex flex_column" style="margin-left: 5rpx;">
  35. <u-icon name="arrow-up-fill" size="12" color="#ccc"></u-icon>
  36. <u-icon name="arrow-down-fill" size="12" color="#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.shelfPlaceBindNum}}</text>
  54. </view>
  55. <view>
  56. 待补货产品数量:
  57. <text class="item-detail-text">{{item.shelfPlaceNum}}</text>
  58. </view>
  59. </view>
  60. <view class="item-detail">
  61. <view>
  62. 最后一次补货时间:
  63. <text class="item-detail-text">{{item.createDate}}</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 { getShelfList, shelfSave } from '@/api/shelf'
  83. export default {
  84. data() {
  85. return {
  86. shelfName: '',
  87. isGobleSearch: false,
  88. shelfList: [],
  89. pageNo:1,
  90. pageSize: 15,
  91. total: 0, // 列表总数
  92. noDataText: '暂无货架',
  93. status: 'loading',
  94. tempData: null
  95. }
  96. },
  97. onLoad(opts) {
  98. uni.$on("setCustome",(data)=>{
  99. this.saveShelf(data)
  100. })
  101. },
  102. onUnload() {
  103. uni.$off("setCustome")
  104. },
  105. onShow() {
  106. this.search()
  107. },
  108. methods: {
  109. clearSearch(){
  110. this.shelfName = ''
  111. this.search()
  112. },
  113. change(v){
  114. if(v==''){
  115. this.clearSearch()
  116. }
  117. },
  118. search(){
  119. this.pageNo = 1
  120. this.shelfList = []
  121. this.getShelfList()
  122. },
  123. // 关联客户
  124. saveShelf(data){
  125. uni.showLoading({
  126. mask: true,
  127. title: '正在关联客户...'
  128. })
  129. shelfSave({
  130. shelfSn: this.tempData.shelfSn,
  131. customerSn: data.customerSn
  132. }).then(res => {
  133. if(res.status == 200){
  134. uni.navigateTo({
  135. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  136. })
  137. }
  138. uni.hideLoading()
  139. })
  140. },
  141. // 获取数字货架列表
  142. getShelfList(){
  143. const _this = this
  144. let params = {
  145. pageNo: this.pageNo,
  146. pageSize: this.pageSize,
  147. shelfName: this.shelfName
  148. }
  149. _this.status = 'loading'
  150. getShelfList(params).then(res => {
  151. uni.hideLoading()
  152. if(res.status == 200){
  153. let list = res.data.list
  154. if (list && list.length){
  155. // 分页 拼接数据
  156. if(_this.pageNo>1){
  157. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  158. }else{
  159. _this.shelfList = res.data.list
  160. }
  161. _this.total = res.data.count
  162. console.log(res.data.count)
  163. if (_this.shelfList.length == res.data.count) {
  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.noDataText = '暂无货架'
  175. }else{
  176. _this.status = 'loadmore'
  177. _this.shelfList = []
  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.shelfName==''){
  187. return
  188. }
  189. this.pageNo++
  190. this.getShelfList()
  191. }else{
  192. this.status = "nomore"
  193. }
  194. },
  195. viewDetail(item){
  196. this.tempData = item
  197. uni.navigateTo({
  198. url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.tempData))
  199. })
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. .moreShelfPart{
  206. width: 100%;
  207. height: 100vh;
  208. background-color: #f8f8f8;
  209. .moreShelfPart-search{
  210. padding: 20rpx;
  211. background-color: #fff;
  212. }
  213. .moreShelfPart-body{
  214. flex-grow: 1;
  215. }
  216. .nav-right{
  217. padding: 0 30upx;
  218. height: calc(100vh - 170rpx);
  219. box-sizing: border-box;
  220. .nav-right-item{
  221. padding:20upx;
  222. border: 2rpx solid #f5f5f5;
  223. border-radius: 15upx;
  224. margin-bottom: 20upx;
  225. box-shadow: 3rpx 3rpx 8rpx #eee;
  226. background-color: #fff;
  227. display: flex;
  228. align-items: center;
  229. &:active{
  230. background: #f8f8f8;
  231. }
  232. .arrow{
  233. text-align: right;
  234. padding-left: 20rpx;
  235. }
  236. .item-info{
  237. flex:1;
  238. .item-name{
  239. font-size: 30upx;
  240. display: flex;
  241. align-items: center;
  242. }
  243. .item-detail{
  244. margin-top: 10rpx;
  245. display: flex;
  246. align-items: center;
  247. justify-content: space-between;
  248. color: #666;
  249. font-size: 26upx;
  250. .item-detail-text{
  251. font-size: 26upx;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. </style>