shelfList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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="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.pageNo = 1
  76. this.shelfList = []
  77. this.search()
  78. this.saveShelf(data)
  79. })
  80. },
  81. onUnload() {
  82. uni.$off("setCustome")
  83. },
  84. methods: {
  85. clearSearch(){
  86. this.shelfName = ''
  87. this.search()
  88. },
  89. change(v){
  90. if(v==''){
  91. this.clearSearch()
  92. }
  93. },
  94. search(){
  95. this.pageNo = 1
  96. this.shelfList = []
  97. this.getShelfList()
  98. },
  99. // 关联客户
  100. saveShelf(data){
  101. shelfSave({
  102. shelfSn: this.tempData.shelfSn,
  103. customerSn: data.customerSn
  104. }).then(res => {
  105. uni.navigateTo({
  106. url: "/pages/shelfSetting/shelfSet?shelfSn="+this.tempData.shelfSn
  107. })
  108. })
  109. },
  110. // 获取数字货架列表
  111. getShelfList(){
  112. const _this = this
  113. let params = {
  114. pageNo: this.pageNo,
  115. pageSize: this.pageSize,
  116. shelfName: this.shelfName
  117. }
  118. _this.status = 'loading'
  119. getShelfList(params).then(res => {
  120. uni.hideLoading()
  121. if(res.status == 200){
  122. let list = res.data.list
  123. if (list && list.length){
  124. // 分页 拼接数据
  125. if (_this.pageNo != 1) {
  126. _this.shelfList = _this.shelfList ? _this.shelfList.concat(list) : list
  127. } else {
  128. _this.shelfList = list
  129. }
  130. this.total = res.data.count
  131. console.log(res.data.count)
  132. if (_this.shelfList.length == res.data.count) {
  133. _this.status = 'nomore'
  134. } else {
  135. _this.status = 'loadmore'
  136. }
  137. } else {
  138. _this.shelfList = list || []
  139. this.total = 0
  140. _this.status = 'nomore'
  141. _this.noDataText = '没有查询到相关货架'
  142. }
  143. _this.noDataText = '暂无货架'
  144. }else{
  145. _this.status = 'loadmore'
  146. _this.shelfList = []
  147. _this.total = 0
  148. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  149. }
  150. })
  151. },
  152. // 加载更多
  153. onreachBottom () {
  154. if(this.shelfList.length < this.total ){
  155. if(this.isGobleSearch&&this.shelfName==''){
  156. return
  157. }
  158. this.pageNo++
  159. this.getShelfList()
  160. }else{
  161. this.status = "nomore"
  162. }
  163. },
  164. viewDetail(item){
  165. this.tempData = item
  166. // 又关联客户
  167. if(item.customerEntity){
  168. uni.navigateTo({
  169. url: "/pages/shelfSetting/shelfSet?shelfSn="+item.shelfSn
  170. })
  171. }else{
  172. uni.navigateTo({
  173. url: "/pages/sales/chooseCustomer?backPage=shelfSeting&shelfName="+item.shelfName
  174. })
  175. }
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="less">
  181. .moreShelfPart{
  182. width: 100%;
  183. height: 100vh;
  184. .moreShelfPart-search{
  185. padding: 20rpx;
  186. background-color: #FFFFFF;
  187. }
  188. .moreShelfPart-body{
  189. flex-grow: 1;
  190. background-color: #fff;
  191. }
  192. .nav-right{
  193. padding: 0 30upx;
  194. height: calc(100vh - 110rpx);
  195. box-sizing: border-box;
  196. .nav-right-item{
  197. padding:20upx 10upx;
  198. border-bottom: 2rpx solid #f5f5f5;
  199. display: flex;
  200. align-items: center;
  201. &:active{
  202. background: #f8f8f8;
  203. }
  204. .arrow{
  205. text-align: right;
  206. padding-left: 20rpx;
  207. }
  208. .item-info{
  209. flex:1;
  210. .item-name{
  211. font-size: 30upx;
  212. display: flex;
  213. align-items: center;
  214. }
  215. .item-detail{
  216. margin-top: 10rpx;
  217. display: flex;
  218. align-items: center;
  219. justify-content: space-between;
  220. color: #9DA8B5;
  221. font-size: 26upx;
  222. .item-detail-text{
  223. font-size: 26upx;
  224. color: #333;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. </style>