shelfList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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="getShelfList"
  12. @search="getShelfList"
  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="moreShelfPart-body">
  18. <scroll-view
  19. class="nav-right"
  20. scroll-y
  21. @scrolltolower="onreachBottom">
  22. <view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
  23. <view class="item-info">
  24. <view class="item-name">
  25. <text>{{item.shelfName}}</text>
  26. </view>
  27. <view class="item-detail">
  28. <view>
  29. 货位数量:
  30. <text class="item-detail-text">{{item.shelfPlaceNum}}</text>
  31. </view>
  32. <view>
  33. 已绑定产品款数:
  34. <text class="item-detail-text">{{item.shelfPlaceBindNum}}</text>
  35. </view>
  36. <view>
  37. 设置完成:
  38. <text class="item-detail-text">{{item.finishFlag == 1 ? '是': '否'}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="arrow">
  43. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  44. </view>
  45. </view>
  46. <view v-if="shelfList&&shelfList.length==0">
  47. <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>
  48. </view>
  49. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  50. <u-loadmore :status="status" />
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import { getShelfList, shelfSave } from '@/api/shelf'
  58. export default {
  59. data() {
  60. return {
  61. shelfName: '',
  62. isGobleSearch: false,
  63. shelfList: [],
  64. pageNo:1,
  65. pageSize: 15,
  66. total: 0, // 列表总数
  67. noDataText: '暂无货架',
  68. status: 'loading',
  69. tempData: null
  70. }
  71. },
  72. onLoad(opts) {
  73. this.getShelfList()
  74. uni.$on("setCustome",(data)=>{
  75. this.saveShelf(data)
  76. })
  77. },
  78. onUnload() {
  79. uni.$off("setCustome")
  80. },
  81. methods: {
  82. clearSearch(){
  83. this.shelfName = ''
  84. this.pageNo = 1
  85. this.shelfList = []
  86. this.getShelfList()
  87. },
  88. change(v){
  89. if(v==''){
  90. this.clearSearch()
  91. }
  92. },
  93. // 保存数字货架基本信息
  94. saveShelf(data){
  95. shelfSave({
  96. shelfSn: this.tempData.shelfSn,
  97. customerSn: data.customerSn
  98. }).then(res => {
  99. uni.navigateTo({
  100. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  101. })
  102. })
  103. },
  104. // 获取数字货架列表
  105. getShelfList(){
  106. const _this = this
  107. let params = {
  108. pageNo: this.pageNo,
  109. pageSize: this.pageSize,
  110. shelfName: this.shelfName
  111. }
  112. _this.status = 'loading'
  113. getShelfList(params).then(res => {
  114. uni.hideLoading()
  115. if(res.status == 200){
  116. let list = res.data.list
  117. if (list && list.length){
  118. // 分页 拼接数据
  119. if (_this.pageNo != 1) {
  120. _this.shelfList = _this.shelfList ? _this.shelfList.concat(list) : list
  121. } else {
  122. _this.shelfList = list
  123. }
  124. this.total = res.data.count
  125. console.log(res.data.count)
  126. if (_this.shelfList.length == res.data.count) {
  127. _this.status = 'nomore'
  128. } else {
  129. _this.status = 'loadmore'
  130. }
  131. } else {
  132. _this.shelfList = list || []
  133. this.total = 0
  134. _this.status = 'nomore'
  135. _this.noDataText = '没有查询到相关货架'
  136. }
  137. _this.noDataText = '暂无货架'
  138. }else{
  139. _this.status = 'loadmore'
  140. _this.shelfList = []
  141. _this.total = 0
  142. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  143. }
  144. })
  145. },
  146. // 加载更多
  147. onreachBottom () {
  148. if(this.shelfList.length < this.total ){
  149. if(this.isGobleSearch&&this.shelfName==''){
  150. return
  151. }
  152. this.pageNo++
  153. this.getShelfList()
  154. }else{
  155. this.status = "nomore"
  156. }
  157. },
  158. viewDetail(item){
  159. this.tempData = item
  160. // 又关联客户
  161. if(item.customerEntity){
  162. uni.navigateTo({
  163. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  164. })
  165. }else{
  166. uni.navigateTo({
  167. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  168. })
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="less">
  175. .moreShelfPart{
  176. width: 100%;
  177. height: 100vh;
  178. .moreShelfPart-search{
  179. padding: 20rpx;
  180. background-color: #FFFFFF;
  181. }
  182. .moreShelfPart-body{
  183. flex-grow: 1;
  184. background-color: #fff;
  185. }
  186. .nav-right{
  187. padding: 0 30upx;
  188. height: calc(100vh - 110rpx);
  189. box-sizing: border-box;
  190. .nav-right-item{
  191. padding:20upx 10upx;
  192. border-bottom: 2rpx solid #f5f5f5;
  193. display: flex;
  194. align-items: center;
  195. &:active{
  196. background: #f8f8f8;
  197. }
  198. .arrow{
  199. text-align: right;
  200. padding-left: 20rpx;
  201. }
  202. .item-info{
  203. flex:1;
  204. .item-name{
  205. font-size: 30upx;
  206. display: flex;
  207. align-items: center;
  208. }
  209. .item-detail{
  210. margin-top: 10rpx;
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. color: #9DA8B5;
  215. font-size: 26upx;
  216. .item-detail-text{
  217. font-size: 26upx;
  218. color: #333;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. </style>